11angular . module ( 'material.core' )
22 . provider ( '$$interimElement' , InterimElementProvider ) ;
33
4- /*
4+ /**
55 * @ngdoc service
6- * @name $$interimElement
7- * @module material.core
6+ * @name $$interimElementProvider
7+ * @module material.core.interimElement
88 *
99 * @description
1010 *
@@ -13,16 +13,16 @@ angular.module('material.core')
1313 * The service provides a promise-like API for interacting with the temporary
1414 * elements.
1515 *
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+ *
2223 * @param {object= } defaultOptions Options used by default for the `show` method on the service.
2324 *
2425 * @returns {$$interimElement.$service }
25- *
2626 */
2727
2828function InterimElementProvider ( ) {
@@ -71,7 +71,6 @@ function InterimElementProvider() {
7171 /**
7272 * Add a method to the factory that isn't specific to any interim element operations
7373 */
74-
7574 function addMethod ( name , fn ) {
7675 customMethods [ name ] = fn ;
7776 return provider ;
@@ -238,9 +237,7 @@ function InterimElementProvider() {
238237 locals [ interimFactoryName ] = publicService ;
239238 return $injector . invoke ( factory || function ( ) { return defaultVal ; } , { } , locals ) ;
240239 }
241-
242240 }
243-
244241 }
245242
246243 /* @ngInject */
@@ -249,24 +246,21 @@ function InterimElementProvider() {
249246 return function createInterimElementService ( ) {
250247 var SHOW_CANCELLED = false ;
251248
252- /*
249+ /**
253250 * @ngdoc service
254- * @name $$interimElement .$service
251+ * @name $$interimElementProvider .$service
255252 *
256253 * @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.
259256 */
260-
261257 var service ;
262258
263259 var showPromises = [ ] ; // Promises for the interim's which are currently opening.
264260 var hidePromises = [ ] ; // Promises for the interim's which are currently hiding.
265261 var showingInterims = [ ] ; // Interim elements which are currently showing up.
266262
267263 // Publish instance $$interimElement service;
268- // ... used as $mdDialog, $mdToast, $mdMenu, and $mdSelect
269-
270264 return service = {
271265 show : show ,
272266 hide : waitForInterim ( hide ) ,
@@ -275,18 +269,18 @@ function InterimElementProvider() {
275269 $injector_ : $injector
276270 } ;
277271
278- /*
272+ /**
279273 * @ngdoc method
280- * @name $$interimElement .$service#show
274+ * @name $$interimElementProvider .$service#show
281275 * @kind function
282276 *
283277 * @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.
289280 *
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.
290284 */
291285 function show ( options ) {
292286 options = options || { } ;
@@ -341,15 +335,16 @@ function InterimElementProvider() {
341335
342336 /**
343337 * @ngdoc method
344- * @name $$interimElement .$service#hide
338+ * @name $$interimElementProvider .$service#hide
345339 * @kind function
346340 *
347341 * @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() `.
349343 *
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.
353348 */
354349 function hide ( reason , options ) {
355350 options = options || { } ;
@@ -389,15 +384,16 @@ function InterimElementProvider() {
389384
390385 /**
391386 * @ngdoc method
392- * @name $$interimElement .$service#cancel
387+ * @name $$interimElementProvider .$service#cancel
393388 * @kind function
394389 *
395390 * @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()`.
397392 *
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.
401397 */
402398 function cancel ( reason , options ) {
403399 var interim = showingInterims . pop ( ) ;
@@ -445,9 +441,15 @@ function InterimElementProvider() {
445441 } ;
446442 }
447443
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".
451453 */
452454 function destroy ( targetEl ) {
453455 var interim = ! targetEl ? showingInterims . shift ( ) : null ;
@@ -758,7 +760,5 @@ function InterimElementProvider() {
758760
759761 }
760762 } ;
761-
762763 }
763-
764764}
0 commit comments