Tab-Search-and-Manage/src/scripts/dragContainersSetup.js

28 lines
958 B
JavaScript

var count = 2; toMoveID = 0, newIndex = 0;;
var insert = "";
var drake = dragula()
.on('drag', function (el) {
toMoveID = parseInt(el.getAttribute("tabID"));
el.className = el.className.replace('ex-moved', '');
}).on('drop', function (el, container) {
var subCont = document.getElementById("listZone");
var size = subCont.children.length;
for (var i = 0; i < size; i++) {
if (subCont.children[i].getAttribute("tabID") == toMoveID) {
newIndex = i;
}
}
browser.tabs.move(toMoveID, {index: newIndex}).then();
el.className += ' ex-moved';
}).on('over', function (el, container) {
container.className += ' ex-over';
}).on('out', function (el, container) {
container.className = container.className.replace('ex-over', '');
});
// Connect to pre created containers
drake.containers.push(document.querySelector('#listZone'));