Javascript helpers functions

Description#


In order to ease the use of the theme, some javascript functions defined in the file assets/js/theme/modules/helpers.js are provided. These functions are defined globally using the file assets/js/theme/modules/helpersGlobal.js and thus can be called from every scope.

JavaScript helper functions#


CodeDescription
closeModals(modal);

Function managing modal closing:

  • If filled in, only the modal set as input is closed
  • If no input, all modals are closed
disableSmoothScroll();Function deactivating smooth scrolling on main content.
enableSmoothScroll();Fonction activating smooth scrolling on main content.
getFirstVisibleElement(selector);

Function getting the first visible element from a CSS selector:

manageDefaultCollapsibleSidebar();

Function managing the default behavior of the sidebar:

  • If the window is greater than or equal to 1024 pixels wide, sidebar is uncollapsed
  • If the window is less than 1024 pixels wide, sidebar is collapsed
manageDefaultToc();

Function managing the default behavior of the table of contents:

  • If the window is greater than or equal to 1216 pixels wide, table of contents is uncollapsed
  • If the window is less than 1216 pixels wide, table of contents is collapsed
toggleExtendMenu(force);

Function managing the extend menu of the navigation bar (only if it is displayed):

  • force
    • true: the extend menu is displayed
    • false: the extend menu is hidden
toggleSidebar(force, noTransition);

Function managing the sidebar behavior:

  • force
    • true: the sidebar is uncollapsed
    • false: the sidebar is collapsed
  • noTransition
    • true: turn off menu transition animation
    • false: turn on menu transition animation (default behavior)
toggleSidebarEntry(entry, force);

Function managing the sidebar entry:

  • entry
    • menu entry that can expand or shrink its elements (<a> elements containing is-icon-expandable class)
  • force
    • true: entry is expanded
    • false: entry is shrinked
toggleSidebarEntries(force);

Function managing the sidebar entries:

  • force
    • true: all entries are expanded
    • false: all entries are shrinked
toggleToc(force);

Function managing the table of contents behavior:

  • force
    • true: the table of contents is uncollapsed
    • false: the table of contents is collapsed