Skip to content

Instantly share code, notes, and snippets.

@kamicane
Created March 14, 2009 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamicane/79175 to your computer and use it in GitHub Desktop.
Save kamicane/79175 to your computer and use it in GitHub Desktop.

MooTools 1.3dev CheatSheet

Legend

Object:method

method is a prototype of Object

Object.method

method is an Object generic

Object::method

method is both a prototype and a generic of object

function(type)

the function accepts an argument of type type

function(item:type)

the function accepts an argument named item of type type

function(item:type || item:type)

the function accepts an argument named item of type type or an argument named item of type type

function(type?)

the argument of type type is not mandatory

function(type, type?, …)

the function accepts any number of arguments of type type after the first one

function() » function(type)

the function returns a function that has an argument of type type passed as arguments

function() » {key: type}

the function returns an object that has a key named key with a value of type type

function() » this

the function returns this

function() » self

the function returns its first argument (often with generics)

Core

nil(*) » boolean

valueOf(*) » *.valueOf()
typeOf(*) » type:string || null
instanceOf(*, function || class || native) » boolean || null
constructorOf(*) » object || null

UID.uidOf(*) » uid:string
UID.itemOf(uid:string) » *

Type.is*()

Native

Native:extend((key:string, value:*) || (properties:object)) » this
Native:implement((key:string, value:*) || (properties:object)) » this
Native:mirror(native || mirror:function) » this

Table (Native)

new Table() » this

Table:set(key:*, value:*) » this
Table:get(key:*) » value:*
Table:erase(key:*) » value:*
Table:each(iterator:function, context:*?) » this

Array (Native)

Array.from(*) » array

Array::each(iterator:function, context:*?) » this
Array::filter(iterator:function, context:*?) » filtered:array
Array::indexOf(item:*) » index:number
Array::map(iterator:function, context:*?) » mapped:array
Array::every(iterator:function, context:*?) » boolean
Array::some(iterator:function, context:*?) » boolean
Array::clean() » this
Array::call(method:string, arguments:*?) » array
Array::append(enumerable) » this
Array::contains(item:*) » boolean
Array::last() » item:*
Array::random() » item:*
Array::include(item:*) » this
Array::combine(enumerable) » this
Array::erase(item:*) » item:*
Array::empty() » this
Array::flatten() » array

Object

Object.from(keys:*, values:*) » object
Object.pick(item:*, item:*?, …) » item:* || null

Object.has(self:object, key:string) » boolean
Object.each(self:object, function, *?) » self
Object.append(self:object) » self
Object.beget(self:object) » object
Object.clone(self:object) » object
Object.mixin(self:object, object?, …) » self
Object.map(self:object, iterator:function, context:*?) » mapped:object
Object.filter(self:object, iterator:function, context:*?) » filtered:object
Object.every(self:object, iterator:function, context:*?) » boolean
Object.some(self:object, iterator:function, context:*?) » boolean
Object.keys(self:object) » keys:array
Object.values(self:object) » values:array

Function (Native)

Function.from(*) » function

Function.argument(index:number) » function
Function.clear(interval || timeout) » null
Function.stab(function, function?, …) » function() || null

Function::extend((key:string, value:*) || (properties:object)) » this
Function::implement((key:string, value:*) || (properties:object)) » this

Function::attempt(arguments:*, context:*?) » this() || null
Function::bind(context:*, arguments:*?) » function
Function::bindWithEvent(context:*, arguments:*?) » function
Function::delay(delay:number, context:*?, arguments:*?) » timeout
Function::pass(arguments:*, context:*?) » function
Function::periodical(number, context:*?, arguments:*?) » interval
Function::run(arguments:*, context:*?) » this.apply(context:*, arguments:*)

String (Native)

String.from(*) » string

String.exec(script:string) » script:string

String:stripScripts() » this
String::test(regexp || string, parameters:string?) » boolean
String::contains(string) » boolean
String::trim() » trimmed:string
String::clean() » clean:string
String::camelCase() » camelcased:string
String::hyphenate() » hyphenated:string
String::capitalize() » capitalized:string
String::substitute(object, regexp?) » substituted:string

