Jump To:

  1. ui/theme-toggle.initializer
  2. ui/theme-toggle.defaults
  3. ui/theme-toggle.setDefaults(options)
  4. ui/theme-toggle.init()
  5. ui/theme-toggle.setupToggle(toggle)
    1. setupToggle~toggleState()
    2. setupToggle~onToggleClick()
    3. setupToggle~attachRemotes()
    4. setupToggle~cleanupRemotes()
    5. setupToggle~destroy()
  6. ui/theme-toggle~setState()
  7. ui/theme-toggle~resolveInitial() ⇒ String
  8. ui/theme-toggle~getMatchingThemeQuery() ⇒ String
  9. ui/theme-toggle~getNextThemeKey()
  10. ui/theme-toggle~getOtherThemes()
  11. ui/theme-toggle~concatThemeClasses()
  12. ui/theme-toggle~getStorageKey()

ui/theme-toggle

ui/theme-toggle.initializer

Theme Toggle Component Initializer

Kind: static constant of ui/theme-toggle

ui/theme-toggle.defaults

Default Options

  • Can be overridden using data-attributes

Kind: static constant of ui/theme-toggle

ui/theme-toggle.setDefaults(options)

Kind: static method of ui/theme-toggle

Param Type Description
options Object Change options used as default for dialogs, can then be overridden by data attribute settings on element

ui/theme-toggle.init()

Initialize everything in document

  • This will only initialize elements once, it is safe to call on page changes

Kind: static method of ui/theme-toggle

ui/theme-toggle.setupToggle(toggle)

Sets up a single toggle

Kind: static method of ui/theme-toggle

Param Type Description
toggle HTMLElement A toggle to be setup

setupToggle~toggleState()

Instance function to get the next theme in cycle

Kind: inner method of setupToggle

setupToggle~onToggleClick()

Handler for click for both toggle and remote toggles

Kind: inner method of setupToggle

setupToggle~attachRemotes()

Utility to attach remote handlers

  • Used initially and when page is modified

Kind: inner method of setupToggle

setupToggle~cleanupRemotes()

This only cleans up remotes that are still in DOM

  • For ones that have been removed we don't store any references to them

Kind: inner method of setupToggle

setupToggle~destroy()

Function to cleanup listeners and remove init attributes

Kind: inner method of setupToggle

ui/theme-toggle~setState()

Change the state of target/toggle

Kind: inner method of ui/theme-toggle

ui/theme-toggle~resolveInitial() ⇒ String

Function determines what the initial state is

  • Check OS preference, saved preference, or initialState depending on options

Kind: inner method of ui/theme-toggle
Returns: String - The resolved initial theme's key

ui/theme-toggle~getMatchingThemeQuery() ⇒ String

Check each theme for a matching media query

Kind: inner method of ui/theme-toggle
Returns: String - Matching theme key

ui/theme-toggle~getNextThemeKey()

Get the next key in the themes based on the currentKey

Kind: inner method of ui/theme-toggle

ui/theme-toggle~getOtherThemes()

Get all other theme object except the current

Kind: inner method of ui/theme-toggle

ui/theme-toggle~concatThemeClasses()

Concatenates multiple class properties into one array

Kind: inner method of ui/theme-toggle

ui/theme-toggle~getStorageKey()

Creates the storage key (either prefix or prefix with group name)

Kind: inner method of ui/theme-toggle