Add custom AJAX spinner.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -718,3 +718,38 @@ a i {
|
|||||||
height: auto;
|
height: auto;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ajax-spinner {
|
||||||
|
margin-top: 12px;
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: transparent;
|
||||||
|
border: 2px solid #222;
|
||||||
|
border-top: 2px solid #03A9F4;
|
||||||
|
border-bottom: 2px solid #03A9F4;
|
||||||
|
-webkit-animation: .5s spin linear infinite;
|
||||||
|
animation: .5s spin linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes spin {
|
||||||
|
from {
|
||||||
|
-webkit-transform: rotate(0deg);
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
-webkit-transform: rotate(360deg);
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
from {
|
||||||
|
-webkit-transform: rotate(0deg);
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
-webkit-transform: rotate(360deg);
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ class MayanApp {
|
|||||||
|
|
||||||
parameters = parameters || {}
|
parameters = parameters || {}
|
||||||
|
|
||||||
|
this.ajaxSpinnerSeletor = '#ajax-spinner';
|
||||||
|
this.ajaxExecuting = false;
|
||||||
this.window = $(window);
|
this.window = $(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +107,12 @@ class MayanApp {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
callbackAJAXSpinnerUpdate () {
|
||||||
|
if (this.ajaxExecuting) {
|
||||||
|
$(this.ajaxSpinnerSeletor).fadeIn(50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
doRefreshMainMenu (options) {
|
doRefreshMainMenu (options) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
complete: function() {
|
complete: function() {
|
||||||
@@ -112,7 +120,7 @@ class MayanApp {
|
|||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var $elements = $('.dropdown.open');
|
var $elements = $('.dropdown.open');
|
||||||
if ($elements.length === 0) {
|
if (($elements.length === 0) && (this.ajaxExecuting === false)) {
|
||||||
// Don't refresh the HTML if there are open dropdowns
|
// Don't refresh the HTML if there are open dropdowns
|
||||||
$('#main-menu').html(data);
|
$('#main-menu').html(data);
|
||||||
}
|
}
|
||||||
@@ -193,7 +201,8 @@ class MayanApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initialize () {
|
initialize () {
|
||||||
this.setupAJAXperiodicWorkers();
|
this.setupAJAXPeriodicWorkers();
|
||||||
|
this.setupAJAXSpinner();
|
||||||
this.setupAutoSubmit();
|
this.setupAutoSubmit();
|
||||||
this.setupFullHeightResizing();
|
this.setupFullHeightResizing();
|
||||||
this.setupItemsSelector();
|
this.setupItemsSelector();
|
||||||
@@ -206,7 +215,7 @@ class MayanApp {
|
|||||||
partialNavigation.initialize();
|
partialNavigation.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
setupAJAXperiodicWorkers () {
|
setupAJAXPeriodicWorkers () {
|
||||||
var app = this;
|
var app = this;
|
||||||
|
|
||||||
$('a[data-apw-url]').each(function() {
|
$('a[data-apw-url]').each(function() {
|
||||||
@@ -222,6 +231,26 @@ class MayanApp {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupAJAXSpinner () {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
$(document).ajaxStart(function() {
|
||||||
|
self.ajaxExecuting = true;
|
||||||
|
setTimeout(
|
||||||
|
function () {
|
||||||
|
self.callbackAJAXSpinnerUpdate();
|
||||||
|
}, 150
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$(document).ajaxStop(function() {
|
||||||
|
$(self.ajaxSpinnerSeletor).fadeOut();
|
||||||
|
self.ajaxExecuting = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setupAutoSubmit () {
|
setupAutoSubmit () {
|
||||||
$('body').on('change', '.select-auto-submit', function () {
|
$('body').on('change', '.select-auto-submit', function () {
|
||||||
if ($(this).val()) {
|
if ($(this).val()) {
|
||||||
|
|||||||
@@ -33,6 +33,9 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
<div class="nav navbar-nav navbar-right">
|
||||||
|
<div class="hidden-xs hidden-sm" id="ajax-spinner"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
Reference in New Issue
Block a user