Number (Native)

Number.random(min:number, max:number) » random:number
Number.toInteger(*) » integer:number
Number.toFloat(*) » float:number

Number::limit(min:number, max:number) » limited:number
Number::round(precision:number?) » rounded:number
Number::times(iterator:function, context:*?) » this

Element (Native) » (Implements Storage, Accessors, Events)

new Element(tag:string, properties:object?) » element

Document:id(id:string || element) » element

new Elements(elements:array) » elements

Elements:filter(iterator:function || match:string, context:*) » elements

Document:newElement(tag:string, properties:object?) » element
Document:newTextNode(text:string) » textnode

Document | Element Search

(Element::find || Document:find || $)(selector:string || element) » element
(Element::search || Document:search || $$)(selector:string) » elements

Element::match(selector:string) » boolean

Element Manipulation

Element::inject(element, "before" || "after" || "top" || "bottom" ? "bottom") » this
Element::grab(element,  "before" || "after" || "top" || "bottom" ? "bottom") » this
Element::wrap(element,  "before" || "after" || "top" || "bottom" ? "bottom") » this

Element::replaces(element) » this
Element::adopt((element || elements || array), (element || elements || array)?, …) » this
Element::dispose() » this

Element Storage

Element::store((key:string, value:*) || (properties:object)) » this
Element::retrieve(key:string || keys:array) » value:* || values:object
Element::dump(key:string || keys:array) » value:* || values:object

Element Getters and Setters

Element.defineGetter(key:string, getter:function) » Element
Element.defineSetter(key:string, setter:function) » Element

Element::set((key:string, value:*) || (properties:object)) » this
Element::get(key:string || keys:array) » value:* || values:object

Element::set("text", text:string) » this
Element::set("html", (html:string || html:array)) » this
Element::set("class", class:string) » this
Element::set("css", css:string) » this

Element::get("html") » html:string
Element::get("tag") » tag:string
Element::get("text") » text:string
Element::get("class") » classes:string
Element::get("css") » css:string

Element Style

Element.defineStyleGetter(key:string, getter:function) » Element
Element.defineStyleSetter(key:string, setter:function) » Element

Element::setStyle((key:string, value:*) || (properties:object)) » this
Element::getStyle(key:string || keys:array) » style:* || styles:object

Element | Document | Window Events

(Element || Document || Window).definePseudoEvent(event, argument:string) » (Element || Document || Window)
(Element || Document || Window).defineEventModifier(action:function, remove:boolean) » (Element || Document || Window)

(Element || Document || Window)::addEvent((type:string, event:function) || object) » this
(Element || Document || Window)::removeEvent((type:string, event:function) || object) » this
(Element || Document || Window)::removeEvents(type:string || types:array) » this
(Element || Document || Window)::fireEvent((type:string, event:function) || object) » this

(Element || Document)::observe(("type(selector)":string, event:function) || object) » this
(Element || Document)::overlook(("type(selector)":string, event:function) || object) » this

(Element || Document) event mouseenter
(Element || Document) event mouseleave
(Element || Document) event mousewheel

(Window || Document) event mousewheel

Element Dimensions

Element::getPosition
Element::setPosition
Element::scrollTo
Element::getSize
Element::getScrollSize
Element::getScroll
Element::getScrolls
Element::getOffsetParent
Element::getOffsets
Element::getCoordinates

Mixins (can be implemented / extended in any object / class / function / native)

Storage (Native)

new Storage() » storage

Storage::store((key:string, value:*) || (properties:object)) » this
Storage::retrieve((key:string, value:*) || (properties:object)) » value:*
Storage::dump(key:string || keys:array) value:* || values:object

Events (Native)

new Events() » events

Events::addEvent((type:string, event:function) || object) » this
Events::removeEvent((type:string, event:function) || object) » this
Events::removeEvents(type:string || types:array) » this
Events::fireEvent((type:string, event:function) || object) » this

