Skip to content

Commit

Permalink
feat($ionicBackdrop): add backdrop show/hide service
Browse files Browse the repository at this point in the history
Closes #1084
  • Loading branch information
ajoslin committed Apr 11, 2014
1 parent bc3e223 commit 730a33b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
14 changes: 13 additions & 1 deletion docs/templates/api_menu_version.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,19 @@
</ul>
</li>


<!-- Backdrop -->
<li class="menu-section">
<a href="#" class="api-section">
Backdrop
</a>
<ul>
<li>
<a href="{{ page.versionHref }}/api/service/$ionicBackdrop">
$ionicBackdrop
</a>
</li>
</ul>
</li>

<!-- Utility -->
<li class="menu-section">
Expand Down
44 changes: 43 additions & 1 deletion js/ext/angular/src/service/ionicBackdrop.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
angular.module('ionic')

/**
* @private
* @ngdoc service
* @name $ionicBackdrop
* @module ionic
* @description
* Shows and hides a backdrop over the UI. Appears behind popups, loading,
* and other overlays.
*
* Often, multiple UI components require a backdrop, but only one backdrop is
* ever needed in the DOM at a time.
*
* Therefore, each component that requires the backdrop to be shown calls
* `$ionicBackdrop.retain()` when it wants the backdrop, then `$ionicBackdrop.release()`
* when it is done with the backdrop.
*
* For each time `retain` is called, the backdrop will be shown until `release` is called.
*
* For example, if `retain` is called three times, the backdrop will be shown until `release`
* is called three times.
*
* @usage
*
* ```js
* function MyController($scope, $ionicBackdrop, $timeout) {
* //Show a backdrop for one second
* $scope.action = function() {
* $ionicBackdrop.retain();
* $timeout(function() {
* $ionicBackdrop.release();
* }, 1000);
* };
* }
* ```
*/
.factory('$ionicBackdrop', [
'$document',
Expand All @@ -13,7 +44,18 @@ function($document) {
$document[0].body.appendChild(el[0]);

return {
/**
* @ngdoc method
* @name $ionicBackdrop#retain
* @description Retains the backdrop.
*/
retain: retain,
/**
* @ngdoc method
* @name $ionicBackdrop#retain
* @description
* Releases the backdrop.
*/
release: release,
// exposed for testing
_element: el
Expand Down

0 comments on commit 730a33b

Please sign in to comment.