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) {
|
function loadNotesToCards(notes, oldnotes, callback) {
|
||||||
|
var reloadCards = true;
|
||||||
if (force_card_refresh != true && notes.length == oldnotes.length) {
|
if (force_card_refresh != true && notes.length == oldnotes.length) {
|
||||||
var allSame = true;
|
var allSame = true;
|
||||||
var allPresent = true;
|
var allPresent = true;
|
||||||
@ -64,18 +65,16 @@ function loadNotesToCards(notes, oldnotes, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (allSame && allPresent) {
|
if (allSame && allPresent) {
|
||||||
window.shuffleInstance.layout();
|
reloadCards = false;
|
||||||
if (typeof callback == 'function') {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
force_card_refresh = false;
|
force_card_refresh = false;
|
||||||
|
if (reloadCards) {
|
||||||
for (i in window.shuffleInstance.items) {
|
for (i in window.shuffleInstance.items) {
|
||||||
window.shuffleInstance.remove(window.shuffleInstance.items[i]);
|
window.shuffleInstance.remove(window.shuffleInstance.items[i]);
|
||||||
}
|
}
|
||||||
$(".notecard-col").remove();
|
$(".notecard-col").remove();
|
||||||
|
}
|
||||||
var trayitems = [];
|
var trayitems = [];
|
||||||
for (n in notes) {
|
for (n in notes) {
|
||||||
var note = notes[n];
|
var note = notes[n];
|
||||||
@ -83,6 +82,7 @@ function loadNotesToCards(notes, oldnotes, callback) {
|
|||||||
if (note.getSyncStatus() == "LOCAL_DELETED") {
|
if (note.getSyncStatus() == "LOCAL_DELETED") {
|
||||||
continue;
|
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") + '">'
|
$("#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="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">'
|
+ '<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 class="card-content card-content-padding"><div class="btnswrapthing"></div>' + note.getHTML() + '</div>'
|
||||||
+ '</div>'
|
+ '</div>'
|
||||||
+ '</div>');
|
+ '</div>');
|
||||||
|
}
|
||||||
trayitems.push({
|
trayitems.push({
|
||||||
title: note.getTitle(),
|
title: note.getTitle(),
|
||||||
id: note.getID()
|
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])").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:not(:checked))").addClass("parsedown-task-list-open");
|
||||||
$(".notecard .card-content ul li:has(input[type=checkbox]:checkbox:checked)").addClass("parsedown-task-list-close");
|
$(".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");
|
return el.getAttribute("data-favorite");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
setTrayMenu(trayitems);
|
setTrayMenu(trayitems);
|
||||||
// Make sure gutters and stuff work
|
// Make sure gutters and stuff work
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@ -180,7 +183,7 @@ function deleteNote(id) {
|
|||||||
window.shuffleInstance.remove(document.getElementById("notecard-col-" + id));
|
window.shuffleInstance.remove(document.getElementById("notecard-col-" + id));
|
||||||
$("#notecard-col-" + id).remove();
|
$("#notecard-col-" + id).remove();
|
||||||
window.shuffleInstance.layout();
|
window.shuffleInstance.layout();
|
||||||
NOTES.syncAll();
|
loadCards();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user