From 74ea775af1897934ed793dac6f826be72b5a7a6a Mon Sep 17 00:00:00 2001 From: zombieFox Date: Fri, 6 Mar 2020 13:41:20 +0000 Subject: [PATCH] [feature] add open all override control at group level --- src/html/menu/content/groups/openall.html | 6 ++++ src/js/bookmarks.js | 2 ++ src/js/link.js | 36 +++++++++++++++++++++-- src/js/update.js | 3 ++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/html/menu/content/groups/openall.html b/src/html/menu/content/groups/openall.html index 5fae119b..4474826b 100644 --- a/src/html/menu/content/groups/openall.html +++ b/src/html/menu/content/groups/openall.html @@ -7,6 +7,12 @@ +
+

The Open all button will show when there is at least one Bookmark in a Group.

+
+
+

This can be overridden for individual Groups using their edit conttrols.

+
diff --git a/src/js/bookmarks.js b/src/js/bookmarks.js index e15fab9e..1b3c52bd 100644 --- a/src/js/bookmarks.js +++ b/src/js/bookmarks.js @@ -4,6 +4,7 @@ var bookmarks = (function() { mod.all = [{ name: "Cool stuff", + openAll: true, items: [{ display: "icon", letter: "AS", @@ -127,6 +128,7 @@ var bookmarks = (function() { }] }, { name: "Dev sites", + openAll: true, items: [{ display: "icon", letter: "DEV", diff --git a/src/js/link.js b/src/js/link.js index c720df1b..cf61fa25 100644 --- a/src/js/link.js +++ b/src/js/link.js @@ -7,18 +7,21 @@ var link = (function() { }, group: { name: null, + openAll: null, items: null } }; stagedGroup.init = function() { stagedGroup.group.items = []; + stagedGroup.group.openAll = true; }; stagedGroup.reset = function() { stagedGroup.position.origin = null; stagedGroup.position.destination = null; stagedGroup.group.name = null; + stagedGroup.group.openAll = null; stagedGroup.group.items = null; }; @@ -473,7 +476,7 @@ var link = (function() { if (state.get.current().group.name.show) { groupHeader.appendChild(groupHeaderItemName); }; - if (state.get.current().group.openAll.show && stagedGroup.group.items.length > 0) { + if (state.get.current().group.openAll.show && stagedGroup.group.openAll && stagedGroup.group.items.length > 0) { groupHeader.appendChild(groupHeaderItemOpenall); }; group.appendChild(groupHeader); @@ -501,17 +504,40 @@ var link = (function() { // group name var groupFormNameInputWrap = helper.node("div|class:form-wrap"); - var groupFormInputLabel = helper.node("label:Name|for:group-form-input-name"); + var groupFormInputNameLabel = helper.node("label:Name|for:group-form-input-name"); var groupFormInputName = helper.node("input|type:text,class:group-form-input-name,id:group-form-input-name,placeholder:Example group,tabindex:1,autocomplete:off,autocorrect:off,autocapitalize:off,spellcheck:false"); + // open all + var groupFormOpenAllInputWrap = helper.node("div|class:form-wrap"); + var groupFormInputOpenallLabel = helper.node("label|for:group-form-input-openall"); + var groupFormInputOpenallLabelText = helper.node("span:Show Open all in this Group"); + var groupFormInputOpenallLabelIcon = helper.node("span|class:label-icon"); + var groupFormOpenAllInput = helper.node("input|type:checkbox,class:group-form-input-openall,id:group-form-input-openall,placeholder:Example group,tabindex:1,autocomplete:off,autocorrect:off,autocapitalize:off,spellcheck:false,checked"); + var groupFormOpenAllInputHelper1 = helper.node("div|class:form-helper"); + var groupFormOpenAllInputHelper1Item = helper.node("p:Override the global Group setting to show or hide the Open all button.|class:link-form-input-icon-helper form-helper-item"); + var groupFormOpenAllInputHelper2 = helper.node("div|class:form-helper"); + var groupFormOpenAllInputHelper2Item = helper.node("p:The Open all button will show when there is at least one Bookmark in this Group.|class:link-form-input-icon-helper form-helper-item"); + groupFormPositionInputWrap.appendChild(groupFormPositionLabel); groupFormPositionInputWrap.appendChild(groupFormPositionSelect); groupFormRandomNameButtonWrap.appendChild(groupFormRandomNameButton); - groupFormNameInputWrap.appendChild(groupFormInputLabel); + groupFormNameInputWrap.appendChild(groupFormInputNameLabel); groupFormNameInputWrap.appendChild(groupFormInputName); + groupFormInputOpenallLabel.appendChild(groupFormInputOpenallLabelIcon); + groupFormInputOpenallLabel.appendChild(groupFormInputOpenallLabelText); + groupFormOpenAllInputHelper1.appendChild(groupFormOpenAllInputHelper1Item); + groupFormOpenAllInputHelper2.appendChild(groupFormOpenAllInputHelper2Item); + groupFormOpenAllInputWrap.appendChild(groupFormOpenAllInput); + groupFormOpenAllInputWrap.appendChild(groupFormInputOpenallLabel); + groupFormOpenAllInputWrap.appendChild(groupFormOpenAllInputHelper1); + groupFormOpenAllInputWrap.appendChild(groupFormOpenAllInputHelper2); + fieldset.appendChild(groupFormNameInputWrap); fieldset.appendChild(groupFormRandomNameButtonWrap); + fieldset.appendChild(helper.node("hr")); fieldset.appendChild(groupFormPositionInputWrap); + fieldset.appendChild(helper.node("hr")); + fieldset.appendChild(groupFormOpenAllInputWrap); form.appendChild(fieldset); var makeGroupOptions = function() { @@ -527,6 +553,7 @@ var link = (function() { var populateForm = function() { groupFormPositionSelect.selectedIndex = stagedGroup.position.origin; groupFormInputName.value = stagedGroup.group.name; + groupFormOpenAllInput.checked = stagedGroup.group.openAll; }; var setLastPosition = function() { @@ -561,6 +588,9 @@ var link = (function() { stagedGroup.group.name = randomName; groupFormInputName.value = randomName; }, false); + groupFormOpenAllInput.addEventListener("change", function(event) { + stagedGroup.group.openAll = this.checked; + }, false); return form; }, diff --git a/src/js/update.js b/src/js/update.js index 619a623c..37e1b098 100644 --- a/src/js/update.js +++ b/src/js/update.js @@ -884,6 +884,9 @@ var update = (function() { "5.0.0": function(data) { data.state.layout.direction = "vertical"; data.state.link.area.direction = "ltr"; + data.bookmarks.forEach(function(arrayItem, index) { + arrayItem.openAll = true; + }); return data; } };