MooTools Position Toggle Class

Source: Internet
Author: User
Tags array bind mootools

1.var Posswitch = new Class ({
2.
3. Options: {
4. API: ' http://6.cn/6cntest/p/h.html ',//Pending
5. Transition: {duration:1000,transition:fx.transitions.cubic.easeout}
6.},
7.
8. Initialize:function (parentid,boxclass,options) {
9.
This.setoptions (options);
This.idarr = []; Array of module order (sent to the PHP-side saved Array)
This.parentid = ParentID; The total parent container for the module
This.boxclass = Boxclass; Class of the module
This.boxs = $$ (' # ' + This.parentid + ' div. ' + this.boxclass); Array of sorted modules
This.num = This.boxs.length;
if (this.num = 0) return; Number of modules sorted
for (var i=0; i<this.num; i++) {
var box = This.boxs[i]
This.idArr.push (box.id);
20.}
$$ (' # ' +this.boxs[0].id + ' P ') [0].addclass (' top ');
$$ (' # ' +this.boxs[this.num-1].id + ' P ') [0].addclass (' bottom ');
var uplinks = $$ (' # ' + this.parentid + ' a.up ');
var downlinks = $$ (' # ' + this.parentid + ' a.down ');
Uplinks.each (function (ele) {
Ele.addevent (' click ', Function (event) {event.stop (); This.switup (ele)}.bindwithevent (this))
}.bind (This)
28.)
Downlinks.each (function (ele) {
Ele.addevent (' click ', Function (event) {event.stop (); This.switdown (ele)}.bindwithevent (this))
}.bind (This)
32.)
33.},
34.
Switdown:function (ele) {
var thisobj = $ (ele.parentNode.parentNode);
var thisindex = this.idArr.indexOf (thisobj.id);
var thatobj = $ (this.idarr[thisindex+1]);
This.idarr[thisindex] = thatobj.id;
THIS.IDARR[THISINDEX+1] = thisobj.id;
41.
var thistop = Thisobj.getstyle (' top ') = = ' Auto '? 0:thisobj.getstyle (' top '). ToInt ();
var thattop = Thatobj.getstyle (' top ') = = ' Auto '? 0:thatobj.getstyle (' top '). ToInt ();
var thisheight = thisobj.getstyle (' height '). ToInt (); Block height
var thatheight = thatobj.getstyle (' height '). ToInt ();
var e = new Fx.styles (thisobj, this.options.transition);
E.start ({' Top ': [Thistop,thistop+thatheight], ' opacity ': [0.5,1]});
var f = new Fx.styles (thatobj, this.options.transition);
F.start ({' Top ': [Thattop, Thattop-thisheight], ' opacity ': [0.5,1]});
This.arrowchange ();
51.},
52.
Switup:function (ele) {
var thisobj = $ (ele.parentNode.parentNode);
var thisindex = this.idArr.indexOf (thisobj.id);
var thatobj = $ (this.idarr[thisindex-1]);
This.idarr[thisindex] = thatobj.id;
This.idarr[thisindex-1] = thisobj.id;
59.
var thistop = Thisobj.getstyle (' top ') = = ' Auto '? 0:thisobj.getstyle (' top '). ToInt ();
var thattop = Thatobj.getstyle (' top ') = = ' Auto '? 0:thatobj.getstyle (' top '). ToInt ();
var thisheight = thisobj.getstyle (' height '). ToInt (); Block height
var thatheight = thatobj.getstyle (' height '). ToInt ();
var e = new Fx.styles (thisobj, this.options.transition);
E.start ({' Top ': [Thistop,thistop-thatheight], ' opacity ': [0.5,1]});
var f = new Fx.styles (thatobj, this.options.transition);
F.start ({' Top ': [Thattop, Thattop+thisheight], ' opacity ': [0.5,1]});
This.arrowchange ();
69.
70.},
71.
Arrowchange:function () {
var links = $$ (' # ' + This.parentid + ' A.down, a.up ');
A. for (Var i=0;i<links.length;i++) {
$ (Links[i].parentnode). Removeclass (' top '). Removeclass (' bottom ');
76.}
$$ (' # ' +this.idarr[0] + ' P ') [0].addclass (' top ');
$$ (' # ' +this.idarr[this.num-1] + ' P ') [0].addclass (' bottom ');
79.
80.},
81.
Save:function () {
The var url = this.options.api;
The var data = ' order= ' + This.idarr + ' &uid= ' + pagemessage.uid;
The var callback = This.back.bind (this);
alert (data);
Request.resend (Url,data,callback);
88.},
89.
Back:function (httpobj) {
91.
92.}
93.
94.
95.})
96.posswitch.implement (New Events, new Options);
97.window.addevent (' Load ', function () {
Myswitch = new Posswitch (' Scrollwrap ', ' mypanelbox ');
99.})

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.