API/libsapojs/SAPO/Dom/Css

[Elements] are optional

Class SAPO.Dom.Css


class SAPO.Dom.Css
Defined in Dom/Css/0.1/lib.js

Function Summary
addClassName (DOMElement|String elm, String class)
add a class to a given element
appendStyleTag (String selector, String style, Object options)
Adds css style tags to the head section of a page
appendStylesheet (String path, Object options)
Adds a link tag for a stylesheet to the head section of a page
converts decimal to hexadecimal values, for use with colors
String getStyle (DOMElement|String elm, String style)
Gets the value for an element's style attribute
Boolean hasClassName (DOMElement|String elm, String class)
Number hexToDec (String hex)
converts hexadecimal values to decimal, for use with colors
hide (DOMElement|String elm)
Hides an element
removeClassName (DOMElement|String elm, String class)
removes a class from a given element
setOpacity (DOMElement|String elm, Number value)
sets the opacity of given client a given element
setStyle (DOMElement|String elm, String style)
Sets the value for an element's style attribute
show (DOMElement|String elm)
Makes an element visible
toggle (DOMElement|String elm, Boolean forceShow)
Shows or hides an element depending on current state
toggleClassName (DOMElement|String elm, String className, Boolean forceAdd)
add or remove a class name from a given element

Function Details

function addClassName

addClassName(DOMElement|String elm, String class)
add a class to a given element
Parameters:
elm - DOM element or element id
class name

function appendStyleTag

appendStyleTag(String selector, String style, Object options)
Adds css style tags to the head section of a page
Parameters:
selector - The css selector for the rule
style - The content of the style rule
options - Options for the tag
  • String type - file type
  • Boolean force - if true, style tag will be appended to end of head

function appendStylesheet

appendStylesheet(String path, Object options)
Adds a link tag for a stylesheet to the head section of a page
Parameters:
path - File path
options - Options for the tag
  • String media - media type
  • String type - file type
  • Boolean force - if true, tag will be appended to end of head

function decToHex

String decToHex(String dec)
converts decimal to hexadecimal values, for use with colors
Parameters:
dec - Either a single decimal value , an rgb(r, g, b) string or an Object with r, g and b properties
Returns:
Hexadecimal value

function getStyle

String getStyle(DOMElement|String elm, String style)
Gets the value for an element's style attribute
Parameters:
elm - DOM element or element id
style - Which css attribute to fetch
Returns:
Style value

function hasClassName

Boolean hasClassName(DOMElement|String elm, String class)
Parameters:
elm - DOM element or element id
class name
Returns:
true if a given class is applied to a given element

function hexToDec

Number hexToDec(String hex)
converts hexadecimal values to decimal, for use with colors
Parameters:
hex - hexadecimal value with 6 or 2 characters
Returns:
Decimal value

function hide

hide(DOMElement|String elm)
Hides an element
Parameters:
elm - DOM element or element id

function removeClassName

removeClassName(DOMElement|String elm, String class)
removes a class from a given element
Parameters:
elm - DOM element or element id
class name

function setOpacity

setOpacity(DOMElement|String elm, Number value)
sets the opacity of given client a given element
Parameters:
elm - DOM element or element id
value - allows 0 to 1(default mode decimal) or percentage (warning using 0 or 1 will reset to default mode)

function setStyle

setStyle(DOMElement|String elm, String style)
Sets the value for an element's style attribute
Parameters:
elm - DOM element or element id
style - Which css attribute to set

function show

show(DOMElement|String elm)
Makes an element visible
Parameters:
elm - DOM element or element id

function toggle

toggle(DOMElement|String elm, Boolean forceShow)
Shows or hides an element depending on current state
Parameters:
elm - DOM element or element id
forceShow - Forces showing if element is hidden

function toggleClassName

toggleClassName(DOMElement|String elm, String className, Boolean forceAdd)
add or remove a class name from a given element
Parameters:
elm - DOM element or element id
className - class name
forceAdd - forces the addition of the class if it doesn't exists