NewTabPage/js/editBookmarks.js

69 lines
1.7 KiB
JavaScript
Raw Normal View History

$(document).ready(function () {
2017-12-14 22:13:26 +00:00
$("#btnEdit").click(toggleEditing);
});
2017-12-14 22:13:26 +00:00
2018-01-02 00:55:44 +00:00
function toggleEditing () {
2017-12-30 04:51:47 +00:00
if ($("#btnEdit").hasClass("btn-warning"))
disableEditing();
else
enableEditing();
2017-12-14 22:13:26 +00:00
}
2017-12-30 04:51:47 +00:00
function enableEditing() {
$("#btnEdit").removeClass("btn-light btn-dark").addClass("btn-warning");
$("#btnImport").prop("disabled", true);
$("#btnAdd").prop("disabled", true);
2018-01-02 00:55:44 +00:00
$(".bookmarkGroup").each(function (index, item) {
var item = $(item);
2017-12-30 04:51:47 +00:00
item.sortable({
group: { name: "bookmarkLists", pull: true, put: true },
draggable: ".bookmark",
handle: ".dragHandle",
animation: 100,
onEnd: bookmarkMoved
});
});
$("#cardList").sortable({
group: { name: "bookmarksGroups" },
draggable: ".bookmarkGroupContainer",
handle: ".dragGroupHandle",
animation: 100,
onEnd: groupMoved
});
$(".btnDel").show(200);
$(".btnDelGroup").show(200);
$(".dragHandle").show(200);
$(".dragGroupHandle").show(200);
$(".bookmark").click(disableLink);
$(".btnDel").click(deleteBookmark);
$(".btnDelGroup").click(deleteGroup);
}
function disableEditing() {
2018-01-02 00:55:44 +00:00
$(".bookmarkGroup").each(function (index, item) {
$(item).sortable("destroy");
2017-12-30 04:51:47 +00:00
});
$("#cardList").sortable("destroy");
$("#btnEdit").removeClass("btn-warning");
$("#btnImport").prop("disabled", false);
$("#btnAdd").prop("disabled", false);
if ($("#btnAbout").hasClass("btn-light")) {
$("#btnEdit").addClass("btn-light");
} else {
$("#btnEdit").addClass("btn-dark");
}
$(".btnDel").hide(200);
$(".btnDelGroup").hide(200);
$(".dragHandle").hide(200);
$(".dragGroupHandle").hide(200);
$(".bookmark").off("click", disableLink);
$(".btnDel").off("click", deleteBookmark);
$(".btnDelGroup").off("click", deleteGroup);
}