Skip to content

Commit

Permalink
ajax progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
mzhelskiy committed Feb 3, 2014
1 parent abb3f1f commit 28a6b6f
Show file tree
Hide file tree
Showing 4 changed files with 395 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
"___path.framework.frontend.web___/js/vendor/parsley/parsley.js",
"___path.framework.frontend.web___/js/vendor/parsley/i18n/messages.ru.js",
"___path.framework.frontend.web___/js/vendor/fotorama/fotorama.js",
"___path.framework.frontend.web___/js/vendor/nprogress/nprogress.js",

/* Core */
"___path.framework.frontend.web___/js/core/main.js",
Expand Down
16 changes: 15 additions & 1 deletion frontend/framework/js/core/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ ls.ajax = (function ($) {
more = more || {};
params = params || {};

if (!more.progressNotShow) {
NProgress.start();
}

if ( typeof LIVESTREET_SECURITY_KEY !== 'undefined' ) params.security_ls_key = LIVESTREET_SECURITY_KEY;

$.each(params, function(k, v){
Expand All @@ -46,6 +50,7 @@ ls.ajax = (function ($) {
ls.debug.apply(ls, arguments);
}.bind(this),
complete: function(msg){
NProgress.done();
ls.debug("ajax complete: ");
ls.debug.apply(ls, arguments);
}.bind(this)
Expand All @@ -67,6 +72,10 @@ ls.ajax = (function ($) {

params.security_ls_key = LIVESTREET_SECURITY_KEY;

if (!more.progressNotShow) {
NProgress.start();
}

if (url.indexOf('http://') != 0 && url.indexOf('https://') != 0 && url.indexOf('/') != 0) {
url = aRouter['ajax'] + url + '/';
}
Expand Down Expand Up @@ -107,9 +116,14 @@ ls.ajax = (function ($) {
ls.debug("ajax error: ");
ls.debug.apply(ls, arguments);
}.bind(this),
complete: more.complete || function(){
complete: function(){
NProgress.done();
ls.debug("ajax complete: ");
ls.debug.apply(ls, arguments);

if (more.complete) {
more.complete.apply(ls,arguments);
}
}.bind(this)
};

Expand Down
64 changes: 64 additions & 0 deletions frontend/framework/js/vendor/nprogress/nprogress.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* Make clicks pass-through */
#nprogress {
pointer-events: none;
}

#nprogress .bar {
background: #29d;

position: fixed;
z-index: 100;
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: 100;
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;
}

@-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); }
}

Loading

0 comments on commit 28a6b6f

Please sign in to comment.