2019-01-03 23:30:27 +01:00
|
|
|
var header = (function() {
|
|
|
|
|
|
|
|
var _bind = function() {
|
2019-02-16 23:27:54 +01:00
|
|
|
window.addEventListener("resize", function() {
|
2019-05-23 20:15:14 +02:00
|
|
|
render.shade();
|
2019-01-03 23:30:27 +01:00
|
|
|
}, false);
|
2019-02-16 23:27:54 +01:00
|
|
|
window.addEventListener("scroll", function() {
|
2019-05-23 20:15:14 +02:00
|
|
|
render.shade();
|
2019-01-24 21:28:11 +01:00
|
|
|
}, false);
|
2019-01-15 13:49:10 +01:00
|
|
|
helper.eA(".container").forEach(function(arrayItem, index) {
|
|
|
|
arrayItem.addEventListener("transitionend", function() {
|
2019-05-23 20:15:14 +02:00
|
|
|
render.shade();
|
2019-01-15 13:49:10 +01:00
|
|
|
}, false);
|
|
|
|
});
|
2019-04-18 14:30:40 +02:00
|
|
|
document.fonts.ready.then(function() {
|
2019-05-23 20:15:14 +02:00
|
|
|
render.shade();
|
2019-04-18 14:30:40 +02:00
|
|
|
});
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
|
|
|
|
2019-05-23 20:15:14 +02:00
|
|
|
var render = {
|
2019-06-11 11:54:10 +02:00
|
|
|
area: {
|
|
|
|
width: function() {
|
|
|
|
_renderWidth();
|
2019-04-03 13:47:41 +02:00
|
|
|
}
|
2019-05-23 20:15:14 +02:00
|
|
|
},
|
|
|
|
shade: function() {
|
2019-06-11 11:54:10 +02:00
|
|
|
_renderShade();
|
2019-05-23 20:15:14 +02:00
|
|
|
},
|
|
|
|
opacity: function() {
|
2019-06-11 11:54:10 +02:00
|
|
|
_renderOpacity();
|
2019-05-23 20:15:14 +02:00
|
|
|
},
|
|
|
|
border: function() {
|
2019-06-11 11:54:10 +02:00
|
|
|
_renderBorder();
|
|
|
|
},
|
|
|
|
search: {
|
|
|
|
width: function() {
|
|
|
|
_renderSearchWidth();
|
|
|
|
},
|
|
|
|
size: function() {
|
|
|
|
_renderSearchSize();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
greeting: {
|
|
|
|
size: function() {
|
|
|
|
_renderGreetingSize();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
transitional: {
|
|
|
|
size: function() {
|
|
|
|
_renderTransitionalSize();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
clock: {
|
|
|
|
size: function() {
|
|
|
|
_renderClockSize();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
date: {
|
|
|
|
size: function() {
|
|
|
|
_renderDateSize();
|
|
|
|
}
|
2019-05-23 20:15:14 +02:00
|
|
|
},
|
2019-06-11 11:54:10 +02:00
|
|
|
button: {
|
|
|
|
size: function() {
|
|
|
|
_renderButtonSize();
|
2019-06-13 19:28:51 +02:00
|
|
|
},
|
|
|
|
style: function() {
|
|
|
|
_renderButtonStyle();
|
2019-06-11 11:54:10 +02:00
|
|
|
}
|
2019-05-23 20:15:14 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-06-11 11:54:10 +02:00
|
|
|
var _renderWidth = function() {
|
2019-05-23 20:15:14 +02:00
|
|
|
var html = helper.e("html");
|
|
|
|
html.style.setProperty("--header-area-width", state.get().header.area.width + "%");
|
|
|
|
};
|
|
|
|
|
2019-06-11 11:54:10 +02:00
|
|
|
var _renderShade = function() {
|
2019-01-03 23:30:27 +01:00
|
|
|
var html = helper.e("html");
|
2019-02-16 23:27:54 +01:00
|
|
|
var fontSize = parseInt(getComputedStyle(html).fontSize, 10);
|
|
|
|
var scrollPosition = document.documentElement.scrollTop;
|
2019-05-23 20:15:14 +02:00
|
|
|
if (state.get().header.shade.show) {
|
|
|
|
if (state.get().header.shade.style == "always") {
|
|
|
|
html.style.setProperty("--header-shade-color", "var(--gray-01)");
|
|
|
|
} else if (state.get().header.shade.style == "scroll") {
|
|
|
|
if (scrollPosition > (fontSize * 2)) {
|
2019-02-16 23:27:54 +01:00
|
|
|
html.style.setProperty("--header-shade-color", "var(--gray-01)");
|
|
|
|
} else {
|
|
|
|
html.style.setProperty("--header-shade-color", "transparent");
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
html.style.setProperty("--header-shade-color", "transparent");
|
|
|
|
};
|
2019-05-23 20:15:14 +02:00
|
|
|
} else {
|
|
|
|
html.style.setProperty("--header-shade-color", "transparent");
|
2019-02-16 23:27:54 +01:00
|
|
|
};
|
2019-05-23 20:15:14 +02:00
|
|
|
};
|
|
|
|
|
2019-06-11 11:54:10 +02:00
|
|
|
var _renderOpacity = function() {
|
2019-05-23 20:15:14 +02:00
|
|
|
var html = helper.e("html");
|
|
|
|
if (state.get().header.shade.show) {
|
|
|
|
html.style.setProperty("--header-shade-opacity", state.get().header.shade.opacity);
|
2019-02-16 23:27:54 +01:00
|
|
|
};
|
2019-05-23 20:15:14 +02:00
|
|
|
};
|
|
|
|
|
2019-06-11 11:54:10 +02:00
|
|
|
var _renderBorder = function() {
|
2019-05-23 20:15:14 +02:00
|
|
|
var html = helper.e("html");
|
2019-06-13 16:47:00 +02:00
|
|
|
html.style.setProperty("--header-border-top", state.get().header.border.top);
|
|
|
|
html.style.setProperty("--header-border-bottom", state.get().header.border.bottom);
|
2019-05-23 20:15:14 +02:00
|
|
|
};
|
|
|
|
|
2019-06-11 11:54:10 +02:00
|
|
|
var _renderSearchWidth = function() {
|
2019-05-23 20:15:14 +02:00
|
|
|
var html = helper.e("html");
|
2019-06-11 11:54:10 +02:00
|
|
|
html.style.setProperty("--header-search-width", state.get().header.search.width + "%");
|
|
|
|
};
|
|
|
|
|
|
|
|
var _renderSearchSize = function() {
|
|
|
|
var html = helper.e("html");
|
|
|
|
html.style.setProperty("--header-search-size", state.get().header.search.size + "em");
|
|
|
|
};
|
|
|
|
|
|
|
|
var _renderGreetingSize = function() {
|
|
|
|
var html = helper.e("html");
|
|
|
|
html.style.setProperty("--header-greeting-size", state.get().header.greeting.size + "em");
|
|
|
|
};
|
|
|
|
|
|
|
|
var _renderTransitionalSize = function() {
|
|
|
|
var html = helper.e("html");
|
|
|
|
html.style.setProperty("--header-transitional-size", state.get().header.transitional.size + "em");
|
|
|
|
};
|
|
|
|
|
|
|
|
var _renderClockSize = function() {
|
|
|
|
var html = helper.e("html");
|
|
|
|
html.style.setProperty("--header-clock-size", state.get().header.clock.size + "em");
|
|
|
|
};
|
|
|
|
|
|
|
|
var _renderDateSize = function() {
|
|
|
|
var html = helper.e("html");
|
|
|
|
html.style.setProperty("--header-date-size", state.get().header.date.size + "em");
|
|
|
|
};
|
|
|
|
|
|
|
|
var _renderButtonSize = function() {
|
|
|
|
var html = helper.e("html");
|
|
|
|
html.style.setProperty("--header-button-size", state.get().header.button.size + "em");
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
|
|
|
|
2019-06-13 19:28:51 +02:00
|
|
|
var _renderButtonStyle = function() {
|
|
|
|
var action = {
|
|
|
|
box: function() {
|
|
|
|
helper.removeClass(helper.getClosest(helper.e(".control-link-edit"), ".input-wrap"), "input-button-link");
|
|
|
|
helper.removeClass(helper.getClosest(helper.e(".control-theme-accent-current"), ".input-wrap"), "input-button-link");
|
|
|
|
helper.removeClass(helper.e(".control-link-add"), "button-link");
|
|
|
|
helper.removeClass(helper.e(".control-menu"), "button-link");
|
|
|
|
},
|
|
|
|
clear: function() {
|
|
|
|
helper.addClass(helper.getClosest(helper.e(".control-link-edit"), ".input-wrap"), "input-button-link");
|
|
|
|
helper.addClass(helper.getClosest(helper.e(".control-theme-accent-current"), ".input-wrap"), "input-button-link");
|
|
|
|
helper.addClass(helper.e(".control-link-add"), "button-link");
|
|
|
|
helper.addClass(helper.e(".control-menu"), "button-link");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
action[state.get().header.button.style]();
|
|
|
|
};
|
|
|
|
|
2019-01-03 23:30:27 +01:00
|
|
|
var init = function() {
|
|
|
|
_bind();
|
2019-06-11 11:54:10 +02:00
|
|
|
render.area.width();
|
2019-05-23 20:15:14 +02:00
|
|
|
render.shade();
|
|
|
|
render.opacity();
|
|
|
|
render.border();
|
2019-06-11 11:54:10 +02:00
|
|
|
render.greeting.size();
|
|
|
|
render.transitional.size();
|
|
|
|
render.clock.size();
|
|
|
|
render.date.size();
|
|
|
|
render.search.width();
|
|
|
|
render.search.size();
|
|
|
|
render.button.size();
|
2019-06-13 19:28:51 +02:00
|
|
|
render.button.style();
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// exposed methods
|
|
|
|
return {
|
2019-04-03 13:47:41 +02:00
|
|
|
render: render,
|
|
|
|
init: init
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|