@@ -1847,23 +1847,33 @@ MdPanelRef.prototype._configureEscapeToClose = function() {
1847
1847
*/
1848
1848
MdPanelRef . prototype . _configureClickOutsideToClose = function ( ) {
1849
1849
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 ;
1852
1854
1853
1855
// Keep track of the element on which the mouse originally went down
1854
1856
// 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.
1857
1859
var mousedownHandler = function ( ev ) {
1858
- sourceElem = ev . target ;
1860
+ sourceEl = ev . target ;
1859
1861
} ;
1860
1862
1861
1863
// We check if our original element and the target is the backdrop
1862
1864
// because if the original was the backdrop and the target was inside the
1863
1865
// panel we don't want to panel to close.
1864
1866
var self = this ;
1865
1867
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 ] ) {
1867
1877
ev . stopPropagation ( ) ;
1868
1878
ev . preventDefault ( ) ;
1869
1879
@@ -2744,6 +2754,7 @@ MdPanelPosition.prototype._constrainToViewport = function(panelEl) {
2744
2754
}
2745
2755
} ;
2746
2756
2757
+
2747
2758
/**
2748
2759
* Switches between 'start' and 'end'.
2749
2760
* @param {string } position Horizontal position of the panel
@@ -2933,6 +2944,7 @@ MdPanelAnimation.prototype.closeTo = function(closeTo) {
2933
2944
return this ;
2934
2945
} ;
2935
2946
2947
+
2936
2948
/**
2937
2949
* Specifies the duration of the animation in milliseconds.
2938
2950
* @param {number|{open: number, close: number} } duration
@@ -2958,6 +2970,7 @@ MdPanelAnimation.prototype.duration = function(duration) {
2958
2970
}
2959
2971
} ;
2960
2972
2973
+
2961
2974
/**
2962
2975
* Returns the element and bounds for the animation target.
2963
2976
* @param {string|!Element|{top: number, left: number} } location
0 commit comments