@@ -1825,23 +1825,33 @@ MdPanelRef.prototype._configureEscapeToClose = function() {
18251825 */
18261826MdPanelRef . prototype . _configureClickOutsideToClose = function ( ) {
18271827 if ( this . config [ 'clickOutsideToClose' ] ) {
1828- var target = this . panelContainer ;
1829- var sourceElem ;
1828+ var target = this . config [ 'propagateContainerEvents' ] ?
1829+ angular . element ( document . body ) :
1830+ this . panelContainer ;
1831+ var sourceEl ;
18301832
18311833 // Keep track of the element on which the mouse originally went down
18321834 // so that we can only close the backdrop when the 'click' started on it.
1833- // A simple 'click' handler does not work,
1834- // it sets the target object as the element the mouse went down on.
1835+ // A simple 'click' handler does not work, it sets the target object as the
1836+ // element the mouse went down on.
18351837 var mousedownHandler = function ( ev ) {
1836- sourceElem = ev . target ;
1838+ sourceEl = ev . target ;
18371839 } ;
18381840
18391841 // We check if our original element and the target is the backdrop
18401842 // because if the original was the backdrop and the target was inside the
18411843 // panel we don't want to panel to close.
18421844 var self = this ;
18431845 var mouseupHandler = function ( ev ) {
1844- if ( sourceElem === target [ 0 ] && ev . target === target [ 0 ] ) {
1846+ if ( self . config [ 'propagateContainerEvents' ] ) {
1847+
1848+ // We check if the sourceEl of the event is the panel element or one
1849+ // of it's children. If it is not, then close the panel.
1850+ if ( sourceEl !== self . panelEl [ 0 ] && ! self . panelEl [ 0 ] . contains ( sourceEl ) ) {
1851+ self . close ( ) ;
1852+ }
1853+
1854+ } else if ( sourceEl === target [ 0 ] && ev . target === target [ 0 ] ) {
18451855 ev . stopPropagation ( ) ;
18461856 ev . preventDefault ( ) ;
18471857
@@ -2713,6 +2723,7 @@ MdPanelPosition.prototype._constrainToViewport = function(panelEl) {
27132723 }
27142724} ;
27152725
2726+
27162727/**
27172728 * Switches between 'start' and 'end'.
27182729 * @param {string } position Horizontal position of the panel
@@ -2902,6 +2913,7 @@ MdPanelAnimation.prototype.closeTo = function(closeTo) {
29022913 return this ;
29032914} ;
29042915
2916+
29052917/**
29062918 * Specifies the duration of the animation in milliseconds.
29072919 * @param {number|{open: number, close: number} } duration
@@ -2927,6 +2939,7 @@ MdPanelAnimation.prototype.duration = function(duration) {
29272939 }
29282940} ;
29292941
2942+
29302943/**
29312944 * Returns the element and bounds for the animation target.
29322945 * @param {string|!Element|{top: number, left: number} } location
0 commit comments