Home | Docs | Download

Classes


top

Global functions: Bicycle Core

Bicycle Core is the main collection of 3rd party functions. Credits go to (see source code for details):

Note: All of these functions are available in the Bicycle Chain wrapper, anyway this package is mantained for compatibility reasons and for those developers not needing chainability.

 

Field Summary
Field Attributes Field Name and Description
<static>
Custom events object
requires Bicycle Chain
 
ff js API (c) 2005 by Sven Helmberger ( sven dot helmberger at gmx dot de ) project homepage: http://fforw.de/post/ff_javascript_library/ available under a revised BSD-like library
Method Summary
Method Attributes Method Name and Description
DOM
 
$getEls(multiple)
Gets multiple elements by id.
 
getElements(tagName, opt)
Collects elements with options
 
$TN(tag, index, parent)
Shortcut to extract the first or the last element of an "elementsByTagName()" array.
Returns the first (if index is not defined) or last (if index is "last") element in the array of elements found inside the parent node.
 
$EN(name, index, parent)
Shortcut to extract the first or the last element of an "elementsByName()" array. Returns the first (if index is not defined) or last (if index is "last") element with given name attribute inside the parent node.
 
getNext(node)
Returns the next non-text element relative to the node element.
 
getPrev(node)
Returns the previous non-text element relative to the node element.
 
getText(el)
Gets the text inside a given element with no regards to childrens.
 
getElementsByClassName(className, tag, elm)
Gets an elements collection filtered by class name
Styles /Attributes
 
$S(el)
Shortcut to the .style of an element.
 
getStyle(element, property)
Returns the value of a specific style of an element.
 
getDimension(element)
Gets Element Dimensions.
 
getPosition(element, top, scrolling)
Returns an object with the position in px of an element relative to an ancestor.
 
getMousePosition(e, element)
Returns the position of your cursor, relative to an element.
 
changeDisplay(element)
Toggles element visibility (CSS display)
 
uniqueId(prefix)
Gets a unique id string for an element.
<static>  
ff.dom.setAttribute(e, a, v)
Crossbrowser method to set the value of the attribute of the given element. If element is a string it points to a defined element ID
<static>  
ff.dom.getAttribute(e, a)
Crossbrowser method which returns the value of the attribute of the given element. If element is a string it points to a defined element ID
DOM Manipulation
 
$E(data)
document.createElement convenience wrapper The data parameter is an object that must have the "tag" key, containing a string with the tagname of the element to create.
 
addDIV(id, parent, text)
Creates a new DIV element with given ID and appends it to the given AppendElement.
<static>  
ff.dom.clear(elem)
Removes all children from the given DOMElement
<static>  
ff.dom.replace(elem, newChildren)
Replaces the current children of the DOM element with the given child(ren)
<static>  
ff.dom.append(elem, c)
Appends the given child(ren) to the children of the given DOM element
 
insertAfter(parent, node, referenceNode)
Inserts the node element inside the parent node and after a reference node.
Events Handling
 
addHandler(element, types, handler)
Attaches specified event(s) function to passed in element(s)
 
removeHandler(element, types, handler)
Removes an event handler.
Utilities: Strings
 
camelCase(string)
Converts a hyphenate string to camelcase.
Utilities: Array
 
isArray(object)
Checks if the passed in object is an Array.
Utilities: Object
 
extendObject(destination, source)
Extends the destination Object with passed in source Object.
 
getLength(object)
Gets the number of an Object's properties.
 
$merge(obj)
Merges a number of objects recursively without referencing them or their sub-objects.
requires Bicycle Chain
Utilities: General
 
Browser sniffer.
 
$defined(obj)
Checks if the passed in value/object is defined
requires Bicycle Chain
 
$type(obj)
Returns the type of object that matches the element passed in.
requires Bicycle Chain
Field Detail
$b.events

Custom events object


See:
$b.on

ff.dom

ff js API (c) 2005 by Sven Helmberger ( sven dot helmberger at gmx dot de )

project homepage: http://fforw.de/post/ff_javascript_library/ available under a revised BSD-like library

Author: Sven Helmberger ( sven dot helmberger at gmx dot de ).

 

Method Detail
{DOMElement|Array} $getEls(multiple)
Get multiple elements by id.
		<div id="myDiv"></div>
