[refactor] Improve global, link and group edit states

This commit is contained in:
Kombie 2019-12-22 13:14:44 +00:00 committed by GitHub
parent 73d2795018
commit 41d183ba66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 286 additions and 227 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "nighttab", "name": "nighttab",
"version": "4.1.3", "version": "4.2.1",
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.", "description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -847,6 +847,7 @@ input[type="range"]:disabled::-moz-range-progress {
display: inline-block; display: inline-block;
} }
/* input button */
.input-button input[type="checkbox"]+label, .input-button input[type="checkbox"]+label,
.input-button input[type="radio"]+label, .input-button input[type="radio"]+label,
.input-button input[type="color"]+label, .input-button input[type="color"]+label,
@ -998,6 +999,7 @@ input[type="range"]:disabled::-moz-range-progress {
background-color: rgb(var(--button-border-disabled)); background-color: rgb(var(--button-border-disabled));
} }
/* input button link */
.input-button-link input[type="checkbox"]+label, .input-button-link input[type="checkbox"]+label,
.input-button-link input[type="radio"]+label, .input-button-link input[type="radio"]+label,
.input-button-link input[type="color"]+label, .input-button-link input[type="color"]+label,
@ -1032,7 +1034,6 @@ input[type="range"]:disabled::-moz-range-progress {
.input-button-link input:disabled[type="color"]+label, .input-button-link input:disabled[type="color"]+label,
.input-button-link input:disabled[type="file"]+label { .input-button-link input:disabled[type="file"]+label {
background-color: transparent; background-color: transparent;
color: transparent;
pointer-events: none; pointer-events: none;
} }

View File

@ -55,12 +55,12 @@
} }
.is-group-order-headerbody.is-group-name-show .group-header, .is-group-order-headerbody.is-group-name-show .group-header,
.is-group-order-headerbody.is-link-edit .group-header { .is-group-order-headerbody.is-edit .group-header {
padding-bottom: calc(var(--layout-space) * var(--layout-gutter)); padding-bottom: calc(var(--layout-space) * var(--layout-gutter));
} }
.is-group-order-bodyheader.is-group-name-show .group-header, .is-group-order-bodyheader.is-group-name-show .group-header,
.is-group-order-bodyheader.is-link-edit .group-header { .is-group-order-bodyheader.is-edit .group-header {
padding-top: calc(var(--layout-space) * var(--layout-gutter)); padding-top: calc(var(--layout-space) * var(--layout-gutter));
} }
@ -101,7 +101,7 @@
margin var(--layout-timing-extra-fast); margin var(--layout-timing-extra-fast);
} }
.is-link-edit .group-control { .is-edit .group-control {
height: 2.5em; height: 2.5em;
width: 16em; width: 16em;
transition: transition:
@ -110,12 +110,12 @@
margin var(--layout-timing-extra-fast) var(--layout-duration-04); margin var(--layout-timing-extra-fast) var(--layout-duration-04);
} }
.is-link-edit.is-group-name-show.is-group-area-alignment-left .group-control, .is-edit.is-group-name-show.is-group-area-alignment-left .group-control,
.is-link-edit.is-group-name-show.is-group-area-alignment-center .group-control { .is-edit.is-group-name-show.is-group-area-alignment-center .group-control {
margin-right: 1em; margin-right: 1em;
} }
.is-link-edit.is-group-name-show.is-group-area-alignment-right .group-control { .is-edit.is-group-name-show.is-group-area-alignment-right .group-control {
margin-left: 1em; margin-left: 1em;
} }

View File

