Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 17 additions & 29 deletions js/angular/service/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ var LOADING_TPL =
'</div>' +
'</div>';

var LOADING_HIDE_DEPRECATED = '$ionicLoading instance.hide() has been deprecated. Use $ionicLoading.hide().';
var LOADING_SHOW_DEPRECATED = '$ionicLoading instance.show() has been deprecated. Use $ionicLoading.show().';
var LOADING_SET_DEPRECATED = '$ionicLoading instance.setContent() has been deprecated. Use $ionicLoading.show({ template: \'my content\' }).';

/**
* @ngdoc service
* @name $ionicLoading
Expand All @@ -24,10 +20,14 @@ var LOADING_SET_DEPRECATED = '$ionicLoading instance.setContent() has been depre
* $scope.show = function() {
* $ionicLoading.show({
* template: 'Loading...'
* }).then(function(){
* console.log("The loading indicator is now displayed");
Copy link
Contributor

@dylanvdmerwe dylanvdmerwe May 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danbucholtz I really don't think the console.log outputs should be there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is just the documentation on how to use it.

* });
* };
* $scope.hide = function(){
* $ionicLoading.hide();
* $ionicLoading.hide().then(function(){
* console.log("The loading indicator is now hidden");
* });
* };
* });
* ```
Expand All @@ -47,7 +47,10 @@ var LOADING_SET_DEPRECATED = '$ionicLoading instance.setContent() has been depre
* });
* app.controller('AppCtrl', function($scope, $ionicLoading) {
* $scope.showLoading = function() {
* $ionicLoading.show(); //options default to values in $ionicLoadingConfig
* //options default to values in $ionicLoadingConfig
* $ionicLoading.show().then(function(){
* console.log("The loading indicator is now displayed");
* });
* };
* });
* ```
Expand Down Expand Up @@ -82,9 +85,8 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
* @ngdoc method
* @name $ionicLoading#show
* @description Shows a loading indicator. If the indicator is already shown,
* it will set the options given and keep the indicator shown. Note: While this
* function still returns an $ionicLoading instance for backwards compatiblity,
* its use has been deprecated.
* it will set the options given and keep the indicator shown.
* @returns {promise} A promise which is resolved when the loading indicator is presented.
* @param {object} opts The options for the loading indicator. Available properties:
* - `{string=}` `template` The html content of the indicator.
* - `{string=}` `templateUrl` The url of an html template to load as the content of the indicator.
Expand All @@ -101,6 +103,7 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
* @ngdoc method
* @name $ionicLoading#hide
* @description Hides the loading indicator, if shown.
* @returns {promise} A promise which is resolved when the loading indicator is hidden.
*/
hide: hideLoader,
/**
Expand Down Expand Up @@ -198,6 +201,8 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,

function showLoader(options) {
options = extend({}, $ionicLoadingConfig || {}, options || {});
// use a default delay of 100 to avoid some issues reported on github
// https://github.com/driftyco/ionic/issues/3717
var delay = options.delay || options.showDelay || 0;

deregisterStateListener1();
Expand All @@ -210,34 +215,17 @@ function($ionicLoadingConfig, $ionicBody, $ionicTemplateLoader, $ionicBackdrop,
//If loading.show() was called previously, cancel it and show with our new options
$timeout.cancel(loadingShowDelay);
loadingShowDelay = $timeout(noop, delay);
loadingShowDelay.then(getLoader).then(function(loader) {
return loadingShowDelay.then(getLoader).then(function(loader) {
return loader.show(options);
});

return {
hide: function deprecatedHide() {
$log.error(LOADING_HIDE_DEPRECATED);
return hideLoader.apply(this, arguments);
},
show: function deprecatedShow() {
$log.error(LOADING_SHOW_DEPRECATED);
return showLoader.apply(this, arguments);
},
setContent: function deprecatedSetContent(content) {
$log.error(LOADING_SET_DEPRECATED);
return getLoader().then(function(loader) {
loader.show({ template: content });
});
}
};
}

function hideLoader() {
deregisterStateListener1();
deregisterStateListener2();
$timeout.cancel(loadingShowDelay);
getLoader().then(function(loader) {
loader.hide();
return getLoader().then(function(loader) {
return loader.hide();
});
}
}]);
1 change: 0 additions & 1 deletion test/unit/angular/service/loading.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,3 @@ describe('$ionicLoadingConfig', function() {
}));

});