Procházet zdrojové kódy

delay icon update

master
Pascal Gloor před 5 roky
rodič
revize
29b7a68c32
1 změnil soubory, kde provedl 28 přidání a 20 odebrání
  1. 28
    20
      www/js/autodoc.js

+ 28
- 20
www/js/autodoc.js Zobrazit soubor

@@ -97,12 +97,12 @@ $(document).ready(function () {
var docid = $('#autodoc_tab_document').data('docid');
var pageid = $('.autodoc_document_image').data('pageid');

conf.busy++;
loader_icon_on();
$.ajax({
type: "PATCH",
url: conf.openapi + "/documents/" + docid + "?primarypage=" + pageid,
success: function () {
conf.busy--;
loader_icon_off();
$('.autodoc_document_btn_primary').removeClass('disabled');
}
});
@@ -147,12 +147,12 @@ $(document).ready(function () {
url += tagId;
}

conf.busy++;
loader_icon_on();
$.ajax({
type: method,
url: url + '?' + urlparam,
success: function () {
conf.busy--;
loader_icon_off();
location.reload();
}
});
@@ -163,12 +163,12 @@ $(document).ready(function () {
var tagId = $('.autodoc_tag_id').val();

if (tagId != "") {
conf.busy++;
loader_icon_on();
$.ajax({
type: "DELETE",
url: conf.openapi + "/tags/" + tagId,
success: function () {
conf.busy--;
loader_icon_off();
location.reload();
}
});
@@ -282,11 +282,11 @@ function page_load_document(args) {

$('.autodoc_document_image').attr('src','');

conf.busy++;
loader_icon_on();
$.getJSON(
conf.openapi + "/documents/" + docid,
function (doc) {
conf.busy--;
loader_icon_off();
$('span.autodoc_document_name').html(doc.name);
$('input.autodoc_document_name').val(doc.name);
@@ -343,9 +343,9 @@ function page_load_upload() {

function page_load_tags() {
// update tag list
conf.busy++;
loader_icon_on();
$.getJSON(conf.openapi + "/tags", function (tags) {
conf.busy--;
loader_icon_off();
$.each(tags, function (n, tag) {
$('.autodoc_tag_list').append(
'<option data="' + tag.color + '" value="' + tag.id + '">' +
@@ -366,7 +366,7 @@ function document_load() {
.find(".autodoc_template_home_row")
.clone();

conf.busy++;
loader_icon_on();
$.getJSON(
conf.openapi +
"/documents?pageSize=" +
@@ -376,7 +376,7 @@ function document_load() {
null,
function (data, textStatus, jqXHR) {
// last document was loaded, stop scrolling
conf.busy--;
loader_icon_off();
if (data.length < conf.home.width) {
conf.home.end = 1;
}
@@ -501,9 +501,9 @@ function upload_handler() {
console.log("upload_handler");
if (temp.documentid == null) {
console.log("creating documentId");
conf.busy++;
loader_icon_on();
$.post(conf.openapi + "/documents", {}, function (data) {
conf.busy--;
loader_icon_off();
temp.documentid = data.id;
});
stop = 0;
@@ -558,7 +558,7 @@ function upload_read_event(e) {

temp.upload[e.data]['progress'] = 50;

conf.busy++;
loader_icon_on();
$.ajax({
type: 'POST',
url: conf.openapi + "/documents/" + temp.documentid + "/data",
@@ -583,7 +583,7 @@ function upload_read_event(e) {
return xhr;
},
success: function (data, status, xhr) {
conf.busy--;
loader_icon_off();
temp.upload[this.id].progress = 100;

}
@@ -690,9 +690,9 @@ function home_modal_page_next() {
}

function home_modal_open(docid) {
conf.busy++;
loader_icon_on();
$.getJSON(conf.openapi + "/documents/" + docid, function (data) {
conf.busy--;
loader_icon_off();
$('#autodoc_home_modal').data('document', data);
$('#autodoc_home_modal').data('documentid', docid);

@@ -721,12 +721,12 @@ function home_modal_close(docid) {
}

function document_update_name(docid, name) {
conf.busy++;
loader_icon_on();
$.ajax({
type: "PATCH",
url: conf.openapi + "/documents/" + docid + "?name=" + encodeURIComponent(name),
success: function (data) {
conf.busy--;
loader_icon_off();
$('span.autodoc_home_modal_name').removeClass('d-none');
$('input.autodoc_home_modal_name').addClass('d-none');
home_modal_open(docid);
@@ -734,6 +734,14 @@ function document_update_name(docid, name) {
});
}

function loader_icon_on() {
conf.busy++;
}

function load_icon_off() {
setTimeout(function() { conf.busy--; }, 1000);
}

function loader_icon_update() {
if ( conf.busy > 0 ) {
$('.autodoc_ajax_on').removeClass('d-none');

Načítá se…
Zrušit
Uložit