A whole lotta shit

This commit is contained in:
Max Lynch
2013-10-21 10:44:35 -05:00
parent 073b30c818
commit aad3bb92b5
48 changed files with 25069 additions and 306 deletions

View 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;
}
};
}]);