Skip to content

Commit

Permalink
Replaced div as tab list container instead of ul (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
aadishjain08 authored Dec 10, 2021
1 parent e7e0c6f commit 66afb2b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions js/tab-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ function displayGroupList() {

groupElement.setAttribute("prop", prop);

const list = document.createElement("ul");
const tabContainer = document.createElement("div");

list.ondrop = (e) => listonDrop(e, prop, list);
tabContainer.ondrop = (e) => listonDrop(e, prop, tabContainer);

// Creating elements for each item of a group
store[prop].tabList.forEach((tab, i) => {
const tabElement = document.createElement("div");
tabElement.classList.add("tab-container");
list.title = "Click to restore this tab, Drag to drop to another group";
tabContainer.title = "Click to restore this tab, Drag to drop to another group";

const buttons = document.createElement("label");
buttons.classList.add("bullet-container");
Expand Down Expand Up @@ -223,7 +223,7 @@ function displayGroupList() {
});
tabElement.addEventListener("dragover", (e) => e.preventDefault());

list.appendChild(tabElement);
tabContainer.appendChild(tabElement);
});

// Elements for adding tab manually
Expand All @@ -240,7 +240,7 @@ function displayGroupList() {
addTabInput.className = "add-tab-input" + " prop-" + prop.toString();
addTabInput.setAttribute("placeholder", "Enter URL of the tab to add");
addTab.appendChild(addTabInput);
list.appendChild(addTab);
tabContainer.appendChild(addTab);

const header = document.createElement("div");
header.className = "header";
Expand All @@ -263,7 +263,7 @@ function displayGroupList() {

groupElement.appendChild(header);
header.appendChild(groupButtons);
groupElement.appendChild(list);
groupElement.appendChild(tabContainer);
groupList.appendChild(groupElement);
});
}
Expand Down Expand Up @@ -331,11 +331,11 @@ document.getElementById("clear-storage-btn").addEventListener("click", () => {
browser.storage.local.clear().then(window.location.reload());
});

function listonDrop(e, prop, list) {
function listonDrop(e, prop, tabContainer) {
e.preventDefault();
const data = e.dataTransfer.getData("element-data");
const element = document.getElementById(data);
list.appendChild(element);
tabContainer.appendChild(element);
const elementProp = element.getAttribute("prop");
const index = element.getAttribute("index");
const originalTabList = store[elementProp].tabList;
Expand Down

0 comments on commit 66afb2b

Please sign in to comment.