/*______________
|       ______  |   U I Z E     J A V A S C R I P T     A P I
|     /      /  |   -----------------------------------------
|    /    O /   |    MODULE : Uize.Widget.ImagePort 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 c_a=true,c_b=false,c_c=Uize.Element;var c_d=Uize.Widget,c_e=c_d.ImagePort=c_d.subclass(),c_f=c_e.prototype;c_f.updateUi=function(){var c_g=this;if(c_g.wired()){var c_h=c_c.getDimensions(c_g.getNode()),c_i=c_g.getNode('image');if(!c_g.c_j){c_g.c_j=c_i.width;c_g.c_k=c_i.height;}var c_l=c_g.getScaledRect({portWidth:c_h.width,portHeight:c_h.height,rectWidth:c_g.c_j,rectHeight:c_g.c_k});
c_g.portVsScaledDelta[0]=c_h.width-c_l.width;c_g.portVsScaledDelta[1]=c_h.height-c_l.height;c_c.setStyle(c_i,{position:'absolute'});c_c.setCoords(c_i,c_l);}};c_f.wireUi=function(){var c_g=this;if(!c_g.wired()){c_g.setNodeStyle('',{overflow:'hidden'});c_g.portVsScaledDelta=[];c_d.prototype.wireUi.call(c_g);}};c_f.getScaledRect=c_e.getScaledRect=function(c_m){function c_n(c_o){return c_o=='fit'?c_p:(c_o=='fill'?c_q:0);}function c_r(c_s){return typeof c_m[c_s]!='undefined'?c_m[c_s]:c_g.get(c_s);}var c_g=this,c_t=c_m.portWidth,c_u=c_m.portHeight,c_v=c_m.rectWidth,c_w=c_m.rectHeight,c_x=c_r('coordConverter'),c_y=c_t/c_v,c_z=c_u/c_w,c_p=Math.min(c_y,c_z),c_q=Math.max(c_y,c_z),c_A=c_n(c_r('sizingLowerBound')),c_B=c_n(c_r('sizingUpperBound')),c_C=Math.min(c_A+(c_B-c_A)*c_r('sizingValue'),c_r('maxScaling')),c_D=c_v*c_C,c_E=c_w*c_C,c_F={left:c_x((c_t-c_D)*c_r('alignX')),top:c_x((c_u-c_E)*c_r('alignY')),width:c_x(c_D),height:c_x(c_E)};return c_F;};function c_G(){this.updateUi();this.fireEvent('Position Changed');}
c_e.registerProperties({c_H:{name:'alignX',onChange:c_G},c_I:{name:'alignY',onChange:c_G},c_x:'coordConverter',c_J:{name:'maxScaling',onChange:c_G},c_K:{name:'sizingLowerBound',onChange:c_G},c_L:{name:'sizingUpperBound',onChange:c_G},c_M:{name:'sizingValue',onChange:c_G}});c_e.set({c_H:.5,c_I:.5,c_x:function(c_N){return c_N},c_J:Infinity,c_K:'fit',c_L:'fill',c_M:1,useNewIdSyntax:c_a});})();
