Browse Source

add tags finished

master
Pascal Gloor 5 years ago
parent
commit
093d133b0a
2 changed files with 40 additions and 42 deletions
  1. 4
    4
      www/index.html
  2. 36
    38
      www/js/autodoc.js

+ 4
- 4
www/index.html View File

</td> </td>
<td> <td>
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button type="button" class="btn btn-primary autodoc_tag_color" data="autodoc_tag_color_primary">
<span class="autodoc_tag_btn_on d-none">
<button type="button" class="btn btn-primary autodoc_tag_color active" data="autodoc_tag_color_primary">
<span class="autodoc_tag_btn_on">
<i class="fas fa-check"></i> <i class="fas fa-check"></i>
</span> </span>
<span class="autodoc_tag_btn_off">
<span class="autodoc_tag_btn_off d-none">
<i class="fas fa-times"></i> <i class="fas fa-times"></i>
</span> </span>
</button> </button>
--> -->
</td> </td>
<td> <td>
<span id="autodoc_tag_result" class="badge"></span>
<span id="autodoc_tag_result" class="badge badge-primary"></span>
</td> </td>
<td> <td>
<button type="button" class="btn btn-outline-primary">Add Tag</button> <button type="button" class="btn btn-outline-primary">Add Tag</button>

+ 36
- 38
www/js/autodoc.js View File



$(document).ready(function () { $(document).ready(function () {


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

// initialise drop zone
upload_zone_init(); upload_zone_init();


// main page scroll event
$(document).scroll(function () { $(document).scroll(function () {
page_home_scroll(); page_home_scroll();
}); });


// modal left paging
$('#autodoc_home_modal_left').mouseenter(function (e) { $('#autodoc_home_modal_left').mouseenter(function (e) {
$(e.target).fadeTo("slow", 0.8); $(e.target).fadeTo("slow", 0.8);
}) })
home_modal_page_prev(); home_modal_page_prev();
}); });


$('#autodoc_home_modal_right').mouseenter(function (e) {
$(e.target).fadeTo("slow", 0.8);
})
// modal right paging
$('#autodoc_home_modal_right')
.mouseenter(function (e) {
$(e.target).fadeTo("slow", 0.8);
})
.mouseleave(function (e) { .mouseleave(function (e) {
$(e.target).fadeTo("slow", 0.15); $(e.target).fadeTo("slow", 0.15);
}) })
home_modal_page_next(); home_modal_page_next();
}); });


$('.autodoc_home_modal_size').click(function(e) {
// modal resize buttons events
$('.autodoc_home_modal_size').click(function (e) {
$('.autodoc_home_modal_size').removeClass("active"); $('.autodoc_home_modal_size').removeClass("active");
$(e.target).addClass("active"); $(e.target).addClass("active");
home_modal_resize($(e.target).html()); home_modal_resize($(e.target).html());
});
});


$('span.autodoc_home_modal_name').click(function(e) {
// click to rename page in modal
$('span.autodoc_home_modal_name').click(function (e) {
$(e.target).addClass('d-none'); $(e.target).addClass('d-none');
$('input.autodoc_home_modal_name').removeClass('d-none'); $('input.autodoc_home_modal_name').removeClass('d-none');
}); });


$('input.autodoc_home_modal_name').change(function(e) {
// [enter] event of modal name edit
$('input.autodoc_home_modal_name').change(function (e) {
var docid = $('#autodoc_home_modal').data('documentid'); var docid = $('#autodoc_home_modal').data('documentid');
document_update_name(docid, $(e.target).val(), docid); document_update_name(docid, $(e.target).val(), docid);
}); });


$('.autodoc_tag_color').click(function(e) {
// tag add color events
$('.autodoc_tag_color').click(function (e) {
var btn = e.target; var btn = e.target;
while($(btn).prop("tagName") != "BUTTON") {
console.log(btn);
while ($(btn).prop("tagName") != "BUTTON") {
btn = $(btn).parent(); btn = $(btn).parent();
} }




$(btn).children('.autodoc_tag_btn_on').removeClass('d-none'); $(btn).children('.autodoc_tag_btn_on').removeClass('d-none');
$(btn).children('.autodoc_tag_btn_off').addClass('d-none'); $(btn).children('.autodoc_tag_btn_off').addClass('d-none');


$(btn).parent().children().each(function(id,x) {

$(btn).parent().children().each(function (id, x) {
var myclass = 'badge-' + $(x).attr('data').split('_').pop(); var myclass = 'badge-' + $(x).attr('data').split('_').pop();
$('#autodoc_tag_result').removeClass(myclass); $('#autodoc_tag_result').removeClass(myclass);
}); });


}); });


$('.NOPE_autodoc_tag_color').click(function(e) {
$(e.target).parent().children().html('0');
$(e.target).html('1');
$(e.target).parent().children().each(function(id, x) {
console.log(x);
console.log($(x).attr('data'));
$("#autodoc_tag_result").removeClass("badge-" + $(x).attr('data'));
});
$("#autodoc_tag_result").addClass("badge-" + $(e.target).attr('data'));
return false;
})

$('.autodoc_tag_text').keyup(function(e) {
// tag add text events
$('.autodoc_tag_text').keyup(function (e) {
$('#autodoc_tag_result').html($(e.target).val()); $('#autodoc_tag_result').html($(e.target).val());
}); });
}); });



// anchor change event
$(window).bind("hashchange", function () { $(window).bind("hashchange", function () {
change_page(); change_page();
}); });
$(col) $(col)
.find(".autodoc_template_home_name") .find(".autodoc_template_home_name")
.html(doc.name); .html(doc.name);
$(col) $(col)
.find(".autodoc_template_home_pages") .find(".autodoc_template_home_pages")
.html(doc.pageId.length); .html(doc.pageId.length);
var doc = $('#autodoc_home_modal').data('document'); var doc = $('#autodoc_home_modal').data('document');
var pageTotal = doc.pageId.length; var pageTotal = doc.pageId.length;


if ( pageNum < 0 ) {
pageNum=pageTotal-1;
if (pageNum < 0) {
pageNum = pageTotal - 1;
} }


if ( pageNum > pageTotal - 1 ) {
if (pageNum > pageTotal - 1) {
pageNum = 0; pageNum = 0;
} }


$('.autodoc_home_modal_page').html(pageNum+1);
$('.autodoc_home_modal_page').html(pageNum + 1);
$('#autodoc_home_modal').data('pageNum', pageNum); $('#autodoc_home_modal').data('pageNum', pageNum);


$('#autodoc_home_modal_img').attr('src', $('#autodoc_home_modal_img').attr('src',


function home_modal_resize(size) { function home_modal_resize(size) {
var newclass; var newclass;
$('#autodoc_home_modal').children().removeClass('modal-sm modal-lg modal-xl'); $('#autodoc_home_modal').children().removeClass('modal-sm modal-lg modal-xl');
switch(size) {
switch (size) {
case "S": newclass = "modal-sm"; break; case "S": newclass = "modal-sm"; break;
case "M": break; case "M": break;
case "L": newclass = "modal-lg"; break; case "L": newclass = "modal-lg"; break;
case "XL": newclass = "modal-xl"; break; case "XL": newclass = "modal-xl"; break;
} }


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

Loading…
Cancel
Save