From 5931fee4dada73f4346a49e35aba20ebf6cbba2e Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Fri, 17 Mar 2023 19:26:57 +0700 Subject: [PATCH] Added ability to hide ajax loading alert (#617) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Позволяет сделать процесс выполнения ajax скрипта не таким явным. Т. е скрывает алерт в углу. Добавляется как опциональный параметр для ajax.exec. Будет полезно в некоторых кейсах, где запрос выполняется с неким интервалом. P.S - Скрытие не работает в случае ошибки (Оно и понятно) --- styles/js/main.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/styles/js/main.js b/styles/js/main.js index dcf7146e9..e504b57f3 100644 --- a/styles/js/main.js +++ b/styles/js/main.js @@ -320,10 +320,12 @@ Ajax.prototype = { request: {}, // request data params: {}, // action params, format: ajax.params[ElementID] = { param: "val" ... } form_token: '', + hide_loading: null, - exec: function (request) { + exec: function (request, hide_loading = false) { this.request[request.action] = request; request['form_token'] = this.form_token; + this.hide_loading = hide_loading; $.ajax({ url: this.url, type: this.type, @@ -451,12 +453,16 @@ Ajax.prototype = { $(document).ready(function () { // Setup ajax-loading box $("#ajax-loading").ajaxStart(function () { - $("#ajax-error").hide(); - $(this).show(); - ajax.setStatusBoxPosition($(this)); + if (ajax.hide_loading === false) { + $("#ajax-error").hide(); + $(this).show(); + ajax.setStatusBoxPosition($(this)); + } }); $("#ajax-loading").ajaxStop(function () { - $(this).hide(); + if (ajax.hide_loading === false) { + $(this).hide(); + } }); // Setup ajax-error box