mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
A whole lotta shit
This commit is contained in:
48
js/ext/angular/src/service/ionicLoading.js
vendored
Normal file
48
js/ext/angular/src/service/ionicLoading.js
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
angular.module('ionic.service.loading', ['ionic.ui.loading'])
|
||||
|
||||
.factory('Loading', ['$rootScope', '$document', '$compile', function($rootScope, $document, $compile) {
|
||||
return {
|
||||
/**
|
||||
* Load an action sheet with the given template string.
|
||||
*
|
||||
* A new isolated scope will be created for the
|
||||
* action sheet and the new element will be appended into the body.
|
||||
*
|
||||
* @param {object} opts the options for this ActionSheet (see docs)
|
||||
*/
|
||||
show: function(opts) {
|
||||
var defaults = {
|
||||
content: '',
|
||||
animation: 'fade-in',
|
||||
showBackdrop: true
|
||||
};
|
||||
|
||||
opts = angular.extend(defaults, opts);
|
||||
|
||||
var scope = $rootScope.$new(true);
|
||||
angular.extend(scope, opts);
|
||||
|
||||
// Make sure there is only one loading element on the page at one point in time
|
||||
var existing = angular.element($document[0].querySelector('.loading-backdrop'));
|
||||
if(existing.length) {
|
||||
var scope = existing.scope();
|
||||
if(scope.loading) {
|
||||
scope.loading.show();
|
||||
return scope.loading;
|
||||
}
|
||||
}
|
||||
|
||||
// Compile the template
|
||||
var element = $compile('<loading>' + opts.content + '</loading>')(scope);
|
||||
|
||||
$document[0].body.appendChild(element[0]);
|
||||
|
||||
var loading = new ionic.views.Loading({el: element[0] });
|
||||
loading.show();
|
||||
|
||||
scope.loading = loading;
|
||||
|
||||
return loading;
|
||||
}
|
||||
};
|
||||
}]);
|
||||
Reference in New Issue
Block a user