angular-loading-bar
Advanced tools
Comparing version 0.4.2 to 0.4.3
{ | ||
"name": "angular-loading-bar", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"main": ["src/loading-bar.js", "src/loading-bar.css"], | ||
@@ -5,0 +5,0 @@ "ignore": [ |
/*! | ||
* angular-loading-bar v0.4.2 | ||
* angular-loading-bar v0.4.3 | ||
* https://chieffancypants.github.io/angular-loading-bar | ||
@@ -120,3 +120,3 @@ * Copyright (c) 2014 Wes Cruver | ||
'response': function(response) { | ||
if (!isCached(response.config)) { | ||
if (!response.config.ignoreLoadingBar && !isCached(response.config)) { | ||
reqsCompleted++; | ||
@@ -134,3 +134,3 @@ $rootScope.$broadcast('cfpLoadingBar:loaded', {url: response.config.url}); | ||
'responseError': function(rejection) { | ||
if (!isCached(rejection.config)) { | ||
if (!rejection.config.ignoreLoadingBar && !isCached(rejection.config)) { | ||
reqsCompleted++; | ||
@@ -137,0 +137,0 @@ $rootScope.$broadcast('cfpLoadingBar:loaded', {url: rejection.config.url}); |
/*! | ||
* angular-loading-bar v0.4.2 | ||
* angular-loading-bar v0.4.3 | ||
* https://chieffancypants.github.io/angular-loading-bar | ||
@@ -7,2 +7,2 @@ * Copyright (c) 2014 Wes Cruver | ||
*/ | ||
!function(){"use strict";angular.module("angular-loading-bar",["cfp.loadingBarInterceptor"]),angular.module("chieffancypants.loadingBar",["cfp.loadingBarInterceptor"]),angular.module("cfp.loadingBarInterceptor",["cfp.loadingBar"]).config(["$httpProvider",function(a){var b=["$q","$cacheFactory","$timeout","$rootScope","cfpLoadingBar",function(b,c,d,e,f){function g(){d.cancel(i),f.complete(),k=0,j=0}function h(b){var d,e=a.defaults;if("GET"!==b.method||b.cache===!1)return b.cached=!1,!1;d=b.cache===!0&&void 0===e.cache?c.get("$http"):void 0!==e.cache?e.cache:b.cache;var f=void 0!==d?void 0!==d.get(b.url):!1;return void 0!==b.cached&&f!==b.cached?b.cached:(b.cached=f,f)}var i,j=0,k=0,l=f.latencyThreshold;return{request:function(a){return a.ignoreLoadingBar||h(a)||(e.$broadcast("cfpLoadingBar:loading",{url:a.url}),0===j&&(i=d(function(){f.start()},l)),j++,f.set(k/j)),a},response:function(a){return h(a.config)||(k++,e.$broadcast("cfpLoadingBar:loaded",{url:a.config.url}),k>=j?g():f.set(k/j)),a},responseError:function(a){return h(a.config)||(k++,e.$broadcast("cfpLoadingBar:loaded",{url:a.config.url}),k>=j?g():f.set(k/j)),b.reject(a)}}}];a.interceptors.push(b)}]),angular.module("cfp.loadingBar",[]).provider("cfpLoadingBar",function(){this.includeSpinner=!0,this.includeBar=!0,this.latencyThreshold=100,this.startSize=.02,this.parentSelector="body",this.$get=["$document","$timeout","$animate","$rootScope",function(a,b,c,d){function e(){var e=a.find(l);b.cancel(k),p||(d.$broadcast("cfpLoadingBar:started"),p=!0,s&&c.enter(m,e),r&&c.enter(o,e),f(t))}function f(a){if(p){var c=100*a+"%";n.css("width",c),q=a,b.cancel(j),j=b(function(){g()},250)}}function g(){if(!(h()>=1)){var a=0,b=h();a=b>=0&&.25>b?(3*Math.random()+3)/100:b>=.25&&.65>b?3*Math.random()/100:b>=.65&&.9>b?2*Math.random()/100:b>=.9&&.99>b?.005:0;var c=h()+a;f(c)}}function h(){return q}function i(){d.$broadcast("cfpLoadingBar:completed"),f(1),k=b(function(){c.leave(m,function(){q=0,p=!1}),c.leave(o)},500)}var j,k,l=this.parentSelector,m=angular.element('<div id="loading-bar"><div class="bar"><div class="peg"></div></div></div>'),n=m.find("div").eq(0),o=angular.element('<div id="loading-bar-spinner"><div class="spinner-icon"></div></div>'),p=!1,q=0,r=this.includeSpinner,s=this.includeBar,t=this.startSize;return{start:e,set:f,status:h,inc:g,complete:i,includeSpinner:this.includeSpinner,latencyThreshold:this.latencyThreshold,parentSelector:this.parentSelector,startSize:this.startSize}}]})}(); | ||
!function(){"use strict";angular.module("angular-loading-bar",["cfp.loadingBarInterceptor"]),angular.module("chieffancypants.loadingBar",["cfp.loadingBarInterceptor"]),angular.module("cfp.loadingBarInterceptor",["cfp.loadingBar"]).config(["$httpProvider",function(a){var b=["$q","$cacheFactory","$timeout","$rootScope","cfpLoadingBar",function(b,c,d,e,f){function g(){d.cancel(i),f.complete(),k=0,j=0}function h(b){var d,e=a.defaults;if("GET"!==b.method||b.cache===!1)return b.cached=!1,!1;d=b.cache===!0&&void 0===e.cache?c.get("$http"):void 0!==e.cache?e.cache:b.cache;var f=void 0!==d?void 0!==d.get(b.url):!1;return void 0!==b.cached&&f!==b.cached?b.cached:(b.cached=f,f)}var i,j=0,k=0,l=f.latencyThreshold;return{request:function(a){return a.ignoreLoadingBar||h(a)||(e.$broadcast("cfpLoadingBar:loading",{url:a.url}),0===j&&(i=d(function(){f.start()},l)),j++,f.set(k/j)),a},response:function(a){return a.config.ignoreLoadingBar||h(a.config)||(k++,e.$broadcast("cfpLoadingBar:loaded",{url:a.config.url}),k>=j?g():f.set(k/j)),a},responseError:function(a){return a.config.ignoreLoadingBar||h(a.config)||(k++,e.$broadcast("cfpLoadingBar:loaded",{url:a.config.url}),k>=j?g():f.set(k/j)),b.reject(a)}}}];a.interceptors.push(b)}]),angular.module("cfp.loadingBar",[]).provider("cfpLoadingBar",function(){this.includeSpinner=!0,this.includeBar=!0,this.latencyThreshold=100,this.startSize=.02,this.parentSelector="body",this.$get=["$document","$timeout","$animate","$rootScope",function(a,b,c,d){function e(){var e=a.find(l);b.cancel(k),p||(d.$broadcast("cfpLoadingBar:started"),p=!0,s&&c.enter(m,e),r&&c.enter(o,e),f(t))}function f(a){if(p){var c=100*a+"%";n.css("width",c),q=a,b.cancel(j),j=b(function(){g()},250)}}function g(){if(!(h()>=1)){var a=0,b=h();a=b>=0&&.25>b?(3*Math.random()+3)/100:b>=.25&&.65>b?3*Math.random()/100:b>=.65&&.9>b?2*Math.random()/100:b>=.9&&.99>b?.005:0;var c=h()+a;f(c)}}function h(){return q}function i(){d.$broadcast("cfpLoadingBar:completed"),f(1),k=b(function(){c.leave(m,function(){q=0,p=!1}),c.leave(o)},500)}var j,k,l=this.parentSelector,m=angular.element('<div id="loading-bar"><div class="bar"><div class="peg"></div></div></div>'),n=m.find("div").eq(0),o=angular.element('<div id="loading-bar-spinner"><div class="spinner-icon"></div></div>'),p=!1,q=0,r=this.includeSpinner,s=this.includeBar,t=this.startSize;return{start:e,set:f,status:h,inc:g,complete:i,includeSpinner:this.includeSpinner,latencyThreshold:this.latencyThreshold,parentSelector:this.parentSelector,startSize:this.startSize}}]})}(); |
Changelog | ||
========== | ||
## 0.4.3 | ||
- update z-index to work with other css frameworks ([#69](https://github.com/chieffancypants/angular-loading-bar/pull/69)) | ||
- ignoreLoadingBar not ignored when calculating percentage complete ([#70](https://github.com/chieffancypants/angular-loading-bar/pull/70)) | ||
## 0.4.2 | ||
@@ -5,0 +9,0 @@ - Split loading bar into different modules so they can be included separately ([#46](https://github.com/chieffancypants/angular-loading-bar/issues/46)) |
{ | ||
"name": "angular-loading-bar", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "An automatic loading bar for AngularJS", | ||
@@ -5,0 +5,0 @@ "main": "src/loading-bar.js", |
@@ -51,3 +51,3 @@ angular-loading-bar | ||
**Turn the spinner on or off:** | ||
#### Turn the spinner on or off: | ||
The insertion of the spinner can be controlled through configuration. It's on by default, but if you'd like to turn it off, simply configure the service: | ||
@@ -62,3 +62,3 @@ | ||
**Turn the loading bar on or off:** | ||
#### Turn the loading bar on or off: | ||
Like the spinner configuration above, the loading bar can also be turned off for cases where you only want the spinner: | ||
@@ -73,3 +73,13 @@ | ||
**Ignoring particular XHR requests:** | ||
#### Latency Threshold | ||
By default, the loading bar will only display after it has been waiting for a response for over 100ms. This helps keep things feeling snappy, and avoids the annoyingness of showing a loading bar every few seconds on really chatty applications. This threshold is totally configurable: | ||
```js | ||
angular.module('myApp', ['angular-loading-bar']) | ||
.config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) { | ||
cfpLoadingBarProvider.latencyThreshold = 500; | ||
}]) | ||
``` | ||
#### Ignoring particular XHR requests: | ||
The loading bar can also be forced to ignore certain requests, for example, when long-polling or periodically sending debugging information back to the server. | ||
@@ -145,2 +155,2 @@ | ||
## License: | ||
Licensed under the MIT license | ||
Licensed under the MIT license |
@@ -114,3 +114,3 @@ /* | ||
'response': function(response) { | ||
if (!isCached(response.config)) { | ||
if (!response.config.ignoreLoadingBar && !isCached(response.config)) { | ||
reqsCompleted++; | ||
@@ -128,3 +128,3 @@ $rootScope.$broadcast('cfpLoadingBar:loaded', {url: response.config.url}); | ||
'responseError': function(rejection) { | ||
if (!isCached(rejection.config)) { | ||
if (!rejection.config.ignoreLoadingBar && !isCached(rejection.config)) { | ||
reqsCompleted++; | ||
@@ -131,0 +131,0 @@ $rootScope.$broadcast('cfpLoadingBar:loaded', {url: rejection.config.url}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
71349
153