Accessors (Native)

new Accessors() » accessors

Accessors::defineGetter(key:string, getter:function) » this
Accessors::defineSetter(key:string, setter:function) » this
Accessors::lookupGetter(key:string) » this
Accessors::lookupSetter(key:string) » this

Options (Native)

new Options() » options

Options::setOption((key:string, value:*) || (properties:object)) » this
Options::getOption(key:string || keys:array) » value:* || values:object

Chain (Native)

new Chain() » chain

Chain::chain(function, function, …) » this
Chain::callChain() » this
Chain::clearChain() » this

Class (Native)

new Class class

this.parent / method.protect

Class mutator Extends
Class mutator Implements

Class:implement((key:string, value:*) || (properties:object)) » this

Browser

Browser.Engine.name » name:string
Browser.Engine.version » version:number

Browser.Plugins.Flash.version » version:number
Browser.Plugins.Flash.build » build:number

Event (Implements Accessors)

new Event() » event

Event:stop() » this
Event:stopPropagation() » this
Event:preventDefault() » this

Event:get(key:string || keys:array) » value:*

Event.defineGetter(key:string, getter:function) » Event

Event:get("type") » string
Event:get("client") » {x: number, y: number}
Event:get("page") » {x: number, y: number}
Event:get("target") » element
Event:get("related-target") » element
Event:get("key") » string
Event:get("shift") » boolean
Event:get("control") » boolean
Event:get("alt") » boolean
Event:get("meta") » boolean
Event:get("right-click") » boolean
Event:get("wheel") » number

Effects

Fx (Class) (Implements Events, Options, Chain)

new Fx(options:object) object

Fx.setFPS(fps:number) » Fx

Fx:start(from:number, to:number) » this
Fx:cancel() » this
Fx:pause() » this
Fx:resume() » this

Events

onStart
onComplete
onCancel
onChainComplete

Fx.Tween (Class) (Extends Fx)

new Fx.Tween() » object

Fx.Tween:start((from:*, to:*) || to:*) » this

Element::set("tween", options:object) » this
Element::get("tween") » tween:object

Element::fade(("in" || "out" || "toggle") || (from:number, to:number) || to:number) » this
Element::tween(property:string, from:number, to:number) » this
Element::highlight((from:color, to:color) || to:color) » this

Fx.Morph (Class) (Extends Fx)

new Fx.Morph(element, options:object?) » object

Fx.Morph:start(properties:object) » this

Element::set("morph", options:object) » this
Element::get("morph") » morph:object

Element::morph(properties:object) » this

Request

Request (Class) (Implements Chain, Options, Events)

new Request(options:object) » object

Request:send
Request:cancel
Request:post
Request:get

Element::set("send", options:object) » this
Element::get("send") » tween:object

Element::Send

Events

onComplete
onSuccess
onException
onRequest
onCancel

Request.HTML (Class) (Extends Request)

Element::set("load", options:object) » this
Element::get("load") » load:object

Element::load

Request.JSON (Class) (Extends Request)

Slick

Public API

slick(context:node, expression:string || node) » nodes:array

slick.getAttribute » overridden with Element::get
slick.uidOf(node) » uid:string
slick.contains(context:node, node) » boolean
slick.match(node, match:string) » boolean

slick.definePseudoSelector(key:string, pseudo:function) » slick
slick.lookupPseudoSelector(key:string) » pseudo:function

Tag Name

tag

ID

#id

Class Names

.class1.class2.class3…

Attributes

[name]
[name=value]
[name!=value]
[name^=value]
[name$=value]
[name*=value]
[name~=value]
[name|=value]

Pseudo Selectors

:checked
:empty
:not
:contains
:first-child
:last-child
:only-child
:nth-child

:index
:even
:odd

Combinators

" " » children
">" » direct children
"<" » parent nodes
"±" » previous siblings and next siblings
"»" » next siblings
"«" » previous siblings
"≥" » next sibling
"≤" » previous sibling
"^" » first child
"$" » last child
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment