Added ability to hide ajax loading alert (#617)

Позволяет сделать процесс выполнения ajax скрипта не таким явным. Т. е скрывает алерт в углу.

Добавляется как опциональный параметр для ajax.exec.

Будет полезно в некоторых кейсах, где запрос выполняется с неким интервалом.

P.S - Скрытие не работает в случае ошибки (Оно и понятно)
This commit is contained in:
Roman Kelesidis 2023-03-17 19:26:57 +07:00 committed by GitHub
commit 5931fee4da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -320,10 +320,12 @@ Ajax.prototype = {
request: {}, // request data request: {}, // request data
params: {}, // action params, format: ajax.params[ElementID] = { param: "val" ... } params: {}, // action params, format: ajax.params[ElementID] = { param: "val" ... }
form_token: '', form_token: '',
hide_loading: null,
exec: function (request) { exec: function (request, hide_loading = false) {
this.request[request.action] = request; this.request[request.action] = request;
request['form_token'] = this.form_token; request['form_token'] = this.form_token;
this.hide_loading = hide_loading;
$.ajax({ $.ajax({
url: this.url, url: this.url,
type: this.type, type: this.type,
@ -451,12 +453,16 @@ Ajax.prototype = {
$(document).ready(function () { $(document).ready(function () {
// Setup ajax-loading box // Setup ajax-loading box
$("#ajax-loading").ajaxStart(function () { $("#ajax-loading").ajaxStart(function () {
if (ajax.hide_loading === false) {
$("#ajax-error").hide(); $("#ajax-error").hide();
$(this).show(); $(this).show();
ajax.setStatusBoxPosition($(this)); ajax.setStatusBoxPosition($(this));
}
}); });
$("#ajax-loading").ajaxStop(function () { $("#ajax-loading").ajaxStop(function () {
if (ajax.hide_loading === false) {
$(this).hide(); $(this).hide();
}
}); });
// Setup ajax-error box // Setup ajax-error box