First experience using the mootools development plug-in

Source: Internet
Author: User

/*/Call method:

Pop (this ,{

Pos: 3, // top; right; bottom; left

Tim: 3000,

Oft: {x: 10, y: 0 },

Htm: 'The content to be displayed <br> parsing of the new HTML5 entry tag ', // It can be fun

Fun: function (I ){}

});

Pop ();

/*/

Core code

Var Pop = function (I, opt ){

Var $ Pop, $ Hand;

If (! I |! Opt) {Function. attempt (function () {$ ('_ Pop'). destroy () ;}); return false ;}

If (! Opt.htm) {return false ;}

Opt. pos = (opt. pos) | 1;

Opt. fun = (opt. fun) | function (){};

Opt. oft = (opt. oft) | {x: 0, y: 0 };

If (! $ ('_ Pop ')){

$ Boxw.css = 'display: inline-block; # display: inline; # zoom: 1; position: relative; border-style: solid; border-color: # BBB ;';

$ Box2_css = '# left:-2px; border-width: 0 1px; background-color: # FEFFE5 ;';

$ Pop = new Element ('div ', {'id':' _ Pop ', 'style': 'font-size: 12px; position: absolute ;'}). inject (document. body, 'top ');

$ Pop_box1 = new Element ('div '). inject ($ Pop, 'top ');

$ Pop_box2 = new Element ('div '). inject ($ pop_box1, 'top ');

$ Mess = new Element ('div ', {'id': 'mess'}). inject ($ pop_box2, 'top ');

$ Hand = new Element ('div ', {'id':' _ pop_n'}). inject ($ Pop, 'top ');

$ Pop_box1.setProperty ('style', $ box1_css + 'border-width: 1px ;');

$ Pop_box2.setProperty ('style', $ box1_css + $ box2_css + 'margin: 0-2px ;');

$ Mess. setProperty ('style', $ boxw.css + $ box2_css + 'margin: 1px-2px; padding: 4px 8px; line-height: 1.5 ;');

$ Box1_css = $ box2_css = $ pop_box1 = $ pop_box2 = null;

} Else {

$ Pop = $ ('_ Pop ');

$ Hand = $ Pop. getElementById ('_ Pop_n ');

$ Mess = $ Pop. getElementById ('mess ');

$ Pop. setStyles ({'left': $ Ox + 'px', 'top': $ Oy + 'px '});

}

If(typeOf(opt.htm) = 'string '){

Optional mess.set('html', opt.htm );

} Else {

Var htm = '';

Function.attempt(function(){htm?opt.htm ();});

$ Mess. set ('html', htm );

Htm = null;

}

 

$ Fo = 8; // corrected value

$ Ox = $ (I). getPosition (). x; // event Coordinate

$ Oy = $ (I). getPosition (). y;

$ Ix = I. getSize (). x; // Obj width

$ Iy = I. getSize (). y;

$ Bx = $ Pop. getSize (). x; // Pop width

$ By = $ Pop. getSize (). y;

$ Hcss = 'height: 0; width: 0; border-width: 6px; position: absolute ;';

 

Switch (opt. pos ){

Case 1:

$ Oy = $ Oy + $ Iy + $ fo; $ Ox = $ Ox + $ fo;

$ Hcss + = 'border-color: transparent # BBB transparent; border-style: dashed solid dashed; left: 10px; top:-12px ;';

Break;

Case 2:

$ Ox = $ Ox-$ Bx-$ fo; $ Oy = $ Oy-$ fo;

$ Hcss + = 'border-color: transparent # BBB; border-style: dashed solid; right:-14px; top: 10px ;';

Break;

Case 3:

$ Oy = $ Oy-$ By-$ fo; $ Ox = $ Ox + $ fo;

$ Hcss + = 'border-color: # BBB transparent; border-style: solid dashed; left: 10px; bottom:-12px ;';

Break;

Case 4:

$ Ox = $ Ox + $ Ix + $ fo; $ Oy = $ Oy-$ fo;

$ Hcss + = 'border-color: transparent # BBB transparent; border-style: dashed solid dashed; left:-14px; top: 10px ;';

Break;

}

$ Ox = (opt. oft. x )? ($ Ox + (opt. oft. x): $ Ox;

$ Oy = (opt. oft. y )? ($ Oy + (opt. oft. y): $ Oy;

$ Pop. setStyles ({'left': $ Ox + 'px', 'top': $ Oy + 'px '});

$ Hand. setProperty ('style', $ hcss );

 

If (opt. tim ){

Var myFun = function () {$ Pop. destroy ()}; myFun. delay (opt. tim, $ Pop );

Var timer = myFun. delay (opt. tim); clearTimeout (timer );

}

 

If (opt. fun) {opt. fun ($ Pop );}

Opt = $ Ix = $ Iy = $ Bx = $ By = $ hcss = null;

};

 

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.