1
1
angular . module ( 'material.core' )
2
2
. provider ( '$$interimElement' , InterimElementProvider ) ;
3
3
4
- /*
4
+ /**
5
5
* @ngdoc service
6
- * @name $$interimElement
7
- * @module material.core
6
+ * @name $$interimElementProvider
7
+ * @module material.core.interimElement
8
8
*
9
9
* @description
10
10
*
@@ -13,16 +13,16 @@ angular.module('material.core')
13
13
* The service provides a promise-like API for interacting with the temporary
14
14
* elements.
15
15
*
16
- * ```js
17
- * app.service('$mdToast', function($$interimElement) {
18
- * var $mdToast = $$interimElement(toastDefaultOptions);
19
- * return $mdToast;
20
- * });
21
- * ```
16
+ * <hljs lang="js">
17
+ * app.service('$mdToast', function($$interimElement) {
18
+ * var $mdToast = $$interimElement(toastDefaultOptions);
19
+ * return $mdToast;
20
+ * });
21
+ * </hljs>
22
+ *
22
23
* @param {object= } defaultOptions Options used by default for the `show` method on the service.
23
24
*
24
25
* @returns {$$interimElement.$service }
25
- *
26
26
*/
27
27
28
28
function InterimElementProvider ( ) {
@@ -71,7 +71,6 @@ function InterimElementProvider() {
71
71
/**
72
72
* Add a method to the factory that isn't specific to any interim element operations
73
73
*/
74
-
75
74
function addMethod ( name , fn ) {
76
75
customMethods [ name ] = fn ;
77
76
return provider ;
@@ -238,9 +237,7 @@ function InterimElementProvider() {
238
237
locals [ interimFactoryName ] = publicService ;
239
238
return $injector . invoke ( factory || function ( ) { return defaultVal ; } , { } , locals ) ;
240
239
}
241
-
242
240
}
243
-
244
241
}
245
242
246
243
/* @ngInject */
@@ -249,24 +246,21 @@ function InterimElementProvider() {
249
246
return function createInterimElementService ( ) {
250
247
var SHOW_CANCELLED = false ;
251
248
252
- /*
249
+ /**
253
250
* @ngdoc service
254
- * @name $$interimElement .$service
251
+ * @name $$interimElementProvider .$service
255
252
*
256
253
* @description
257
- * A service used to control inserting and removing an element into the DOM.
258
- *
254
+ * A service used to control inserting and removing of an element from the DOM.
255
+ * It is used by $mdBottomSheet, $mdDialog, $mdToast, $mdMenu, $mdPanel, and $mdSelect.
259
256
*/
260
-
261
257
var service ;
262
258
263
259
var showPromises = [ ] ; // Promises for the interim's which are currently opening.
264
260
var hidePromises = [ ] ; // Promises for the interim's which are currently hiding.
265
261
var showingInterims = [ ] ; // Interim elements which are currently showing up.
266
262
267
263
// Publish instance $$interimElement service;
268
- // ... used as $mdDialog, $mdToast, $mdMenu, and $mdSelect
269
-
270
264
return service = {
271
265
show : show ,
272
266
hide : waitForInterim ( hide ) ,
@@ -275,18 +269,18 @@ function InterimElementProvider() {
275
269
$injector_ : $injector
276
270
} ;
277
271
278
- /*
272
+ /**
279
273
* @ngdoc method
280
- * @name $$interimElement .$service#show
274
+ * @name $$interimElementProvider .$service#show
281
275
* @kind function
282
276
*
283
277
* @description
284
- * Adds the `$interimElement` to the DOM and returns a special promise that will be resolved or rejected
285
- * with hide or cancel, respectively. To external cancel/hide, developers should use the
286
- *
287
- * @param {* } options is hashMap of settings
288
- * @returns a Promise
278
+ * Adds the `$interimElement` to the DOM and returns a special promise that will be resolved
279
+ * or rejected with hide or cancel, respectively.
289
280
*
281
+ * @param {object } options map of options and values
282
+ * @returns {Promise } a Promise that will be resolved when hide() is called or rejected when
283
+ * cancel() is called.
290
284
*/
291
285
function show ( options ) {
292
286
options = options || { } ;
@@ -341,15 +335,16 @@ function InterimElementProvider() {
341
335
342
336
/**
343
337
* @ngdoc method
344
- * @name $$interimElement .$service#hide
338
+ * @name $$interimElementProvider .$service#hide
345
339
* @kind function
346
340
*
347
341
* @description
348
- * Removes the `$interimElement` from the DOM and resolves the promise returned from `show`.
342
+ * Removes the `$interimElement` from the DOM and resolves the Promise returned from `show() `.
349
343
*
350
- * @param {* } reason Data to resolve the promise with
351
- * @param {object } options
352
- * @returns {Promise } a Promise that will be resolved after the element has been removed.
344
+ * @param {* } reason Data used to resolve the Promise
345
+ * @param {object } options map of options and values
346
+ * @returns {Promise } a Promise that will be resolved after the element has been removed
347
+ * from the DOM.
353
348
*/
354
349
function hide ( reason , options ) {
355
350
options = options || { } ;
@@ -389,15 +384,16 @@ function InterimElementProvider() {
389
384
390
385
/**
391
386
* @ngdoc method
392
- * @name $$interimElement .$service#cancel
387
+ * @name $$interimElementProvider .$service#cancel
393
388
* @kind function
394
389
*
395
390
* @description
396
- * Removes the `$interimElement` from the DOM and rejects the promise returned from `show`
391
+ * Removes the `$interimElement` from the DOM and rejects the Promise returned from `show()`.
397
392
*
398
- * @param {* } reason Data to reject the promise with
399
- * @param {object } options
400
- * @returns {Promise } Promise that will be resolved after the element has been removed.
393
+ * @param {* } reason Data used to resolve the Promise
394
+ * @param {object } options map of options and values
395
+ * @returns {Promise } Promise that will be resolved after the element has been removed
396
+ * from the DOM.
401
397
*/
402
398
function cancel ( reason , options ) {
403
399
var interim = showingInterims . pop ( ) ;
@@ -445,9 +441,15 @@ function InterimElementProvider() {
445
441
} ;
446
442
}
447
443
448
- /*
449
- * Special method to quick-remove the interim element without animations
450
- * Note: interim elements are in "interim containers"
444
+ /**
445
+ * @ngdoc method
446
+ * @name $$interimElementProvider.$service#destroy
447
+ * @kind function
448
+ *
449
+ * Special method to quick-remove the interim element without running animations. This is
450
+ * useful when the parent component has been or is being destroyed.
451
+ *
452
+ * Note: interim elements are in "interim containers".
451
453
*/
452
454
function destroy ( targetEl ) {
453
455
var interim = ! targetEl ? showingInterims . shift ( ) : null ;
@@ -758,7 +760,5 @@ function InterimElementProvider() {
758
760
759
761
}
760
762
} ;
761
-
762
763
}
763
-
764
764
}
0 commit comments