Always reload tray menu in loadNotesToCards(), loadCards() on delete, close #9
This commit is contained in:
parent
673b8fba4f
commit
265ae7d004
@ -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;
|
||||
if (reloadCards) {
|
||||
for (i in window.shuffleInstance.items) {
|
||||
window.shuffleInstance.remove(window.shuffleInstance.items[i]);
|
||||
}
|
||||
$(".notecard-col").remove();
|
||||
}
|
||||
var trayitems = [];
|
||||
for (n in notes) {
|
||||
var note = notes[n];
|
||||
@ -83,6 +82,7 @@ function loadNotesToCards(notes, oldnotes, callback) {
|
||||
if (note.getSyncStatus() == "LOCAL_DELETED") {
|
||||
continue;
|
||||
}
|
||||
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">'
|
||||
@ -94,11 +94,13 @@ function loadNotesToCards(notes, oldnotes, callback) {
|
||||
+ '<div class="card-content card-content-padding"><div class="btnswrapthing"></div>' + note.getHTML() + '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>');
|
||||
}
|
||||
trayitems.push({
|
||||
title: note.getTitle(),
|
||||
id: note.getID()
|
||||
});
|
||||
}
|
||||
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");
|
||||
@ -114,6 +116,7 @@ function loadNotesToCards(notes, oldnotes, callback) {
|
||||
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…
x
Reference in New Issue
Block a user