/*______________
|       ______  |   U I Z E     J A V A S C R I P T     A P I
|     /      /  |   -----------------------------------------
|    /    O /   |    MODULE : Uize.Widget.ImagePort.Draggable Class (version 1.0.0)
|   /    / /    |    AUTHOR : Chris van Rensburg (http://www.tomkidding.com)
|  /    / /  /| |    ONLINE : http://www.tomkidding.com/uize/uize-js-api
| /____/ /__/_| | COPYRIGHT : (c)2005-2006 Chris van Rensburg
|           |__ |   LICENSE : Distributed under the terms of the GNU General Public License
|_______________|             http://www.gnu.org/licenses/gpl.txt
*/
(function(){var d_a=true,d_b=false,d_c=Uize.Element,d_d=Uize.Widget;var d_e=d_d.ImagePort,d_f=d_e.Draggable=d_e.subclass(),d_g=d_f.prototype;d_g.wireUi=function(){var d_h=this;if(!d_h.wired()){var d_i=new d_d.Drag({element:d_h.getNode()}),d_j=[],d_k,d_l;d_i.addEventHandlers({'Drag Start':function(d_m){d_l=d_m.clientEvent.ctrlKey?'sizing':'alignment';d_h.set({d_n:d_a});d_k=d_h.get('sizingValue');d_j[0]=d_h.get('alignX');
d_j[1]=d_h.get('alignY');},'Drag Update':function(d_m){if(d_l=='sizing'){d_h.set({sizingValue:Math.max(Math.min(d_k+(0-d_i.eventDeltaPos[1])/100,d_h.d_o),d_h.d_p)});}else{function d_q(d_r){return Math.max(Math.min(d_j[d_r]+d_i.eventDeltaPos[d_r]*(d_h.portVsScaledDelta[d_r]?(1/d_h.portVsScaledDelta[d_r]):0),1),0);}d_h.set({alignX:d_q(0),alignY:d_q(1)});}},'Drag Done':function(){d_h.set({d_n:d_b})}});d_h.widgets.add('drag',d_i);d_e.prototype.wireUi.call(d_h);}};d_f.registerProperties({d_n:'inDrag',d_o:'maxSizingValue',d_p:'minSizingValue'});d_f.set({d_n:d_b,d_o:Infinity,d_p:0});})();