the compact javascript framework
in partnership with mediatemple
Mootools | My Object Oriented javascript. |
MIT-style license.
copyright © 2007 Valerio Proietti, https://github.com/kamicane
Core.js | |
Core Functions | |
Functions | |
$defined | Returns true if the passed in value/object is defined, that means is not null or undefined. |
$type | Returns the type of object that matches the element passed in. |
$merge | merges a number of objects recursively without referencing them or their sub-objects. |
$extend | Copies all the properties from the second passed object to the first passed Object. |
$native | Will add a .extend method to the objects passed as a parameter, but the property passed in will be copied to the object’s prototype only if non previously existent. |
$chk | Returns true if the passed in value/object exists or is 0, otherwise returns false. |
$pick | Returns the first object if defined, otherwise returns the second. |
$random | Returns a random integer number between the two passed in values. |
$time | Returns the current timestamp |
$clear | clears a timeout or an Interval. |
Abstract | Abstract class, to be used as singleton. |
window | Some properties are attached to the window object by the browser detection. |
Functions | |
$defined | Returns true if the passed in value/object is defined, that means is not null or undefined. |
$type | Returns the type of object that matches the element passed in. |
$merge | merges a number of objects recursively without referencing them or their sub-objects. |
$extend | Copies all the properties from the second passed object to the first passed Object. |
$native | Will add a .extend method to the objects passed as a parameter, but the property passed in will be copied to the object’s prototype only if non previously existent. |
$chk | Returns true if the passed in value/object exists or is 0, otherwise returns false. |
$pick | Returns the first object if defined, otherwise returns the second. |
$random | Returns a random integer number between the two passed in values. |
$time | Returns the current timestamp |
$clear | clears a timeout or an Interval. |
Returns true if the passed in value/object is defined, that means is not null or undefined.
obj | object to inspect |
Returns the type of object that matches the element passed in.
obj | the object to inspect. |
var myString = 'hello'; $type(myString); //returns "string"
’element’ | if obj is a DOM element node |
’textnode’ | if obj is a DOM text node |
’whitespace’ | if obj is a DOM whitespace node |
’arguments’ | if obj is an arguments object |
’object’ | if obj is an object |
’string’ | if obj is a string |
’number’ | if obj is a number |
’boolean’ | if obj is a boolean |
’function’ | if obj is a function |
’regexp’ | if obj is a regular expression |
’class’ | if obj is a Class. (created with new Class, or the extend of another class). |
’collection’ | if obj is a native htmlelements collection, such as childNodes, getElementsByTagName .. etc. |
false | (boolean) if the object is not defined or none of the above. |
function $merge()
merges a number of objects recursively without referencing them or their sub-objects.
any number of objects.
var mergedObj = $merge(obj1, obj2, obj3); //obj1, obj2, and obj3 are unaltered
var $extend = function()
Copies all the properties from the second passed object to the first passed Object. If you do myWhatever.extend = $extend the first parameter will become myWhatever, and your extend function will only need one parameter.
var firstOb = { 'name': 'John', 'lastName': 'Doe' }; var secondOb = { 'age': '20', 'sex': 'male', 'lastName': 'Dorian' }; $extend(firstOb, secondOb); //firstOb will become: { 'name': 'John', 'lastName': 'Dorian', 'age': '20', 'sex': 'male' };
The first object, extended.
var $native = function()
Will add a .extend method to the objects passed as a parameter, but the property passed in will be copied to the object’s prototype only if non previously existent. Its handy if you dont want the .extend method of an object to overwrite existing methods. Used automatically in MooTools to implement Array/String/Function/Number methods to browser that dont support them whitout manual checking.
a number of classes/native javascript objects
Returns true if the passed in value/object exists or is 0, otherwise returns false. Useful to accept zeroes.
obj | object to inspect |
Returns the first object if defined, otherwise returns the second.
obj | object to test |
picked | the default to return |
function say(msg){ alert($pick(msg, 'no meessage supplied')); }
Returns a random integer number between the two passed in values.
min | integer, the minimum value (inclusive). |
max | integer, the maximum value (inclusive). |
a random integer between min and max.
clears a timeout or an Interval.
null
timer | the setInterval or setTimeout to clear. |
var myTimer = myFunction.delay(5000); //wait 5 seconds and execute my function. myTimer = $clear(myTimer); //nevermind
Abstract class, to be used as singleton. Will add .extend to any object
an object
the object with an .extend property, equivalent to $extend.
Some properties are attached to the window object by the browser detection.
browser detection is entirely object-based. We dont sniff.
window.ie | will be set to true if the current browser is internet explorer (any). |
window.ie6 | will be set to true if the current browser is internet explorer 6. |
window.ie7 | will be set to true if the current browser is internet explorer 7. |
window.gecko | will be set to true if the current browser is Mozilla/Gecko. |
window.webkit | will be set to true if the current browser is Safari/Konqueror. |
window.webkit419 | will be set to true if the current browser is Safari2 / webkit till version 419. |
window.webkit420 | will be set to true if the current browser is Safari3 (Webkit SVN Build) / webkit over version 419. |
window.opera | is set to true by opera itself. |
Documentation by Aaron Newton & Mootools Developers, generated by NaturalDocs and GeSHi