<div id="my2ndDiv"></div> $getEls("myDiv"); //returns a reference to myDiv $getEls("myDiv",DOMElementReference); // returns [myDiv,DOMElementReference]
Parameters:
{String[]|DOMElement[]} multiple
elements id or element reference
Returns:
{DOMElement|Array} Returns an element reference if a single argument is passed else an Array of elements references
See:
liberty - Basic JavaScript Library 0.1

{Array} getElements(tagName, opt)
Collects elements with options

Author: Marco Solazzi, inspired by Liberty getElements.
		// Get a list of all links, with class myClass. 
		var elements = getElements('a',{'class':'myClass'});

		// Get a list of all links, which have class myClass and a url that contains 'google'. 
		var elements2 = getElements('a',{'class':'myClass', 'href':/google/});

		// Get a list of all links, which have class myClass inside the element with id myId. 
		var elements2 = getElements('a',{'class':'myClass', parent:$getEls('myId')});
Parameters:
{String} tagName
Tag name to collect or '*' for all tags
{Object} opt Optional
attributes filter, specify html attribute and value as string or regular expression. Use '*' to just check attribute presence; You can pass a parent element by adding property 'parent' : DOMElement
Returns:
{Array} Returns an array of matched Elements

{DOMElement} $TN(tag, index, parent)
Shortcut to extract the first or the last element of an "elementsByTagName()" array.
Returns the first (if index is not defined) or last (if index is "last") element in the array of elements found inside the parent node.
If parent is not defined defaults to whole document.
Parameters:
{String} tag
Name of tags to collect
{String} index Optional
if "last" returns the last element of the array
{DOMElement} parent Optional
Parent element
Returns:
{DOMElement} Returns the first (if index is not defined) or last (if index is "last") element in the array

$EN(name, index, parent)
Shortcut to extract the first or the last element of an "elementsByName()" array.
Returns the first (if index is not defined) or last (if index is "last") element in the array of elements found inside the parent node.
If parent is not defined defaults to whole document.
Parameters:
{String} name
Name of elements to collect
{String} index Optional
if "last" returns the last element of the array
{DOMElement} parent Optional
Parent element
Returns:
Returns the first (if index is not defined) or last (if index is "last") element in the array

{DOMElement} getNext(node)
Returns the next non-text element relative to the node element.

Author: Ben Nadel.
Parameters:
{DOMElement} node
The reference node
Returns:
{DOMElement} The next non-text element relative to the node element
See:
http://www.bennadel.com/snippets/categories/4-Javascript-Library-snippets.htm

{DOMElement} getPrev(node)
Returns the previous non-text element relative to the node element.

Author: Ben Nadel.
Parameters:
{DOMElement} node
The reference node
Returns:
{DOMElement} The previous non-text element relative to the node element
See:
http://www.bennadel.com/snippets/categories/4-Javascript-Library-snippets.htm

{String} getText(el)
Gets the text inside a given element with no regards to childrens.
Parameters:
{DOMElement} el
Element containing the text
Returns:
{String} The text inside a given element with no regards to childrens
See:
http://www.thescripts.com/forum/thread596105.html

getElementsByClassName(className, tag, elm)
Gets an elements collection filtered by class name

Author: Robert Nyman, http://www.robertnyman.com.
Parameters:
{String} className
The class name
{String} tag Optional
Tag name
{DOMElement} elm Optional
Parent element
See:
http://code.google.com/p/getelementsbyclassname/

$S(el)
Shortcut to the .style of an element.
Note that, differently from GetStyle(), CSS properties use Javascript names: http://codepunk.hardwar.org.uk/css2js.htm

		//Set the backgrond color of an element with ID “myId” to “#FFFF00”
		$S(“myId”).backgroundColor = “#FFFF00”;
Parameters:
{DOMElement|String} el
Element reference or ID string

{String} getStyle(element, property)
Returns the value of a specific style of an element.
		//Get the backgrond color of an element with ID "myId"
     getStyle("myId", "background-color");
Parameters:
{DOMElement|String} element
Could be an element reference or a ID string
{String} property
The name of the CSS property
Returns:
{String} The CSS style value
See:
liberty - Basic JavaScript Library 0.1

{Object} getDimension(element)
Gets element dimensions.
		//Get dimensions of element with id 'what'
		var dim = getDimension('what');
 	alert('Dimensions:'+dim.width+' x '+dim.height);
