Browse Source

Always reload tray menu in loadNotesToCards(), loadCards() on delete, close #9

tags/v1.2.0
Skylar Ittner 9 months ago
parent
commit
265ae7d004
1 changed files with 37 additions and 34 deletions
  1. 37
    34
      www/js/home.js

+ 37
- 34
www/js/home.js View File

@@ -52,6 +52,7 @@ $(".view-main").on("click", ".parsedown-task-list", function (e) {
});

function loadNotesToCards(notes, oldnotes, callback) {
var reloadCards = true;
if (force_card_refresh != true && notes.length == oldnotes.length) {
var allSame = true;
var allPresent = true;
@@ -64,18 +65,16 @@ function loadNotesToCards(notes, oldnotes, callback) {
}
}
if (allSame && allPresent) {
window.shuffleInstance.layout();
if (typeof callback == 'function') {
callback();
}
return;
reloadCards = false;
}
}
force_card_refresh = false;
for (i in window.shuffleInstance.items) {
window.shuffleInstance.remove(window.shuffleInstance.items[i]);
if (reloadCards) {
for (i in window.shuffleInstance.items) {
window.shuffleInstance.remove(window.shuffleInstance.items[i]);
}
$(".notecard-col").remove();
}
$(".notecard-col").remove();
var trayitems = [];
for (n in notes) {
var note = notes[n];
@@ -83,37 +82,41 @@ function loadNotesToCards(notes, oldnotes, callback) {
if (note.getSyncStatus() == "LOCAL_DELETED") {
continue;
}
$("#notecards-bin").append('<div class="col-100 tablet-50 desktop-33 notecard-col grid-item" id="notecard-col-' + note.noteid + '" data-favorite="' + (note.favorite ? "1" : "0") + '">'
+ '<div class="card notecard" id="notecard-' + note.getID() + '" data-id="' + note.getID() + '" data-favorite="' + (note.getFavorite() ? "1" : "0") + '" data-bg="' + note.getColor() + '" data-fg="' + note.getTextColor() + '" style="background-color: #' + note.getColor() + '; color: #' + note.getTextColor() + ';">'
+ '<div class="editbtn">'
+ '<i class="material-icons">edit</i>'
+ '</div>'
+ '<div class="menubtn">'
+ '<i class="material-icons">more_vert</i>'
+ '</div>'
+ '<div class="card-content card-content-padding"><div class="btnswrapthing"></div>' + note.getHTML() + '</div>'
+ '</div>'
+ '</div>');
if (reloadCards) {
$("#notecards-bin").append('<div class="col-100 tablet-50 desktop-33 notecard-col grid-item" id="notecard-col-' + note.noteid + '" data-favorite="' + (note.favorite ? "1" : "0") + '">'
+ '<div class="card notecard" id="notecard-' + note.getID() + '" data-id="' + note.getID() + '" data-favorite="' + (note.getFavorite() ? "1" : "0") + '" data-bg="' + note.getColor() + '" data-fg="' + note.getTextColor() + '" style="background-color: #' + note.getColor() + '; color: #' + note.getTextColor() + ';">'
+ '<div class="editbtn">'
+ '<i class="material-icons">edit</i>'
+ '</div>'
+ '<div class="menubtn">'
+ '<i class="material-icons">more_vert</i>'
+ '</div>'
+ '<div class="card-content card-content-padding"><div class="btnswrapthing"></div>' + note.getHTML() + '</div>'
+ '</div>'
+ '</div>');
}
trayitems.push({
title: note.getTitle(),
id: note.getID()
});
}
$(".notecard .card-content ul li:has(input[type=checkbox])").addClass("parsedown-task-list");
$(".notecard .card-content ul li:has(input[type=checkbox]:checkbox:not(:checked))").addClass("parsedown-task-list-open");
$(".notecard .card-content ul li:has(input[type=checkbox]:checkbox:checked)").addClass("parsedown-task-list-close");
$(".parsedown-task-list input[type=checkbox]").removeAttr("disabled");
var noteElements = document.getElementsByClassName("notecard-col");
window.shuffleInstance.add(noteElements);
window.shuffleInstance.sort({
reverse: true,
by: function (el) {
if (el.getAttribute("id") == "offline-indicator") {
return "999999999";
if (reloadCards) {
$(".notecard .card-content ul li:has(input[type=checkbox])").addClass("parsedown-task-list");
$(".notecard .card-content ul li:has(input[type=checkbox]:checkbox:not(:checked))").addClass("parsedown-task-list-open");
$(".notecard .card-content ul li:has(input[type=checkbox]:checkbox:checked)").addClass("parsedown-task-list-close");
$(".parsedown-task-list input[type=checkbox]").removeAttr("disabled");
var noteElements = document.getElementsByClassName("notecard-col");
window.shuffleInstance.add(noteElements);
window.shuffleInstance.sort({
reverse: true,
by: function (el) {
if (el.getAttribute("id") == "offline-indicator") {
return "999999999";
}
return el.getAttribute("data-favorite");
}
return el.getAttribute("data-favorite");
}
});
});
}
setTrayMenu(trayitems);
// Make sure gutters and stuff work
setTimeout(function () {
@@ -180,7 +183,7 @@ function deleteNote(id) {
window.shuffleInstance.remove(document.getElementById("notecard-col-" + id));
$("#notecard-col-" + id).remove();
window.shuffleInstance.layout();
NOTES.syncAll();
loadCards();
});
}


Loading…
Cancel
Save