-
-
-
-
+ ${zindex == numberTotalContainers ? `` : upButtons}
+ ${zindex == 1 ? `` : downButtons}
@@ -1003,6 +1115,36 @@
`
);
+
+ /** fill in inputs with current values */
+ let containerSettings = this.containerSettings;
+ // SHADOW / GLOW
+ document.getElementById(this.id + "-settings-shadow-x").value =
+ containerSettings.shadowX;
+ document.getElementById(this.id + "-settings-shadow-y").value =
+ containerSettings.shadowY;
+ document.getElementById(this.id + "-settings-shadow-blur").value =
+ containerSettings.shadowBlur;
+ document.getElementById(this.id + "-settings-shadow-color").value =
+ rgbToHex(
+ containerSettings.shadowRgba
+ .replace("rgba(", "")
+ .slice(0, -1)
+ .split(",")
+ .splice(0, 3)
+ );
+ document.getElementById(this.id + "-settings-shadow-alpha").value =
+ containerSettings.shadowRgba
+ .replace("rgba(", "")
+ .slice(0, -1)
+ .split(",")[3] * 100;
+ // BORDER
+ document.getElementById(this.id + "-settings-border-color").value =
+ containerSettings.borderColor;
+ document.getElementById(this.id + "-settings-border-width").value =
+ containerSettings.borderWidth;
+ document.getElementById(this.id + "-settings-border-radius").value =
+ containerSettings.borderRadius;
}
/*
@@ -1031,26 +1173,6 @@
containerSettings.shadowBlur +
"px " +
containerSettings.shadowRgba;
- // fill in settings ui
- document.getElementById(this.id + "-settings-shadow-x").value =
- containerSettings.shadowX;
- document.getElementById(this.id + "-settings-shadow-y").value =
- containerSettings.shadowY;
- document.getElementById(this.id + "-settings-shadow-blur").value =
- containerSettings.shadowBlur;
- document.getElementById(this.id + "-settings-shadow-color").value =
- rgbToHex(
- containerSettings.shadowRgba
- .replace("rgba(", "")
- .slice(0, -1)
- .split(",")
- .splice(0, 3)
- );
- document.getElementById(this.id + "-settings-shadow-alpha").value =
- containerSettings.shadowRgba
- .replace("rgba(", "")
- .slice(0, -1)
- .split(",")[3] * 100;
/** BORDER */
document.getElementById(this.id).style.borderStyle = "solid";
@@ -1060,13 +1182,7 @@
containerSettings.borderRadius + "px";
document.getElementById(this.id).style.borderColor =
containerSettings.borderColor;
- // fill-in settings ui
- document.getElementById(this.id + "-settings-border-color").value =
- containerSettings.borderColor;
- document.getElementById(this.id + "-settings-border-width").value =
- containerSettings.borderWidth;
- document.getElementById(this.id + "-settings-border-radius").value =
- containerSettings.borderRadius;
+
/** if this is an image container, all relevant settings have been applied */
if (this.imageUrl != undefined) {
@@ -1074,19 +1190,11 @@
}
/** FONT */
- if (containerSettings.fontName == "") {
- document.getElementById(this.id + "-settings-font-name").innerHTML =
- "system default";
- } else {
- document.getElementById(this.id + "-settings-font-name").innerHTML =
- containerSettings.fontName;
- }
if (containerSettings.fontCode != "") {
document.head.insertAdjacentHTML(
"beforeend",
containerSettings.fontCode
);
- // fill in settings ui
document.getElementById(this.id).style.fontFamily =
containerSettings.fontName;
}
@@ -1097,11 +1205,7 @@
} else {
document.getElementById(this.id).style.textAlign = "left";
}
- // fill-in settings ui
- document.getElementById(this.id + "-settings-left-align").checked =
- !containerSettings.centerAlign;
- document.getElementById(this.id + "-settings-center-align").checked =
- containerSettings.centerAlign;
+
/** BOOKMARK CUSTOMIZATION */
// apply link customization
@@ -1118,38 +1222,12 @@
sectionElements[i].style.fontWeight = containerSettings.sectionBold ? "bold" : "normal";
sectionElements[i].style.fontStyle = containerSettings.sectionItalic ? "italic" : "normal";
}
- // fill-in settings ui
- document.getElementById(this.id + "-settings-section-color").value =
- containerSettings.sectionColor;
- document.getElementById(this.id + "-settings-section-size").value =
- containerSettings.sectionSize;
- document.getElementById(this.id + "-settings-section-bold").checked =
- containerSettings.sectionBold;
- document.getElementById(this.id + "-settings-section-italic").checked =
- containerSettings.sectionItalic;
- document.getElementById(this.id + "-settings-link-color").value =
- containerSettings.linkColor;
- document.getElementById(this.id + "-settings-link-size").value =
- containerSettings.linkSize;
/** BACKGROUND COLOR */
document.getElementById(this.id).style.backgroundColor =
containerSettings.backgroundRgba;
- // fill-in settings ui
- document.getElementById(this.id + "-settings-bg-color").value =
- rgbToHex(
- containerSettings.backgroundRgba
- .replace("rgba(", "")
- .slice(0, -1)
- .split(",")
- .splice(0, 3)
- );
- document.getElementById(this.id + "-settings-bg-alpha").value =
- containerSettings.backgroundRgba
- .replace("rgba(", "")
- .slice(0, -1)
- .split(",")[3] * 100;
+
/** HEADER */
// show header elements
@@ -1166,19 +1244,7 @@
containerSettings.headerBold ? "bold" : "normal";
document.getElementById(this.id + "-header").style.fontStyle =
containerSettings.headerItalic ? "italic" : "normal";
- // fill-in settings ui
- document.getElementById(this.id + "-settings-date-toggle").checked =
- containerSettings.enableDate;
- document.getElementById(this.id + "-settings-clock-toggle").checked =
- containerSettings.enableClock;
- document.getElementById(this.id + "-settings-clock-color").value =
- containerSettings.headerColor;
- document.getElementById(this.id + "-settings-clock-size").value =
- containerSettings.headerSize;
- document.getElementById(this.id + "-settings-clock-bold").checked =
- containerSettings.headerBold;
- document.getElementById(this.id + "-settings-clock-italic").checked =
- containerSettings.headerItalic;
+
/** DIVIDER */
let divider = document.getElementById(this.id + "-divider");
@@ -1194,11 +1260,6 @@
divider.style.backgroundColor = containerSettings.dividerColor;
divider.style.borderColor = containerSettings.dividerColor;
}
- // fill-in settings ui
- document.getElementById(this.id + "-settings-divider-toggle").checked =
- containerSettings.enableDivider;
- document.getElementById(this.id + "-settings-divider-color").value =
- containerSettings.dividerColor;
}
/**
@@ -1481,12 +1542,8 @@
let containerMapValues =
JSON.parse(localStorage.getItem("containerMapValues")) || [];
+ numberTotalContainers = containerMapValues.length;
for (let i = 0; i < containerMapValues.length; i++) {
- // containerDataMap.set(containerMapValues[i].id, containerMapValues[i]);
- if (containerMapValues[i].id == "settingsContainer") {
- continue;
- }
-
containerDataMap.set(containerMapValues[i].id, new Container(
containerMapValues[i].id,
containerMapValues[i].name,
@@ -1830,33 +1887,70 @@
function reorderContainer(buttonPressed, direction) {
let containerId = buttonPressed.id.split("--")[0];
- let container = document.getElementById(containerId);
- let currentIndex = container.containerSettings.zIndex;
- let copy = container;
+ let movingContainer = containerDataMap.get(containerId);
- // move indicated container
+ let currentIndex = parseInt(movingContainer.containerSettings.zIndex);
+ let destinationIndex;
if (direction == "up") {
- zIndexMap.set(currentIndex, zIndexMap.get(currentIndex + 1));
- zIndexMap.set(currentIndex + 1, copy);
+ destinationIndex = currentIndex + 1;
}
else if (direction == "down") {
- zIndexMap.set(currentIndex, zIndexMap.get(currentIndex - 1));
- zIndexMap.set(currentIndex - 1, copy);
+ destinationIndex = currentIndex - 1;
}
else if (direction == "top") {
- zIndexMap.set(
- currentIndex, zIndexMap.get(numberOfImageContainers + numberOfTextContainers)
- );
- zIndexMap.set(numberOfImageContainers + numberOfTextContainers, copy);
+ destinationIndex = numberOfImageContainers + numberOfTextContainers;
}
else if (direction == "bottom") {
- zIndexMap.set(currentIndex, zIndexMap.get(1));
- zIndexMap.set(1, copy);
+ destinationIndex = 1;
}
- // consider a redraw function for menu listings
+ currentIndex = String(currentIndex);
+ destinationIndex = String(destinationIndex);
+
+ console.log('currentIndex: ' + currentIndex);
+ console.log('destinationIndex: ' + destinationIndex);
+ console.log('zindexmap: ' + zIndexMap.get(destinationIndex));
+ console.log('container map: ' + containerDataMap.get(zIndexMap.get(destinationIndex)));
+
+
+ // actually move containers (swap with destination index)
+ document.getElementById(zIndexMap.get(destinationIndex)).style.zIndex = currentIndex;
+ document.getElementById(containerId).style.zIndex = destinationIndex;
+
+ // save new indexes
+ movingContainer.containerSettings.zIndex = destinationIndex;
+ containerDataMap.get(zIndexMap.get(destinationIndex))
+ .containerSettings.zIndex = currentIndex;
+ zIndexMap.set(currentIndex, zIndexMap.get(destinationIndex));
+ zIndexMap.set(destinationIndex, movingContainer.id);
+
+ /** adjust container listings on settings menu
+ let copy = document.getElementById(containerId + "-container-listing");
+ document.getElementById(containerId + "-container-listing").remove();
+
+ let destinationContainerElement = document.getElementById(zIndexMap.get(destinationIndex) + "-container-listing");
+
+ destinationContainerElement.insertAdjacentHTML("afterend", copy);
+ copy = destinationContainerElement;
+ */
+
+
+ redrawContainerListings();
}
+ function redrawContainerListings() {
+ document.getElementById("containers").innerHTML = "";
+ for (let i = 1; i <= numberTotalContainers; i++) {
+ let currentContainer = containerDataMap.get(zIndexMap.get(String(i)));
+ if (currentContainer.imageUrl == undefined) {
+ currentContainer.createTextContainerMenuListing();
+ }
+ else {
+ currentContainer.createImageContainerMenuListing();
+ }
+ currentContainer.addSettingsMenuEventListeners();
+ }
+ }
function deleteContainer(buttonPressed) {
let containerId = buttonPressed.id.split("--")[0];
@@ -1871,6 +1965,7 @@
}
containerDataMap.delete(containerId);
+ numberTotalContainers--;
document.getElementById(containerId).remove();
document.getElementById(containerId + "-container-listing").remove();