HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux sa-dev.otherchirps.net 5.15.0-139-generic #149-Ubuntu SMP Fri Apr 11 22:06:13 UTC 2025 x86_64
User: www-data (33)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wp-content/plugins/editorplus/assets/scripts/toggles.js
class EditorPlusToggles {
  constructor(toggleWrapper) {
    this.wrapper = toggleWrapper;
    this.toggleItemWrapper = this.wrapper.querySelectorAll(
      ".ep_toggle_item_wrapper"
    );
    this.toggleTitles = this.wrapper.querySelectorAll(".ep_toggle_item_title");
    this.toggleContents = this.wrapper.querySelectorAll(
      ".ep_toggle_item_content"
    );

    // saving toggle content heights.
    this.toggleContentsHeights = Array.from(this.toggleContents).map(
      (contentElem) => contentElem.clientHeight
    );
    this.toggleContentsPadding = Array.from(this.toggleContents).map(
      (contentElem) => getComputedStyle(contentElem).getPropertyValue("padding")
    );
    this.defaultFirstItemOpen = this.wrapper.dataset.open_first;
    this.isAccordion = this.wrapper.dataset.isaccordion;
    this.titleIcon = this.wrapper.querySelectorAll(".ep_toggles_icon");
    this.initialize();
  }
  initialize() {
    this.attachEventHandler();
    this.showInitialToggle();
  }
  showInitialToggle() {
    let isInitialToggleOpen =
      this.defaultFirstItemOpen === "true" ? true : false;
    if (isInitialToggleOpen && this.toggleItemWrapper.length > 0) {
      this.toggleItemWrapper[0].classList.add("ep_ti_open");
      this.toggleContents[0].style.height =
        this.toggleContentsHeights[0] + "px";

      this.toggleContents[0].style.padding = this.toggleContentsPadding[0];
    }
  }
  setActiveToggle(idx) {
    let isAccordion = this.isAccordion === "true" ? true : false;
    this.inActiveIcon = this.titleIcon[idx].dataset.icon;
    this.activeIcon = this.titleIcon[idx].dataset.activeicon;

    // Toggle
    if (!isAccordion && this.toggleItemWrapper.length > 0) {
      this.toggleItemWrapper[idx].classList.toggle("ep_ti_open");
    } else {
      this.toggleItemWrapper.forEach((wrapper, wrapperIndex) => {
        if (idx === wrapperIndex && this.toggleItemWrapper.length > 0) {
          wrapper.classList.toggle("ep_ti_open");
          this.toggleContents[wrapperIndex].style.height =
            this.toggleContentsHeights[wrapperIndex] + "px";

          this.toggleContents[wrapperIndex].style.padding =
            this.toggleContentsPadding[wrapperIndex];
        } else {
          wrapper.classList.remove("ep_ti_open");
          this.toggleContents[wrapperIndex].style.height = 0;
          this.toggleContents[wrapperIndex].style.paddingTop = 0;
          this.toggleContents[wrapperIndex].style.paddingBottom = 0;
        }
      });
    }
    // Accordion
    if (this.toggleItemWrapper[idx].classList.contains("ep_ti_open")) {
      this.titleIcon[idx].classList.remove(this.inActiveIcon);
      this.titleIcon[idx].classList.add(this.activeIcon);

      this.toggleContents[idx].style.height =
        this.toggleContentsHeights[idx] + "px";

      this.toggleContents[idx].style.padding = this.toggleContentsPadding[idx];
    } else {
      this.titleIcon[idx].classList.remove(this.activeIcon);
      this.titleIcon[idx].classList.add(this.inActiveIcon);

      this.toggleContents[idx].style.height = 0;
      this.toggleContents[idx].style.paddingTop = 0;
      this.toggleContents[idx].style.paddingBottom = 0;
    }
  }
  attachEventHandler() {
    this.toggleTitles.forEach((title, idx) => {
      this.toggleContents[idx].style.height = 0;
      this.toggleContents[idx].style.paddingTop = 0;
      this.toggleContents[idx].style.paddingBottom = 0;
      title.addEventListener("click", (event) => {
        event.stopPropagation();
        this.setActiveToggle(idx);
      });
    });
  }
}
window.addEventListener("load", () => {
  const toggleWrappers = document.querySelectorAll(".ep_toggles_wrapper");
  toggleWrappers.forEach(
    (toggleWrapper) => new EditorPlusToggles(toggleWrapper)
  );
});