@ -239,29 +239,29 @@
border-bottom-right-radius: calc(var(--theme-radius) / 4); border-bottom-right-radius: calc(var(--theme-radius) / 4);
} }
.is-link-edit .link-panel-front, .is-edit .link-panel-front,
.is-link-edit .link-item:hover .link-panel-front, .is-edit .link-item:hover .link-panel-front,
.is-link-edit .link-item:focus .link-panel-front { .is-edit .link-item:focus .link-panel-front {
height: calc(100% - var(--link-item-edit-height)); height: calc(100% - var(--link-item-edit-height));
} }
.is-theme-radius.is-link-edit.is-link-orientation-top .link-panel-front, .is-theme-radius.is-edit.is-link-orientation-top .link-panel-front,
.is-theme-radius.is-link-edit.is-link-orientation-top .link-item:hover .link-panel-front, .is-theme-radius.is-edit.is-link-orientation-top .link-item:hover .link-panel-front,
.is-theme-radius.is-link-edit.is-link-orientation-top .link-item:focus .link-panel-front { .is-theme-radius.is-edit.is-link-orientation-top .link-item:focus .link-panel-front {
border-top-left-radius: calc(var(--theme-radius) / 4); border-top-left-radius: calc(var(--theme-radius) / 4);
border-top-right-radius: calc(var(--theme-radius) / 4); border-top-right-radius: calc(var(--theme-radius) / 4);
} }
.is-theme-radius.is-link-edit.is-link-orientation-bottom .link-panel-front, .is-theme-radius.is-edit.is-link-orientation-bottom .link-panel-front,
.is-theme-radius.is-link-edit.is-link-orientation-bottom .link-item:hover .link-panel-front, .is-theme-radius.is-edit.is-link-orientation-bottom .link-item:hover .link-panel-front,
.is-theme-radius.is-link-edit.is-link-orientation-bottom .link-item:focus .link-panel-front { .is-theme-radius.is-edit.is-link-orientation-bottom .link-item:focus .link-panel-front {
border-bottom-left-radius: calc(var(--theme-radius) / 4); border-bottom-left-radius: calc(var(--theme-radius) / 4);
border-bottom-right-radius: calc(var(--theme-radius) / 4); border-bottom-right-radius: calc(var(--theme-radius) / 4);
} }
.is-link-item-shadow-show.is-link-edit .link-panel-front, .is-link-item-shadow-show.is-edit .link-panel-front,
.is-link-item-shadow-show.is-link-edit .link-item:hover .link-panel-front, .is-link-item-shadow-show.is-edit .link-item:hover .link-panel-front,
.is-link-item-shadow-show.is-link-edit .link-item:focus .link-panel-front { .is-link-item-shadow-show.is-edit .link-item:focus .link-panel-front {
box-shadow: var(--layout-shadow-medium); box-shadow: var(--layout-shadow-medium);
} }
@ -276,7 +276,7 @@
transition: font-size var(--layout-timing-extra-fast), top var(--layout-timing-extra-fast), left var(--layout-timing-extra-fast); transition: font-size var(--layout-timing-extra-fast), top var(--layout-timing-extra-fast), left var(--layout-timing-extra-fast);
} }
.is-link-edit .link-display { .is-edit .link-display {
font-size: 0.6em; font-size: 0.6em;
} }
@ -683,23 +683,23 @@
clip-path: polygon(0 calc(100% - calc(var(--link-item-url-height) + 10%)), 100% calc(100% - calc(var(--link-item-url-height) + 10%)), 100% 100%, 0 100%); clip-path: polygon(0 calc(100% - calc(var(--link-item-url-height) + 10%)), 100% calc(100% - calc(var(--link-item-url-height) + 10%)), 100% 100%, 0 100%);
} }
.is-link-edit.is-link-orientation-top .link-panel-back, .is-edit.is-link-orientation-top .link-panel-back,
.is-link-edit.is-link-orientation-top .link-panel-back, .is-edit.is-link-orientation-top .link-panel-back,
.is-link-edit.is-link-orientation-top .link-panel-back, .is-edit.is-link-orientation-top .link-panel-back,
.is-link-edit.is-link-orientation-top .link-item:focus .link-panel-back, .is-edit.is-link-orientation-top .link-item:focus .link-panel-back,
.is-link-edit.is-link-orientation-top .link-item:focus-within .link-panel-back, .is-edit.is-link-orientation-top .link-item:focus-within .link-panel-back,
.is-link-edit.is-link-orientation-top .link-item:hover .link-panel-back { .is-edit.is-link-orientation-top .link-item:hover .link-panel-back {
height: 100%; height: 100%;
top: 0; top: 0;
clip-path: polygon(0 0, 100% 0, 100% calc(100% - calc(var(--link-item-edit-height) - 10%)), 0 calc(100% - calc(var(--link-item-edit-height) - 10%))) clip-path: polygon(0 0, 100% 0, 100% calc(100% - calc(var(--link-item-edit-height) - 10%)), 0 calc(100% - calc(var(--link-item-edit-height) - 10%)))
} }
.is-link-edit.is-link-orientation-bottom .link-panel-back, .is-edit.is-link-orientation-bottom .link-panel-back,
.is-link-edit.is-link-orientation-bottom .link-panel-back, .is-edit.is-link-orientation-bottom .link-panel-back,
.is-link-edit.is-link-orientation-bottom .link-panel-back, .is-edit.is-link-orientation-bottom .link-panel-back,
.is-link-edit.is-link-orientation-bottom .link-item:focus .link-panel-back, .is-edit.is-link-orientation-bottom .link-item:focus .link-panel-back,
.is-link-edit.is-link-orientation-bottom .link-item:focus-within .link-panel-back, .is-edit.is-link-orientation-bottom .link-item:focus-within .link-panel-back,
.is-link-edit.is-link-orientation-bottom .link-item:hover .link-panel-back { .is-edit.is-link-orientation-bottom .link-item:hover .link-panel-back {
height: 100%; height: 100%;
top: 0; top: 0;
clip-path: polygon(0 calc(100% - calc(var(--link-item-edit-height) + 10%)), 100% calc(100% - calc(var(--link-item-edit-height) + 10%)), 100% 100%, 0 100%); clip-path: polygon(0 calc(100% - calc(var(--link-item-edit-height) + 10%)), 100% calc(100% - calc(var(--link-item-edit-height) + 10%)), 100% 100%, 0 100%);
@ -717,7 +717,7 @@
transition: height var(--layout-timing-extra-fast); transition: height var(--layout-timing-extra-fast);
} }
.is-link-edit .link-control { .is-edit .link-control {
height: var(--link-item-edit-height); height: var(--link-item-edit-height);
} }
@ -850,9 +850,9 @@
justify-content: flex-end; justify-content: flex-end;
} }
.is-link-item-url-show:not(.is-link-edit) .link-item:focus-within .link-url, .is-link-item-url-show:not(.is-edit) .link-item:focus-within .link-url,
.is-link-item-url-show:not(.is-link-edit) .link-item:focus .link-url, .is-link-item-url-show:not(.is-edit) .link-item:focus .link-url,
.is-link-item-url-show:not(.is-link-edit) .link-item:hover .link-url { .is-link-item-url-show:not(.is-edit) .link-item:hover .link-url {
height: var(--link-item-url-height); height: var(--link-item-url-height);
} }
@ -873,14 +873,14 @@
color: rgb(var(--theme-white)); color: rgb(var(--theme-white));
} }
.is-link-edit.is-link-item-url-show .link-item:focus .link-panel-front, .is-edit.is-link-item-url-show .link-item:focus .link-panel-front,
.is-link-edit.is-link-item-url-show .link-item:focus-within .link-panel-front, .is-edit.is-link-item-url-show .link-item:focus-within .link-panel-front,
.is-link-edit.is-link-item-url-show .link-item:hover .link-panel-front { .is-edit.is-link-item-url-show .link-item:hover .link-panel-front {
height: calc(100% - var(--link-item-edit-height)); height: calc(100% - var(--link-item-edit-height));
} }
.is-link-edit .link-item:hover .link-url, .is-edit .link-item:hover .link-url,
.is-link-edit .link-item:focus .link-url { .is-edit .link-item:focus .link-url {
height: 0; height: 0;
} }

