MooTools framework "Seven"-common: MooTools Construction Application of infrastructure class Common.js

Source: Internet
Author: User
Tags implement mootools

Description: Precisely because MooTools is based on OO ideas, the idea of OO is fully used in MooTools's own functions-inheritance and implementation. MooTools provides a set of basic functional classes: Chain,events,options,group, Then we can extend them to implement the functionality they provide in our classes. These basic functional classes are implemented by MooTools the AJAX,XHR and Fx.base classes that they provide.

Note: In general, chain,events and options are not used alone and will be extended by other classes (implement) to provide enhancements to these classes

1. Class: Chain

Function: Here the chain class organizes function into a chain structure.

Method:

Chain: Add a function to the chain

Callchain: The first function in the chain is executed and then deleted (the second function in the chain will change to a new

The top of the chain)

Clearchain: Clear all functions in chain

Example:

var c = new Chain (). Chain (function () {
Alert (' Func a! ');
}). Chain (function () {
Alert (' Func b! ');
}). Chain (function () {
Alert (' Func c! ');
});
C.callchain (); "Func a!"
C.callchain (); "Func b!"
C.callchain (); "Func c!"

2. Category: Events

Role: In layman's terms, it's actually like an event manager (everyone feels that most of the cases should be

Custom events). Other classes can implement it for their own event management.

Method:

Addevent: Adds a listener for the specified event to the organizer

FireEvent: Triggers the execution of all listener methods under the specified event

Removeevent: Removes the listener for the specified event from the organizer

Example:

var Evts = new Events ();
var fa = function (e) {
Alert (' aaaaaaa ');
};
var fb = function (e) {
Alert (' bbbbbbb ');
};
Evts.addevent (' onmyevent ', FA). Addevent (' MyEvent ', FB);
Evts.fireevent (' onmyevent '); First alert out "AAAAAAA", then alert out "BBBBBBB"
Evts.removeevent (' onmyevent ', FA);
Evts.fireevent (' onmyevent '); Alert out "BBBBBBB"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.