delay ajax load indicator by 300ms

* avoid flashing for short AJAX calls
This commit is contained in:
Tobias Stenzel 2017-09-14 12:18:51 +00:00
parent fcbc4aa497
commit 8b88745f0f
2 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,14 @@
function delayAjaxIndicator() {
$(document).off('ajaxSend').bind('ajaxSend', function(event, xhr, settings) {
if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') {
$('#ajax-indicator').stop(true, false).delay(300).show(0);
}
});
$(document).off('ajaxStop').bind('ajaxStop', function() {
$('#ajax-indicator').hide(0);
});
};
$(document).ready(delayAjaxIndicator)

View File

@ -188,6 +188,7 @@ module Additionals
def additionals_load_select2
additionals_include_js('additionals_to_select2')
additionals_include_js('additionals_delay_ajax_indicator')
end
def additionals_load_font_awesome