Back

Theme Switcher Plugin for Emy

Please select a theme from the list below

Remember this theme Forget current theme

Theme Switcher plugin

Theme Switcher is a plugin for Emy. Its intend is to help you change which Emy theme you want to be used on-the-fly.

It comes as a javascript object, "theme-switcher.js" and installs itself in emy.plugin.

Variables

functions

emy.plugin.themeSwitcher.defaultTheme (String)

It is set once on load by init().

First link element in the header with a "title" attribute and "rel" attribute equals to "stylesheet".

Ex: "ios", "android"

emy.plugin.themeSwitcher.currentTheme (String)

It is set by init(), updated by setTheme().

This is the theme currently in use. By default, same as defaultTheme.

Ex: "ios", "android"

emy.plugin.themeSwitcher.themes (Array)

It will be set by init() and updated by addTheme() and removeTheme().

Selecting in the header all link elements with "rel" attribute value containing "stylesheet" and an existing title attribute.

Ex: array("iphone", "android", "webos")

emy.plugin.themeSwitcher.init (function)

Initialized on load.
no parameter

Selecting in the header all link elements with both a "rel" attribute value containing "stylesheet" and an existing title attribute and store their title attribute value in the themes array. If "stylesheet" attribute does not contain "alternate", both defaultTheme and currentTheme are defined.

emy.plugin.themeSwitcher.setTheme (function)

Set a theme by its title.
- title (string)

It disables all link elements with a "rel" attribute that contains "stylesheet" and a "title" attribute, and enable the one with the "title" attribute value equal to the title name given as a parameter.
It will also update currentTheme value to title name given as a parameter.

Ex: setTheme('android');

emy.plugin.themeSwitcher.setDefaultTheme (function)

Alias to setTheme(defaultTheme)
no parameter

Ex: "setDefaultTheme('ios')"

emy.plugin.themeSwitcher.rememberTheme (function)

Store the theme currently in use
no parameter

It stores currentTheme value in localStorage (if supported) as "emy-theme".
Note that init() will activate this theme over the default one.

Ex: emy.plugin.themeSwitcher.rememberTheme();

emy.plugin.themeSwitcher.addTheme (function)

Add a theme in the DOM.
- title (string)
- link (string)
- setIt (true/false - optional, default is false)

It adds a new link element in the header with "title" parameter value as "title" attribute value, and "link" parameter value as "href" attribute value. It also adds/pushes "title" parameter value to themes array. If setIt is defined as true, setTheme() will be activated with it using this new theme.
You can use absolute url as "link" value, theme doesn't have to be in emy/themes folder (but it would be cleaner).

Ex: emy.plugin.themeSwitcher.addTheme('nokia', 'main.css');

emy.plugin.themeSwitcher.removeTheme (function)

Remove a theme from the DOM.
- title (string)

It removes the "link" element in the header with "title" parameter value equal to "title" attribute value. It also removes it from the themes array.
If you remove the theme currently in use, setDefaultTheme will be used.

Ex: emy.plugin.themeSwitcher.addTheme('nokia', 'nokia-theme.css');