Parameters:
{DOMElement|String} element
An element reference or a id String
Returns:
{Object} Returns an object with real width and height of a HTML element in px.
See:
liberty - Basic JavaScript Library 0.1

{Object} getPosition(element, top, scrolling)
Returns an object with the position in px of an element relative to an ancestor.

		var position = getPosition('elementId', $('anchestorId'));
		alert('Position: '+position.x+', '+position.y);
Parameters:
{DOMElement|String} element
Element Reference or ID string
{DOMElement|String} top Optional, Default: "document.body"
Ancestor of passed in element. If not defined defaults to
{Bool} scrolling Optional
Defines if the scrolling inside of elements should be subtracted (default: true - better for absolute positioning).
Returns:
{Object} Object with x and y keys
See:
liberty - Basic JavaScript Library 0.1

{Object} getMousePosition(e, element)
Returns the position of your cursor, relative to an element. You have to set an event as first argument.
		// alert mouse position when clicking on a specified element
		addHandler($('elementId'),'click',function (e) {
			var position = getMousePosition(e,this);
			alert('Mouse Position: '+position.x+', '+position.y);
		});
Parameters:
{Object} e
Event reference
{DOMElement|String} element Optional
A reference element, either DOM element or ID string
Returns:
{Object} Object with x and y keys
See:
liberty - Basic JavaScript Library 0.1

{String} changeDisplay(element)
Toggles element visibility (CSS display property )
Parameters:
{DOMElement|String} element
Element to show or hide
Returns:
{String} CSS display property value
See:
liberty - Basic JavaScript Library 0.1

{String} uniqueId(prefix)
Gets na unique id string for an element.
Parameters:
{String} prefix
Prefix for the id
Returns:
{String} Returns a unique string formed by prefix+number (starting from 0), prefix defaults to “id”.
See:
liberty - Basic JavaScript Library 0.1

<static> ff.dom.setAttribute(e, a, v)
Crossbrowser method to set an attribute's value (a,v) for a given element (e).
If element is a string it points to a defined element ID
Parameters:
{String|DOMEelent} e
Element reference or ID string
{String} a
Attribute to set
{String} v
Attribute value
 
See:
ff javascript library 1.11

<static> ff.dom.getAttribute(e, a)
Crossbrowser method which to retrieve an attribute's value (a) from an element (e).
If element is a string it points to a defined element ID
Parameters:
{String|DOMEelent} e
Element reference or ID string
{String} a
Attribute to retrieve
See:
ff javascript library 1.11

{Element} $E(data)

document.createElement convenience wrapper.
The data parameter is an object that must have the "tag" key, containing a string with the tag's name of the element to create.
It can optionally have a "children" key which can be:

Any other key is taken as an attribute to be applied to this tag.


		 var element=$E({
		    tag:'div',
		    className:'toolGroup',
		    id:'toolGroup_1',
		    children:{
		        tag:'div',
		        className:'roundBarTop',
		        children:[{
		            tag:'div',
		            className:'leftEdge'
		        },{
		            tag:'div',
		            className:'rightEdge'
		        },{
		            tag:'div',
		            className:'heading',
		            children:[{
		                tag:'a',
		                className:'collapser'
		            },
		                'Group Heading'
		            ]
		        }]
		    }
		});
Parameters:
{Object} data
The data representing the element to create
Returns:
{Element} The element created.
See:
http://programming.arantius.com/dollar-e

{DOMElement} addDIV(id, parent, text)
Creates a new DIV element with given ID and appends it to the given parent.
		
addDIV('child','parentEl','this is a test'); // returns
this is a test
Parameters:
{String} id
The ID of the new DIV
{DOMElement|String} parent Optional
Parent container Element, either an element reference or ID string
{String} text Optional
Text to insert in the new DIV
Returns:
{DOMElement} the new DIV element

<static> ff.dom.clear(elem)
Removes all children elements of the given element.
Parameters:
{DOMElement} elem
The DOM element
See:
ff javascript library 1.11

<static> ff.dom.replace(elem, newChildren)
Replaces the current children of the DOM element with the given child(ren)
Parameters:
{DOMElement} elem
The DOM element
{DOMElement|Array} newChildren
The new child/children
 
See:
ff javascript library 1.11

<static> ff.dom.append(elem, c)
Appends the given child(ren) to the children of the given DOM element
Parameters:
{DOMElement} elem
The DOM element
{DOMElement|Array} e
The child/children elements
See:
ff javascript library 1.11

