// Gaia Ajax Widgets Copyright (C) 2007 - 2008 Gaiaware AS. details at http://ajaxwidgets.com/
Gaia.AspectDraggable=Class.create();Object.extend(Gaia.AspectDraggable.prototype,Gaia.Aspect.prototype);Object.extend(Gaia.AspectDraggable.prototype,{initialize:function(parentId,options){this.initializeMovable(parentId,options);},initializeMovable:function(parentId,options){this.initializeAspect(parentId,options);this.options=Object.extend({hasEvent:true,revert:false,zIndex:5000,rect:false,silent:false,effects:1.0,hitEffect:false,handle:null,idToPass:''},this.options);this.onSnap=this._snap.bind(this);this.onStart=this._startDrag.bind(this);this.onDropped=this._dropped.bind(this);this.createDragger();},_snap:function(x,y){if(!this.options.rect)
return[x,y];return[Math.min(Math.max(x,this.options.rect.left),this.options.rect.right),Math.min(Math.max(y,this.options.rect.top),this.options.rect.bottom)];},_startDrag:function(){if(this.options.effects!=1.0){this.oldOpacity=Element.getOpacity(this.getWrappedControl().element);new Effect.Opacity(this.getWrappedControl().element,{duration:0.2,from:this.oldOpacity,to:this.options.effects});}},_dropped:function(){if(this.options.effects!=1.0){new Effect.Opacity(this.getWrappedControl().element,{duration:0.2,from:this.options.effects,to:this.oldOpacity});}
if(this.options.hasEvent){Gaia.Control.callAspectMethod.bind(this.getWrappedControl())('DroppedMethod',[parseInt(this.getWrappedControl().element.style.left,10)||0,parseInt(this.getWrappedControl().element.style.top,10)||0]);}},createDragger:function(){this.draggable=new Draggable($(this.parentId),{quiet:this.options.silent,snap:(this.options.rect?this.onSnap:null),revert:this.options.revert,starteffect:this.onStart,endeffect:this.onDropped,hitEffect:this.options.hitEffect,handle:this.options.handle,idToPass:this.options.idToPass,zindex:this.options.zIndex});},forceAnUpdate:function(){this.destroyDraggable();},reInit:function(){this.createDragger();},destroy:function(){this.destroyDraggable();},destroyDraggable:function(){if(this.draggable){this.draggable.destroy();delete this.draggable;}}});Gaia.AspectDraggable.browserFinishedLoading=true;