Mootools framework [2 to 10]

Source: Internet
Author: User
Tags mootools

Http://www.cnblogs.com/ziyiFly/category/153863.html (2-10)

Mootools framework [2]-core: main method test example
<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" %>

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> mootools-core </title>
<Script language = "JavaScript" type = "text/JavaScript" src = "mootools-1.2-core-jm.js"> </SCRIPT>
<Script language = "JavaScript" type = "text/JavaScript">
{
// 1. Create an object using the following form:
VaR cat = new class ({
Initialize: function (name ){
This. Name = Name;
}
});

// Test the instance
VaR cat = new CAT ('Kitty ');
Alert (Cat. Name );

// Class for inheritance. mootools does this:
VaR animal = new class ({
Initialize: function (name ){
This. Name = Name;
}
});

// Inherit
VaR cat2 = animal. Extend ({
Initialize: function (name, age ){
This. Parent (name); // call animal's initialize method
This. Age = age;
}
});

// Test the instance
VaR excat = new cat2 ('Kitty ', 20 );
Alert (excat. Name + '--' + excat. Age );


// Extension
VaR person = new class ({
Initialize: function (name ){
This. Name = Name;
}
});

Person. Implement ({
Initialize: function (name, age ){
This. Name = Name;
This. Age = age;
},

Myaction: function (){
Alert (this. Name + '--' + this. Age );
}
});

// Test the instance
VaR P = new person ('zarknight ', 24 );
P. myaction ();

// 6. $ pick
VaR x = $ pick ("openfdc", "zarknight"); // openfdc
Alert (X );
Var y = $ pick (null, "zarknight"); // zarknight
Alert (y );
VaR z = $ pick (1, 2); // 1
Alert (z );

}
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>

</Div>
</Form>
</Body>
</Html>

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.