Uname: Linux premium294.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 104.21.96.1
Your Ip: 216.73.216.165
User: mjbynoyq (1574) | Group: mjbynoyq (1570)
Safe Mode: OFF
Disable Function:
NONE

name : footer.js
export default class Footer {
  #elements = {
    mainSection: document.querySelector("#main"),
  };
  #footerPositionState = null;

  constructor() {
    if (!this.#elements.mainSection) {
      return;
    }

    this.#setElements();
    this.#setupEventListeners();
  }

  #setElements = () => {
    this.#elements = {
      ...this.#elements,
      WPAdminbar: document.querySelector("#wpadminbar"),
      siteFooter: document.querySelector("#footer"),
      calloutFooter: document.querySelector("#footer-callout-wrap"),
      footerBar: document.querySelector("#footer-bar"),
      parallax: document.querySelector(".parallax-footer"),
      html: document.querySelector("html"),
      body: document.body,
      wrapSection: document.querySelector("#wrap"),
    };
  };

  #setupEventListeners = () => {
    window.addEventListener("load", this.#onWindowLoad);
    window.addEventListener("resize", this.#onWindowResize);
  };

  #onWindowLoad = (event) => {
    this.#fixedFooter();
    this.#parallaxFooter();
  };

  #onWindowResize = (event) => {
    this.#fixedFooter();
    this.#parallaxFooter();
  };

  #fixedFooter = () => {
    if (!document.body.classList.contains("has-fixed-footer")) {
      return;
    }

    const wpAdminbarHeight = this.#elements.WPAdminbar?.offsetHeight ?? 0;
    const footerBarHeight = this.#elements.footerBar?.offsetHeight ?? 0;
    const htmlHeight = this.#elements.html.offsetHeight - wpAdminbarHeight;

    if (htmlHeight < window.innerHeight) {
      this.#elements.wrapSection.style.cssText = `
                display: flex;
                flex-direction: column;
                min-height: calc(100vh - ${wpAdminbarHeight}px - ${footerBarHeight}px);
            `;

      if (!!this.#elements.calloutFooter) {
        this.#elements.calloutFooter.style.marginTop = "auto";
      } else if (!!this.#elements.siteFooter) {
        this.#elements.siteFooter.style.marginTop = "auto";
      }

      this.#footerPositionState = "changed";
    } else if (this.#footerPositionState === "changed") {
      this.#elements.wrapSection.style.cssText = "";

      if (!!this.#elements.calloutFooter) {
        this.#elements.calloutFooter.style.marginTop = null;
      } else {
        this.#elements.siteFooter.style.marginTop = null;
      }

      this.#footerPositionState = null;
    }
  };

  #parallaxFooter = () => {
    if (this.#elements.body.classList.contains("has-parallax-footer")) {
      setTimeout(() => {
        let mainSectionMarginBottom = 0;

        mainSectionMarginBottom += this.#elements.parallax?.offsetHeight;

        if (!!this.#elements.calloutFooter) {
          this.#elements.calloutFooter.style.bottom = `${mainSectionMarginBottom}px`;
          mainSectionMarginBottom += this.#elements.calloutFooter.offsetHeight;
        }

        this.#elements.mainSection.style.marginBottom = `${mainSectionMarginBottom}px`;
      }, 10);
    }
  };
}
© 2025 XylotrechusZ