webpack-bootstrap-ui-kit/src/js_old/_components/_ui.header-footer.js

73 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-08-18 20:51:15 +02:00
"use strict";
2020-05-13 16:47:49 +02:00
2021-08-18 20:51:15 +02:00
import $ from "jquery";
import Events from "../_events";
2020-05-13 16:47:49 +02:00
const HeaderUI = (($) => {
const D = document;
const W = window;
2021-08-18 20:51:15 +02:00
const $Body = $("html,body");
const NAME = "HeaderUI";
2020-05-13 16:47:49 +02:00
const CLASSNAME = `js${NAME}`;
class HeaderUI {
static init() {
const ui = this;
ui.dispose();
2020-09-09 17:40:58 +02:00
console.log(`${NAME}: init`);
2020-05-13 16:47:49 +02:00
2020-05-13 18:05:34 +02:00
const $header = $(`#Header,.js${NAME}`);
2020-05-13 16:47:49 +02:00
const updateHeader = () => {
const h = $header.height();
const s = $Body.scrollTop();
if (s + 50 > h) {
2021-08-18 20:51:15 +02:00
$Body.addClass("shrink");
2020-05-13 16:47:49 +02:00
} else {
2021-08-18 20:51:15 +02:00
$Body.removeClass("shrink");
2020-05-13 16:47:49 +02:00
}
};
updateHeader();
const updateFooter = (i, el) => {
const $el = $(el);
const footerHeight = $el.height();
2021-08-18 20:51:15 +02:00
$el.css("height", footerHeight);
2020-05-13 16:47:49 +02:00
2021-08-18 20:51:15 +02:00
$el.css("margin-top", -footerHeight);
$el.siblings(".wrapper").css("padding-bottom", footerHeight);
2020-05-13 16:47:49 +02:00
};
2021-08-18 20:51:15 +02:00
$(".footer,.jsFooterUI").css("height", "auto");
2020-05-24 08:58:18 +02:00
setTimeout(() => {
2021-08-18 20:51:15 +02:00
$(".footer,.jsFooterUI").each(updateFooter);
2020-05-24 08:58:18 +02:00
}, 500);
2020-05-13 16:47:49 +02:00
}
static dispose() {
2020-12-24 23:42:33 +01:00
console.log(`${NAME}: dispose`);
2020-09-09 17:40:58 +02:00
2021-08-18 20:51:15 +02:00
$Body.removeClass("shrink");
$(`#Header,.js${NAME},.footer,.jsFooterUI,.wrapper`).attr("css", "");
2020-05-13 16:47:49 +02:00
}
}
$(W).on(`${Events.AJAX} ${Events.LOADED}`, () => {
HeaderUI.init();
});
// align event content
$(W).on(`${Events.RESIZE}`, () => {
setTimeout(() => {
HeaderUI.init();
}, 200);
});
2020-05-13 16:47:49 +02:00
W.HeaderUI = new HeaderUI();
return HeaderUI;
})($);
export default HeaderUI;