mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 13:24:01 -07:00
Added ability to hide ajax loading alert (#617)
Позволяет сделать процесс выполнения ajax скрипта не таким явным. Т. е скрывает алерт в углу. Добавляется как опциональный параметр для ajax.exec. Будет полезно в некоторых кейсах, где запрос выполняется с неким интервалом. P.S - Скрытие не работает в случае ошибки (Оно и понятно)
This commit is contained in:
parent
0e3a2a0e8a
commit
5931fee4da
1 changed files with 11 additions and 5 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue