2018-12-26 07:45:53 +00:00
|
|
|
var theme = (function() {
|
|
|
|
|
2018-12-28 07:04:22 +00:00
|
|
|
var state = {
|
2018-12-26 07:45:53 +00:00
|
|
|
r: 255,
|
|
|
|
g: 170,
|
|
|
|
b: 51,
|
|
|
|
};
|
|
|
|
|
|
|
|
var get = function() {
|
2018-12-28 07:04:22 +00:00
|
|
|
return state;
|
2018-12-26 07:45:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var bind = function() {
|
|
|
|
var themeAccent = helper.e(".theme-input");
|
|
|
|
themeAccent.addEventListener("change", function() {
|
|
|
|
_updateAcent(this);
|
|
|
|
render();
|
|
|
|
data.save();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var _updateAcent = function(input) {
|
2018-12-28 07:04:22 +00:00
|
|
|
state = helper.hexToRgb(input.value);
|
2018-12-26 07:45:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var _updateInput = function() {
|
|
|
|
var themeAccent = helper.e(".theme-input");
|
2018-12-28 07:04:22 +00:00
|
|
|
themeAccent.value = helper.rgbToHex(state);
|
2018-12-26 07:45:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var render = function(input) {
|
|
|
|
var html = helper.e("html");
|
2018-12-28 07:04:22 +00:00
|
|
|
html.style.setProperty("--accent", state.r + ", " + state.g + ", " + state.b);
|
2018-12-26 07:45:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var restore = function(object) {
|
2018-12-26 23:46:53 +00:00
|
|
|
if (object) {
|
2018-12-28 07:04:22 +00:00
|
|
|
state = object;
|
2018-12-26 23:46:53 +00:00
|
|
|
_updateInput();
|
|
|
|
render();
|
|
|
|
};
|
2018-12-26 07:45:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var init = function() {
|
|
|
|
bind();
|
|
|
|
};
|
|
|
|
|
|
|
|
// exposed methods
|
|
|
|
return {
|
|
|
|
init: init,
|
|
|
|
get: get,
|
|
|
|
restore: restore,
|
|
|
|
render: render
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|