@@ -33,6 +33,39 @@ var theme = (function(){
3333
3434var mod = { } ;
3535
36+ mod . apply = function ( data ) {
37+ helper . setObject ( {
38+ object : state . get . current ( ) ,
39+ path : "theme.font" ,
40+ newValue : data . font
41+ } ) ;
42+ helper . setObject ( {
43+ object : state . get . current ( ) ,
44+ path : "theme.color" ,
45+ newValue : data . color
46+ } ) ;
47+ helper . setObject ( {
48+ object : state . get . current ( ) ,
49+ path : "theme.accent.current" ,
50+ newValue : data . accent
51+ } ) ;
52+ helper . setObject ( {
53+ object : state . get . current ( ) ,
54+ path : "theme.radius" ,
55+ newValue : data . radius
56+ } ) ;
57+ helper . setObject ( {
58+ object : state . get . current ( ) ,
59+ path : "theme.style" ,
60+ newValue : data . style
61+ } ) ;
62+ helper . setObject ( {
63+ object : state . get . current ( ) ,
64+ path : "theme.shadow" ,
65+ newValue : data . shadow
66+ } ) ;
67+ } ;
68+
3669mod . style = {
3770light : function ( ) {
3871helper . setObject ( {
@@ -136,38 +169,6 @@ var theme = (function(){
136169} ;
137170
138171mod . preset = {
139- set : function ( themePreset ) {
140- helper . setObject ( {
141- object : state . get . current ( ) ,
142- path : "theme.font" ,
143- newValue : themePreset . font
144- } ) ;
145- helper . setObject ( {
146- object : state . get . current ( ) ,
147- path : "theme.color" ,
148- newValue : themePreset . color
149- } ) ;
150- helper . setObject ( {
151- object : state . get . current ( ) ,
152- path : "theme.accent.current" ,
153- newValue : themePreset . accent
154- } ) ;
155- helper . setObject ( {
156- object : state . get . current ( ) ,
157- path : "theme.radius" ,
158- newValue : themePreset . radius
159- } ) ;
160- helper . setObject ( {
161- object : state . get . current ( ) ,
162- path : "theme.style" ,
163- newValue : themePreset . style
164- } ) ;
165- helper . setObject ( {
166- object : state . get . current ( ) ,
167- path : "theme.shadow" ,
168- newValue : themePreset . shadow
169- } ) ;
170- } ,
171172get : function ( index ) {
172173return JSON . parse ( JSON . stringify ( mod . preset . all [ index ] ) ) ;
173174} ,
@@ -1087,38 +1088,6 @@ var theme = (function(){
10871088} ;
10881089
10891090mod . custom = {
1090- set : function ( themeCustom ) {
1091- helper . setObject ( {
1092- object : state . get . current ( ) ,
1093- path : "theme.font" ,
1094- newValue : themeCustom . font
1095- } ) ;
1096- helper . setObject ( {
1097- object : state . get . current ( ) ,
1098- path : "theme.color" ,
1099- newValue : themeCustom . color
1100- } ) ;
1101- helper . setObject ( {
1102- object : state . get . current ( ) ,
1103- path : "theme.accent.current" ,
1104- newValue : themeCustom . accent
1105- } ) ;
1106- helper . setObject ( {
1107- object : state . get . current ( ) ,
1108- path : "theme.radius" ,
1109- newValue : themeCustom . radius
1110- } ) ;
1111- helper . setObject ( {
1112- object : state . get . current ( ) ,
1113- path : "theme.style" ,
1114- newValue : themeCustom . style
1115- } ) ;
1116- helper . setObject ( {
1117- object : state . get . current ( ) ,
1118- path : "theme.shadow" ,
1119- newValue : themeCustom . shadow
1120- } ) ;
1121- } ,
11221091get : function ( index ) {
11231092return JSON . parse ( JSON . stringify ( state . get . current ( ) . theme . custom [ index ] ) ) ;
11241093} ,
@@ -1405,7 +1374,7 @@ var theme = (function(){
14051374formInline . appendChild ( themePresetItem ) ;
14061375
14071376themePresetButton . addEventListener ( "click" , function ( ) {
1408- mod . preset . set ( mod . preset . get ( index ) ) ;
1377+ mod . apply ( mod . preset . get ( index ) ) ;
14091378data . save ( ) ;
14101379render . font . display . name ( ) ;
14111380render . font . display . weight ( ) ;
@@ -1492,7 +1461,7 @@ var theme = (function(){
14921461var copyStagedThemeCustom = JSON . parse ( JSON . stringify ( stagedThemeCustom ) ) ;
14931462
14941463themeCustomButton . addEventListener ( "click" , function ( ) {
1495- mod . custom . set ( mod . custom . get ( index ) ) ;
1464+ mod . apply ( mod . custom . get ( index ) ) ;
14961465data . save ( ) ;
14971466render . font . display . name ( ) ;
14981467render . font . display . weight ( ) ;
@@ -1686,10 +1655,6 @@ var theme = (function(){
16861655}
16871656}
16881657
1689- var preset = function ( name ) {
1690- mod . preset . set ( name ) ;
1691- } ;
1692-
16931658var custom = {
16941659add : function ( ) {
16951660render . custom . add ( ) ;
@@ -1725,7 +1690,6 @@ var theme = (function(){
17251690render : render ,
17261691style : style ,
17271692accent : accent ,
1728- preset : preset ,
17291693custom : custom
17301694} ;
17311695
0 commit comments