mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 05:43:55 -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
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue