Clean up data on bookmarks elements
This commit is contained in:
parent
7e48ac502a
commit
fd80625003
|
@ -59,8 +59,8 @@ function bookmarkMoved(dropEvt) {
|
||||||
var newIndex = dropEvt.newIndex;
|
var newIndex = dropEvt.newIndex;
|
||||||
|
|
||||||
if (dropEvt.from != dropEvt.to) {
|
if (dropEvt.from != dropEvt.to) {
|
||||||
var oldGroupIndex = $(dropEvt.from).data("group-index");
|
var oldGroupIndex = $(dropEvt.from).parent().data("group-index");
|
||||||
var newGroupIndex = $(dropEvt.to).data("group-index");
|
var newGroupIndex = $(dropEvt.to).parent().data("group-index");
|
||||||
|
|
||||||
var item = $(dropEvt.item);
|
var item = $(dropEvt.item);
|
||||||
var itemData = {name: item.data("name"), address: item.data("address")};
|
var itemData = {name: item.data("name"), address: item.data("address")};
|
||||||
|
@ -87,7 +87,7 @@ function bookmarkMoved(dropEvt) {
|
||||||
}
|
}
|
||||||
openDBRequest.onerror = function (err) { console.error(err); }
|
openDBRequest.onerror = function (err) { console.error(err); }
|
||||||
} else if (oldIndex != newIndex) {
|
} else if (oldIndex != newIndex) {
|
||||||
var groupIndex = $(dropEvt.from).data("group-index");
|
var groupIndex = $(dropEvt.from).parent().data("group-index");
|
||||||
|
|
||||||
var openDBRequest = window.indexedDB.open("bookmarks");
|
var openDBRequest = window.indexedDB.open("bookmarks");
|
||||||
openDBRequest.onsuccess = function (dbe) {
|
openDBRequest.onsuccess = function (dbe) {
|
||||||
|
@ -112,8 +112,8 @@ function bookmarkMoved(dropEvt) {
|
||||||
|
|
||||||
function deleteBookmark(e) {
|
function deleteBookmark(e) {
|
||||||
var item = $(this).parent();
|
var item = $(this).parent();
|
||||||
var groupName = item.parent().data("group");
|
var groupName = item.parent().parent().data("group-name");
|
||||||
var groupIndex = item.parent().data("group-index");
|
var groupIndex = item.parent().parent().data("group-index");
|
||||||
var bookmarkIndex = item.index();
|
var bookmarkIndex = item.index();
|
||||||
var bookmarkItem = $("#" + groupName + "-" + bookmarkIndex);
|
var bookmarkItem = $("#" + groupName + "-" + bookmarkIndex);
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ function deleteBookmark(e) {
|
||||||
|
|
||||||
function deleteGroup(e) {
|
function deleteGroup(e) {
|
||||||
var group = $(this); // the delete group button
|
var group = $(this); // the delete group button
|
||||||
var groupIndex = group.data("group");
|
var groupIndex = group.parent().parent().data("group-index");
|
||||||
|
|
||||||
var openDBRequest = window.indexedDB.open("bookmarks");
|
var openDBRequest = window.indexedDB.open("bookmarks");
|
||||||
|
|
||||||
|
|
|
@ -87,15 +87,13 @@ function buildCard(title, groupIndex, itemList) {
|
||||||
var btnDrag = $("<span>").addClass("mr-2 start-hidden dragGroupHandle")
|
var btnDrag = $("<span>").addClass("mr-2 start-hidden dragGroupHandle")
|
||||||
.append($("<span>").addClass("fas fa-bars"));
|
.append($("<span>").addClass("fas fa-bars"));
|
||||||
var btnDel = $("<span>")
|
var btnDel = $("<span>")
|
||||||
.attr("data-group", groupIndex)
|
|
||||||
.addClass("btnDelGroup far fa-trash-alt float-right mt-1 start-hidden text-danger clickable");
|
.addClass("btnDelGroup far fa-trash-alt float-right mt-1 start-hidden text-danger clickable");
|
||||||
btnDel.appendTo(cardHead);
|
btnDel.appendTo(cardHead);
|
||||||
btnDrag.prependTo(cardHead);
|
btnDrag.prependTo(cardHead);
|
||||||
card.append(cardHead);
|
card.append(cardHead);
|
||||||
|
|
||||||
var cardList = $("<div>");
|
var cardList = $("<div>");
|
||||||
cardList.addClass("list-group list-group-flush bookmarkGroup")
|
cardList.addClass("list-group list-group-flush bookmarkGroup");
|
||||||
.attr({"data-group": title, "data-group-index": groupIndex});
|
|
||||||
card.append(cardList);
|
card.append(cardList);
|
||||||
|
|
||||||
for (var i = 0; i < itemList.length; i++) {
|
for (var i = 0; i < itemList.length; i++) {
|
||||||
|
@ -106,7 +104,6 @@ function buildCard(title, groupIndex, itemList) {
|
||||||
.append($("<span>").addClass("fas fa-bars"));
|
.append($("<span>").addClass("fas fa-bars"));
|
||||||
|
|
||||||
var del = $("<span>")
|
var del = $("<span>")
|
||||||
.attr({"data-group": title, "data-group-index": groupIndex, "data-key": i})
|
|
||||||
.addClass("btnDel far fa-trash-alt float-right mt-1 start-hidden text-danger");
|
.addClass("btnDel far fa-trash-alt float-right mt-1 start-hidden text-danger");
|
||||||
del.css("cursor: pointer;");
|
del.css("cursor: pointer;");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue