Section 11.4. Element Extensions


11.4. Element Extensions

Defined in effects.js except where noted. All of these methods (except where noted) are added to Prototype's Element.Methods object, which is automatically mixed in to all DOM elements accessed via Prototype's $( ) or $$( ) functions. When used as a mix-in, the element argument is omitted. For example, these two are equivalent:

Element.collectTextNodes('target') $('target').collectTextNodes(  )


collectTextNodes( element )

Returns all the text nodes that are children of element, concatenated into one string.

// <div ><div>one</div><div>two</div></div> Element.collectTextNodes('target') // => 'onetwo'


collectTextNodesIgnoreClass( element, className )

Returns all the text nodes that are children of element, except for those nodes with the class className, concatenated into one string.

// <div ><div >one</div><div>two</div></div> Element.collectTextNodesIgnoreClass('target', 'a') // => 'two'


setContentZoom( element, percent )

Sets the zoom level of element to percent by changing the font size style.

// Double text size Element.setContentZoom('target', 200)


getOpacity( element )

Returns the opacity of element as a float value between 1 (opaque) and 0 (transparent).

Element.getOpacity('target') // => 1


setOpacity( element, value )

Sets the opacity of element to value, which should be between 1 and 0.

// Make 50% transparent Element.setOpacity('target', 0.5)


getInlineOpacity( element )

Returns element's inline opacity property (ignoring any property set in an external stylesheet) or an empty string if not available.

Element.getInlineOpacity('target');


childrenWithClassName( element, className[, findFirst] )

Returns all child elements of element whose class matches className. If findFirst istrue, only returns the first element.

// Returns all elements with class 'green' Element.childrenWithClassName('container', 'green') // Returns just the first child with class 'green' Element.childrenWithClassName('container', 'green', true)


forceRerendering( element )

Adds and then removes a text node consisting of a space character to element, causing it to be re-rendered.

Element.forceRerendering('target');


visualEffect( element, effect[, options] )

Creates a new effect object for the given element. Returns the element with ID element. Note that this method expects effect to be lowercase, with underscores rather than camelCase.

Returns element, enabling method calls to be chained.

$('target').visualEffect('blind_up').visualEffect('fade');


isParent( child, element )

Defined in dragdrop.js; not mixed in to Element.Methods. Returns true if child is contained within element.

Element.isParent($('target'), $('container'));


findChildren( element, only, recursive, tagName )

Defined in dragdrop.js; not mixed in to Element.Methods. Returns all child elements of element named tagName, optionally limited to those with class names in only. If recursive, searches all descendents.

Element.findChildren($('container'), null, false, 'div'); Element.findChildren($('container'), 'green', false, 'div') Element.findChildren($('container'), ['green','pink'], false, 'div')


offsetSize( element, type )

Defined in dragdrop.js; not mixed in to Element.Methods. If type is vertical or height, return's element's offset height. Otherwise, returns its offset width.

Element.offsetSize($('target'), 'vertical') Element.offsetSize($('target'));




Ajax on Rails
Ajax on Rails
ISBN: 0596527446
EAN: 2147483647
Year: 2006
Pages: 103
Authors: Scott Raymond

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net