first commit
This commit is contained in:
36
admin/static/js/wpj.buttonLoading.js
Normal file
36
admin/static/js/wpj.buttonLoading.js
Normal file
@@ -0,0 +1,36 @@
|
||||
$(()=> {
|
||||
$('body').on('click', '[data-submit-loading]', function() {
|
||||
$(this).addClass('is-submitting');
|
||||
});
|
||||
|
||||
$('body').on('click', '[data-request-recieved-loading]', function() {
|
||||
|
||||
function setCookie(c_name, value, time) {
|
||||
var exTime = new Date();
|
||||
exTime.setTime(exTime.getTime() + (time * 1000));
|
||||
var c_value = encodeURIComponent(value) + '; path=/' + (exTime == null ? '' : '; expires=' + exTime.toUTCString());
|
||||
document.cookie = c_name + '=' + c_value;
|
||||
}
|
||||
|
||||
function getCookie(name) {
|
||||
const value = '; ' + document.cookie;
|
||||
const parts = value.split('; ' + name + '=');
|
||||
if (parts.length === 2) return parts.pop().split(';').shift();
|
||||
}
|
||||
|
||||
const timeout = 15 * 60;
|
||||
const startTime = Date.now();
|
||||
|
||||
var interval = 0;
|
||||
interval = setInterval(() => {
|
||||
|
||||
if (!getCookie('wpjRequestNotFinished') || (startTime + timeout * 1000) < Date.now()) {
|
||||
clearInterval(interval);
|
||||
$(this).removeClass('is-submitting');
|
||||
}
|
||||
}, 500);
|
||||
|
||||
setCookie('wpjRequestNotFinished', Date.now(), timeout);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user