@@ -129,6 +129,12 @@ angular
129129 * outside the panel to close it. Defaults to false.
130130 * - `escapeToClose` - `{boolean=}`: Whether the user can press escape to
131131 * close the panel. Defaults to false.
132+ * - `onCloseSuccess` - `{function(!panelRef, string)=}`: Function that is
133+ * called after the close successfully finishes. The first parameter passed
134+ * into this function is the current panelRef and the 2nd is an optional
135+ * string explaining the close reason. The currently supported closeReasons
136+ * can be found in the MdPanelRef.closeReasons enum. These are by default
137+ * passed along by the panel.
132138 * - `trapFocus` - `{boolean=}`: Whether focus should be trapped within the
133139 * panel. If `trapFocus` is true, the user will not be able to interact
134140 * with the rest of the page until the panel is dismissed. Defaults to
@@ -870,6 +876,18 @@ function MdPanelService($rootElement, $rootScope, $injector, $window) {
870876 * @type {enum }
871877 */
872878 this . interceptorTypes = MdPanelRef . interceptorTypes ;
879+
880+ /**
881+ * Possible values for closing of a panel.
882+ * @type {enum }
883+ */
884+ this . closeReasons = MdPanelRef . closeReasons ;
885+
886+ /**
887+ * Possible values of absolute position.
888+ * @type {enum }
889+ */
890+ this . absPosition = MdPanelPosition . absPosition ;
873891}
874892
875893
@@ -1200,20 +1218,24 @@ MdPanelRef.prototype.open = function() {
12001218
12011219/**
12021220 * Closes the panel.
1221+ * @param {string } closeReason The event type that triggered the close.
12031222 * @returns {!angular.$q.Promise<!MdPanelRef> } A promise that is resolved when
12041223 * the panel is closed and animations finish.
12051224 */
1206- MdPanelRef . prototype . close = function ( ) {
1225+ MdPanelRef . prototype . close = function ( closeReason ) {
12071226 var self = this ;
12081227
12091228 return this . _$q ( function ( resolve , reject ) {
12101229 self . _callInterceptors ( MdPanelRef . interceptorTypes . CLOSE ) . then ( function ( ) {
12111230 var done = self . _done ( resolve , self ) ;
12121231 var detach = self . _simpleBind ( self . detach , self ) ;
1232+ var onCloseSuccess = self . config [ 'onCloseSuccess' ] || angular . noop ;
1233+ onCloseSuccess = angular . bind ( self , onCloseSuccess , self , closeReason ) ;
12131234
12141235 self . hide ( )
12151236 . then ( detach )
12161237 . then ( done )
1238+ . then ( onCloseSuccess )
12171239 . catch ( reject ) ;
12181240 } , reject ) ;
12191241 } ) ;
@@ -1802,7 +1824,7 @@ MdPanelRef.prototype._configureEscapeToClose = function() {
18021824 ev . stopPropagation ( ) ;
18031825 ev . preventDefault ( ) ;
18041826
1805- self . close ( ) ;
1827+ self . close ( MdPanelRef . closeReasons . ESCAPE ) ;
18061828 }
18071829 } ;
18081830
@@ -1845,7 +1867,7 @@ MdPanelRef.prototype._configureClickOutsideToClose = function() {
18451867 ev . stopPropagation ( ) ;
18461868 ev . preventDefault ( ) ;
18471869
1848- self . close ( ) ;
1870+ self . close ( MdPanelRef . closeReasons . CLICK_OUTSIDE ) ;
18491871 }
18501872 } ;
18511873
@@ -2154,6 +2176,14 @@ MdPanelRef.prototype.removeFromGroup = function(groupName) {
21542176 }
21552177} ;
21562178
2179+ /**
2180+ * Possible default closeReasons for the close function.
2181+ * @enum {string}
2182+ */
2183+ MdPanelRef . closeReasons = {
2184+ CLICK_OUTSIDE : 'clickOutsideToClose' ,
2185+ ESCAPE : 'escapeToClose' ,
2186+ } ;
21572187
21582188/*****************************************************************************
21592189 * MdPanelPosition *
0 commit comments