View File

@ -88,8 +88,8 @@
<div class="header-button-body"> <div class="header-button-body">
<div class="form-group nested-button mb-0"> <div class="form-group nested-button mb-0">
<div class="input-wrap input-button input-hide py-0"> <div class="input-wrap input-button input-hide py-0">
<input id="control-link-edit" class="control-link-edit" type="checkbox" tabindex="1"> <input id="control-edit" class="control-edit" type="checkbox" tabindex="1">
<label for="control-link-edit" class="mb-0"><span class="label-icon"></span> Edit</label> <label for="control-edit" class="mb-0"><span class="label-icon"></span> Edit</label>
</div> </div>
<div class="input-wrap py-0"> <div class="input-wrap py-0">
<div class="form-dropdown"> <div class="form-dropdown">

View File

@ -73,8 +73,8 @@ var control = (function() {
link.add.group.open(); link.add.group.open();
} }
}, { }, {
element: helper.e(".control-link-edit"), element: helper.e(".control-edit"),
path: "link.edit", path: "edit",
type: "checkbox", type: "checkbox",
func: function() { func: function() {
link.tabindex(); link.tabindex();
@ -2876,6 +2876,12 @@ var control = (function() {
render.class = function() { render.class = function() {
var html = helper.e("html"); var html = helper.e("html");
var _edit = function() {
helper.removeClass(html, "is-edit");
if (state.get.current().edit) {
helper.addClass(html, "is-edit");
};
};
var _menu = function() { var _menu = function() {
helper.addClass(html, "is-menu"); helper.addClass(html, "is-menu");
}; };
@ -3044,7 +3050,6 @@ var control = (function() {
helper.removeClass(html, "is-link-style-block"); helper.removeClass(html, "is-link-style-block");
helper.removeClass(html, "is-link-orientation-top"); helper.removeClass(html, "is-link-orientation-top");
helper.removeClass(html, "is-link-orientation-bottom"); helper.removeClass(html, "is-link-orientation-bottom");
helper.removeClass(html, "is-link-edit");
if (state.get.current().link.show) { if (state.get.current().link.show) {
helper.addClass(html, "is-link-show"); helper.addClass(html, "is-link-show");
helper.addClass(html, "is-link-area-alignment-" + state.get.current().link.area.alignment); helper.addClass(html, "is-link-area-alignment-" + state.get.current().link.area.alignment);
@ -3074,9 +3079,6 @@ var control = (function() {
if (state.get.current().link.item.border > 0) { if (state.get.current().link.item.border > 0) {
helper.addClass(html, "is-link-item-border"); helper.addClass(html, "is-link-item-border");
}; };
if (state.get.current().link.edit) {
helper.addClass(html, "is-link-edit");
};
}; };
}; };
var _theme = function() { var _theme = function() {
@ -3115,6 +3117,7 @@ var control = (function() {
helper.removeClass(html, "is-background-image-show"); helper.removeClass(html, "is-background-image-show");
}; };
}; };
_edit();
_menu(); _menu();
_header(); _header();
_group(); _group();
@ -3465,9 +3468,9 @@ var control = (function() {
}; };
var _edit = function() { var _edit = function() {
if (bookmarks.get().length > 0) { if (bookmarks.get().length > 0) {
_disable.input(".control-link-edit", false); _disable.input(".control-edit", false);
} else { } else {
_disable.input(".control-link-edit", false); _disable.input(".control-edit", true);
}; };
}; };
var _group = function() { var _group = function() {

View File

@ -134,24 +134,19 @@ var header = (function() {
style: function() { style: function() {
var action = { var action = {
box: function() { box: function() {
helper.removeClass(helper.getClosest(helper.e(".control-link-edit"), ".input-wrap"), "input-button-link"); helper.removeClass(helper.getClosest(helper.e(".control-edit"), ".input-wrap"), "input-button-link");
helper.removeClass(helper.e(".control-add-toggle"), "button-link"); helper.removeClass(helper.e(".control-add-toggle"), "button-link");
helper.removeClass(helper.getClosest(helper.e(".control-theme-accent-current-quick"), ".input-wrap"), "input-button-link"); helper.removeClass(helper.getClosest(helper.e(".control-theme-accent-current-quick"), ".input-wrap"), "input-button-link");
helper.removeClass(helper.e(".control-menu-open"), "button-link"); helper.removeClass(helper.e(".control-menu-open"), "button-link");
}, },
clear: function() { clear: function() {
helper.addClass(helper.getClosest(helper.e(".control-link-edit"), ".input-wrap"), "input-button-link"); helper.addClass(helper.getClosest(helper.e(".control-edit"), ".input-wrap"), "input-button-link");
helper.addClass(helper.e(".control-add-toggle"), "button-link"); helper.addClass(helper.e(".control-add-toggle"), "button-link");
helper.addClass(helper.getClosest(helper.e(".control-theme-accent-current-quick"), ".input-wrap"), "input-button-link"); helper.addClass(helper.getClosest(helper.e(".control-theme-accent-current-quick"), ".input-wrap"), "input-button-link");
helper.addClass(helper.e(".control-menu-open"), "button-link"); helper.addClass(helper.e(".control-menu-open"), "button-link");
} }
}; };
action[state.get.current().header.button.style](); action[state.get.current().header.button.style]();
},
edit: function() {
if (!state.get.current().link.edit) {
helper.e(".control-link-edit").checked = false;
};
} }
}; };

View File

@ -14,18 +14,28 @@ var keyboard = (function() {
dropdown.close(); dropdown.close();
} else if (state.get.current().autoSuggest) { } else if (state.get.current().autoSuggest) {
autoSuggest.close(); autoSuggest.close();
} else if (state.get.current().link.edit) {
link.edit.item.close();
shade.close();
data.save();
} else if (state.get.current().link.add) { } else if (state.get.current().link.add) {
link.add.item.close(); link.add.item.close();
shade.close();
data.save();
} else if (state.get.current().group.edit) {
link.edit.group.close();
shade.close();
data.save();
} else if (state.get.current().group.add) { } else if (state.get.current().group.add) {
link.add.group.close(); link.add.group.close();
} else if (state.get.current().link.edit && state.get.current().modal) { shade.close();
link.add.item.close();
} else if (state.get.current().link.edit) {
link.edit.close();
data.save(); data.save();
} else if (state.get.current().modal) { } else if (state.get.current().modal) {
modal.close(); modal.close();
shade.close(); shade.close();
} else if (state.get.current().edit) {
link.edit.mode.close();
data.save();
}; };
data.save(); data.save();
}; };
@ -103,7 +113,11 @@ var keyboard = (function() {
window.addEventListener("keydown", function(event) { window.addEventListener("keydown", function(event) {
// ctrl+alt+e // ctrl+alt+e
if (event.ctrlKey && event.altKey && event.keyCode == 69) { if (event.ctrlKey && event.altKey && event.keyCode == 69) {
link.edit.toggle(); if (bookmarks.get().length > 0) {
link.edit.mode.toggle();
} else {
link.edit.mode.close();
};
data.save(); data.save();
}; };
}, false); }, false);

View File

@ -125,13 +125,23 @@ var link = (function() {
}; };
mod.edit = { mod.edit = {
toggle: function() { mode: {
if (state.get.current().link.edit) { open: function() {
mod.edit.close(); helper.setObject({
} else { object: state.get.current(),
mod.edit.open(); path: "edit",
}; newValue: true
});
}, },
close: function() {
helper.setObject({
object: state.get.current(),
path: "edit",
newValue: false
});
}
},
item: {
open: function() { open: function() {
helper.setObject({ helper.setObject({
object: state.get.current(), object: state.get.current(),
@ -145,15 +155,23 @@ var link = (function() {
path: "link.edit", path: "link.edit",
newValue: false newValue: false
}); });
}
}, },
check: function() { group: {
if (bookmarks.get().length <= 0) { open: function() {
helper.setObject({ helper.setObject({
object: state.get.current(), object: state.get.current(),
path: "link.edit", path: "group.edit",
newValue: true
});
},
close: function() {
helper.setObject({
object: state.get.current(),
path: "group.edit",
newValue: false newValue: false
}); });
}; }
} }
}; };
@ -281,7 +299,7 @@ var link = (function() {
render.focus.group.next.down(copyStagedGroup); render.focus.group.next.down(copyStagedGroup);
} }
}, },
link: { item: {
left: function(copyStagedLink) { left: function(copyStagedLink) {
stagedLink.link = JSON.parse(JSON.stringify(copyStagedLink.link)); stagedLink.link = JSON.parse(JSON.stringify(copyStagedLink.link));
stagedLink.position = JSON.parse(JSON.stringify(copyStagedLink.position)); stagedLink.position = JSON.parse(JSON.stringify(copyStagedLink.position));
@ -390,7 +408,7 @@ var link = (function() {
}, false); }, false);
itemGroupControlItemEdit.addEventListener("click", function() { itemGroupControlItemEdit.addEventListener("click", function() {
render.edit.group(copyStagedGroup); edit.group.open(copyStagedGroup);
}, false); }, false);
itemGroupControlItemRemove.addEventListener("click", function() { itemGroupControlItemRemove.addEventListener("click", function() {
@ -492,7 +510,7 @@ var link = (function() {
}, },
tabindex: function() { tabindex: function() {
var allGroupControlItem = helper.eA(".group-control-item"); var allGroupControlItem = helper.eA(".group-control-item");
if (state.get.current().link.edit) { if (state.get.current().edit) {
allGroupControlItem.forEach(function(arrayItem, index) { allGroupControlItem.forEach(function(arrayItem, index) {
arrayItem.tabIndex = 1; arrayItem.tabIndex = 1;
}); });
@ -629,15 +647,15 @@ var link = (function() {
var copyStagedLink = JSON.parse(JSON.stringify(stagedLink)); var copyStagedLink = JSON.parse(JSON.stringify(stagedLink));
linkLeft.addEventListener("click", function() { linkLeft.addEventListener("click", function() {
render.move.link.left(copyStagedLink); render.move.item.left(copyStagedLink);
}, false); }, false);
linkRight.addEventListener("click", function() { linkRight.addEventListener("click", function() {
render.move.link.right(copyStagedLink); render.move.item.right(copyStagedLink);
}, false); }, false);
linkEdit.addEventListener("click", function() { linkEdit.addEventListener("click", function() {
render.edit.item(copyStagedLink); edit.item.open(copyStagedLink);
}, false); }, false);
linkRemove.addEventListener("click", function() { linkRemove.addEventListener("click", function() {
@ -1053,7 +1071,7 @@ var link = (function() {
}, },
tabindex: function() { tabindex: function() {
var allLinkControlItem = helper.eA(".link-control-item"); var allLinkControlItem = helper.eA(".link-control-item");
if (state.get.current().link.edit) { if (state.get.current().edit) {
allLinkControlItem.forEach(function(arrayItem, index) { allLinkControlItem.forEach(function(arrayItem, index) {
arrayItem.tabIndex = 1; arrayItem.tabIndex = 1;
}); });
@ -1361,13 +1379,12 @@ var link = (function() {
render.add = { render.add = {
item: { item: {
open: function() { open: function() {
mod.add.item.open();
stagedLink.init(); stagedLink.init();
var successAction = function() { var successAction = function() {
stagedLink.link.timeStamp = new Date().getTime(); stagedLink.link.timeStamp = new Date().getTime();
bookmarks.mod.add.link(JSON.parse(JSON.stringify(stagedLink))); bookmarks.mod.add.link(JSON.parse(JSON.stringify(stagedLink)));
add.item.close();
data.save(); data.save();
mod.add.item.close();
groupAndItems(); groupAndItems();
control.render.dependents(); control.render.dependents();
control.render.class(); control.render.class();
@ -1375,11 +1392,8 @@ var link = (function() {
pagelock.unlock(); pagelock.unlock();
}; };
var cancelAction = function() { var cancelAction = function() {
mod.add.item.close(); add.item.close();
stagedLink.reset();
autoSuggest.close();
shade.close(); shade.close();
pagelock.unlock();
}; };
modal.open({ modal.open({
heading: "Add a new Bookmark", heading: "Add a new Bookmark",
@ -1391,21 +1405,16 @@ var link = (function() {
}); });
shade.open({ shade.open({
action: function() { action: function() {
mod.add.item.close(); add.item.close();
stagedLink.reset();
autoSuggest.close();
modal.close();
pagelock.unlock();
} }
}); });
pagelock.lock(); pagelock.lock();
stagedLink.position.destination.item = helper.e(".link-form-position").selectedIndex; stagedLink.position.destination.item = helper.e(".link-form-position").selectedIndex;
}, },
close: function() { close: function() {
mod.add.item.close();
stagedLink.reset(); stagedLink.reset();
autoSuggest.close();
modal.close(); modal.close();
shade.close();
pagelock.unlock(); pagelock.unlock();
}, },
selectGroup: function(groupIndex) { selectGroup: function(groupIndex) {
@ -1421,22 +1430,20 @@ var link = (function() {
}, },
group: { group: {
open: function() { open: function() {
mod.add.group.open();
stagedGroup.init(); stagedGroup.init();
var successAction = function() { var successAction = function() {
bookmarks.mod.add.group(JSON.parse(JSON.stringify(stagedGroup))); bookmarks.mod.add.group(JSON.parse(JSON.stringify(stagedGroup)));
add.group.close();
data.save(); data.save();
mod.add.group.close();
groupAndItems(); groupAndItems();
control.render.dependents();
control.render.class();
shade.close(); shade.close();
pagelock.unlock(); pagelock.unlock();
}; };
var cancelAction = function() { var cancelAction = function() {
mod.add.group.close(); add.group.close();
stagedGroup.reset();
autoSuggest.close();
shade.close(); shade.close();
pagelock.unlock();
}; };
modal.open({ modal.open({
heading: "Add a new Group", heading: "Add a new Group",
@ -1450,28 +1457,24 @@ var link = (function() {
}); });
shade.open({ shade.open({
action: function() { action: function() {
mod.add.group.close(); add.group.close();
stagedGroup.reset();
autoSuggest.close();
modal.close();
pagelock.unlock();
} }
}); });
pagelock.lock(); pagelock.lock();
stagedGroup.position.destination = helper.e(".group-form-position").selectedIndex; stagedGroup.position.destination = helper.e(".group-form-position").selectedIndex;
}, },
close: function() { close: function() {
mod.add.group.close();
stagedGroup.reset(); stagedGroup.reset();
autoSuggest.close();
modal.close(); modal.close();
shade.close();
pagelock.unlock(); pagelock.unlock();
} }
} }
}; };
render.edit = { render.edit = {
item: function(copyStagedLink) { item: {
open: function(copyStagedLink) {
stagedLink.link = JSON.parse(JSON.stringify(copyStagedLink.link)); stagedLink.link = JSON.parse(JSON.stringify(copyStagedLink.link));
stagedLink.position = JSON.parse(JSON.stringify(copyStagedLink.position)); stagedLink.position = JSON.parse(JSON.stringify(copyStagedLink.position));
var form = render.item.form({ var form = render.item.form({
@ -1494,9 +1497,7 @@ var link = (function() {
pagelock.unlock(); pagelock.unlock();
}; };
var cancelAction = function() { var cancelAction = function() {
stagedLink.reset(); edit.item.close();
autoSuggest.close();
pagelock.unlock();
shade.close(); shade.close();
}; };
modal.open({ modal.open({
@ -1509,15 +1510,20 @@ var link = (function() {
}); });
shade.open({ shade.open({
action: function() { action: function() {
stagedLink.reset(); edit.item.close();
autoSuggest.close();
pagelock.unlock();
modal.close();
} }
}); });
pagelock.lock(); pagelock.lock();
}, },
group: function(copyStagedGroup) { close: function() {
stagedLink.reset();
autoSuggest.close();
modal.close();
pagelock.unlock();
}
},
group: {
open: function(copyStagedGroup) {
stagedGroup.group = JSON.parse(JSON.stringify(copyStagedGroup.group)); stagedGroup.group = JSON.parse(JSON.stringify(copyStagedGroup.group));
stagedGroup.position = JSON.parse(JSON.stringify(copyStagedGroup.position)); stagedGroup.position = JSON.parse(JSON.stringify(copyStagedGroup.position));
var form = render.group.form({ var form = render.group.form({
@ -1535,9 +1541,7 @@ var link = (function() {
pagelock.unlock(); pagelock.unlock();
}; };
var cancelAction = function() { var cancelAction = function() {
stagedGroup.reset(); edit.group.close();
autoSuggest.close();
pagelock.unlock();
shade.close(); shade.close();
}; };
modal.open({ modal.open({
@ -1550,13 +1554,17 @@ var link = (function() {
}); });
shade.open({ shade.open({
action: function() { action: function() {
stagedGroup.reset(); edit.group.close();
autoSuggest.close();
pagelock.unlock();
modal.close();
} }
}); });
pagelock.lock(); pagelock.lock();
},
close: function() {
stagedGroup.reset();
autoSuggest.close();
modal.close();
pagelock.unlock();
}
} }
}; };
@ -1573,13 +1581,12 @@ var link = (function() {
var successAction = function() { var successAction = function() {
var copyStagedLink = JSON.parse(JSON.stringify(stagedLink)); var copyStagedLink = JSON.parse(JSON.stringify(stagedLink));
bookmarks.remove.link(copyStagedLink); bookmarks.remove.link(copyStagedLink);
edit.mode.check();
data.save(); data.save();
mod.edit.check();
header.render.button.edit();
groupAndItems(); groupAndItems();
render.focus.item.previous.remove(copyStagedLink);
control.render.dependents(); control.render.dependents();
control.render.class(); control.render.class();
render.focus.item.previous.remove(copyStagedLink);
shade.close(); shade.close();
pagelock.unlock(); pagelock.unlock();
}; };
@ -1618,13 +1625,12 @@ var link = (function() {
var successAction = function() { var successAction = function() {
var copyStagedGroup = JSON.parse(JSON.stringify(stagedGroup)); var copyStagedGroup = JSON.parse(JSON.stringify(stagedGroup));
bookmarks.remove.group(copyStagedGroup); bookmarks.remove.group(copyStagedGroup);
edit.mode.check();
data.save(); data.save();
mod.edit.check();
header.render.button.edit();
groupAndItems(); groupAndItems();
render.focus.group.previous.remove(copyStagedGroup);
control.render.dependents(); control.render.dependents();
control.render.class(); control.render.class();
render.focus.group.previous.remove(copyStagedGroup);
shade.close(); shade.close();
pagelock.unlock(); pagelock.unlock();
}; };
@ -1656,9 +1662,11 @@ var link = (function() {
var add = { var add = {
item: { item: {
open: function() { open: function() {
mod.add.item.open();
render.add.item.open(); render.add.item.open();
}, },
close: function() { close: function() {
mod.add.item.close();
render.add.item.close(); render.add.item.close();
}, },
selectGroup: function(groupIndex) { selectGroup: function(groupIndex) {
@ -1667,35 +1675,61 @@ var link = (function() {
}, },
group: { group: {
open: function() { open: function() {
mod.add.group.open();
render.add.group.open(); render.add.group.open();
}, },
close: function() { close: function() {
mod.add.group.close();
render.add.group.close(); render.add.group.close();
} }
} }
}; };
var edit = { var edit = {
toggle: function() { mode: {
mod.edit.toggle();
render.group.tabindex();
render.item.tabindex();
control.render.update();
control.render.class();
},
open: function() { open: function() {
mod.edit.open(); mod.edit.mode.open();
render.group.tabindex();
render.item.tabindex();
control.render.update(); control.render.update();
control.render.class(); control.render.class();
}, },
close: function() { close: function() {
mod.edit.close(); mod.edit.mode.close();
render.group.tabindex();
render.item.tabindex();
control.render.update(); control.render.update();
control.render.class(); control.render.class();
},
check: function() {
if (bookmarks.get().length <= 0) {
edit.mode.close();
};
},
toggle: function() {
if (state.get.current().edit) {
edit.mode.close();
} else {
edit.mode.open();
};
render.item.tabindex();
}
},
item: {
open: function(copyStagedLink) {
mod.edit.item.open();
render.edit.item.open(copyStagedLink);
},
close: function() {
mod.edit.item.close();
render.edit.item.close();
}
},
group: {
open: function(copyStagedGroup) {
mod.edit.group.open();
render.edit.group.open(copyStagedGroup);
},
close: function() {
mod.edit.group.close();
render.edit.group.close();
}
} }
}; };

View File

@ -95,7 +95,10 @@ var menu = (function() {
render.tabindex.toggle(); render.tabindex.toggle();
shade.open({ shade.open({
action: function() { action: function() {
close(); mod.close();
render.close();
render.tabindex.toggle();
pagelock.unlock();
} }
}); });
pagelock.lock(); pagelock.lock();

View File

@ -75,6 +75,7 @@ var shade = (function() {
shade.remove(); shade.remove();
}; };
mod.close(); mod.close();
_previousShade = null;
}; };
shade.addEventListener("transitionend", function(event, elapsed) { shade.addEventListener("transitionend", function(event, elapsed) {
if (event.propertyName === "opacity" && getComputedStyle(this).opacity == 0) { if (event.propertyName === "opacity" && getComputedStyle(this).opacity == 0) {

View File

@ -195,7 +195,8 @@ var state = (function() {
}, },
border: 0, border: 0,
order: "headerbody", order: "headerbody",
add: false add: false,
edit: true
}, },
layout: { layout: {
alignment: "centercenter", alignment: "centercenter",
@ -246,6 +247,7 @@ var state = (function() {
accent: 0 accent: 0
} }
}, },
edit: false,
pagelock: false, pagelock: false,
shade: false, shade: false,
edge: false, edge: false,

View File

@ -685,6 +685,12 @@ var update = (function() {
"4.1.0": function(data) { "4.1.0": function(data) {
data.state.link.item.display.gutter = 2; data.state.link.item.display.gutter = 2;
return data; return data;
},
"4.2.0": function(data) {
data.state.edit = false;
data.state.link.edit = false;
data.state.group.edit = false;
return data;
} }
}; };

View File

@ -1,6 +1,6 @@
var version = (function() { var version = (function() {
var current = "4.1.3"; var current = "4.2.1";
var name = "Enchanting Aardvark"; var name = "Enchanting Aardvark";

View File

@ -2,7 +2,7 @@
"name": "nightTab", "name": "nightTab",
"short_name": "nightTab", "short_name": "nightTab",
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.", "description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
"version": "4.1.3", "version": "4.2.1",
"manifest_version": 2, "manifest_version": 2,
"chrome_url_overrides": { "chrome_url_overrides": {
"newtab": "index.html" "newtab": "index.html"