|
70 | 70 | return getSkinForState(getSkinModeState());
|
71 | 71 | }
|
72 | 72 |
|
73 |
| - function toggleSkin(event) { |
74 |
| - const currentSkinState = getSkinModeState(); |
75 |
| - if (currentSkinState == darkModeStateOff) { |
76 |
| - event.target.classList.remove('fa-toggle-on'); |
77 |
| - event.target.classList.add('fa-toggle-off'); |
78 |
| - } |
79 |
| - else { |
80 |
| - event.target.classList.remove('fa-toggle-off'); |
81 |
| - event.target.classList.add('fa-toggle-on'); |
82 |
| - } |
83 |
| - setSkinModeState(currentSkinState == darkModeStateOff ? darkModeStateOn : darkModeStateOff); |
84 |
| - event.currentTarget.blur(); |
85 |
| - } |
86 |
| - |
87 | 73 | function saveColorChanges() {
|
88 | 74 | const htmlStyle = window.getComputedStyle(document.documentElement);
|
89 | 75 | const backgroundColor = htmlStyle.backgroundColor;
|
90 | 76 | setCookie(selectedSkinBackgroundColorKey, backgroundColor);
|
91 | 77 | };
|
92 | 78 |
|
93 |
| - function toggleIcon(target, off) { |
94 |
| - if (off) { |
| 79 | + function setIcon(target, isOff) { |
| 80 | + if (isOff) { |
95 | 81 | target.classList.remove('fa-toggle-on');
|
96 | 82 | target.classList.add('fa-toggle-off');
|
97 | 83 | }
|
|
105 | 91 | var off = getSkinModeState() == darkModeStateOff;
|
106 | 92 |
|
107 | 93 | setSkinModeState(off ? darkModeStateOn : darkModeStateOff);
|
108 |
| - toggleIcon(event.target, off); |
| 94 | + setIcon(event.target, off == false); |
109 | 95 |
|
110 | 96 | event.currentTarget.blur();
|
111 | 97 | }
|
|
121 | 107 | // Why this is not working?!?!
|
122 | 108 | //document.body.style.removeProperty("backgroundColor");
|
123 | 109 | document.body.style.backgroundColor = "";
|
124 |
| - |
125 |
| - toggleIcon($('#skin-button').find('.masthead_button_icon')[0], getSkinModeState()); |
| 110 | + |
| 111 | + var currSkinModeState = getSkinModeState(); |
| 112 | + setIcon($('#skin-button').find('.masthead_button_icon')[0], currSkinModeState == darkModeStateOff); |
| 113 | + |
126 | 114 | $("#skin-button").on("click", toggleSkin);
|
127 | 115 |
|
128 | 116 | // TODO: See, setSkinModeState - stylesheet.onload
|
|
0 commit comments