class SAPO.Utility.Styler
Authors:
jose.p.dias AT co.sapo.pt
Version:
0.1 This class makes it easy to port static CSS rules so they apply only to a given element. It stores the element's id (or assigns it one if missing) It then creates a style element which it controls. One then must pass it rules assigned to sections. These rules get prefixed with the element's id and updated in the style element, When common browsers support scoped styles, these could be detected and used preferably: 'scoped' in document.createElement('style')
Since:
January 2013
Defined in Utility/Styler/0.1/lib.js

Constructor Summary
Styler (String|DOMElement idOrEl, [Boolean outputSectionComments])

Function Summary
addSection (String sectionName)
adds a new section to the style. sections get rendered in the order specified by the addSection(s) invocations.
addSections (String[] | String sectionNames)
allows adding several sections at once
appendToSection (String sectionName, String rules, [Boolean skipUpdate])
appends additional CSS rules to a section
setSection (String sectionName, String rules, [Boolean skipUpdate])
replaces the CSS rules assigned to a section

Constructor Details

constructor Styler

Styler(String|DOMElement idOrEl, [Boolean outputSectionComments])
Parameters:
idOrEl id of an element or the element itself
[outputSectionComments] set trueish value if you want the CSS rules to be prefix by a comment specifying the section name

Function Details

function addSection

addSection(String sectionName)
adds a new section to the style. sections get rendered in the order specified by the addSection(s) invocations.
Parameters:
sectionName name for the section to add

function addSections

addSections(String[] | String sectionNames)
allows adding several sections at once
Parameters:
sectionNames names for the sections. can be a space-separated string or array of strings

function appendToSection

appendToSection(String sectionName, String rules, [Boolean skipUpdate])
appends additional CSS rules to a section
Parameters:
sectionName name of the section. in inexistent, creates one
rules CSS rules to append to the section
[skipUpdate] use trueish value if you're calling setSection and appendToSections sequentially

function setSection

setSection(String sectionName, String rules, [Boolean skipUpdate])
replaces the CSS rules assigned to a section
Parameters:
sectionName name of the section. in inexistent, creates one
rules CSS rules to set to the section
[skipUpdate] use trueish value if you're calling setSection and appendToSections sequentially