[ Index ]

PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12)

title

Body

[close]

/template/lib/mootools/more/Drag/ -> Drag.Move.js (source)

   1  Drag.Move=new Class({Extends:Drag,options:{droppables:[],container:false,precalculate:false,includeMargins:true,checkDroppables:true},initialize:function(b,a){this.parent(b,a);b=this.element;this.droppables=$$(this.options.droppables);this.container=document.id(this.options.container);if(this.container&&$type(this.container)!="element"){this.container=document.id(this.container.getDocument().body)}if(this.options.modifiers.x=="left"&&this.options.modifiers.y=="top"){var f,c=b.getOffsetParent();if(c){f=c.getStyles("border-top-width","border-left-width")}var d=b.getStyles("left","top");if(c&&d.left=="auto"||d.top=="auto"){var e=b.getPosition(c);e.x=e.x-(f["border-left-width"]?f["border-left-width"].toInt():0);e.y=e.y-(f["border-top-width"]?f["border-top-width"].toInt():0);b.setPosition(e)}}if(b.getStyle("position")=="static"){b.setStyle("position","absolute")}this.addEvent("start",this.checkDroppables,true);this.overed=null},start:function(a){if(this.container){this.options.limit=this.calculateLimit()}if(this.options.precalculate){this.positions=this.droppables.map(function(b){return b.getCoordinates()})}this.parent(a)},calculateLimit:function(){var d=document.id(this.element.getOffsetParent())||document.body,h=this.container.getCoordinates(d),g={},c={},b={},j={},f={},l={};["top","right","bottom","left"].each(function(p){g[p]=this.container.getStyle("border-"+p).toInt();b[p]=this.element.getStyle("border-"+p).toInt();c[p]=this.element.getStyle("margin-"+p).toInt();j[p]=this.container.getStyle("margin-"+p).toInt();l[p]=d.getStyle("padding-"+p).toInt();f[p]=d.getStyle("border-"+p).toInt()},this);var e=this.element.offsetWidth+c.left+c.right,o=this.element.offsetHeight+c.top+c.bottom,i=0,k=0,n=h.right-g.right-e,a=h.bottom-g.bottom-o;if(this.options.includeMargins){i+=c.left;k+=c.top}else{n+=c.right;a+=c.bottom}if(this.element.getStyle("position")=="relative"){var m=this.element.getCoordinates(d);m.left-=this.element.getStyle("left").toInt();m.top-=this.element.getStyle("top").toInt();i+=g.left-m.left;k+=g.top-m.top;n+=c.left-m.left;a+=c.top-m.top;if(this.container!=d){i+=j.left+l.left;k+=(Browser.Engine.trident4?0:j.top)+l.top}}else{i-=c.left;k-=c.top;if(this.container==d){n-=g.left;a-=g.top}else{i+=h.left+g.left-f.left;k+=h.top+g.top-f.top;n-=f.left;a-=f.top}}return{x:[i,n],y:[k,a]}},checkAgainst:function(c,b){c=(this.positions)?this.positions[b]:c.getCoordinates();var a=this.mouse.now;return(a.x>c.left&&a.x<c.right&&a.y<c.bottom&&a.y>c.top)},checkDroppables:function(){var a=this.droppables.filter(this.checkAgainst,this).getLast();if(this.overed!=a){if(this.overed){this.fireEvent("leave",[this.element,this.overed])}if(a){this.fireEvent("enter",[this.element,a])}this.overed=a}},drag:function(a){this.parent(a);if(this.options.checkDroppables&&this.droppables.length){this.checkDroppables()}},stop:function(a){this.checkDroppables();this.fireEvent("drop",[this.element,this.overed,a]);this.overed=null;return this.parent(a)}});Element.implement({makeDraggable:function(a){var b=new Drag.Move(this,a);this.store("dragger",b);return b}});


Generated: Sun Jan 29 16:31:14 2012 Cross-referenced by PHPXref 0.7.1