Theme Singleton

Several utilities for handling global styling for your application.

Theme()

Example

//Change default focus colour of all classes.
 Theme.set({
    BaseFocus: {
       styles: {
          backgroundColor: '#c0de70'
       }
    }
 });

Methods

Fonts.add(name, file, formats) static

Add a font to the application.

Parameters:

NameTypeArgumentDescription
nameString

Font name.

fileString

Location to the font file.

formatsArrayoptional 

Default is ['eot', 'woff', 'truetype']

Fonts.has(name) static

Check if a certain font is available for the application

Parameters:

NameTypeDescription
nameString

Font name.

Fonts.remove(name) static

Remove a certain font from the application.

Parameters:

NameTypeDescription
nameString

Font name which to remove.

alias(alias, original)

Make a alias of a existing configuration

Parameters:

NameTypeDescription
aliasString

Name of the alias

originalString

ClassName of a existing configuration.

Example

//Set the styling of ControlTextButton to 'myClass'
 Theme.alias('myClass', 'ControlTextButton');

 var myClassPrototype = new MAF.Class({
    ClassName: 'myClass',
    Extends: MAF.element.Container
 });

get(name, key)

Retrieve a Theme configuration.

Parameters:

NameTypeArgumentDescription
nameString

Name of the configuration to retrieve.

keyStringoptional 

Specific subentry in the configuration to retrieve.

Example

//You can store extra things in the configuration besides styles.
 Theme.set({
    myClass: {
       styles: {
          width: 30
       },
       unchecked: FontAwesome.get(['square-o']),
       checked: FontAwesome.get(['check-square-o'])
    }
 });

 var isChecked = true;
 new MAF.element.Text({
    ClassName: 'myClass',
    label: Theme.get('myClass', (isChecked) ? 'checked' : 'unchecked')
 }).appendTo(this);

getStyles(controlname, state) → {Object}

Parameters:

NameTypeArgumentDefaultDescription
controlnameString

Name of the component.

stateStringoptional normal

If the control has styles configured for different states you can retrieve the configuration for a specific state only.

Returns:

Control configurations, if a state is found it only returns the styles for the specific state. If no state is found the normal styles are returned.

renderSkin(name, state, width, height, agrs)

If a renderskin method is defined in the Theme of the class, you can execute it with this method.

Parameters:

NameTypeArgumentDescription
nameString

Class skin you want to build.

stateString

State of the skin.

widthNumber

Width the skins needs to be.

heightNumber

Height the skin needs to be.

agrsObjectoptional 

Optional arguments.

set(blob)

Set a Theme configuration.

Parameters:

NameTypeDescription
blobObject

This can contain theme settings for several classes

Example

Theme.set({
    myClass: {
       styles: {
          backgroundColor: 'white',
          width: 'inherit',
          height: 52
       }
    }
 });

 var myClassPrototype = new MAF.Class({
    ClassName: 'myClass',
    Extends: MAF.element.Container
 });