Parcourir la source

ajax load btn

master
Pascal Gloor il y a 5 ans
Parent
révision
763d5e1ed9
2 fichiers modifiés avec 49 ajouts et 5 suppressions
  1. 8
    0
      www/index.html
  2. 41
    5
      www/js/autodoc.js

+ 8
- 0
www/index.html Voir le fichier

@@ -54,6 +54,14 @@
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Quick Search" aria-label="Search" />
</form>
<div>
<button type="button" class="autodoc_ajax_off btn btn-secondary">
<i class="fas fa-times"></i>
</button>
<button type="button" class="autodoc_ajax_on d-none btn btn-primary">
<i class="fas fa-times"></i>
</button>
</div>
</div>
</nav>


+ 41
- 5
www/js/autodoc.js Voir le fichier

@@ -17,7 +17,8 @@ var conf = {
run: {
"upload_handler": 0,
"upload_status": 0
}
},
busy: 0
};

var temp = {
@@ -27,6 +28,9 @@ var temp = {

$(document).ready(function () {

// loader icon thread
loader_icon_update();

// load the current page based on anchor
change_page();

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

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

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

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

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

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

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

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

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

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

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

@@ -699,13 +721,27 @@ function home_modal_close(docid) {
}

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

function loader_icon_update() {
if ( conf.busy > 0 ) {
$('.autodoc_ajax_on').removeClass('d-none');
$('.autodoc_ajax_off').addClass('d-none');
}
else {
$('.autodoc_ajax_of').removeClass('d-none');
$('.autodoc_ajax_on').addClass('d-none');
}
setTimeout(loader_icon_update, 100);
}

Chargement…
Annuler
Enregistrer