added progress bar
This commit is contained in:
parent
2efae5103f
commit
443c95a135
74
html/css/nprogress.css
Normal file
74
html/css/nprogress.css
Normal file
@ -0,0 +1,74 @@
|
||||
/* Make clicks pass-through */
|
||||
#nprogress {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
#nprogress .bar {
|
||||
background: #29d;
|
||||
|
||||
position: fixed;
|
||||
z-index: 1031;
|
||||
top: 0;
|
||||
left: 0;
|
||||
|
||||
width: 100%;
|
||||
height: 2px;
|
||||
}
|
||||
|
||||
/* Fancy blur effect */
|
||||
#nprogress .peg {
|
||||
display: block;
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
width: 100px;
|
||||
height: 100%;
|
||||
box-shadow: 0 0 10px #29d, 0 0 5px #29d;
|
||||
opacity: 1.0;
|
||||
|
||||
-webkit-transform: rotate(3deg) translate(0px, -4px);
|
||||
-ms-transform: rotate(3deg) translate(0px, -4px);
|
||||
transform: rotate(3deg) translate(0px, -4px);
|
||||
}
|
||||
|
||||
/* Remove these to get rid of the spinner */
|
||||
#nprogress .spinner {
|
||||
display: block;
|
||||
position: fixed;
|
||||
z-index: 1031;
|
||||
top: 15px;
|
||||
right: 15px;
|
||||
}
|
||||
|
||||
#nprogress .spinner-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
box-sizing: border-box;
|
||||
|
||||
border: solid 2px transparent;
|
||||
border-top-color: #29d;
|
||||
border-left-color: #29d;
|
||||
border-radius: 50%;
|
||||
|
||||
-webkit-animation: nprogress-spinner 400ms linear infinite;
|
||||
animation: nprogress-spinner 400ms linear infinite;
|
||||
}
|
||||
|
||||
.nprogress-custom-parent {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.nprogress-custom-parent #nprogress .spinner,
|
||||
.nprogress-custom-parent #nprogress .bar {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
@-webkit-keyframes nprogress-spinner {
|
||||
0% { -webkit-transform: rotate(0deg); }
|
||||
100% { -webkit-transform: rotate(360deg); }
|
||||
}
|
||||
@keyframes nprogress-spinner {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
|
||||
<link rel="stylesheet" href="css/normalize-min.css">
|
||||
<link rel="stylesheet" href="css/skeleton-min.css">
|
||||
<link rel="stylesheet" href="css/nprogress.css">
|
||||
<style>
|
||||
.info {
|
||||
border-bottom: 1px solid #bbbbbb;
|
||||
@ -66,7 +67,8 @@
|
||||
<script type="text/javascript" src="js/moment.js"></script>
|
||||
<script type="text/javascript" src="js/ejs.js"></script>-->
|
||||
<script type="text/javascript" src="js/output.min.js"></script>
|
||||
<script type="text/javascript" src="js/app.prod.min.js"></script>
|
||||
<script type="text/javascript" src="js/nprogress.js"></script>
|
||||
<script type="text/javascript" src="js/app.prod.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
|
@ -45,6 +45,7 @@ var APP = {
|
||||
console.log(this);
|
||||
console.log('get ' + this.feeds[this.refreshStep]);
|
||||
$('#lastupdate').empty().append('Refreshing...');
|
||||
NProgress.start();
|
||||
this.doRefresh();
|
||||
|
||||
},
|
||||
@ -60,6 +61,7 @@ var APP = {
|
||||
});
|
||||
} else {
|
||||
console.log('Done');
|
||||
NProgress.inc(0.2);
|
||||
this.doSave();
|
||||
}
|
||||
},
|
||||
@ -70,6 +72,7 @@ var APP = {
|
||||
|
||||
console.log(this._storage);
|
||||
this.refreshStep++;
|
||||
NProgress.inc(0.2);
|
||||
this.doRefresh();
|
||||
},
|
||||
doSave: function() {
|
||||
@ -79,6 +82,7 @@ var APP = {
|
||||
localStorage.setItem('lastUpdated', this.lastUpdated);
|
||||
localStorage.setItem('_storage', JSON.stringify(this._storage));
|
||||
this.getLastUpdateDate();
|
||||
NProgress.done(true);
|
||||
},
|
||||
doLoad: function() {
|
||||
|
||||
|
2
html/js/app.prod.min.js
vendored
2
html/js/app.prod.min.js
vendored
@ -1,2 +1,2 @@
|
||||
var APP={refreshStep:0,preUrl:"/",_storage:{lastupdated:null,feeds:{}},_list:null,_feed:null,feeds:["paleo","lifestyle"],lastUpdated:null,preCache:function(){this._list=new EJS({url:"ejs/list.ejs"}),this._feed=new EJS({url:"ejs/test.ejs"})},init:function(){$("#refresh").on("click",$.proxy(this.refresh,this)),console.log("app starting..."),this.preCache(),this.doLoad(),this.getLastUpdateDate(),console.log("Last updated: "+this.lastUpdated)},getLastUpdateDate:function(){var e,t;null==this.lastUpdated?$("#lastupdate").empty().append("Never"):(t=new Date(this.lastUpdated),e=moment(t).startOf("minute").fromNow(),console.log(e),$("#lastupdate").empty().append(e))},refresh:function(){this.refreshStep=0,console.log("refresh"),console.log(this),console.log("get "+this.feeds[this.refreshStep]),$("#lastupdate").empty().append("Refreshing..."),this.doRefresh()},doRefresh:function(){var e=this;if(this.refreshStep<this.feeds.length){var t=this.preUrl+this.feeds[this.refreshStep]+".json";$("#lastupdate").empty().append("Refreshing: "+this.feeds[this.refreshStep]),$.getJSON(t,function(t){console.log(e),e.doUpdate(t)})}else console.log("Done"),this.doSave()},doUpdate:function(e){console.log(this),console.log(e),this._storage.feeds[this.feeds[this.refreshStep]]=e,console.log(this._storage),this.refreshStep++,this.doRefresh()},doSave:function(){console.log("Saving..."),this.lastUpdated=new Date,this._storage.lastupdated=this.lastUpdated,localStorage.setItem("lastUpdated",this.lastUpdated),localStorage.setItem("_storage",JSON.stringify(this._storage)),this.getLastUpdateDate()},doLoad:function(){var e=localStorage.getItem("_storage");$("#lastupdate").empty().append("Loading..."),this._storage=null!=e?JSON.parse(e):{lastupdated:null,feeds:{}},this.lastUpdated=this._storage.lastupdated||null,this.showList()},showList:function(){var e,t={},s=[];for(var o in this._storage.feeds)console.log(o),s.push({name:o});t.list=s;var e=this._list.render(t);$("#list").empty().append(e);for(var o in this._storage.feeds)$("#"+o).on("click",$.proxy(this.showFeed,this,o))},showFeed:function(e){var t,s;console.log("show feed "+e),$("#feedcontent").empty(),s={d:this._storage.feeds[e]};var t=this._feed.render(s);$("#feedcontent").append(t)}};Zepto(function(){console.log("Start app"),"undefined"!=typeof Storage?APP.init():alert("No local storage")});
|
||||
var APP={refreshStep:0,preUrl:"/",_storage:{lastupdated:null,feeds:{}},_list:null,_feed:null,feeds:["paleo","lifestyle"],lastUpdated:null,preCache:function(){this._list=new EJS({url:"ejs/list.ejs"}),this._feed=new EJS({url:"ejs/test.ejs"})},init:function(){$("#refresh").on("click",$.proxy(this.refresh,this)),console.log("app starting..."),this.preCache(),this.doLoad(),this.getLastUpdateDate(),console.log("Last updated: "+this.lastUpdated)},getLastUpdateDate:function(){var e,t;null==this.lastUpdated?$("#lastupdate").empty().append("Never"):(t=new Date(this.lastUpdated),e=moment(t).startOf("minute").fromNow(),console.log(e),$("#lastupdate").empty().append(e))},refresh:function(){this.refreshStep=0,console.log("refresh"),console.log(this),console.log("get "+this.feeds[this.refreshStep]),$("#lastupdate").empty().append("Refreshing..."),NProgress.start(),this.doRefresh()},doRefresh:function(){var e=this;if(this.refreshStep<this.feeds.length){var t=this.preUrl+this.feeds[this.refreshStep]+".json";$("#lastupdate").empty().append("Refreshing: "+this.feeds[this.refreshStep]),$.getJSON(t,function(t){console.log(e),e.doUpdate(t)})}else console.log("Done"),NProgress.inc(.2),this.doSave()},doUpdate:function(e){console.log(this),console.log(e),this._storage.feeds[this.feeds[this.refreshStep]]=e,console.log(this._storage),this.refreshStep++,NProgress.inc(.2),this.doRefresh()},doSave:function(){console.log("Saving..."),this.lastUpdated=new Date,this._storage.lastupdated=this.lastUpdated,localStorage.setItem("lastUpdated",this.lastUpdated),localStorage.setItem("_storage",JSON.stringify(this._storage)),this.getLastUpdateDate(),NProgress.done(!0)},doLoad:function(){var e=localStorage.getItem("_storage");$("#lastupdate").empty().append("Loading..."),this._storage=null!=e?JSON.parse(e):{lastupdated:null,feeds:{}},this.lastUpdated=this._storage.lastupdated||null,this.showList()},showList:function(){var e,t={},s=[];for(var o in this._storage.feeds)console.log(o),s.push({name:o});t.list=s;var e=this._list.render(t);$("#list").empty().append(e);for(var o in this._storage.feeds)$("#"+o).on("click",$.proxy(this.showFeed,this,o))},showFeed:function(e){var t,s;console.log("show feed "+e),$("#feedcontent").empty(),s={d:this._storage.feeds[e]};var t=this._feed.render(s);$("#feedcontent").append(t)}};Zepto(function(){console.log("Start app"),"undefined"!=typeof Storage?APP.init():alert("No local storage")});
|
||||
//# sourceMappingURL=app.prod.min.js.map
|
||||
|
@ -1 +1 @@
|
||||
{"version":3,"sources":["app.prod.js"],"names":["APP","refreshStep","preUrl","_storage","lastupdated","feeds","_list","_feed","lastUpdated","preCache","this","EJS","url","init","$","on","proxy","refresh","console","log","doLoad","getLastUpdateDate","formatted","dt","empty","append","Date","moment","startOf","fromNow","doRefresh","self","length","feedUrl","getJSON","data","doUpdate","doSave","localStorage","setItem","JSON","stringify","_load","getItem","parse","showList","output","d","list","key","push","name","render","showFeed","opt","Zepto","alert"],"mappings":"AAAA,GAAIA,MACAC,YAAa,EACbC,OAAQ,IAERC,UACIC,YAAa,KACbC,UAEJC,MAAQ,KACRC,MAAQ,KAERF,OAAQ,QAAS,aACjBG,YAAa,KACbC,SAAU,WACNC,KAAKJ,MAAQ,GAAIK,MAAKC,IAAK,iBAC3BF,KAAKH,MAAQ,GAAII,MACbC,IAAK,kBAGbC,KAAM,WACFC,EAAE,YAAYC,GAAG,QAASD,EAAEE,MAAMN,KAAKO,QAASP,OAChDQ,QAAQC,IAAI,mBACZT,KAAKD,WACLC,KAAKU,SACLV,KAAKW,oBACLH,QAAQC,IAAI,iBAAmBT,KAAKF,cAExCa,kBAAmB,WACf,GAAIC,GAAWC,CAGS,OAApBb,KAAKF,YACLM,EAAE,eAAeU,QAAQC,OAAO,UAEhCF,EAAK,GAAIG,MAAKhB,KAAKF,aACnBc,EAAYK,OAAOJ,GAAIK,QAAQ,UAAUC,UACzCX,QAAQC,IAAIG,GACZR,EAAE,eAAeU,QAAQC,OAAOH,KAIxCL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,GAAEC,KAAOA,CAET,IAAIF,GAASpC,KAAKJ,MAAM8C,OAAOL,EAC/BjC,GAAE,SAASU,QAAQC,OAAOqB,EAE1B,KAAK,GAAIG,KAAOvC,MAAKP,SAASE,MAC1BS,EAAE,IAAMmC,GAAKlC,GAAG,QAASD,EAAEE,MAAMN,KAAK2C,SAAU3C,KAAMuC,KAK9DI,SAAU,SAASC,GACf,GAAIR,GAAQC,CACZ7B,SAAQC,IAAI,aAAemC,GAC3BxC,EAAE,gBAAgBU,QAClBuB,GACIA,EAAGrC,KAAKP,SAASE,MAAMiD,GAE3B,IAAIR,GAASpC,KAAKH,MAAM6C,OAAOL,EAE/BjC,GAAE,gBAAgBW,OAAOqB,IAMjCS,OAAM,WACFrC,QAAQC,IAAI,aACY,mBAAd,SACNnB,IAAIa,OAGJ2C,MAAM"}
|
||||
{"version":3,"sources":["app.prod.js"],"names":["APP","refreshStep","preUrl","_storage","lastupdated","feeds","_list","_feed","lastUpdated","preCache","this","EJS","url","init","$","on","proxy","refresh","console","log","doLoad","getLastUpdateDate","formatted","dt","empty","append","Date","moment","startOf","fromNow","NProgress","start","doRefresh","self","length","feedUrl","getJSON","data","doUpdate","inc","doSave","localStorage","setItem","JSON","stringify","done","_load","getItem","parse","showList","output","d","list","key","push","name","render","showFeed","opt","Zepto","alert"],"mappings":"AAAA,GAAIA,MACAC,YAAa,EACbC,OAAQ,IAERC,UACIC,YAAa,KACbC,UAEJC,MAAQ,KACRC,MAAQ,KAERF,OAAQ,QAAS,aACjBG,YAAa,KACbC,SAAU,WACNC,KAAKJ,MAAQ,GAAIK,MAAKC,IAAK,iBAC3BF,KAAKH,MAAQ,GAAII,MACbC,IAAK,kBAGbC,KAAM,WACFC,EAAE,YAAYC,GAAG,QAASD,EAAEE,MAAMN,KAAKO,QAASP,OAChDQ,QAAQC,IAAI,mBACZT,KAAKD,WACLC,KAAKU,SACLV,KAAKW,oBACLH,QAAQC,IAAI,iBAAmBT,KAAKF,cAExCa,kBAAmB,W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CjC,GAAE,eAAeU,QAAQC,OAAO,cAE5Bf,KAAKP,SADI,MAAT2C,EACgBH,KAAKK,MAAMF,IAGvB1C,YAAa,KACbC,UAERK,KAAKF,YAAcE,KAAKP,SAASC,aAAe,KAChDM,KAAKuC,YAETA,SAAU,WACN,GAAIC,GAAQC,KACRC,IACJ,KAAK,GAAIC,KAAO3C,MAAKP,SAASE,MAC1Ba,QAAQC,IAAIkC,GACZD,EAAKE,MACDC,KAAMF,GAIdF,GAAEC,KAAOA,CAET,IAAIF,GAASxC,KAAKJ,MAAMkD,OAAOL,EAC/BrC,GAAE,SAASU,QAAQC,OAAOyB,EAE1B,KAAK,GAAIG,KAAO3C,MAAKP,SAASE,MAC1BS,EAAE,IAAMuC,GAAKtC,GAAG,QAASD,EAAEE,MAAMN,KAAK+C,SAAU/C,KAAM2C,KAK9DI,SAAU,SAASC,GACf,GAAIR,GAAQC,CACZjC,SAAQC,IAAI,aAAeuC,GAC3B5C,EAAE,gBAAgBU,QAClB2B,GACIA,EAAGzC,KAAKP,SAASE,MAAMqD,GAE3B,IAAIR,GAASxC,KAAKH,MAAMiD,OAAOL,EAE/BrC,GAAE,gBAAgBW,OAAOyB,IAMjCS,OAAM,WACFzC,QAAQC,IAAI,aACY,mBAAd,SACNnB,IAAIa,OAGJ+C,MAAM"}
|
476
html/js/nprogress.js
Normal file
476
html/js/nprogress.js
Normal file
@ -0,0 +1,476 @@
|
||||
/* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress
|
||||
* @license MIT */
|
||||
|
||||
;(function(root, factory) {
|
||||
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
module.exports = factory();
|
||||
} else {
|
||||
root.NProgress = factory();
|
||||
}
|
||||
|
||||
})(this, function() {
|
||||
var NProgress = {};
|
||||
|
||||
NProgress.version = '0.2.0';
|
||||
|
||||
var Settings = NProgress.settings = {
|
||||
minimum: 0.08,
|
||||
easing: 'ease',
|
||||
positionUsing: '',
|
||||
speed: 200,
|
||||
trickle: true,
|
||||
trickleRate: 0.02,
|
||||
trickleSpeed: 800,
|
||||
showSpinner: true,
|
||||
barSelector: '[role="bar"]',
|
||||
spinnerSelector: '[role="spinner"]',
|
||||
parent: 'body',
|
||||
template: '<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates configuration.
|
||||
*
|
||||
* NProgress.configure({
|
||||
* minimum: 0.1
|
||||
* });
|
||||
*/
|
||||
NProgress.configure = function(options) {
|
||||
var key, value;
|
||||
for (key in options) {
|
||||
value = options[key];
|
||||
if (value !== undefined && options.hasOwnProperty(key)) Settings[key] = value;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Last number.
|
||||
*/
|
||||
|
||||
NProgress.status = null;
|
||||
|
||||
/**
|
||||
* Sets the progress bar status, where `n` is a number from `0.0` to `1.0`.
|
||||
*
|
||||
* NProgress.set(0.4);
|
||||
* NProgress.set(1.0);
|
||||
*/
|
||||
|
||||
NProgress.set = function(n) {
|
||||
var started = NProgress.isStarted();
|
||||
|
||||
n = clamp(n, Settings.minimum, 1);
|
||||
NProgress.status = (n === 1 ? null : n);
|
||||
|
||||
var progress = NProgress.render(!started),
|
||||
bar = progress.querySelector(Settings.barSelector),
|
||||
speed = Settings.speed,
|
||||
ease = Settings.easing;
|
||||
|
||||
progress.offsetWidth; /* Repaint */
|
||||
|
||||
queue(function(next) {
|
||||
// Set positionUsing if it hasn't already been set
|
||||
if (Settings.positionUsing === '') Settings.positionUsing = NProgress.getPositioningCSS();
|
||||
|
||||
// Add transition
|
||||
css(bar, barPositionCSS(n, speed, ease));
|
||||
|
||||
if (n === 1) {
|
||||
// Fade out
|
||||
css(progress, {
|
||||
transition: 'none',
|
||||
opacity: 1
|
||||
});
|
||||
progress.offsetWidth; /* Repaint */
|
||||
|
||||
setTimeout(function() {
|
||||
css(progress, {
|
||||
transition: 'all ' + speed + 'ms linear',
|
||||
opacity: 0
|
||||
});
|
||||
setTimeout(function() {
|
||||
NProgress.remove();
|
||||
next();
|
||||
}, speed);
|
||||
}, speed);
|
||||
} else {
|
||||
setTimeout(next, speed);
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
NProgress.isStarted = function() {
|
||||
return typeof NProgress.status === 'number';
|
||||
};
|
||||
|
||||
/**
|
||||
* Shows the progress bar.
|
||||
* This is the same as setting the status to 0%, except that it doesn't go backwards.
|
||||
*
|
||||
* NProgress.start();
|
||||
*
|
||||
*/
|
||||
NProgress.start = function() {
|
||||
if (!NProgress.status) NProgress.set(0);
|
||||
|
||||
var work = function() {
|
||||
setTimeout(function() {
|
||||
if (!NProgress.status) return;
|
||||
NProgress.trickle();
|
||||
work();
|
||||
}, Settings.trickleSpeed);
|
||||
};
|
||||
|
||||
if (Settings.trickle) work();
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Hides the progress bar.
|
||||
* This is the *sort of* the same as setting the status to 100%, with the
|
||||
* difference being `done()` makes some placebo effect of some realistic motion.
|
||||
*
|
||||
* NProgress.done();
|
||||
*
|
||||
* If `true` is passed, it will show the progress bar even if its hidden.
|
||||
*
|
||||
* NProgress.done(true);
|
||||
*/
|
||||
|
||||
NProgress.done = function(force) {
|
||||
if (!force && !NProgress.status) return this;
|
||||
|
||||
return NProgress.inc(0.3 + 0.5 * Math.random()).set(1);
|
||||
};
|
||||
|
||||
/**
|
||||
* Increments by a random amount.
|
||||
*/
|
||||
|
||||
NProgress.inc = function(amount) {
|
||||
var n = NProgress.status;
|
||||
|
||||
if (!n) {
|
||||
return NProgress.start();
|
||||
} else {
|
||||
if (typeof amount !== 'number') {
|
||||
amount = (1 - n) * clamp(Math.random() * n, 0.1, 0.95);
|
||||
}
|
||||
|
||||
n = clamp(n + amount, 0, 0.994);
|
||||
return NProgress.set(n);
|
||||
}
|
||||
};
|
||||
|
||||
NProgress.trickle = function() {
|
||||
return NProgress.inc(Math.random() * Settings.trickleRate);
|
||||
};
|
||||
|
||||
/**
|
||||
* Waits for all supplied jQuery promises and
|
||||
* increases the progress as the promises resolve.
|
||||
*
|
||||
* @param $promise jQUery Promise
|
||||
*/
|
||||
(function() {
|
||||
var initial = 0, current = 0;
|
||||
|
||||
NProgress.promise = function($promise) {
|
||||
if (!$promise || $promise.state() === "resolved") {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (current === 0) {
|
||||
NProgress.start();
|
||||
}
|
||||
|
||||
initial++;
|
||||
current++;
|
||||
|
||||
$promise.always(function() {
|
||||
current--;
|
||||
if (current === 0) {
|
||||
initial = 0;
|
||||
NProgress.done();
|
||||
} else {
|
||||
NProgress.set((initial - current) / initial);
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
/**
|
||||
* (Internal) renders the progress bar markup based on the `template`
|
||||
* setting.
|
||||
*/
|
||||
|
||||
NProgress.render = function(fromStart) {
|
||||
if (NProgress.isRendered()) return document.getElementById('nprogress');
|
||||
|
||||
addClass(document.documentElement, 'nprogress-busy');
|
||||
|
||||
var progress = document.createElement('div');
|
||||
progress.id = 'nprogress';
|
||||
progress.innerHTML = Settings.template;
|
||||
|
||||
var bar = progress.querySelector(Settings.barSelector),
|
||||
perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0),
|
||||
parent = document.querySelector(Settings.parent),
|
||||
spinner;
|
||||
|
||||
css(bar, {
|
||||
transition: 'all 0 linear',
|
||||
transform: 'translate3d(' + perc + '%,0,0)'
|
||||
});
|
||||
|
||||
if (!Settings.showSpinner) {
|
||||
spinner = progress.querySelector(Settings.spinnerSelector);
|
||||
spinner && removeElement(spinner);
|
||||
}
|
||||
|
||||
if (parent != document.body) {
|
||||
addClass(parent, 'nprogress-custom-parent');
|
||||
}
|
||||
|
||||
parent.appendChild(progress);
|
||||
return progress;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes the element. Opposite of render().
|
||||
*/
|
||||
|
||||
NProgress.remove = function() {
|
||||
removeClass(document.documentElement, 'nprogress-busy');
|
||||
removeClass(document.querySelector(Settings.parent), 'nprogress-custom-parent');
|
||||
var progress = document.getElementById('nprogress');
|
||||
progress && removeElement(progress);
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if the progress bar is rendered.
|
||||
*/
|
||||
|
||||
NProgress.isRendered = function() {
|
||||
return !!document.getElementById('nprogress');
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine which positioning CSS rule to use.
|
||||
*/
|
||||
|
||||
NProgress.getPositioningCSS = function() {
|
||||
// Sniff on document.body.style
|
||||
var bodyStyle = document.body.style;
|
||||
|
||||
// Sniff prefixes
|
||||
var vendorPrefix = ('WebkitTransform' in bodyStyle) ? 'Webkit' :
|
||||
('MozTransform' in bodyStyle) ? 'Moz' :
|
||||
('msTransform' in bodyStyle) ? 'ms' :
|
||||
('OTransform' in bodyStyle) ? 'O' : '';
|
||||
|
||||
if (vendorPrefix + 'Perspective' in bodyStyle) {
|
||||
// Modern browsers with 3D support, e.g. Webkit, IE10
|
||||
return 'translate3d';
|
||||
} else if (vendorPrefix + 'Transform' in bodyStyle) {
|
||||
// Browsers without 3D support, e.g. IE9
|
||||
return 'translate';
|
||||
} else {
|
||||
// Browsers without translate() support, e.g. IE7-8
|
||||
return 'margin';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Helpers
|
||||
*/
|
||||
|
||||
function clamp(n, min, max) {
|
||||
if (n < min) return min;
|
||||
if (n > max) return max;
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* (Internal) converts a percentage (`0..1`) to a bar translateX
|
||||
* percentage (`-100%..0%`).
|
||||
*/
|
||||
|
||||
function toBarPerc(n) {
|
||||
return (-1 + n) * 100;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* (Internal) returns the correct CSS for changing the bar's
|
||||
* position given an n percentage, and speed and ease from Settings
|
||||
*/
|
||||
|
||||
function barPositionCSS(n, speed, ease) {
|
||||
var barCSS;
|
||||
|
||||
if (Settings.positionUsing === 'translate3d') {
|
||||
barCSS = { transform: 'translate3d('+toBarPerc(n)+'%,0,0)' };
|
||||
} else if (Settings.positionUsing === 'translate') {
|
||||
barCSS = { transform: 'translate('+toBarPerc(n)+'%,0)' };
|
||||
} else {
|
||||
barCSS = { 'margin-left': toBarPerc(n)+'%' };
|
||||
}
|
||||
|
||||
barCSS.transition = 'all '+speed+'ms '+ease;
|
||||
|
||||
return barCSS;
|
||||
}
|
||||
|
||||
/**
|
||||
* (Internal) Queues a function to be executed.
|
||||
*/
|
||||
|
||||
var queue = (function() {
|
||||
var pending = [];
|
||||
|
||||
function next() {
|
||||
var fn = pending.shift();
|
||||
if (fn) {
|
||||
fn(next);
|
||||
}
|
||||
}
|
||||
|
||||
return function(fn) {
|
||||
pending.push(fn);
|
||||
if (pending.length == 1) next();
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* (Internal) Applies css properties to an element, similar to the jQuery
|
||||
* css method.
|
||||
*
|
||||
* While this helper does assist with vendor prefixed property names, it
|
||||
* does not perform any manipulation of values prior to setting styles.
|
||||
*/
|
||||
|
||||
var css = (function() {
|
||||
var cssPrefixes = [ 'Webkit', 'O', 'Moz', 'ms' ],
|
||||
cssProps = {};
|
||||
|
||||
function camelCase(string) {
|
||||
return string.replace(/^-ms-/, 'ms-').replace(/-([\da-z])/gi, function(match, letter) {
|
||||
return letter.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
function getVendorProp(name) {
|
||||
var style = document.body.style;
|
||||
if (name in style) return name;
|
||||
|
||||
var i = cssPrefixes.length,
|
||||
capName = name.charAt(0).toUpperCase() + name.slice(1),
|
||||
vendorName;
|
||||
while (i--) {
|
||||
vendorName = cssPrefixes[i] + capName;
|
||||
if (vendorName in style) return vendorName;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
function getStyleProp(name) {
|
||||
name = camelCase(name);
|
||||
return cssProps[name] || (cssProps[name] = getVendorProp(name));
|
||||
}
|
||||
|
||||
function applyCss(element, prop, value) {
|
||||
prop = getStyleProp(prop);
|
||||
element.style[prop] = value;
|
||||
}
|
||||
|
||||
return function(element, properties) {
|
||||
var args = arguments,
|
||||
prop,
|
||||
value;
|
||||
|
||||
if (args.length == 2) {
|
||||
for (prop in properties) {
|
||||
value = properties[prop];
|
||||
if (value !== undefined && properties.hasOwnProperty(prop)) applyCss(element, prop, value);
|
||||
}
|
||||
} else {
|
||||
applyCss(element, args[1], args[2]);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
/**
|
||||
* (Internal) Determines if an element or space separated list of class names contains a class name.
|
||||
*/
|
||||
|
||||
function hasClass(element, name) {
|
||||
var list = typeof element == 'string' ? element : classList(element);
|
||||
return list.indexOf(' ' + name + ' ') >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* (Internal) Adds a class to an element.
|
||||
*/
|
||||
|
||||
function addClass(element, name) {
|
||||
var oldList = classList(element),
|
||||
newList = oldList + name;
|
||||
|
||||
if (hasClass(oldList, name)) return;
|
||||
|
||||
// Trim the opening space.
|
||||
element.className = newList.substring(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* (Internal) Removes a class from an element.
|
||||
*/
|
||||
|
||||
function removeClass(element, name) {
|
||||
var oldList = classList(element),
|
||||
newList;
|
||||
|
||||
if (!hasClass(element, name)) return;
|
||||
|
||||
// Replace the class name.
|
||||
newList = oldList.replace(' ' + name + ' ', ' ');
|
||||
|
||||
// Trim the opening and closing spaces.
|
||||
element.className = newList.substring(1, newList.length - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* (Internal) Gets a space separated list of the class names on the element.
|
||||
* The list is wrapped with a single space on each end to facilitate finding
|
||||
* matches within the list.
|
||||
*/
|
||||
|
||||
function classList(element) {
|
||||
return (' ' + (element.className || '') + ' ').replace(/\s+/gi, ' ');
|
||||
}
|
||||
|
||||
/**
|
||||
* (Internal) Removes an element from the DOM.
|
||||
*/
|
||||
|
||||
function removeElement(element) {
|
||||
element && element.parentNode && element.parentNode.removeChild(element);
|
||||
}
|
||||
|
||||
return NProgress;
|
||||
});
|
||||
|
2332
html/lifestyle.json
2332
html/lifestyle.json
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user