insertAfter(parent, node, referenceNode)
Inserts the node element inside the parent node and after a reference node.
Parameters:
{DOMElement} parent
The parent node
{DOMElement} node
The Element to insert inside the parent
{DOMElement} referenceNode Optional
The node after which insert passed in node
See:
http://www.dustindiaz.com/top-ten-javascript/

{Bool} addHandler(element, types, handler)
Attaches specified event(s) function to passed in element(s)
		// Fire the function “tryMe()” when clicking on the element with ID “myId”
		addHandler('myId', 'click', tryMe);

		// Set the links title attribute of the document to show the query of each Google link
     var elements = getElements('a',{'href':/google/i});

		//now add an event handler function to those elements
		// - for the events 'mouseover' and 'mouseout'
      var changeTitle = function(event) {
      	if (event.type == 'mouseover') {
     		document._title = document.title;
      		document.title = this.href;
      	}
      	else if (event.type == 'mouseout') {
      		document.title = document._title;
      	}
      }

		addHandler(elements, ['mouseover', 'mouseout'], changeTitle);
Parameters:
{Array|DOMElement|String} element
ID string reference, or DOM element reference. Either single or as array
{String|Array} types
Event type(s) without "on" prefix. Either single or as array
{Function} handler
Function to bind to element(s) on specified event(s)
Returns:
{Bool} Returns true if handler is a function
See:
liberty - Basic JavaScript Library 0.1

{Bool} removeHandler(element, types, handler)
Removes an event handler. If you let handler undefined, all handlers for the specified event types are removed.
		//Remove all link handlers from link elements: 
		removeHandler(getElements('a'), ['mouseover', 'mouseout']);
Parameters:
{Array|DOMElement|String} element
ID string reference, or DOM element reference. Either single or as array
{String|Array} types
Event type(s) without "on" prefix. Either single or as array
{Function} handler Optional
Function to bind to element(s) on specified event(s)
Returns:
{Bool} Returns true if handler is specified and is a function
See:
liberty - Basic JavaScript Library 0.1

{String} camelCase(string)
Converts a hyphenated string to camelcase.

Author: Valerio Proietti.

		camelCase("just-simple-test"); //returns justSimpleTest
Parameters:
{String} string
The string to convert
Returns:
{String} The converted string
See:
Mootools 1.0

{Bool} isArray(object)
Checks if the passed in object is an array.
		var myArray = ['apple', 'lemon', 'orange', 'banana']; alert(isArray(myArray));
		// will alert "true"
Parameters:
{Object} object
The object to check
Returns:
{Bool} Returns true if object is an array
See:
liberty - Basic JavaScript Library 0.1

{Object} extendObject(destination, source)
Extends the destination Object with passed in source Object.

		extendObject(String.prototype, {
			escapeXML: function() {
				// function code ...
			},
			unescapeXML: function() {
				// function code ...
			}
		});
Parameters:
{Object} destination
The object to extend
{Object} source
The object to use for extension
Returns:
{Object} The Extended object
See:
liberty - Basic JavaScript Library 0.1

{Number} getLength(object)
Gets the number of an Object's properties.
Parameters:
{Object} object
The passed in object
Returns:
{Number} Returns the number of an Object's properties
See:
liberty - Basic JavaScript Library 0.1


{Object} $merge(obj)
Merges a number of objects recursively without referencing them or their sub-objects.

Author: Valerio Proietti (from MooTools 1.11).
Parameters:
{Object} obj
Any number of objects
Returns:
{Object} Merged object

{Bool} $browser

Browser sniffer.

Possible browser match:

Returns:
{Bool} Returns true if browser matches.
See:
http://www.sitomega.net/projects/extendDOM/main.php

{Bool} $defined(obj)
Checks if the passed in value/object is defined

Author: Valerio Proietti (from MooTools 1.11).
Parameters:
{Object} obj
Any type of variable to check
Returns:
{Bool} Returns true if the passed in value/object is defined, that means is not null or undefined.

{String|Bool} $type(obj)
Returns the type of object that matches the element passed in.

Author: Valerio Proietti (from MooTools 1.11).

	var myString = 'hello';
	$type(myString); //returns "string"
Parameters:
{Object} obj
Any type of variable
Returns:
{String|Bool}

Documentation generated by JsDoc Toolkit 2.1.0 on Thu Mar 12 2009 21:32:34 GMT+0100 (CET)