diff --git a/src/js/auto-suggest.js b/src/js/auto-suggest.js index afb9622f..791e5c64 100644 --- a/src/js/auto-suggest.js +++ b/src/js/auto-suggest.js @@ -8,7 +8,7 @@ var autoSuggest = (function() { mod.open = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "autoSuggest", newValue: true }); @@ -16,7 +16,7 @@ var autoSuggest = (function() { mod.close = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "autoSuggest", newValue: false }); diff --git a/src/js/background.js b/src/js/background.js index 171bdff0..0be9a054 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -15,12 +15,12 @@ var background = (function() { mod.clear = { file: function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "background.image.file.name", newValue: "" }); helper.setObject({ - object: state.get(), + object: state.get.current(), path: "background.image.file.data", newValue: "" }); @@ -30,12 +30,12 @@ var background = (function() { mod.image = { file: function(name, data) { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "background.image.file.name", newValue: name }); helper.setObject({ - object: state.get(), + object: state.get.current(), path: "background.image.file.data", newValue: data }); @@ -71,7 +71,7 @@ var background = (function() { render.color = { custom: function() { - helper.e("html").style.setProperty("--background-color-custom", state.get().background.color.custom.r + ", " + state.get().background.color.custom.g + ", " + state.get().background.color.custom.b); + helper.e("html").style.setProperty("--background-color-custom", state.get.current().background.color.custom.r + ", " + state.get.current().background.color.custom.g + ", " + state.get.current().background.color.custom.b); }, clearHTML: function() { helper.e("html").style.backgroundColor = ""; @@ -80,16 +80,16 @@ var background = (function() { render.image = function() { var html = helper.e("html"); - if (state.get().background.image.show) { - if (state.get().background.image.from == "file") { - html.style.setProperty("--background-image", "url(" + state.get().background.image.file.data + ")"); - } else if (state.get().background.image.from == "url") { - if (/\s+/g.test(state.get().background.image.url)) { - var allUrls = state.get().background.image.url.split(/\s+/); + if (state.get.current().background.image.show) { + if (state.get.current().background.image.from == "file") { + html.style.setProperty("--background-image", "url(" + state.get.current().background.image.file.data + ")"); + } else if (state.get.current().background.image.from == "url") { + if (/\s+/g.test(state.get.current().background.image.url)) { + var allUrls = state.get.current().background.image.url.split(/\s+/); var randomUrl = allUrls[Math.floor(Math.random() * allUrls.length)]; html.style.setProperty("--background-image", "url(" + randomUrl + ")"); } else { - html.style.setProperty("--background-image", "url(" + state.get().background.image.url + ")"); + html.style.setProperty("--background-image", "url(" + state.get.current().background.image.url + ")"); }; }; } else { @@ -99,27 +99,27 @@ var background = (function() { render.blur = function() { var html = helper.e("html"); - html.style.setProperty("--background-blur", state.get().background.image.blur + "px"); + html.style.setProperty("--background-blur", state.get.current().background.image.blur + "px"); }; render.grayscale = function() { var html = helper.e("html"); - html.style.setProperty("--background-grayscale", state.get().background.image.grayscale); + html.style.setProperty("--background-grayscale", state.get.current().background.image.grayscale); }; render.opacity = function() { var html = helper.e("html"); - html.style.setProperty("--background-opacity", state.get().background.image.opacity); + html.style.setProperty("--background-opacity", state.get.current().background.image.opacity); }; render.scale = function() { var html = helper.e("html"); - html.style.setProperty("--background-scale", state.get().background.image.scale); + html.style.setProperty("--background-scale", state.get.current().background.image.scale); }; render.accent = function() { var html = helper.e("html"); - html.style.setProperty("--background-accent", state.get().background.image.accent); + html.style.setProperty("--background-accent", state.get.current().background.image.accent); }; render.input = { @@ -127,16 +127,16 @@ var background = (function() { helper.e(".control-background-image-file").value = ""; }, picker: function() { - helper.e(".control-background-color-custom-current-picker").value = helper.rgbToHex(state.get().background.color.custom); + helper.e(".control-background-color-custom-current-picker").value = helper.rgbToHex(state.get.current().background.color.custom); }, hex: function() { - helper.e(".control-background-color-custom-current-hex").value = helper.rgbToHex(state.get().background.color.custom); + helper.e(".control-background-color-custom-current-hex").value = helper.rgbToHex(state.get.current().background.color.custom); } }; render.feedback = { init: function() { - if (state.get().background.image.file.name != "") { + if (state.get.current().background.image.file.name != "") { render.feedback.current(); } else { render.feedback.empty(); @@ -150,7 +150,7 @@ var background = (function() { current: function() { var controlBackgroundImageFileFeedback = helper.e(".control-background-image-file-feedback"); var para1 = helper.node("p:Image loaded.|class:muted small"); - var para2 = helper.node("p:" + state.get().background.image.file.name); + var para2 = helper.node("p:" + state.get.current().background.image.file.name); controlBackgroundImageFileFeedback.appendChild(para1); controlBackgroundImageFileFeedback.appendChild(para2); }, diff --git a/src/js/clock.js b/src/js/clock.js index cef4dc36..3c57a882 100644 --- a/src/js/clock.js +++ b/src/js/clock.js @@ -19,7 +19,7 @@ var clock = (function() { }; render.all = function() { - if (state.get().header.clock.seconds.show || state.get().header.clock.minutes.show || state.get().header.clock.hours.show) { + if (state.get.current().header.clock.seconds.show || state.get.current().header.clock.minutes.show || state.get.current().header.clock.hours.show) { var timeDateNow = moment(); var timeStrings = { hours: null, @@ -31,20 +31,20 @@ var clock = (function() { hours: { word: function() { timeStrings.hours = timeDateNow.hours(); - if (!state.get().header.clock.hour24.show && timeDateNow.hours() > 12) { + if (!state.get.current().header.clock.hour24.show && timeDateNow.hours() > 12) { timeStrings.hours = timeStrings.hours - 12; }; timeStrings.hours = helper.toWords(timeStrings.hours); - if (state.get().header.clock.hour24.show && timeDateNow.hours() > 0 && timeDateNow.hours() < 10) { + if (state.get.current().header.clock.hour24.show && timeDateNow.hours() > 0 && timeDateNow.hours() < 10) { timeStrings.hours = "Zero " + timeStrings.hours; }; }, number: function() { timeStrings.hours = timeDateNow.hours(); - if (!state.get().header.clock.hour24.show && timeDateNow.hours() > 12) { + if (!state.get.current().header.clock.hour24.show && timeDateNow.hours() > 12) { timeStrings.hours = timeStrings.hours - 12; }; - if (state.get().header.clock.hour24.show && timeDateNow.hours() < 10) { + if (state.get.current().header.clock.hour24.show && timeDateNow.hours() < 10) { timeStrings.hours = "0" + timeStrings.hours; }; } @@ -81,28 +81,28 @@ var clock = (function() { timeStrings.meridiem = timeDateNow.format("A"); } }; - action.hours[state.get().header.clock.hours.display](); - action.minutes[state.get().header.clock.minutes.display](); - action.seconds[state.get().header.clock.seconds.display](); + action.hours[state.get.current().header.clock.hours.display](); + action.minutes[state.get.current().header.clock.minutes.display](); + action.seconds[state.get.current().header.clock.seconds.display](); action.meridiem(); var clock = helper.e(".clock"); var elementHours = helper.node("span:" + timeStrings.hours + "|class:clock-item clock-hours"); var elementMinutes = helper.node("span:" + timeStrings.minutes + "|class:clock-item clock-minutes"); var elementSeconds = helper.node("span:" + timeStrings.seconds + "|class:clock-item clock-seconds"); var elementMeridiem = helper.node("span:" + timeStrings.meridiem + "|class:clock-item clock-meridiem"); - if (state.get().header.clock.hours.show) { + if (state.get.current().header.clock.hours.show) { clock.appendChild(elementHours); }; - if (state.get().header.clock.minutes.show) { + if (state.get.current().header.clock.minutes.show) { clock.appendChild(elementMinutes); }; - if (state.get().header.clock.seconds.show) { + if (state.get.current().header.clock.seconds.show) { clock.appendChild(elementSeconds); }; - if (!state.get().header.clock.hour24.show && state.get().header.clock.meridiem.show) { + if (!state.get.current().header.clock.hour24.show && state.get.current().header.clock.meridiem.show) { clock.appendChild(elementMeridiem); }; - if (state.get().header.clock.separator.show) { + if (state.get.current().header.clock.separator.show) { var separatorCharacter = ":"; var parts = clock.querySelectorAll("span"); if (parts.length > 1) { diff --git a/src/js/control.js b/src/js/control.js index 7b0c0551..8cac1c6c 100644 --- a/src/js/control.js +++ b/src/js/control.js @@ -152,7 +152,10 @@ var control = (function() { } }], func: function() { - mod.setValue("layout.width", 80); + mod.setValue("layout.width", helper.getObject({ + object: state.mod.default, + path: "layout.width" + })); layout.render.width(); render.update(); } @@ -298,7 +301,10 @@ var control = (function() { } }], func: function() { - mod.setValue("layout.padding", 4); + mod.setValue("layout.padding", helper.getObject({ + object: state.mod.default, + path: "layout.padding" + })); layout.render.padding(); render.update(); } @@ -363,7 +369,10 @@ var control = (function() { } }], func: function() { - mod.setValue("layout.gutter", 2); + mod.setValue("layout.gutter", helper.getObject({ + object: state.mod.default, + path: "layout.gutter" + })); layout.render.gutter(); render.update(); } @@ -429,7 +438,10 @@ var control = (function() { } }], func: function() { - mod.setValue("layout.size", 1); + mod.setValue("layout.size", helper.getObject({ + object: state.mod.default, + path: "layout.size" + })); layout.render.size(); render.update(); } @@ -515,7 +527,7 @@ var control = (function() { }], func: function() { mod.setValue("header.area.width", helper.getObject({ - object: state.get(), + object: state.get.current(), path: "link.area.width" })); header.render.area.width(); @@ -694,7 +706,10 @@ var control = (function() { } }], func: function() { - mod.setValue("header.greeting.size", 1); + mod.setValue("header.greeting.size", helper.getObject({ + object: state.mod.default, + path: "header.greeting.size" + })); header.render.greeting.size(); render.update(); } @@ -786,7 +801,10 @@ var control = (function() { } }], func: function() { - mod.setValue("header.transitional.size", 1); + mod.setValue("header.transitional.size", helper.getObject({ + object: state.mod.default, + path: "header.transitional.size" + })); header.render.transitional.size(); render.update(); } @@ -1002,7 +1020,10 @@ var control = (function() { } }], func: function() { - mod.setValue("header.clock.size", 1); + mod.setValue("header.clock.size", helper.getObject({ + object: state.mod.default, + path: "header.clock.size" + })); header.render.clock.size(); render.update(); } @@ -1356,7 +1377,10 @@ var control = (function() { } }], func: function() { - mod.setValue("header.date.size", 1); + mod.setValue("header.date.size", helper.getObject({ + object: state.mod.default, + path: "header.date.size" + })); header.render.date.size(); render.update(); } @@ -1602,7 +1626,10 @@ var control = (function() { } }], func: function() { - mod.setValue("header.search.size", 1); + mod.setValue("header.search.size", helper.getObject({ + object: state.mod.default, + path: "header.search.size" + })); header.render.search.size(); render.update(); } @@ -1698,7 +1725,10 @@ var control = (function() { } }], func: function() { - mod.setValue("header.button.size", 1); + mod.setValue("header.button.size", helper.getObject({ + object: state.mod.default, + path: "header.button.size" + })); header.render.button.size(); render.update(); } @@ -1814,7 +1844,10 @@ var control = (function() { } }], func: function() { - mod.setValue("group.name.size", 1); + mod.setValue("group.name.size", helper.getObject({ + object: state.mod.default, + path: "group.name.size" + })); link.render.group.size(); render.update(); } @@ -1964,7 +1997,7 @@ var control = (function() { }], func: function() { mod.setValue("link.area.width", helper.getObject({ - object: state.get(), + object: state.get.current(), path: "header.area.width" })); link.render.area.width(); @@ -2089,7 +2122,10 @@ var control = (function() { } }], func: function() { - mod.setValue("link.item.size", 1); + mod.setValue("link.item.size", helper.getObject({ + object: state.mod.default, + path: "link.item.size" + })); link.render.item.size(); render.update(); } @@ -2178,7 +2214,10 @@ var control = (function() { element: helper.e(".control-link-item-display-letcon-letter-size-default"), type: "button", func: function() { - mod.setValue("link.item.display.letcon.letter.size", 3); + mod.setValue("link.item.display.letcon.letter.size", helper.getObject({ + object: state.mod.default, + path: "link.item.display.letcon.letter.size" + })); link.render.item.display.letter(); render.update(); } @@ -2196,7 +2235,10 @@ var control = (function() { element: helper.e(".control-link-item-display-letcon-icon-size-default"), type: "button", func: function() { - mod.setValue("link.item.display.letcon.icon.size", 3); + mod.setValue("link.item.display.letcon.icon.size", helper.getObject({ + object: state.mod.default, + path: "link.item.display.letcon.icon.size" + })); link.render.item.display.icon(); render.update(); } @@ -2222,7 +2264,10 @@ var control = (function() { element: helper.e(".control-link-item-display-name-size-default"), type: "button", func: function() { - mod.setValue("link.item.display.name.size", 0.9); + mod.setValue("link.item.display.name.size", helper.getObject({ + object: state.mod.default, + path: "link.item.display.name.size" + })); link.render.item.name(); render.update(); } @@ -2239,7 +2284,10 @@ var control = (function() { element: helper.e(".control-link-item-display-rotate-default"), type: "button", func: function() { - mod.setValue("link.item.display.rotate", 0); + mod.setValue("link.item.display.rotate", helper.getObject({ + object: state.mod.default, + path: "link.item.display.rotate" + })); link.render.item.rotate(); render.update(); } @@ -2257,7 +2305,10 @@ var control = (function() { element: helper.e(".control-link-item-display-translate-x-default"), type: "button", func: function() { - mod.setValue("link.item.display.translate.x", 0); + mod.setValue("link.item.display.translate.x", helper.getObject({ + object: state.mod.default, + path: "link.item.display.translate.x" + })); link.render.item.translate.x(); render.update(); } @@ -2275,7 +2326,10 @@ var control = (function() { element: helper.e(".control-link-item-display-translate-y-default"), type: "button", func: function() { - mod.setValue("link.item.display.translate.y", 0); + mod.setValue("link.item.display.translate.y", helper.getObject({ + object: state.mod.default, + path: "link.item.display.translate.y" + })); link.render.item.translate.y(); render.update(); } @@ -2466,7 +2520,10 @@ var control = (function() { element: helper.e(".control-theme-radius-default"), type: "button", func: function() { - mod.setValue("theme.radius", 0.25); + mod.setValue("theme.radius", helper.getObject({ + object: state.mod.default, + path: "theme.radius" + })); theme.render.radius(); render.update(); } @@ -2678,7 +2735,7 @@ var control = (function() { mod.setValue = function(path, value) { helper.setObject({ - object: state.get(), + object: state.get.current(), path: path, newValue: value }); @@ -2742,12 +2799,12 @@ var control = (function() { }); }; helper.setObject({ - object: state.get(), + object: state.get.current(), path: object.path, newValue: newValue }); // console.log("state set", object.path, helper.getObject({ - // object: state.get(), + // object: state.get.current(), // path: object.path // })); }; @@ -2807,23 +2864,23 @@ var control = (function() { helper.removeClass(html, "is-header-area-alignment-left"); helper.removeClass(html, "is-header-area-alignment-center"); helper.removeClass(html, "is-header-area-alignment-right"); - helper.addClass(html, "is-header-area-alignment-" + state.get().header.area.alignment); + helper.addClass(html, "is-header-area-alignment-" + state.get.current().header.area.alignment); }; var _item = function() { helper.removeClass(html, "is-header-item-alignment-left"); helper.removeClass(html, "is-header-item-alignment-center"); helper.removeClass(html, "is-header-item-alignment-right"); - helper.addClass(html, "is-header-item-alignment-" + state.get().header.item.alignment); + helper.addClass(html, "is-header-item-alignment-" + state.get.current().header.item.alignment); }; var _clock = function() { - if (state.get().header.clock.seconds.show || state.get().header.clock.minutes.show || state.get().header.clock.hours.show) { + if (state.get.current().header.clock.seconds.show || state.get.current().header.clock.minutes.show || state.get.current().header.clock.hours.show) { helper.addClass(html, "is-header-clock-show"); } else { helper.removeClass(html, "is-header-clock-show"); }; }; var _date = function() { - if (state.get().header.date.date.show || state.get().header.date.day.show || state.get().header.date.month.show || state.get().header.date.year.show) { + if (state.get.current().header.date.date.show || state.get.current().header.date.day.show || state.get.current().header.date.month.show || state.get.current().header.date.year.show) { helper.addClass(html, "is-header-date-show"); } else { helper.removeClass(html, "is-header-date-show"); @@ -2836,35 +2893,35 @@ var control = (function() { helper.removeClass(html, "is-header-search-text-alignment-left"); helper.removeClass(html, "is-header-search-text-alignment-center"); helper.removeClass(html, "is-header-search-text-alignment-right"); - if (state.get().header.search.show) { + if (state.get.current().header.search.show) { helper.addClass(html, "is-header-search-show"); - helper.addClass(html, "is-header-search-style-" + state.get().header.search.style); - helper.addClass(html, "is-header-search-text-alignment-" + state.get().header.search.text.alignment); + helper.addClass(html, "is-header-search-style-" + state.get.current().header.search.style); + helper.addClass(html, "is-header-search-text-alignment-" + state.get.current().header.search.text.alignment); }; - helper.e(".control-header-search-engine-custom-name").value = state.get().header.search.engine.custom.name; - helper.e(".control-header-search-engine-custom-url").value = state.get().header.search.engine.custom.url; + helper.e(".control-header-search-engine-custom-name").value = state.get.current().header.search.engine.custom.name; + helper.e(".control-header-search-engine-custom-url").value = state.get.current().header.search.engine.custom.url; }; var _button = function() { - if (state.get().header.button.editAdd.show) { + if (state.get.current().header.button.editAdd.show) { helper.addClass(html, "is-header-button-editadd-show"); } else { helper.removeClass(html, "is-header-button-editadd-show"); }; - if (state.get().header.button.accent.show) { + if (state.get.current().header.button.accent.show) { helper.addClass(html, "is-header-button-accent-show"); } else { helper.removeClass(html, "is-header-button-accent-show"); }; }; var _greeting = function() { - if (state.get().header.greeting.show) { + if (state.get.current().header.greeting.show) { helper.addClass(html, "is-header-greeting-show"); } else { helper.removeClass(html, "is-header-greeting-show"); }; }; var _transitional = function() { - if (state.get().header.transitional.show && (state.get().header.date.date.show || state.get().header.date.day.show || state.get().header.date.month.show || state.get().header.date.year.show || state.get().header.clock.seconds.show || state.get().header.clock.minutes.show || state.get().header.clock.hours.show)) { + if (state.get.current().header.transitional.show && (state.get.current().header.date.date.show || state.get.current().header.date.day.show || state.get.current().header.date.month.show || state.get.current().header.date.year.show || state.get.current().header.clock.seconds.show || state.get.current().header.clock.minutes.show || state.get.current().header.clock.hours.show)) { helper.addClass(html, "is-header-transitional-show"); } else { helper.removeClass(html, "is-header-transitional-show"); @@ -2872,10 +2929,10 @@ var control = (function() { }; var _shade = function() { helper.removeClass(html, "is-header-shade-show"); - if (state.get().header.shade.show) { + if (state.get.current().header.shade.show) { helper.addClass(html, "is-header-shade-show"); }; - if (state.get().header.radius) { + if (state.get.current().header.radius) { helper.addClass(html, "is-header-radius"); } else { helper.removeClass(html, "is-header-radius"); @@ -2884,17 +2941,17 @@ var control = (function() { var _border = function() { helper.removeClass(html, "is-header-border-top"); helper.removeClass(html, "is-header-border-bottom"); - if (state.get().header.border.top > 0) { + if (state.get.current().header.border.top > 0) { helper.addClass(html, "is-header-border-top"); }; - if (state.get().header.border.bottom > 0) { + if (state.get.current().header.border.bottom > 0) { helper.addClass(html, "is-header-border-bottom"); }; }; var _position = function() { helper.removeClass(html, "is-header-position-sticky"); helper.removeClass(html, "is-header-position-inline"); - helper.addClass(html, "is-header-position-" + state.get().header.position); + helper.addClass(html, "is-header-position-" + state.get.current().header.position); }; _area(); _item(); @@ -2913,10 +2970,10 @@ var control = (function() { helper.removeClass(html, "is-group-area-alignment-left"); helper.removeClass(html, "is-group-area-alignment-center"); helper.removeClass(html, "is-group-area-alignment-right"); - helper.addClass(html, "is-group-area-alignment-" + state.get().group.area.alignment); + helper.addClass(html, "is-group-area-alignment-" + state.get.current().group.area.alignment); }; var _name = function() { - if (state.get().group.name.show) { + if (state.get.current().group.name.show) { helper.addClass(html, "is-group-name-show"); } else { helper.removeClass(html, "is-group-name-show"); @@ -2925,11 +2982,11 @@ var control = (function() { var _order = function() { helper.removeClass(html, "is-group-order-headerbody"); helper.removeClass(html, "is-group-order-bodyheader"); - helper.addClass(html, "is-group-order-" + state.get().group.order); + helper.addClass(html, "is-group-order-" + state.get.current().group.order); }; var _border = function() { helper.removeClass(html, "is-group-border"); - if (state.get().group.border > 0) { + if (state.get.current().group.border > 0) { helper.addClass(html, "is-group-border"); }; }; @@ -2968,42 +3025,42 @@ var control = (function() { helper.removeClass(html, "is-link-orientation-top"); helper.removeClass(html, "is-link-orientation-bottom"); helper.removeClass(html, "is-link-edit"); - if (state.get().link.show) { + if (state.get.current().link.show) { helper.addClass(html, "is-link-show"); - helper.addClass(html, "is-link-area-alignment-" + state.get().link.area.alignment); - helper.addClass(html, "is-link-item-display-direction-" + state.get().link.item.display.direction); - helper.addClass(html, "is-link-item-display-order-" + state.get().link.item.display.order); - helper.addClass(html, "is-link-display-alignment-" + state.get().link.item.display.alignment); - helper.addClass(html, "is-link-style-" + state.get().link.style); - helper.addClass(html, "is-link-orientation-" + state.get().link.orientation); - if (state.get().link.item.display.letcon.show) { + helper.addClass(html, "is-link-area-alignment-" + state.get.current().link.area.alignment); + helper.addClass(html, "is-link-item-display-direction-" + state.get.current().link.item.display.direction); + helper.addClass(html, "is-link-item-display-order-" + state.get.current().link.item.display.order); + helper.addClass(html, "is-link-display-alignment-" + state.get.current().link.item.display.alignment); + helper.addClass(html, "is-link-style-" + state.get.current().link.style); + helper.addClass(html, "is-link-orientation-" + state.get.current().link.orientation); + if (state.get.current().link.item.display.letcon.show) { helper.addClass(html, "is-link-item-display-letcon-show"); }; - if (state.get().link.item.display.name.show) { + if (state.get.current().link.item.display.name.show) { helper.addClass(html, "is-link-item-display-name-show"); }; - if (state.get().link.item.url.show) { + if (state.get.current().link.item.url.show) { helper.addClass(html, "is-link-item-url-show"); }; - if (state.get().link.item.line.show) { + if (state.get.current().link.item.line.show) { helper.addClass(html, "is-link-item-line-show"); }; - if (state.get().link.item.shadow.show) { + if (state.get.current().link.item.shadow.show) { helper.addClass(html, "is-link-item-shadow-show"); }; - if (state.get().link.item.hoverScale.show) { + if (state.get.current().link.item.hoverScale.show) { helper.addClass(html, "is-link-item-hoverscale-show"); }; - if (state.get().link.item.border > 0) { + if (state.get.current().link.item.border > 0) { helper.addClass(html, "is-link-item-border"); }; - if (state.get().link.edit) { + if (state.get.current().link.edit) { helper.addClass(html, "is-link-edit"); }; }; }; var _theme = function() { - if (state.get().theme.radius > 0) { + if (state.get.current().theme.radius > 0) { helper.addClass(html, "is-theme-radius"); } else { helper.removeClass(html, "is-theme-radius"); @@ -3022,17 +3079,17 @@ var control = (function() { helper.removeClass(html, "is-layout-alignment-bottomright"); helper.removeClass(html, "is-layout-order-headerlink"); helper.removeClass(html, "is-layout-order-linkheader"); - helper.addClass(html, "is-layout-alignment-" + state.get().layout.alignment); - helper.addClass(html, "is-layout-order-" + state.get().layout.order); - if (state.get().layout.scrollPastEnd) { + helper.addClass(html, "is-layout-alignment-" + state.get.current().layout.alignment); + helper.addClass(html, "is-layout-order-" + state.get.current().layout.order); + if (state.get.current().layout.scrollPastEnd) { helper.addClass(html, "is-layout-scrollpastend"); }; }; var _background = function() { helper.removeClass(html, "is-background-color-by-theme"); helper.removeClass(html, "is-background-color-by-custom"); - helper.addClass(html, "is-background-color-by-" + state.get().background.color.by); - if (state.get().background.image.show) { + helper.addClass(html, "is-background-color-by-" + state.get.current().background.color.by); + if (state.get.current().background.image.show) { helper.addClass(html, "is-background-image-show"); } else { helper.removeClass(html, "is-background-image-show"); @@ -3072,51 +3129,51 @@ var control = (function() { var _header = function() { var _clock = function() { var activeCount = 0; - var toCheck = [state.get().header.clock.seconds.show, state.get().header.clock.minutes.show, state.get().header.clock.hours.show]; + var toCheck = [state.get.current().header.clock.seconds.show, state.get.current().header.clock.minutes.show, state.get.current().header.clock.hours.show]; toCheck.forEach(function(arrayItem, index) { if (arrayItem == true) { activeCount++; }; }); - if (activeCount >= 2 && (state.get().header.clock.seconds.show || state.get().header.clock.minutes.show || state.get().header.clock.hours.show)) { + if (activeCount >= 2 && (state.get.current().header.clock.seconds.show || state.get.current().header.clock.minutes.show || state.get.current().header.clock.hours.show)) { _disable.input(".control-header-clock-separator-show", false); } else { _disable.input(".control-header-clock-separator-show", true); }; - if (state.get().header.clock.seconds.show || state.get().header.clock.minutes.show || state.get().header.clock.hours.show) { + if (state.get.current().header.clock.seconds.show || state.get.current().header.clock.minutes.show || state.get.current().header.clock.hours.show) { _disable.input(".control-header-clock-hour24-show", false); _disable.input(".control-header-clock-meridiem-show", false); } else { _disable.input(".control-header-clock-hour24-show", true); _disable.input(".control-header-clock-meridiem-show", true); }; - if ((state.get().header.clock.seconds.show || state.get().header.clock.minutes.show || state.get().header.clock.hours.show) && !state.get().header.clock.hour24.show) { + if ((state.get.current().header.clock.seconds.show || state.get.current().header.clock.minutes.show || state.get.current().header.clock.hours.show) && !state.get.current().header.clock.hour24.show) { _disable.input(".control-header-clock-meridiem-show", false); } else { _disable.input(".control-header-clock-meridiem-show", true); }; - if (state.get().header.clock.hours.show) { + if (state.get.current().header.clock.hours.show) { _disable.input(".control-header-clock-hours-display-number", false); _disable.input(".control-header-clock-hours-display-word", false); } else { _disable.input(".control-header-clock-hours-display-number", true); _disable.input(".control-header-clock-hours-display-word", true); }; - if (state.get().header.clock.minutes.show) { + if (state.get.current().header.clock.minutes.show) { _disable.input(".control-header-clock-minutes-display-number", false); _disable.input(".control-header-clock-minutes-display-word", false); } else { _disable.input(".control-header-clock-minutes-display-number", true); _disable.input(".control-header-clock-minutes-display-word", true); }; - if (state.get().header.clock.seconds.show) { + if (state.get.current().header.clock.seconds.show) { _disable.input(".control-header-clock-seconds-display-number", false); _disable.input(".control-header-clock-seconds-display-word", false); } else { _disable.input(".control-header-clock-seconds-display-number", true); _disable.input(".control-header-clock-seconds-display-word", true); }; - if (state.get().header.clock.seconds.show || state.get().header.clock.minutes.show || state.get().header.clock.hours.show) { + if (state.get.current().header.clock.seconds.show || state.get.current().header.clock.minutes.show || state.get.current().header.clock.hours.show) { _disable.element("[for=control-header-clock-size]", false); _disable.input(".control-header-clock-size", false); _disable.element(".control-header-clock-size-count", false); @@ -3130,18 +3187,18 @@ var control = (function() { }; var _date = function() { var activeCount = 0; - var toCheck = [state.get().header.date.day.show, state.get().header.date.date.show, state.get().header.date.month.show, state.get().header.date.year.show]; + var toCheck = [state.get.current().header.date.day.show, state.get.current().header.date.date.show, state.get.current().header.date.month.show, state.get.current().header.date.year.show]; toCheck.forEach(function(arrayItem, index) { if (arrayItem == true) { activeCount++; }; }); - if (activeCount >= 2 && (state.get().header.date.day.show || state.get().header.date.date.show || state.get().header.date.month.show || state.get().header.date.year.show)) { + if (activeCount >= 2 && (state.get.current().header.date.day.show || state.get.current().header.date.date.show || state.get.current().header.date.month.show || state.get.current().header.date.year.show)) { _disable.input(".control-header-date-separator-show", false); } else { _disable.input(".control-header-date-separator-show", true); }; - if (state.get().header.date.date.show && state.get().header.date.month.show) { + if (state.get.current().header.date.date.show && state.get.current().header.date.month.show) { _disable.element(".control-header-date-format-label", false); _disable.input(".control-header-date-format-datemonth", false); _disable.input(".control-header-date-format-monthdate", false); @@ -3150,14 +3207,14 @@ var control = (function() { _disable.input(".control-header-date-format-datemonth", true); _disable.input(".control-header-date-format-monthdate", true); }; - if (state.get().header.date.day.show) { + if (state.get.current().header.date.day.show) { _disable.input(".control-header-date-day-display-number", false); _disable.input(".control-header-date-day-display-word", false); } else { _disable.input(".control-header-date-day-display-number", true); _disable.input(".control-header-date-day-display-word", true); }; - if (state.get().header.date.date.show) { + if (state.get.current().header.date.date.show) { _disable.input(".control-header-date-date-display-number", false); _disable.input(".control-header-date-date-display-word", false); _disable.input(".control-header-date-date-ordinal", false); @@ -3168,21 +3225,21 @@ var control = (function() { _disable.input(".control-header-date-date-ordinal", true); _disable.element(".control-header-date-date-ordinal-helper", true); }; - if (state.get().header.date.month.show) { + if (state.get.current().header.date.month.show) { _disable.input(".control-header-date-month-display-number", false); _disable.input(".control-header-date-month-display-word", false); } else { _disable.input(".control-header-date-month-display-number", true); _disable.input(".control-header-date-month-display-word", true); }; - if (state.get().header.date.year.show) { + if (state.get.current().header.date.year.show) { _disable.input(".control-header-date-year-display-number", false); _disable.input(".control-header-date-year-display-word", false); } else { _disable.input(".control-header-date-year-display-number", true); _disable.input(".control-header-date-year-display-word", true); }; - if (state.get().header.date.day.show && state.get().header.date.day.display == "number") { + if (state.get.current().header.date.day.show && state.get.current().header.date.day.display == "number") { _disable.element(".control-header-date-day-week-start-label", false); _disable.input(".control-header-date-day-week-start-monday", false); _disable.input(".control-header-date-day-week-start-sunday", false); @@ -3193,7 +3250,7 @@ var control = (function() { _disable.input(".control-header-date-day-week-start-sunday", true); _disable.element(".control-header-date-day-week-start-helper", true); }; - if (state.get().header.date.day.show && state.get().header.date.day.display == "word") { + if (state.get.current().header.date.day.show && state.get.current().header.date.day.display == "word") { _disable.element(".control-header-date-day-length-label", false); _disable.input(".control-header-date-day-length-long", false); _disable.input(".control-header-date-day-length-short", false); @@ -3202,7 +3259,7 @@ var control = (function() { _disable.input(".control-header-date-day-length-long", true); _disable.input(".control-header-date-day-length-short", true); }; - if (state.get().header.date.month.show && state.get().header.date.month.display == "word") { + if (state.get.current().header.date.month.show && state.get.current().header.date.month.display == "word") { _disable.element(".control-header-date-month-length-label", false); _disable.input(".control-header-date-month-length-long", false); _disable.input(".control-header-date-month-length-short", false); @@ -3211,14 +3268,14 @@ var control = (function() { _disable.input(".control-header-date-month-length-long", true); _disable.input(".control-header-date-month-length-short", true); }; - if (state.get().header.date.month.show && state.get().header.date.month.display == "number") { + if (state.get.current().header.date.month.show && state.get.current().header.date.month.display == "number") { _disable.input(".control-header-date-month-ordinal", false); _disable.element(".control-header-date-month-ordinal-helper", false); } else { _disable.input(".control-header-date-month-ordinal", true); _disable.element(".control-header-date-month-ordinal-helper", true); }; - if (state.get().header.date.day.show || state.get().header.date.date.show || state.get().header.date.month.show || state.get().header.date.year.show) { + if (state.get.current().header.date.day.show || state.get.current().header.date.date.show || state.get.current().header.date.month.show || state.get.current().header.date.year.show) { _disable.element("[for=control-header-date-size]", false); _disable.input(".control-header-date-size", false); _disable.element(".control-header-date-size-count", false); @@ -3231,7 +3288,7 @@ var control = (function() { }; }; var _shade = function() { - if (state.get().header.shade.show) { + if (state.get.current().header.shade.show) { _disable.input(".control-header-shade-style-always", false); _disable.element(".control-header-shade-style-always-helper", false); _disable.input(".control-header-shade-style-scroll", false); @@ -3252,7 +3309,7 @@ var control = (function() { }; }; var _search = function() { - if (state.get().header.search.show) { + if (state.get.current().header.search.show) { _disable.element(".control-header-search-style-label", false); _disable.input(".control-header-search-style-auto", false); _disable.element(".control-header-search-style-auto-helper", false); @@ -3309,7 +3366,7 @@ var control = (function() { _disable.input(".control-header-search-size-default", true); _disable.element(".control-header-search-size-helper", true); }; - if (state.get().header.search.show && state.get().header.search.engine.selected === "custom") { + if (state.get.current().header.search.show && state.get.current().header.search.engine.selected === "custom") { _disable.element("[for=control-header-search-engine-custom-name]", false); _disable.input(".control-header-search-engine-custom-name", false); _disable.element("[for=control-header-search-engine-custom-url]", false); @@ -3322,7 +3379,7 @@ var control = (function() { _disable.input(".control-header-search-engine-custom-url", true); _disable.element(".control-header-search-engine-custom-helper", true); }; - if (state.get().header.search.show && state.get().header.search.style === "custom") { + if (state.get.current().header.search.show && state.get.current().header.search.style === "custom") { _disable.element("[for=control-header-search-width]", false); _disable.input(".control-header-search-width", false); _disable.element(".control-header-search-width-count", false); @@ -3333,7 +3390,7 @@ var control = (function() { }; }; var _greeting = function() { - if (state.get().header.greeting.show) { + if (state.get.current().header.greeting.show) { _disable.element("[for=control-header-greeting-name]", false); _disable.input(".control-header-greeting-name", false); _disable.input(".control-header-greeting-type-good", false); @@ -3356,14 +3413,14 @@ var control = (function() { }; }; var _transitional = function() { - if (state.get().header.date.date.show || state.get().header.date.day.show || state.get().header.date.month.show || state.get().header.date.year.show || state.get().header.clock.seconds.show || state.get().header.clock.minutes.show || state.get().header.clock.hours.show) { + if (state.get.current().header.date.date.show || state.get.current().header.date.day.show || state.get.current().header.date.month.show || state.get.current().header.date.year.show || state.get.current().header.clock.seconds.show || state.get.current().header.clock.minutes.show || state.get.current().header.clock.hours.show) { _disable.input(".control-header-transitional-show", false); _disable.element(".control-header-transitional-show-helper", false); } else { _disable.input(".control-header-transitional-show", true); _disable.element(".control-header-transitional-show-helper", true); }; - if (state.get().header.transitional.show && ((state.get().header.date.date.show || state.get().header.date.day.show || state.get().header.date.month.show || state.get().header.date.year.show || state.get().header.clock.seconds.show || state.get().header.clock.minutes.show || state.get().header.clock.hours.show))) { + if (state.get.current().header.transitional.show && ((state.get.current().header.date.date.show || state.get.current().header.date.day.show || state.get.current().header.date.month.show || state.get.current().header.date.year.show || state.get.current().header.clock.seconds.show || state.get.current().header.clock.minutes.show || state.get.current().header.clock.hours.show))) { _disable.input(".control-header-transitional-type-timeanddate", false); _disable.input(".control-header-transitional-type-its", false); _disable.element("[for=control-header-transitional-size]", false); @@ -3394,7 +3451,7 @@ var control = (function() { }; }; var _group = function() { - if (state.get().group.name.show) { + if (state.get.current().group.name.show) { _disable.element("[for=control-group-name-size]", false); _disable.input(".control-group-name-size", false); _disable.element(".control-group-name-size-count", false); @@ -3489,7 +3546,7 @@ var control = (function() { _disable.input(".control-link-accent-clear", true); _disable.input(".control-link-accent-set", true); _disable.element(".control-link-accent-set-helper", true); - if (state.get().link.show) { + if (state.get.current().link.show) { _disable.input(".control-layout-order-headerlink", false); _disable.input(".control-layout-order-linkheader", false); _disable.element(".control-layout-order-helper", false); @@ -3531,7 +3588,7 @@ var control = (function() { _disable.input(".control-link-accent-clear", false); _disable.input(".control-link-accent-set", false); _disable.element(".control-link-accent-set-helper", false); - if (state.get().link.item.display.letcon.show) { + if (state.get.current().link.item.display.letcon.show) { _disable.element("[for=control-link-item-display-letcon-letter-size]", false); _disable.input(".control-link-item-display-letcon-letter-size", false); _disable.element(".control-link-item-display-letcon-letter-size-count", false); @@ -3541,13 +3598,13 @@ var control = (function() { _disable.element(".control-link-item-display-letcon-icon-size-count", false); _disable.input(".control-link-item-display-letcon-icon-size-default", false); }; - if (state.get().link.item.display.name.show) { + if (state.get.current().link.item.display.name.show) { _disable.element("[for=control-link-item-display-name-size]", false); _disable.input(".control-link-item-display-name-size", false); _disable.element(".control-link-item-display-name-size-count", false); _disable.input(".control-link-item-display-name-size-default", false); }; - if (state.get().link.item.display.letcon.show || state.get().link.item.display.name.show) { + if (state.get.current().link.item.display.letcon.show || state.get.current().link.item.display.name.show) { _disable.element(".control-link-item-display-alignment-grid", false); _disable.element(".control-link-item-display-alignment-label", false); _disable.input(".control-link-item-display-alignment-topleft", false); @@ -3572,7 +3629,7 @@ var control = (function() { _disable.element(".control-link-item-display-translate-y-count", false); _disable.input(".control-link-item-display-translate-y-default", false); }; - if (state.get().link.item.display.letcon.show && state.get().link.item.display.name.show) { + if (state.get.current().link.item.display.letcon.show && state.get.current().link.item.display.name.show) { _disable.input(".control-link-item-display-direction-horizontal", false); _disable.input(".control-link-item-display-direction-vertical", false); _disable.input(".control-link-item-display-order-letconname", false); @@ -3583,7 +3640,7 @@ var control = (function() { }; }; var _theme = function() { - if (state.get().theme.accent.random.active) { + if (state.get.current().theme.accent.random.active) { _disable.input(".control-theme-accent-random-style-any", false); _disable.input(".control-theme-accent-random-style-light", false); _disable.input(".control-theme-accent-random-style-dark", false); @@ -3600,7 +3657,7 @@ var control = (function() { }; }; var _background = function() { - if (state.get().background.image.show) { + if (state.get.current().background.image.show) { _disable.input(".control-background-image-from-file", false); _disable.input(".control-background-image-from-url", false); _disable.element("[for=control-background-image-opacity]", false); @@ -3637,7 +3694,7 @@ var control = (function() { _disable.input(".control-background-image-scale", true); _disable.element(".control-background-image-scale-count", true); }; - if (state.get().background.image.show && state.get().background.image.from == "file") { + if (state.get.current().background.image.show && state.get.current().background.image.from == "file") { _disable.element(".control-background-image-file-feedback", false); _disable.input(".control-background-image-file", false); _disable.input(".control-background-image-file-clear", false); @@ -3648,18 +3705,18 @@ var control = (function() { _disable.input(".control-background-image-file-clear", true); _disable.element(".control-background-image-file-helper", true); }; - if (state.get().background.image.show && state.get().background.image.from == "url") { + if (state.get.current().background.image.show && state.get.current().background.image.from == "url") { _disable.input(".control-background-image-url", false); _disable.element(".control-background-image-url-helper", false); } else { _disable.input(".control-background-image-url", true); _disable.element(".control-background-image-url-helper", true); }; - if (state.get().background.color.by == "theme") { + if (state.get.current().background.color.by == "theme") { _disable.input(".control-background-color-custom-current-picker", true); _disable.input(".control-background-color-custom-current-hex", true); _disable.element(".control-background-color-theme-helper", true); - } else if (state.get().background.color.by == "custom") { + } else if (state.get.current().background.color.by == "custom") { _disable.input(".control-background-color-custom-current-picker", false); _disable.input(".control-background-color-custom-current-hex", false); _disable.element(".control-background-color-theme-helper", false); @@ -3688,19 +3745,19 @@ var control = (function() { var setValue = { checkbox: function(object) { object.element.checked = helper.getObject({ - object: state.get(), + object: state.get.current(), path: object.path }); }, radio: function(object) { helper.e("." + object.element.className.substring(0, object.element.className.lastIndexOf("-") + 1) + helper.getObject({ - object: state.get(), + object: state.get.current(), path: object.path })).checked = true; }, text: function(object) { var newValue = helper.getObject({ - object: state.get(), + object: state.get.current(), path: object.path }); if (object.valueMod) { @@ -3712,7 +3769,7 @@ var control = (function() { }, textarea: function(object) { var newValue = helper.getObject({ - object: state.get(), + object: state.get.current(), path: object.path }); if (object.valueMod) { @@ -3724,13 +3781,13 @@ var control = (function() { }, number: function(object) { object.element.value = helper.getObject({ - object: state.get(), + object: state.get.current(), path: object.path }); }, range: function(object) { var newValue = helper.getObject({ - object: state.get(), + object: state.get.current(), path: object.path }); if (object.valueMod) { @@ -3742,7 +3799,7 @@ var control = (function() { }, color: function(object) { object.element.value = helper.rgbToHex(helper.getObject({ - object: state.get(), + object: state.get.current(), path: object.path })); } diff --git a/src/js/data.js b/src/js/data.js index 6dfadabc..b402cd36 100644 --- a/src/js/data.js +++ b/src/js/data.js @@ -234,7 +234,7 @@ var data = (function() { mod.set(_saveName, JSON.stringify({ nighttab: true, version: version.get().number, - state: state.get(), + state: state.get.current(), bookmarks: bookmarks.get() })); }; diff --git a/src/js/date.js b/src/js/date.js index b7eae603..132484e9 100644 --- a/src/js/date.js +++ b/src/js/date.js @@ -19,7 +19,7 @@ var date = (function() { }; render.all = function() { - if (state.get().header.date.date.show || state.get().header.date.day.show || state.get().header.date.month.show || state.get().header.date.year.show) { + if (state.get.current().header.date.date.show || state.get.current().header.date.day.show || state.get.current().header.date.month.show || state.get.current().header.date.year.show) { var timeDateNow = moment(); var dateStrings = { day: null, @@ -31,31 +31,31 @@ var date = (function() { day: { word: function() { dateStrings.day = timeDateNow.format("dddd"); - if (state.get().header.date.day.length == "short") { + if (state.get.current().header.date.day.length == "short") { dateStrings.day = dateStrings.day.substring(0, 3); }; }, number: function() { dateStrings.day = timeDateNow.day(); - if (state.get().header.date.day.weekStart == "monday") { + if (state.get.current().header.date.day.weekStart == "monday") { if (dateStrings.day == 0) { dateStrings.day = 7; }; - } else if (state.get().header.date.day.weekStart == "sunday") { + } else if (state.get.current().header.date.day.weekStart == "sunday") { dateStrings.day = dateStrings.day + 1; }; } }, date: { word: function() { - if (state.get().header.date.date.ordinal) { + if (state.get.current().header.date.date.ordinal) { dateStrings.date = helper.ordinalWords(helper.toWords(timeDateNow.date())); } else { dateStrings.date = helper.toWords(timeDateNow.date()); }; }, number: function() { - if (state.get().header.date.date.ordinal) { + if (state.get.current().header.date.date.ordinal) { dateStrings.date = timeDateNow.format("Do"); } else { dateStrings.date = timeDateNow.format("DD"); @@ -65,12 +65,12 @@ var date = (function() { month: { word: function() { dateStrings.month = timeDateNow.format("MMMM"); - if (state.get().header.date.month.length == "short") { + if (state.get.current().header.date.month.length == "short") { dateStrings.month = dateStrings.month.substring(0, 3); }; }, number: function() { - if (state.get().header.date.month.ordinal) { + if (state.get.current().header.date.month.ordinal) { dateStrings.month = helper.ordinalNumber(timeDateNow.month() + 1); } else { dateStrings.month = timeDateNow.month() + 1; @@ -86,46 +86,46 @@ var date = (function() { } } }; - wordOrNumber.day[state.get().header.date.day.display](); - wordOrNumber.date[state.get().header.date.date.display](); - wordOrNumber.month[state.get().header.date.month.display](); - wordOrNumber.year[state.get().header.date.year.display](); + wordOrNumber.day[state.get.current().header.date.day.display](); + wordOrNumber.date[state.get.current().header.date.date.display](); + wordOrNumber.month[state.get.current().header.date.month.display](); + wordOrNumber.year[state.get.current().header.date.year.display](); var elementDay = helper.node("span:" + dateStrings.day + "|class:date-item date-day"); var elementDate = helper.node("span:" + dateStrings.date + "|class:date-item date-date"); var elementMonth = helper.node("span:" + dateStrings.month + "|class:date-item date-month"); var elementYear = helper.node("span:" + dateStrings.year + "|class:date-item date-year"); var date = helper.e(".date"); - if (state.get().header.date.day.show) { + if (state.get.current().header.date.day.show) { date.appendChild(elementDay); }; - if (state.get().header.date.date.show && state.get().header.date.month.show) { - if (state.get().header.date.format == "datemonth") { - if (state.get().header.date.date.show) { + if (state.get.current().header.date.date.show && state.get.current().header.date.month.show) { + if (state.get.current().header.date.format == "datemonth") { + if (state.get.current().header.date.date.show) { date.appendChild(elementDate); }; - if (state.get().header.date.month.show) { + if (state.get.current().header.date.month.show) { date.appendChild(elementMonth); }; - } else if (state.get().header.date.format == "monthdate") { - if (state.get().header.date.month.show) { + } else if (state.get.current().header.date.format == "monthdate") { + if (state.get.current().header.date.month.show) { date.appendChild(elementMonth); }; - if (state.get().header.date.date.show) { + if (state.get.current().header.date.date.show) { date.appendChild(elementDate); }; }; } else { - if (state.get().header.date.date.show) { + if (state.get.current().header.date.date.show) { date.appendChild(elementDate); }; - if (state.get().header.date.month.show) { + if (state.get.current().header.date.month.show) { date.appendChild(elementMonth); }; }; - if (state.get().header.date.year.show) { + if (state.get.current().header.date.year.show) { date.appendChild(elementYear); }; - if (state.get().header.date.separator.show) { + if (state.get.current().header.date.separator.show) { var separatorCharacter = "/"; var parts = date.querySelectorAll("span"); if (parts.length > 1) { diff --git a/src/js/dropdown.js b/src/js/dropdown.js index 8316623a..07c2f78c 100644 --- a/src/js/dropdown.js +++ b/src/js/dropdown.js @@ -6,7 +6,7 @@ var dropdown = (function() { mod.open = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "dropdown", newValue: true }); @@ -14,22 +14,22 @@ var dropdown = (function() { mod.close = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "dropdown", newValue: false }); }; mod.toggle = function() { - if (state.get().dropdown) { + if (state.get.current().dropdown) { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "dropdown", newValue: false }); } else { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "dropdown", newValue: true }); @@ -79,7 +79,7 @@ var dropdown = (function() { render.offset = function() { var formDropdownMenu = _currentFormDropdown.querySelector(".form-dropdown-menu"); - if (state.get().dropdown) { + if (state.get.current().dropdown) { var box = formDropdownMenu.getBoundingClientRect(); if (box.right > window.innerWidth) { helper.addClass(formDropdownMenu, "form-dropdown-menu-left"); @@ -100,7 +100,7 @@ var dropdown = (function() { }; render.toggle = function() { - if (state.get().dropdown) { + if (state.get.current().dropdown) { render.open(); } else { render.close(); diff --git a/src/js/edge.js b/src/js/edge.js index 1d194fb1..abc4bbcf 100644 --- a/src/js/edge.js +++ b/src/js/edge.js @@ -24,7 +24,7 @@ var edge = (function() { mod.open = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "edge", newValue: true }); @@ -32,7 +32,7 @@ var edge = (function() { mod.close = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "edge", newValue: false }); diff --git a/src/js/greeting.js b/src/js/greeting.js index 4fb602c8..ab250736 100644 --- a/src/js/greeting.js +++ b/src/js/greeting.js @@ -19,7 +19,7 @@ var greeting = (function() { }; render.all = function() { - if (state.get().header.greeting.show) { + if (state.get.current().header.greeting.show) { var greeting = helper.e(".greeting"); var message = { good: function() { @@ -34,9 +34,9 @@ var greeting = (function() { return "Hi"; } }; - var string = message[state.get().header.greeting.type](); - if (state.get().header.greeting.name != "" && state.get().header.greeting.name != undefined) { - string = string + ", " + state.get().header.greeting.name; + var string = message[state.get.current().header.greeting.type](); + if (state.get.current().header.greeting.name != "" && state.get.current().header.greeting.name != undefined) { + string = string + ", " + state.get.current().header.greeting.name; }; var greetingItem = helper.node("span|class:greeting-item"); var greetingItemText = helper.node("span:" + string + "|class:greeting-item-text"); diff --git a/src/js/header.js b/src/js/header.js index 0805b419..358cbf9b 100644 --- a/src/js/header.js +++ b/src/js/header.js @@ -30,7 +30,7 @@ var header = (function() { render.area = { width: function() { var html = helper.e("html"); - html.style.setProperty("--header-area-width", state.get().header.area.width + "%"); + html.style.setProperty("--header-area-width", state.get.current().header.area.width + "%"); } }; @@ -43,23 +43,23 @@ var header = (function() { // var scrollHeight = document.documentElement.scrollHeight; var innerHeight = window.innerHeight; // if shade show - if (state.get().header.shade.show) { + if (state.get.current().header.shade.show) { // shade always - if (state.get().header.shade.style == "always") { + if (state.get.current().header.shade.style == "always") { helper.removeClass(html, "is-header-shade-style-scroll"); helper.addClass(html, "is-header-shade-style-always"); // shade scroll - } else if (state.get().header.shade.style == "scroll") { + } else if (state.get.current().header.shade.style == "scroll") { helper.removeClass(html, "is-header-shade-style-always"); // check header position - if (state.get().layout.order == "headerlink") { + if (state.get.current().layout.order == "headerlink") { // check scroll position if (scrollTop > fontSize * 2 && headerRect.top == 0) { helper.addClass(html, "is-header-shade-style-scroll"); } else { helper.removeClass(html, "is-header-shade-style-scroll"); }; - } else if (state.get().layout.order == "linkheader") { + } else if (state.get.current().layout.order == "linkheader") { // check scroll position if (headerRect.bottom == innerHeight && (scrollTop + innerHeight) < ((scrollTop + layoutRect.bottom) - (fontSize * 2))) { helper.addClass(html, "is-header-shade-style-scroll"); @@ -76,60 +76,60 @@ var header = (function() { render.opacity = function() { var html = helper.e("html"); - if (state.get().header.shade.show) { - html.style.setProperty("--header-shade-opacity", state.get().header.shade.opacity); + if (state.get.current().header.shade.show) { + html.style.setProperty("--header-shade-opacity", state.get.current().header.shade.opacity); }; }; render.border = function() { var html = helper.e("html"); - html.style.setProperty("--header-border-top", state.get().header.border.top); - html.style.setProperty("--header-border-bottom", state.get().header.border.bottom); + html.style.setProperty("--header-border-top", state.get.current().header.border.top); + html.style.setProperty("--header-border-bottom", state.get.current().header.border.bottom); }; render.search = { width: function() { var html = helper.e("html"); - html.style.setProperty("--header-search-width", state.get().header.search.width + "%"); + html.style.setProperty("--header-search-width", state.get.current().header.search.width + "%"); }, size: function() { var html = helper.e("html"); - html.style.setProperty("--header-search-size", state.get().header.search.size + "em"); + html.style.setProperty("--header-search-size", state.get.current().header.search.size + "em"); } }; render.greeting = { size: function() { var html = helper.e("html"); - html.style.setProperty("--header-greeting-size", state.get().header.greeting.size + "em"); + html.style.setProperty("--header-greeting-size", state.get.current().header.greeting.size + "em"); } }; render.transitional = { size: function() { var html = helper.e("html"); - html.style.setProperty("--header-transitional-size", state.get().header.transitional.size + "em"); + html.style.setProperty("--header-transitional-size", state.get.current().header.transitional.size + "em"); } }; render.clock = { size: function() { var html = helper.e("html"); - html.style.setProperty("--header-clock-size", state.get().header.clock.size + "em"); + html.style.setProperty("--header-clock-size", state.get.current().header.clock.size + "em"); } }; render.date = { size: function() { var html = helper.e("html"); - html.style.setProperty("--header-date-size", state.get().header.date.size + "em"); + html.style.setProperty("--header-date-size", state.get.current().header.date.size + "em"); } }; render.button = { size: function() { var html = helper.e("html"); - html.style.setProperty("--header-button-size", state.get().header.button.size + "em"); + html.style.setProperty("--header-button-size", state.get.current().header.button.size + "em"); }, style: function() { var action = { @@ -146,10 +146,10 @@ var header = (function() { helper.addClass(helper.e(".control-menu-open"), "button-link"); } }; - action[state.get().header.button.style](); + action[state.get.current().header.button.style](); }, edit: function() { - if (!state.get().link.edit) { + if (!state.get.current().link.edit) { helper.e(".control-link-edit").checked = false; }; } diff --git a/src/js/keyboard.js b/src/js/keyboard.js index 228e5a75..dfb923db 100644 --- a/src/js/keyboard.js +++ b/src/js/keyboard.js @@ -6,24 +6,24 @@ var keyboard = (function() { window.addEventListener("keydown", function(event) { // esc if (event.keyCode == 27) { - if (state.get().edge) { + if (state.get.current().edge) { edge.box.close(); - } else if (state.get().menu) { + } else if (state.get.current().menu) { menu.close(); - } else if (state.get().dropdown) { + } else if (state.get.current().dropdown) { dropdown.close(); - } else if (state.get().autoSuggest) { + } else if (state.get.current().autoSuggest) { autoSuggest.close(); - } else if (state.get().link.add) { + } else if (state.get.current().link.add) { link.add.item.close(); - } else if (state.get().group.add) { + } else if (state.get.current().group.add) { link.add.group.close(); - } else if (state.get().link.edit && state.get().modal) { + } else if (state.get.current().link.edit && state.get.current().modal) { link.add.item.close(); - } else if (state.get().link.edit) { + } else if (state.get.current().link.edit) { link.edit.close(); data.save(); - } else if (state.get().modal) { + } else if (state.get.current().modal) { modal.close(); shade.close(); }; @@ -36,14 +36,14 @@ var keyboard = (function() { window.addEventListener("keydown", function(event) { // ctrl+alt+a if (event.ctrlKey && event.altKey && event.keyCode == 65) { - if (state.get().group.add) { + if (state.get.current().group.add) { link.add.group.close(); }; - if (!state.get().link.add) { - if (state.get().menu) { + if (!state.get.current().link.add) { + if (state.get.current().menu) { menu.close(); }; - if (state.get().modal) { + if (state.get.current().modal) { modal.close(); }; link.add.item.open(); @@ -56,14 +56,14 @@ var keyboard = (function() { window.addEventListener("keydown", function(event) { // ctrl+alt+g if (event.ctrlKey && event.altKey && event.keyCode == 71) { - if (state.get().link.add) { + if (state.get.current().link.add) { link.add.item.close(); }; - if (!state.get().group.add) { - if (state.get().menu) { + if (!state.get.current().group.add) { + if (state.get.current().menu) { menu.close(); }; - if (state.get().modal) { + if (state.get.current().modal) { modal.close(); }; link.add.group.open(); @@ -87,10 +87,10 @@ var keyboard = (function() { window.addEventListener("keydown", function(event) { // ctrl+alt+m if (event.ctrlKey && event.altKey && event.keyCode == 77) { - if (state.get().link.add) { + if (state.get.current().link.add) { link.add.item.close(); link.add.group.close(); - } else if (state.get().modal) { + } else if (state.get.current().modal) { modal.close(); shade.close(); }; @@ -112,7 +112,7 @@ var keyboard = (function() { bind.ctrAltR = function() { window.addEventListener("keydown", function(event) { // ctrl+alt+r - if (state.get().theme.accent.random.active && event.ctrlKey && event.altKey && event.keyCode == 82) { + if (state.get.current().theme.accent.random.active && event.ctrlKey && event.altKey && event.keyCode == 82) { theme.render.accent.random(); theme.render.accent.color(); link.groupAndItems(); diff --git a/src/js/layout.js b/src/js/layout.js index 9145f7ac..a39580c6 100644 --- a/src/js/layout.js +++ b/src/js/layout.js @@ -4,22 +4,22 @@ var layout = (function() { render.width = function() { var html = helper.e("html"); - html.style.setProperty("--layout-width", state.get().layout.width + "%"); + html.style.setProperty("--layout-width", state.get.current().layout.width + "%"); }; render.padding = function() { var html = helper.e("html"); - html.style.setProperty("--layout-padding", state.get().layout.padding); + html.style.setProperty("--layout-padding", state.get.current().layout.padding); }; render.gutter = function() { var html = helper.e("html"); - html.style.setProperty("--layout-gutter", state.get().layout.gutter); + html.style.setProperty("--layout-gutter", state.get.current().layout.gutter); }; render.size = function() { var html = helper.e("html"); - html.style.setProperty("--layout-size", state.get().layout.size); + html.style.setProperty("--layout-size", state.get.current().layout.size); }; render.order = function() { @@ -27,16 +27,16 @@ var layout = (function() { var layout = helper.e(".layout"); var header = helper.e(".header"); var link = helper.e(".link"); - if (state.get().layout.order == "headerlink") { + if (state.get.current().layout.order == "headerlink") { layout.insertBefore(header, link); - } else if (state.get().layout.order == "linkheader") { + } else if (state.get.current().layout.order == "linkheader") { layout.insertBefore(link, header); }; }; render.title = function() { var title = helper.e("title"); - title.textContent = state.get().layout.title; + title.textContent = state.get.current().layout.title; }; var init = function() { diff --git a/src/js/link.js b/src/js/link.js index fe6f2a7b..64ff95eb 100644 --- a/src/js/link.js +++ b/src/js/link.js @@ -126,7 +126,7 @@ var link = (function() { mod.edit = { toggle: function() { - if (state.get().link.edit) { + if (state.get.current().link.edit) { mod.edit.close(); } else { mod.edit.open(); @@ -134,14 +134,14 @@ var link = (function() { }, open: function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "link.edit", newValue: true }); }, close: function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "link.edit", newValue: false }); @@ -149,7 +149,7 @@ var link = (function() { check: function() { if (bookmarks.get().length <= 0) { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "link.edit", newValue: false }); @@ -161,14 +161,14 @@ var link = (function() { item: { open: function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "link.add", newValue: true }); }, close: function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "link.add", newValue: false }); @@ -177,14 +177,14 @@ var link = (function() { group: { open: function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "group.add", newValue: true }); }, close: function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "group.add", newValue: false }); @@ -326,7 +326,7 @@ var link = (function() { render.area = { width: function() { var html = helper.e("html"); - html.style.setProperty("--link-area-width", state.get().link.area.width + "%"); + html.style.setProperty("--link-area-width", state.get.current().link.area.width + "%"); } }; @@ -484,15 +484,15 @@ var link = (function() { }, size: function() { var html = helper.e("html"); - html.style.setProperty("--group-name-size", state.get().group.name.size + "em"); + html.style.setProperty("--group-name-size", state.get.current().group.name.size + "em"); }, border: function() { var html = helper.e("html"); - html.style.setProperty("--group-border", state.get().group.border); + html.style.setProperty("--group-border", state.get.current().group.border); }, tabindex: function() { var allGroupControlItem = helper.eA(".group-control-item"); - if (state.get().link.edit) { + if (state.get.current().link.edit) { allGroupControlItem.forEach(function(arrayItem, index) { arrayItem.tabIndex = 1; }); @@ -524,9 +524,9 @@ var link = (function() { linkItemOptions.attr[0].value = linkItemOptions.attr[0].value + " link-text-light"; }; } else { - if (invert(state.get().theme.accent.current, true) == "#000000") { + if (invert(state.get.current().theme.accent.current, true) == "#000000") { linkItemOptions.attr[0].value = linkItemOptions.attr[0].value + " link-text-dark"; - } else if (invert(state.get().theme.accent.current, true) == "#ffffff") { + } else if (invert(state.get.current().theme.accent.current, true) == "#ffffff") { linkItemOptions.attr[0].value = linkItemOptions.attr[0].value + " link-text-light"; }; }; @@ -544,7 +544,7 @@ var link = (function() { value: 1 }] }; - if (state.get().link.newTab) { + if (state.get.current().link.newTab) { linkPanelFrontOptions.attr.push({ key: "target", value: "_blank" @@ -1036,24 +1036,24 @@ var link = (function() { display: { letter: function() { var html = helper.e("html"); - html.style.setProperty("--link-item-display-letter-size", state.get().link.item.display.letcon.letter.size + "em"); + html.style.setProperty("--link-item-display-letter-size", state.get.current().link.item.display.letcon.letter.size + "em"); }, icon: function() { var html = helper.e("html"); - html.style.setProperty("--link-item-display-icon-size", state.get().link.item.display.letcon.icon.size + "em"); + html.style.setProperty("--link-item-display-icon-size", state.get.current().link.item.display.letcon.icon.size + "em"); } }, name: function() { var html = helper.e("html"); - html.style.setProperty("--link-item-display-name-size", state.get().link.item.display.name.size + "em"); + html.style.setProperty("--link-item-display-name-size", state.get.current().link.item.display.name.size + "em"); }, size: function() { var html = helper.e("html"); - html.style.setProperty("--link-item-size", state.get().link.item.size + "em"); + html.style.setProperty("--link-item-size", state.get.current().link.item.size + "em"); }, tabindex: function() { var allLinkControlItem = helper.eA(".link-control-item"); - if (state.get().link.edit) { + if (state.get.current().link.edit) { allLinkControlItem.forEach(function(arrayItem, index) { arrayItem.tabIndex = 1; }); @@ -1065,20 +1065,20 @@ var link = (function() { }, border: function() { var html = helper.e("html"); - html.style.setProperty("--link-item-border", state.get().link.item.border); + html.style.setProperty("--link-item-border", state.get.current().link.item.border); }, rotate: function() { var html = helper.e("html"); - html.style.setProperty("--link-item-display-rotate", state.get().link.item.display.rotate + "deg"); + html.style.setProperty("--link-item-display-rotate", state.get.current().link.item.display.rotate + "deg"); }, translate: { x: function() { var html = helper.e("html"); - html.style.setProperty("--link-item-display-translate-x", state.get().link.item.display.translate.x + "em"); + html.style.setProperty("--link-item-display-translate-x", state.get.current().link.item.display.translate.x + "em"); }, y: function() { var html = helper.e("html"); - html.style.setProperty("--link-item-display-translate-y", state.get().link.item.display.translate.y + "em"); + html.style.setProperty("--link-item-display-translate-y", state.get.current().link.item.display.translate.y + "em"); } } }; @@ -1086,7 +1086,7 @@ var link = (function() { render.all = function() { var linkSection = helper.e(".link"); var bookmarksToRender = false; - if (state.get().search) { + if (state.get.current().search) { bookmarksToRender = search.get(); } else { bookmarksToRender = bookmarks.get(); @@ -1128,7 +1128,7 @@ var link = (function() { } }; // if searching - if (state.get().search) { + if (state.get.current().search) { // if bookmarks exist to be searched if (bookmarksToRender.total > 0) { make.bookmarks(bookmarksToRender.matching); @@ -1188,7 +1188,7 @@ var link = (function() { var paraWrap1 = helper.node("div|class:p-wrap"); var paraWrap2 = helper.node("div|class:p-wrap"); var para1 = helper.node("p:No bookmarks matching \"" + helper.e(".header-search-input").value + "\" found.|class:mb-0"); - var para2 = helper.node("p:\"Enter\" to Search " + state.get().header.search.engine[state.get().header.search.engine.selected].name + ".|class:small muted mb-0"); + var para2 = helper.node("p:\"Enter\" to Search " + state.get.current().header.search.engine[state.get.current().header.search.engine.selected].name + ".|class:small muted mb-0"); paraWrap1.appendChild(para1); paraWrap2.appendChild(para2); linkEmpty.appendChild(paraWrap1); diff --git a/src/js/menu.js b/src/js/menu.js index 68dffc2c..fa8c7043 100644 --- a/src/js/menu.js +++ b/src/js/menu.js @@ -4,7 +4,7 @@ var menu = (function() { mod.open = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "menu", newValue: true }); @@ -12,7 +12,7 @@ var menu = (function() { mod.close = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "menu", newValue: false }); @@ -44,7 +44,7 @@ var menu = (function() { render.tabindex = { toggle: function() { var menu = helper.e(".menu"); - if (state.get().menu) { + if (state.get.current().menu) { menu.tabIndex = 1; menu.querySelectorAll("[tabindex]").forEach(function(arrayItem, index) { arrayItem.tabIndex = 1; @@ -80,7 +80,7 @@ var menu = (function() { }; var toggle = function() { - if (state.get().menu) { + if (state.get.current().menu) { close(); } else { open(); diff --git a/src/js/modal.js b/src/js/modal.js index 3e36a5a0..b8ed102a 100644 --- a/src/js/modal.js +++ b/src/js/modal.js @@ -6,7 +6,7 @@ var modal = (function() { mod.open = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "modal", newValue: true }); @@ -14,7 +14,7 @@ var modal = (function() { mod.close = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "modal", newValue: false }); @@ -23,7 +23,7 @@ var modal = (function() { var render = {}; render.toggle = function(override) { - if (state.get().modal) { + if (state.get.current().modal) { render.open(override); } else { render.close(); diff --git a/src/js/pagelock.js b/src/js/pagelock.js index 82cd9cd4..70b61d11 100644 --- a/src/js/pagelock.js +++ b/src/js/pagelock.js @@ -4,7 +4,7 @@ var pagelock = (function() { mod.lock = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "pagelock", newValue: true }); @@ -12,14 +12,14 @@ var pagelock = (function() { mod.unlock = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "pagelock", newValue: false }); }; mod.toggle = function() { - if (state.get().menu || state.get().modal || state.get().autoSuggest) { + if (state.get.current().menu || state.get.current().modal || state.get.current().autoSuggest) { mod.lock(); } else { mod.unlock(); @@ -37,7 +37,7 @@ var pagelock = (function() { }; render.toggle = function() { - if (state.get().pagelock) { + if (state.get.current().pagelock) { render.lock(); } else { render.unlock(); diff --git a/src/js/search.js b/src/js/search.js index b001d1f8..d5580c24 100644 --- a/src/js/search.js +++ b/src/js/search.js @@ -26,7 +26,7 @@ var search = (function() { mod.searching = { set: function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "search", newValue: helper.e(".search-input").value != "" }); @@ -36,7 +36,7 @@ var search = (function() { var get = function() { var searchInput = helper.e(".search-input"); var string = searchInput.value.toLowerCase().replace(/\s/g, ""); - if (state.get().search) { + if (state.get.current().search) { var searchedBookmarks = { total: 0, matching: [] @@ -73,14 +73,14 @@ var search = (function() { var search = helper.e(".search"); var searchInput = helper.e(".search-input"); var placeholder = ""; - if (state.get().link.show) { + if (state.get.current().link.show) { placeholder = "Find bookmarks or search"; } else { placeholder = "Search"; }; - placeholder = placeholder + " " + state.get().header.search.engine[state.get().header.search.engine.selected].name; + placeholder = placeholder + " " + state.get.current().header.search.engine[state.get.current().header.search.engine.selected].name; searchInput.setAttribute("placeholder", placeholder); - search.setAttribute("action", state.get().header.search.engine[state.get().header.search.engine.selected].url); + search.setAttribute("action", state.get.current().header.search.engine[state.get.current().header.search.engine.selected].url); }; render.clear = {}; @@ -93,7 +93,7 @@ var search = (function() { render.clear.button = function() { var searchClear = helper.e(".search-clear"); - if (state.get().search) { + if (state.get.current().search) { searchClear.removeAttribute("disabled"); } else { searchClear.setAttribute("disabled", ""); @@ -101,7 +101,7 @@ var search = (function() { }; render.focus = function() { - if (state.get().header.search.focus) { + if (state.get.current().header.search.focus) { window.addEventListener("load", function(event) { helper.e(".search-input").focus(); }); diff --git a/src/js/shade.js b/src/js/shade.js index 8f5f1f30..0ba368c0 100644 --- a/src/js/shade.js +++ b/src/js/shade.js @@ -6,7 +6,7 @@ var shade = (function() { mod.open = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "shade", newValue: true }); @@ -14,22 +14,22 @@ var shade = (function() { mod.close = function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "shade", newValue: false }); }; mod.toggle = function() { - if (state.get().shade) { + if (state.get.current().shade) { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "shade", newValue: false }); } else { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "shade", newValue: true }); @@ -39,7 +39,7 @@ var shade = (function() { var render = {}; render.toggle = function(override) { - if (state.get().shade) { + if (state.get.current().shade) { render.open(override); } else { render.close(); diff --git a/src/js/state.js b/src/js/state.js index 218d905c..df8cf52c 100644 --- a/src/js/state.js +++ b/src/js/state.js @@ -255,8 +255,79 @@ var state = (function() { autoSuggest: false }; - mod.get = function() { - return mod.current; + mod.default = { + header: { + area: { + width: 100 + }, + clock: { + size: 1 + }, + date: { + size: 1 + }, + search: { + size: 1 + }, + button: { + size: 1 + }, + greeting: { + size: 1 + }, + transitional: { + size: 1 + } + }, + group: { + name: { + size: 1 + } + }, + link: { + area: { + width: 100 + }, + item: { + display: { + letcon: { + letter: { + size: 3 + }, + icon: { + size: 3 + } + }, + name: { + size: 0.9 + }, + rotate: 0, + translate: { + x: 0, + y: 0 + } + }, + size: 1 + } + }, + layout: { + padding: 4, + gutter: 2, + size: 1, + width: 80 + }, + theme: { + radius: 0.25 + } + }; + + mod.get = { + current: function() { + return mod.current; + }, + default: function() { + return mod.default; + } }; mod.restore = function(data) { @@ -271,8 +342,13 @@ var state = (function() { }; }; - var get = function() { - return mod.get(); + var get = { + current: function() { + return mod.get.current(); + }, + default: function() { + return mod.get.default(); + } }; return { diff --git a/src/js/theme.js b/src/js/theme.js index 938064af..d7ec51ba 100644 --- a/src/js/theme.js +++ b/src/js/theme.js @@ -5,22 +5,22 @@ var theme = (function() { mod.theme = { light: function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "theme.style", newValue: "light" }); }, dark: function() { helper.setObject({ - object: state.get(), + object: state.get.current(), path: "theme.style", newValue: "dark" }); }, toggle: function() { - if (state.get().theme.style == "dark") { + if (state.get.current().theme.style == "dark") { mod.theme.light(); - } else if (state.get().theme.style == "light") { + } else if (state.get.current().theme.style == "light") { mod.theme.dark(); }; } @@ -32,22 +32,22 @@ var theme = (function() { var html = helper.e("html"); helper.removeClass(html, "is-theme-style-dark"); helper.removeClass(html, "is-theme-style-light"); - helper.addClass(html, "is-theme-style-" + state.get().theme.style); + helper.addClass(html, "is-theme-style-" + state.get.current().theme.style); }; render.radius = function() { var html = helper.e("html"); - html.style.setProperty("--theme-radius", state.get().theme.radius + "rem"); + html.style.setProperty("--theme-radius", state.get.current().theme.radius + "rem"); }; render.accent = { color: function() { var html = helper.e("html"); - var color = state.get().theme.accent.current; + var color = state.get.current().theme.accent.current; html.style.setProperty("--theme-accent", color.r + ", " + color.g + ", " + color.b); }, random: function() { - if (state.get().theme.accent.random.active) { + if (state.get.current().theme.accent.random.active) { var randomVal = function(min, max) { return Math.floor(Math.random() * (max - min) + 1) + min; }; @@ -88,14 +88,14 @@ var theme = (function() { }; } }; - var hsl = color[state.get().theme.accent.random.style](); + var hsl = color[state.get.current().theme.accent.random.style](); var randomColor = helper.hslToRgb({ h: hsl.h, s: (hsl.s / 100), l: (hsl.l / 100) }); helper.setObject({ - object: state.get(), + object: state.get.current(), path: "theme.accent.current", newValue: randomColor }); @@ -108,13 +108,13 @@ var theme = (function() { render.input = { quick: function() { - helper.e(".control-theme-accent-current-quick").value = helper.rgbToHex(state.get().theme.accent.current); + helper.e(".control-theme-accent-current-quick").value = helper.rgbToHex(state.get.current().theme.accent.current); }, picker: function() { - helper.e(".control-theme-accent-current-picker").value = helper.rgbToHex(state.get().theme.accent.current); + helper.e(".control-theme-accent-current-picker").value = helper.rgbToHex(state.get.current().theme.accent.current); }, hex: function() { - helper.e(".control-theme-accent-current-hex").value = helper.rgbToHex(state.get().theme.accent.current); + helper.e(".control-theme-accent-current-hex").value = helper.rgbToHex(state.get.current().theme.accent.current); } }; diff --git a/src/js/transitional.js b/src/js/transitional.js index 4606132e..4f1c4f56 100644 --- a/src/js/transitional.js +++ b/src/js/transitional.js @@ -19,29 +19,29 @@ var transitional = (function() { }; render.all = function() { - if (state.get().header.transitional.show) { + if (state.get.current().header.transitional.show) { var transitional = helper.e(".transitional"); var message = { timeanddate: function() { - if ((state.get().header.date.day.show || state.get().header.date.date.show || state.get().header.date.month.show || state.get().header.date.year.show) && (state.get().header.clock.seconds.show || state.get().header.clock.minutes.show || state.get().header.clock.hours.show)) { - if (state.get().header.date.day.show && !state.get().header.date.date.show && !state.get().header.date.month.show && !state.get().header.date.year.show) { + if ((state.get.current().header.date.day.show || state.get.current().header.date.date.show || state.get.current().header.date.month.show || state.get.current().header.date.year.show) && (state.get.current().header.clock.seconds.show || state.get.current().header.clock.minutes.show || state.get.current().header.clock.hours.show)) { + if (state.get.current().header.date.day.show && !state.get.current().header.date.date.show && !state.get.current().header.date.month.show && !state.get.current().header.date.year.show) { return "The time and day is"; } else { return "The time and date is"; }; - } else if (state.get().header.date.day.show || state.get().header.date.date.show || state.get().header.date.month.show || state.get().header.date.year.show) { - if (state.get().header.date.day.show && !state.get().header.date.date.show && !state.get().header.date.month.show && !state.get().header.date.year.show) { + } else if (state.get.current().header.date.day.show || state.get.current().header.date.date.show || state.get.current().header.date.month.show || state.get.current().header.date.year.show) { + if (state.get.current().header.date.day.show && !state.get.current().header.date.date.show && !state.get.current().header.date.month.show && !state.get.current().header.date.year.show) { return "Today is"; - } else if (!state.get().header.date.day.show && state.get().header.date.date.show && !state.get().header.date.month.show && !state.get().header.date.year.show) { + } else if (!state.get.current().header.date.day.show && state.get.current().header.date.date.show && !state.get.current().header.date.month.show && !state.get.current().header.date.year.show) { return "The date is"; - } else if (!state.get().header.date.day.show && !state.get().header.date.date.show && state.get().header.date.month.show && !state.get().header.date.year.show) { + } else if (!state.get.current().header.date.day.show && !state.get.current().header.date.date.show && state.get.current().header.date.month.show && !state.get.current().header.date.year.show) { return "The month is"; - } else if (!state.get().header.date.day.show && !state.get().header.date.date.show && !state.get().header.date.month.show && state.get().header.date.year.show) { + } else if (!state.get.current().header.date.day.show && !state.get.current().header.date.date.show && !state.get.current().header.date.month.show && state.get.current().header.date.year.show) { return "The year is"; } else { return "The date is"; }; - } else if (state.get().header.clock.seconds.show || state.get().header.clock.minutes.show || state.get().header.clock.hours.show) { + } else if (state.get.current().header.clock.seconds.show || state.get.current().header.clock.minutes.show || state.get.current().header.clock.hours.show) { return "The time is"; }; }, @@ -49,7 +49,7 @@ var transitional = (function() { return "It's"; } }; - var string = message[state.get().header.transitional.type](); + var string = message[state.get.current().header.transitional.type](); var transitionalItem = helper.node("span|class:transitional-item"); var transitionalItemText = helper.node("span:" + string + "|class:transitional-item-text"); transitionalItem.appendChild(transitionalItemText);