Class Index | File Index

Classes


Namespace MochiKit.Style

Provides a painless CSS manipulation API.
Defined in: Style.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
<static>  
MochiKit.Style._evalConstraints(sc, ref)
Evaluates the size constraint functions with a refeence dimension object.
<static>  
MochiKit.Style._toPixels(value)
Converts a style pixel value to the corresponding integer.
<static>  
MochiKit.Style.adjustScrollOffset(node, box)
Adjusts the scroll offsets for an HTML DOM node to ensure optimal visibility for the specified coordinates box.
<static>  
MochiKit.Style.getBorderBox(node)
Returns the border widths for an HTML DOM node.
<static>  
MochiKit.Style.getPaddingBox(node)
Returns the padding sizes for an HTML DOM node.
<static>  
MochiKit.Style.getScrollOffset(node)
Returns the scroll offset for an HTML DOM node.
<static>  
MochiKit.Style.registerSizeConstraints(node, width, height, aspect)
Registers algebraic constraints for an element width, height and aspect ratio.
<static>  
MochiKit.Style.resetScrollOffset(node, recursive)
Resets the scroll offsets to zero for for an HTML DOM node.
<static>  
MochiKit.Style.resizeElements()
Resizes a list of DOM nodes using their parent element sizes and any registered size constraints.
<static>  
MochiKit.Style.setScrollOffset(node, offset)
Sets the scroll offset for an HTML DOM node.
Namespace Detail
MochiKit.Style
Method Detail
<static> {Object} MochiKit.Style._evalConstraints(sc, ref)
Evaluates the size constraint functions with a refeence dimension object. This is an internal function used to encapsulate the function calls and provide logging on errors.
Parameters:
{Object} sc
the size constraints object
{Object} ref
the MochiKit.Style.Dimensions maximum reference values
Returns:
{Object} the MochiKit.Style.Dimensions with evaluated size constraint values (some may be null)

<static> {Number} MochiKit.Style._toPixels(value)
Converts a style pixel value to the corresponding integer. If the string ends with "px", those characters will be silently removed.
Parameters:
{String} value
the style string value to convert
Returns:
{Number} the numeric value, or null if the conversion failed

<static> MochiKit.Style.adjustScrollOffset(node, box)
Adjusts the scroll offsets for an HTML DOM node to ensure optimal visibility for the specified coordinates box. This function will scroll the node both vertially and horizontally to ensure that the top left corner of the box is always visible and that as much of the box extent as possible is visible.
Parameters:
{Object} node
the HTML DOM node
{Object} box
the coordinates box with optional properties {l, t, r, b} or {x, y, w, h}

<static> {Object} MochiKit.Style.getBorderBox(node)
Returns the border widths for an HTML DOM node. The widths for all four sides will be returned.
Parameters:
{Object} node
the HTML DOM node
Returns:
{Object} an object with "t", "b", "l" and "r" properties, each containing either an integer value or null

<static> {Object} MochiKit.Style.getPaddingBox(node)
Returns the padding sizes for an HTML DOM node. The sizes for all four sides will be returned.
Parameters:
{Object} node
the HTML DOM node
Returns:
{Object} an object with "t", "b", "l" and "r" properties, each containing either an integer value or null

<static> {Object} MochiKit.Style.getScrollOffset(node)
Returns the scroll offset for an HTML DOM node.
Parameters:
{Object} node
the HTML DOM node
Returns:
{Object} a MochiKit.Style.Coordinates object with "x" and "y" properties containing the element scroll offset

<static> MochiKit.Style.registerSizeConstraints(node, width, height, aspect)
Registers algebraic constraints for an element width, height and aspect ratio. The constraints may either be fixed numeric values, functions or string formulas. The string formulas will be converted to JavaScript functions, replacing any "%" character with the parent reference value (i.e. the parent element width, height or aspect ratio). It is also possible to directly reference the parent values with the "w" and "h" variables. Any functions specified must take both the parent element width and height as arguments (possibly ignoring one or the other) and return a number. Any value returned when evaluating the functions or formulas will be bounded to the parent element size.
// To set width to 50% - 20 px & height to 100%
registerSizeConstraints(node, "50% - 20", "100%");
// To set a square aspect ratio
registerSizeConstraints(node, null, null, 1.0);
Parameters:
{Object} node
the HTML DOM node
{Number/Function/String} width Optional
the width constraint
{Number/Function/String} height Optional
the height constraint
{Number/Function/String} aspect Optional
the aspect ratio constraint

<static> MochiKit.Style.resetScrollOffset(node, recursive)
Resets the scroll offsets to zero for for an HTML DOM node. Optionally all child node offsets can also be reset.
Parameters:
{Object} node
the HTML DOM node
{Boolean} recursive Optional
the recursive flag, defaults to false

<static> MochiKit.Style.resizeElements()
Resizes a list of DOM nodes using their parent element sizes and any registered size constraints. The resize operation is recursive and will also be applied to all child nodes. If an element lacks a size constraint for either width or height, that size aspect will not be modified.
Parameters:
{Object} ... Optional
the HTML DOM nodes to resize
See:
registerSizeConstraints

<static> MochiKit.Style.setScrollOffset(node, offset)
Sets the scroll offset for an HTML DOM node.
Parameters:
{Object} node
the HTML DOM node
{Object} offset
the MochiKit.Style.Coordinates containing the new scroll offset "x" and "y" values

Documentation generated by JsDoc Toolkit 2.0.2 on Sun May 24 2009 13:14:16 GMT+0200 (CEST)