mirror of
https://github.com/zombieFox/nightTab.git
synced 2025-06-26 12:31:47 +02:00
[refactor] improve menu render
This commit is contained in:
parent
cffa73c1fa
commit
b23b7b22a6
@ -40,15 +40,19 @@
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-nav-area {
|
.menu-nav-area-tab {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-nav-area-grow {
|
.menu-nav-area-close {
|
||||||
flex-grow: 1;
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: flex-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-nav:not(:last-child) {
|
.menu-nav:not(:last-child) {
|
||||||
@ -85,31 +89,23 @@
|
|||||||
padding: 0 0 2em 2em;
|
padding: 0 0 2em 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-close {
|
|
||||||
background-color: transparent;
|
|
||||||
margin: 0;
|
|
||||||
padding-top: 0.75em;
|
|
||||||
padding-bottom: 0.75em;
|
|
||||||
border-radius: 0 var(--theme-radius) 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-nav-button {
|
.menu-nav-button {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
margin: 0;
|
|
||||||
padding: 1em;
|
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding-top: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
height: 3.25em;
|
||||||
|
line-height: 1;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-nav-button:first-child {
|
.menu-nav-area-tab .menu-nav-button:first-child {
|
||||||
border-radius: var(--theme-radius) 0 0 0;
|
border-radius: var(--theme-radius) 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-nav-button [class^="icon-"],
|
.menu-nav-area-close .menu-nav-button {
|
||||||
.menu-nav-button [class*=" icon-"] {
|
border-radius: 0 var(--theme-radius) 0 0;
|
||||||
line-height: 1;
|
|
||||||
padding-top: 1.5em;
|
|
||||||
padding-bottom: 1.5em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 550px) {
|
@media (min-width: 550px) {
|
||||||
@ -117,7 +113,7 @@
|
|||||||
width: 80vw;
|
width: 80vw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-nav-button {
|
.menu-nav-area-tab .menu-nav-button {
|
||||||
flex-basis: 33.3333333333%;
|
flex-basis: 33.3333333333%;
|
||||||
max-width: 33.3333333333%;
|
max-width: 33.3333333333%;
|
||||||
}
|
}
|
||||||
@ -160,7 +156,7 @@
|
|||||||
z-index: 3;
|
z-index: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-nav-button {
|
.menu-nav-area-tab .menu-nav-button {
|
||||||
flex-basis: 50%;
|
flex-basis: 50%;
|
||||||
max-width: 50%;
|
max-width: 50%;
|
||||||
}
|
}
|
||||||
@ -180,14 +176,14 @@
|
|||||||
grid-template-columns: 1fr 2fr;
|
grid-template-columns: 1fr 2fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-nav-button {
|
.menu-nav-area-tab .menu-nav-button {
|
||||||
flex-basis: 33.3333333333%;
|
flex-basis: 33.3333333333%;
|
||||||
max-width: 33.3333333333%;
|
max-width: 33.3333333333%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 1100px) {
|
@media (min-width: 1100px) {
|
||||||
.menu-nav-button {
|
.menu-nav-area-tab .menu-nav-button {
|
||||||
flex-basis: 0;
|
flex-basis: 0;
|
||||||
max-width: inherit;
|
max-width: inherit;
|
||||||
}
|
}
|
||||||
|
360
src/index.html
360
src/index.html
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,64 @@
|
|||||||
var control = (function() {
|
var control = (function() {
|
||||||
|
|
||||||
var _allControl = [{
|
var _allControl = [{
|
||||||
element: helper.e(".control-menu"),
|
element: helper.e(".control-menu-open"),
|
||||||
type: "button",
|
type: "button",
|
||||||
func: function() {
|
func: function() {
|
||||||
menu.toggle();
|
menu.mod.open();
|
||||||
|
menu.render.toggle();
|
||||||
|
menu.render.tabindex.toggle();
|
||||||
|
pagelock.render.toggle();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
element: helper.e(".control-menu-layout"),
|
||||||
|
type: "button",
|
||||||
|
func: function() {
|
||||||
|
menu.render.tab(this.element, helper.e(".menu-content-area-layout"));
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
element: helper.e(".control-menu-header"),
|
||||||
|
type: "button",
|
||||||
|
func: function() {
|
||||||
|
menu.render.tab(this.element, helper.e(".menu-content-area-header"));
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
element: helper.e(".control-menu-bookmarks"),
|
||||||
|
type: "button",
|
||||||
|
func: function() {
|
||||||
|
menu.render.tab(this.element, helper.e(".menu-content-area-bookmarks"));
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
element: helper.e(".control-menu-theme"),
|
||||||
|
type: "button",
|
||||||
|
func: function() {
|
||||||
|
menu.render.tab(this.element, helper.e(".menu-content-area-theme"));
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
element: helper.e(".control-menu-background"),
|
||||||
|
type: "button",
|
||||||
|
func: function() {
|
||||||
|
menu.render.tab(this.element, helper.e(".menu-content-area-background"));
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
element: helper.e(".control-menu-data"),
|
||||||
|
type: "button",
|
||||||
|
func: function() {
|
||||||
|
menu.render.tab(this.element, helper.e(".menu-content-area-data"));
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
element: helper.e(".control-menu-nightTab"),
|
||||||
|
type: "button",
|
||||||
|
func: function() {
|
||||||
|
menu.render.tab(this.element, helper.e(".menu-content-area-nightTab"));
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
element: helper.e(".control-menu-close"),
|
||||||
|
type: "button",
|
||||||
|
func: function() {
|
||||||
|
shade.destroy();
|
||||||
|
menu.mod.close();
|
||||||
|
menu.render.toggle();
|
||||||
|
menu.render.tabindex.toggle();
|
||||||
pagelock.render.toggle();
|
pagelock.render.toggle();
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
@ -1448,14 +1502,14 @@ var control = (function() {
|
|||||||
event: "input",
|
event: "input",
|
||||||
func: function() {
|
func: function() {
|
||||||
edge.render.box({
|
edge.render.box({
|
||||||
element: helper.e(".control-menu"),
|
element: helper.e(".control-menu-open"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
event: "mousedown",
|
event: "mousedown",
|
||||||
func: function() {
|
func: function() {
|
||||||
edge.render.box({
|
edge.render.box({
|
||||||
element: helper.e(".control-menu"),
|
element: helper.e(".control-menu-open"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
@ -1473,7 +1527,7 @@ var control = (function() {
|
|||||||
func: function() {
|
func: function() {
|
||||||
if (event.keyCode == 37 || event.keyCode == 38 || event.keyCode == 39 || event.keyCode == 40) {
|
if (event.keyCode == 37 || event.keyCode == 38 || event.keyCode == 39 || event.keyCode == 40) {
|
||||||
edge.render.box({
|
edge.render.box({
|
||||||
element: helper.e(".control-menu"),
|
element: helper.e(".control-menu-open"),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1493,7 +1547,7 @@ var control = (function() {
|
|||||||
event: "click",
|
event: "click",
|
||||||
func: function() {
|
func: function() {
|
||||||
edge.render.box({
|
edge.render.box({
|
||||||
element: helper.e(".control-menu"),
|
element: helper.e(".control-menu-open"),
|
||||||
delay: 500
|
delay: 500
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -137,13 +137,13 @@ var header = (function() {
|
|||||||
helper.removeClass(helper.getClosest(helper.e(".control-link-edit"), ".input-wrap"), "input-button-link");
|
helper.removeClass(helper.getClosest(helper.e(".control-link-edit"), ".input-wrap"), "input-button-link");
|
||||||
helper.removeClass(helper.getClosest(helper.e(".control-theme-accent-current"), ".input-wrap"), "input-button-link");
|
helper.removeClass(helper.getClosest(helper.e(".control-theme-accent-current"), ".input-wrap"), "input-button-link");
|
||||||
helper.removeClass(helper.e(".control-link-add"), "button-link");
|
helper.removeClass(helper.e(".control-link-add"), "button-link");
|
||||||
helper.removeClass(helper.e(".control-menu"), "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-link-edit"), ".input-wrap"), "input-button-link");
|
||||||
helper.addClass(helper.getClosest(helper.e(".control-theme-accent-current"), ".input-wrap"), "input-button-link");
|
helper.addClass(helper.getClosest(helper.e(".control-theme-accent-current"), ".input-wrap"), "input-button-link");
|
||||||
helper.addClass(helper.e(".control-link-add"), "button-link");
|
helper.addClass(helper.e(".control-link-add"), "button-link");
|
||||||
helper.addClass(helper.e(".control-menu"), "button-link");
|
helper.addClass(helper.e(".control-menu-open"), "button-link");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
action[state.get().header.button.style]();
|
action[state.get().header.button.style]();
|
||||||
|
117
src/js/menu.js
117
src/js/menu.js
@ -1,21 +1,43 @@
|
|||||||
var menu = (function() {
|
var menu = (function() {
|
||||||
|
|
||||||
var _bind = function() {
|
var mod = {};
|
||||||
var allMenuNavButton = helper.eA(".menu-nav-button");
|
|
||||||
var menuClose = helper.e(".menu-close");
|
mod.open = function() {
|
||||||
allMenuNavButton.forEach(function(arrayItem, index) {
|
helper.setObject({
|
||||||
arrayItem.addEventListener("click", function() {
|
object: state.get(),
|
||||||
_tab(this);
|
path: "menu",
|
||||||
}, false);
|
newValue: true
|
||||||
});
|
});
|
||||||
menuClose.addEventListener("click", function() {
|
|
||||||
close();
|
|
||||||
shade.destroy();
|
|
||||||
pagelock.render.toggle();
|
|
||||||
}, false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var _scrollToTop = function() {
|
mod.close = function() {
|
||||||
|
helper.setObject({
|
||||||
|
object: state.get(),
|
||||||
|
path: "menu",
|
||||||
|
newValue: false
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
mod.toggle = function() {
|
||||||
|
if (state.get().menu) {
|
||||||
|
helper.setObject({
|
||||||
|
object: state.get(),
|
||||||
|
path: "menu",
|
||||||
|
newValue: false
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
render.scrollToTop();
|
||||||
|
helper.setObject({
|
||||||
|
object: state.get(),
|
||||||
|
path: "menu",
|
||||||
|
newValue: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
var render = {};
|
||||||
|
|
||||||
|
render.scrollToTop = function() {
|
||||||
if (window.innerWidth < 550) {
|
if (window.innerWidth < 550) {
|
||||||
helper.e(".menu-area").scrollTop = 0;
|
helper.e(".menu-area").scrollTop = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -23,71 +45,30 @@ var menu = (function() {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var _tab = function(button) {
|
render.tab = function(menuNavButton, menuContentArea) {
|
||||||
var allMenuNavButton = helper.eA(".menu-nav-button");
|
var allMenuNavButton = helper.eA(".menu-nav-button");
|
||||||
var allMenuContentArea = helper.eA(".menu-content-area");
|
var allMenuContentArea = helper.eA(".menu-content-area");
|
||||||
var target = helper.e(button.dataset.target);
|
|
||||||
allMenuNavButton.forEach(function(arrayItem, index) {
|
allMenuNavButton.forEach(function(arrayItem, index) {
|
||||||
helper.removeClass(arrayItem, "active");
|
helper.removeClass(arrayItem, "active");
|
||||||
});
|
});
|
||||||
allMenuContentArea.forEach(function(arrayItem, index) {
|
allMenuContentArea.forEach(function(arrayItem, index) {
|
||||||
helper.addClass(arrayItem, "is-hidden");
|
helper.addClass(arrayItem, "is-hidden");
|
||||||
});
|
});
|
||||||
helper.addClass(button, "active");
|
helper.addClass(menuNavButton, "active");
|
||||||
helper.removeClass(target, "is-hidden");
|
helper.removeClass(menuContentArea, "is-hidden");
|
||||||
_scrollToTop();
|
render.scrollToTop();
|
||||||
};
|
};
|
||||||
|
|
||||||
var close = function() {
|
render.toggle = function() {
|
||||||
helper.setObject({
|
|
||||||
object: state.get(),
|
|
||||||
path: "menu",
|
|
||||||
newValue: false
|
|
||||||
});
|
|
||||||
render.menu();
|
|
||||||
render.tabindex();
|
|
||||||
};
|
|
||||||
|
|
||||||
var open = function() {
|
|
||||||
_scrollToTop();
|
|
||||||
helper.setObject({
|
|
||||||
object: state.get(),
|
|
||||||
path: "menu",
|
|
||||||
newValue: true
|
|
||||||
});
|
|
||||||
render.menu();
|
|
||||||
render.tabindex();
|
|
||||||
};
|
|
||||||
|
|
||||||
var toggle = function() {
|
|
||||||
if (state.get().menu) {
|
|
||||||
helper.setObject({
|
|
||||||
object: state.get(),
|
|
||||||
path: "menu",
|
|
||||||
newValue: false
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
_scrollToTop();
|
|
||||||
helper.setObject({
|
|
||||||
object: state.get(),
|
|
||||||
path: "menu",
|
|
||||||
newValue: true
|
|
||||||
});
|
|
||||||
};
|
|
||||||
render.menu();
|
|
||||||
render.tabindex();
|
|
||||||
};
|
|
||||||
|
|
||||||
var render = {};
|
|
||||||
|
|
||||||
render.menu = function() {
|
|
||||||
var html = helper.e("html");
|
var html = helper.e("html");
|
||||||
if (state.get().menu) {
|
if (state.get().menu) {
|
||||||
helper.addClass(html, "is-menu-open");
|
helper.addClass(html, "is-menu-open");
|
||||||
helper.e(".menu").focus();
|
helper.e(".menu").focus();
|
||||||
shade.render({
|
shade.render({
|
||||||
action: function() {
|
action: function() {
|
||||||
close();
|
mod.close();
|
||||||
|
render.toggle();
|
||||||
|
menu.render.tabindex.toggle();
|
||||||
pagelock.render.toggle();
|
pagelock.render.toggle();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -96,7 +77,8 @@ var menu = (function() {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
render.tabindex = function() {
|
render.tabindex = {
|
||||||
|
toggle: function() {
|
||||||
var menu = helper.e(".menu");
|
var menu = helper.e(".menu");
|
||||||
if (state.get().menu) {
|
if (state.get().menu) {
|
||||||
menu.tabIndex = 1;
|
menu.tabIndex = 1;
|
||||||
@ -109,18 +91,17 @@ var menu = (function() {
|
|||||||
arrayItem.tabIndex = -1;
|
arrayItem.tabIndex = -1;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var init = function() {
|
var init = function() {
|
||||||
_bind();
|
mod.close();
|
||||||
close();
|
render.toggle();
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
init: init,
|
init: init,
|
||||||
close: close,
|
mod: mod,
|
||||||
open: open,
|
|
||||||
toggle: toggle,
|
|
||||||
render: render
|
render: render
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
var version = (function() {
|
var version = (function() {
|
||||||
|
|
||||||
var current = "3.41.0";
|
var current = "3.42.0";
|
||||||
|
|
||||||
var compare = function(a, b) {
|
var compare = function(a, b) {
|
||||||
var pa = a.split(".");
|
var pa = a.split(".");
|
||||||
|
@ -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": "3.41.0",
|
"version": "3.42.0",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"chrome_url_overrides": {
|
"chrome_url_overrides": {
|
||||||
"newtab": "index.html"
|
"newtab": "index.html"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user