delay ajax load indicator by 300ms
* avoid flashing for short AJAX calls
This commit is contained in:
parent
fcbc4aa497
commit
8b88745f0f
14
assets/javascripts/additionals_delay_ajax_indicator.js
Normal file
14
assets/javascripts/additionals_delay_ajax_indicator.js
Normal 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)
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user