[refactor] theme module

This commit is contained in:
Kuldeep M 2019-07-19 00:16:19 +01:00
parent 218af1dbc3
commit ee1f0d4508
6 changed files with 43 additions and 28 deletions

View File

@ -73,10 +73,7 @@ var control = (function() {
path: "theme.accent.current",
type: "color",
func: function() {
theme.render.accent.color();
link.render.clear();
link.render.item.all();
sortable(".link-area");
theme.accent();
}
}, {
element: helper.e(".control-layout-width"),

View File

@ -55,7 +55,6 @@ var keyboard = (function() {
// ctrl+alt+d
if (event.ctrlKey && event.altKey && event.keyCode == 68) {
theme.toggle();
theme.render.theme();
control.update();
data.save();
};

View File

@ -1,23 +1,29 @@
var theme = (function() {
var toggle = function() {
var style = {
dark: function() {
helper.setObject({
object: state.get(),
path: "theme.style",
newValue: "light"
})
},
var mod = {};
mod.theme = {
light: function() {
helper.setObject({
object: state.get(),
path: "theme.style",
newValue: "light"
});
},
dark: function() {
helper.setObject({
object: state.get(),
path: "theme.style",
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 = {};
@ -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() {
render.theme();
render.accent.random();
@ -107,9 +125,10 @@ var theme = (function() {
// exposed methods
return {
init: init,
render: render,
toggle: toggle,
init: init
accent: accent
};
})();

View File

@ -610,7 +610,7 @@ var update = (function() {
// loop over all updates in _update object
for (var key in _update) {
if (version.compare(data.version, key) == -1) {
console.log("\t= running update", key);
console.log("\t > running update", key);
data = _update[key](data);
data.version = key;
};
@ -618,7 +618,7 @@ var update = (function() {
// if no update is needed version bump
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();
};

View File

@ -1,6 +1,6 @@
var version = (function() {
var current = "3.52.0";
var current = "3.53.0";
var compare = function(a, b) {
var pa = a.split(".");

View File

@ -2,7 +2,7 @@
"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.",
"version": "3.52.0",
"version": "3.53.0",
"manifest_version": 2,
"chrome_url_overrides": {
"newtab": "index.html"