mirror of
https://github.com/linuxserver/Heimdall.git
synced 2026-02-21 12:10:34 +09:00
use sortablejs instead of jquery-ui (#1115)
This commit is contained in:
@@ -52,15 +52,38 @@ $.when($.ready).then(() => {
|
||||
}
|
||||
}); */
|
||||
|
||||
$("#sortable").sortable({
|
||||
stop() {
|
||||
const idsInOrder = $("#sortable").sortable("toArray", {
|
||||
attribute: "data-id",
|
||||
const sortableEl = document.getElementById("sortable");
|
||||
let sortable;
|
||||
if (sortableEl !== null) {
|
||||
// eslint-disable-next-line no-undef
|
||||
sortable = Sortable.create(sortableEl, {
|
||||
disabled: true,
|
||||
animation: 150,
|
||||
forceFallback: !(
|
||||
navigator.userAgent.toLowerCase().indexOf("firefox") > -1
|
||||
),
|
||||
draggable: ".item-container",
|
||||
onEnd() {
|
||||
const idsInOrder = sortable.toArray();
|
||||
$.post(`${base}order`, { order: idsInOrder });
|
||||
},
|
||||
});
|
||||
// prevent Firefox drag behavior
|
||||
if (navigator.userAgent.toLowerCase().indexOf("firefox") > -1) {
|
||||
sortable.option("setData", (dataTransfer) => {
|
||||
dataTransfer.setData("Text", "");
|
||||
});
|
||||
$.post(`${base}order`, { order: idsInOrder });
|
||||
},
|
||||
});
|
||||
$("#sortable").sortable("disable");
|
||||
|
||||
sortableEl.addEventListener("dragstart", (event) => {
|
||||
const { target } = event;
|
||||
if (target.nodeName.toLowerCase() === "a") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
event.dataTransfer.setData("Text", "");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$("#main")
|
||||
.on("mouseenter", "#sortable.ui-sortable-disabled .item", function () {
|
||||
@@ -138,10 +161,10 @@ $.when($.ready).then(() => {
|
||||
$(".item-edit").hide();
|
||||
$("#app").removeClass("sidebar");
|
||||
$("#sortable .tooltip").css("display", "");
|
||||
$("#sortable").sortable("disable");
|
||||
if (sortable !== undefined) sortable.option("disabled", true);
|
||||
} else {
|
||||
$("#sortable .tooltip").css("display", "none");
|
||||
$("#sortable").sortable("enable");
|
||||
if (sortable !== undefined) sortable.option("disabled", false);
|
||||
setTimeout(() => {
|
||||
$(".add-item").fadeIn();
|
||||
$(".item-edit").fadeIn();
|
||||
|
||||
@@ -1125,6 +1125,16 @@ select:-webkit-autofill:focus {
|
||||
color: $app-text!important;
|
||||
}
|
||||
|
||||
.sortable-drag {
|
||||
opacity: 1!important;
|
||||
}
|
||||
|
||||
#sortable {
|
||||
.sortable-ghost:not(.sortable-drag) {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
#sortable:focus-within {
|
||||
.item:focus-within {
|
||||
outline: 1px solid #ffffff91;
|
||||
|
||||
Reference in New Issue
Block a user