@@ -1847,23 +1847,33 @@ MdPanelRef.prototype._configureEscapeToClose = function() {
18471847 */
18481848MdPanelRef . prototype . _configureClickOutsideToClose = function ( ) {
18491849 if ( this . config [ 'clickOutsideToClose' ] ) {
1850- var target = this . panelContainer ;
1851- var sourceElem ;
1850+ var target = this . config [ 'propagateContainerEvents' ] ?
1851+ angular . element ( document . body ) :
1852+ this . panelContainer ;
1853+ var sourceEl ;
18521854
18531855 // Keep track of the element on which the mouse originally went down
18541856 // so that we can only close the backdrop when the 'click' started on it.
1855- // A simple 'click' handler does not work,
1856- // it sets the target object as the element the mouse went down on.
1857+ // A simple 'click' handler does not work, it sets the target object as the
1858+ // element the mouse went down on.
18571859 var mousedownHandler = function ( ev ) {
1858- sourceElem = ev . target ;
1860+ sourceEl = ev . target ;
18591861 } ;
18601862
18611863 // We check if our original element and the target is the backdrop
18621864 // because if the original was the backdrop and the target was inside the
18631865 // panel we don't want to panel to close.
18641866 var self = this ;
18651867 var mouseupHandler = function ( ev ) {
1866- if ( sourceElem === target [ 0 ] && ev . target === target [ 0 ] ) {
1868+ if ( self . config [ 'propagateContainerEvents' ] ) {
1869+
1870+ // We check if the sourceEl of the event is the panel element or one
1871+ // of it's children. If it is not, then close the panel.
1872+ if ( sourceEl !== self . panelEl [ 0 ] && ! self . panelEl [ 0 ] . contains ( sourceEl ) ) {
1873+ self . close ( ) ;
1874+ }
1875+
1876+ } else if ( sourceEl === target [ 0 ] && ev . target === target [ 0 ] ) {
18671877 ev . stopPropagation ( ) ;
18681878 ev . preventDefault ( ) ;
18691879
@@ -2744,6 +2754,7 @@ MdPanelPosition.prototype._constrainToViewport = function(panelEl) {
27442754 }
27452755} ;
27462756
2757+
27472758/**
27482759 * Switches between 'start' and 'end'.
27492760 * @param {string } position Horizontal position of the panel
@@ -2933,6 +2944,7 @@ MdPanelAnimation.prototype.closeTo = function(closeTo) {
29332944 return this ;
29342945} ;
29352946
2947+
29362948/**
29372949 * Specifies the duration of the animation in milliseconds.
29382950 * @param {number|{open: number, close: number} } duration
@@ -2958,6 +2970,7 @@ MdPanelAnimation.prototype.duration = function(duration) {
29582970 }
29592971} ;
29602972
2973+
29612974/**
29622975 * Returns the element and bounds for the animation target.
29632976 * @param {string|!Element|{top: number, left: number} } location
0 commit comments