mirror of
https://github.com/zombieFox/nightTab.git
synced 2025-02-26 07:01:06 +01:00
[refactor] theme module
This commit is contained in:
parent
218af1dbc3
commit
ee1f0d4508
@ -73,10 +73,7 @@ var control = (function() {
|
|||||||
path: "theme.accent.current",
|
path: "theme.accent.current",
|
||||||
type: "color",
|
type: "color",
|
||||||
func: function() {
|
func: function() {
|
||||||
theme.render.accent.color();
|
theme.accent();
|
||||||
link.render.clear();
|
|
||||||
link.render.item.all();
|
|
||||||
sortable(".link-area");
|
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
element: helper.e(".control-layout-width"),
|
element: helper.e(".control-layout-width"),
|
||||||
|
@ -55,7 +55,6 @@ var keyboard = (function() {
|
|||||||
// ctrl+alt+d
|
// ctrl+alt+d
|
||||||
if (event.ctrlKey && event.altKey && event.keyCode == 68) {
|
if (event.ctrlKey && event.altKey && event.keyCode == 68) {
|
||||||
theme.toggle();
|
theme.toggle();
|
||||||
theme.render.theme();
|
|
||||||
control.update();
|
control.update();
|
||||||
data.save();
|
data.save();
|
||||||
};
|
};
|
||||||
|
@ -1,23 +1,29 @@
|
|||||||
var theme = (function() {
|
var theme = (function() {
|
||||||
|
|
||||||
var toggle = function() {
|
var mod = {};
|
||||||
var style = {
|
|
||||||
dark: function() {
|
mod.theme = {
|
||||||
helper.setObject({
|
|
||||||
object: state.get(),
|
|
||||||
path: "theme.style",
|
|
||||||
newValue: "light"
|
|
||||||
})
|
|
||||||
},
|
|
||||||
light: function() {
|
light: function() {
|
||||||
|
helper.setObject({
|
||||||
|
object: state.get(),
|
||||||
|
path: "theme.style",
|
||||||
|
newValue: "light"
|
||||||
|
});
|
||||||
|
},
|
||||||
|
dark: function() {
|
||||||
helper.setObject({
|
helper.setObject({
|
||||||
object: state.get(),
|
object: state.get(),
|
||||||
path: "theme.style",
|
path: "theme.style",
|
||||||
newValue: "dark"
|
newValue: "dark"
|
||||||
})
|
});
|
||||||
}
|
},
|
||||||
|
toggle: function() {
|
||||||
|
if (state.get().theme.style == "dark") {
|
||||||
|
mod.theme.light();
|
||||||
|
} else if (state.get().theme.style == "light") {
|
||||||
|
mod.theme.dark();
|
||||||
};
|
};
|
||||||
style[state.get().theme.style]();
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var render = {};
|
var render = {};
|
||||||
@ -98,6 +104,18 @@ var theme = (function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var toggle = function() {
|
||||||
|
mod.theme.toggle();
|
||||||
|
render.theme();
|
||||||
|
};
|
||||||
|
|
||||||
|
var accent = function() {
|
||||||
|
theme.render.accent.color();
|
||||||
|
link.render.clear();
|
||||||
|
link.render.item.all();
|
||||||
|
sortable(".link-area");
|
||||||
|
};
|
||||||
|
|
||||||
var init = function() {
|
var init = function() {
|
||||||
render.theme();
|
render.theme();
|
||||||
render.accent.random();
|
render.accent.random();
|
||||||
@ -107,9 +125,10 @@ var theme = (function() {
|
|||||||
|
|
||||||
// exposed methods
|
// exposed methods
|
||||||
return {
|
return {
|
||||||
|
init: init,
|
||||||
render: render,
|
render: render,
|
||||||
toggle: toggle,
|
toggle: toggle,
|
||||||
init: init
|
accent: accent
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -610,7 +610,7 @@ var update = (function() {
|
|||||||
// loop over all updates in _update object
|
// loop over all updates in _update object
|
||||||
for (var key in _update) {
|
for (var key in _update) {
|
||||||
if (version.compare(data.version, key) == -1) {
|
if (version.compare(data.version, key) == -1) {
|
||||||
console.log("\t= running update", key);
|
console.log("\t > running update", key);
|
||||||
data = _update[key](data);
|
data = _update[key](data);
|
||||||
data.version = key;
|
data.version = key;
|
||||||
};
|
};
|
||||||
@ -618,7 +618,7 @@ var update = (function() {
|
|||||||
|
|
||||||
// if no update is needed version bump
|
// if no update is needed version bump
|
||||||
if (version.compare(data.version, version.get()) == -1) {
|
if (version.compare(data.version, version.get()) == -1) {
|
||||||
console.log("\t= nothing to update, version bump to", version.get());
|
console.log("\t > nothing to update, version bump to", version.get());
|
||||||
data.version = version.get();
|
data.version = version.get();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
var version = (function() {
|
var version = (function() {
|
||||||
|
|
||||||
var current = "3.52.0";
|
var current = "3.53.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.52.0",
|
"version": "3.53.0",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"chrome_url_overrides": {
|
"chrome_url_overrides": {
|
||||||
"newtab": "index.html"
|
"newtab": "index.html"
|
||||||
|
Loading…
Reference in New Issue
Block a user