Skip to content

Commit ee1f0d4

Browse files
committed
[refactor] theme module
1 parent 218af1d commit ee1f0d4

File tree

6 files changed

+43
-28
lines changed

6 files changed

+43
-28
lines changed

‎src/js/control.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ var control = (function(){
7373
path: "theme.accent.current",
7474
type: "color",
7575
func: function(){
76-
theme.render.accent.color();
77-
link.render.clear();
78-
link.render.item.all();
79-
sortable(".link-area");
76+
theme.accent();
8077
}
8178
},{
8279
element: helper.e(".control-layout-width"),

‎src/js/keyboard.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ var keyboard = (function(){
5555
// ctrl+alt+d
5656
if(event.ctrlKey&&event.altKey&&event.keyCode==68){
5757
theme.toggle();
58-
theme.render.theme();
5958
control.update();
6059
data.save();
6160
};

‎src/js/theme.js‎

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
vartheme=(function(){
22

3-
vartoggle=function(){
4-
varstyle={
5-
dark: function(){
6-
helper.setObject({
7-
object: state.get(),
8-
path: "theme.style",
9-
newValue: "light"
10-
})
11-
},
12-
light: function(){
13-
helper.setObject({
14-
object: state.get(),
15-
path: "theme.style",
16-
newValue: "dark"
17-
})
18-
}
19-
};
20-
style[state.get().theme.style]();
3+
varmod={};
4+
5+
mod.theme={
6+
light: function(){
7+
helper.setObject({
8+
object: state.get(),
9+
path: "theme.style",
10+
newValue: "light"
11+
});
12+
},
13+
dark: function(){
14+
helper.setObject({
15+
object: state.get(),
16+
path: "theme.style",
17+
newValue: "dark"
18+
});
19+
},
20+
toggle: function(){
21+
if(state.get().theme.style=="dark"){
22+
mod.theme.light();
23+
}elseif(state.get().theme.style=="light"){
24+
mod.theme.dark();
25+
};
26+
}
2127
};
2228

2329
varrender={};
@@ -98,6 +104,18 @@ var theme = (function(){
98104
}
99105
};
100106

107+
vartoggle=function(){
108+
mod.theme.toggle();
109+
render.theme();
110+
};
111+
112+
varaccent=function(){
113+
theme.render.accent.color();
114+
link.render.clear();
115+
link.render.item.all();
116+
sortable(".link-area");
117+
};
118+
101119
varinit=function(){
102120
render.theme();
103121
render.accent.random();
@@ -107,9 +125,10 @@ var theme = (function(){
107125

108126
// exposed methods
109127
return{
128+
init: init,
110129
render: render,
111130
toggle: toggle,
112-
init: init
131+
accent: accent
113132
};
114133

115134
})();

‎src/js/update.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,15 +610,15 @@ var update = (function(){
610610
// loop over all updates in _update object
611611
for(varkeyin_update){
612612
if(version.compare(data.version,key)==-1){
613-
console.log("\t= running update",key);
613+
console.log("\t > running update",key);
614614
data=_update[key](data);
615615
data.version=key;
616616
};
617617
};
618618

619619
// if no update is needed version bump
620620
if(version.compare(data.version,version.get())==-1){
621-
console.log("\t= nothing to update, version bump to",version.get());
621+
console.log("\t > nothing to update, version bump to",version.get());
622622
data.version=version.get();
623623
};
624624

‎src/js/version.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
varversion=(function(){
22

3-
varcurrent="3.52.0";
3+
varcurrent="3.53.0";
44

55
varcompare=function(a,b){
66
varpa=a.split(".");

‎src/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nightTab",
33
"short_name": "nightTab",
44
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
5-
"version": "3.52.0",
5+
"version": "3.53.0",
66
"manifest_version": 2,
77
"chrome_url_overrides":{
88
"newtab": "index.html"

0 commit comments

Comments
(0)