(function(h,g){h.widget("ui.resizable",h.ui.mouse,{widgetEventPrefix:"resize",options:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,containment:false,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1000},_create:function(){var m=this,b=this.options;this.element.addClass("ui-resizable");h.extend(this,{_aspectRatio:!!(b.aspectRatio),aspectRatio:b.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:b.helper||b.ghost||b.animate?b.helper||"ui-resizable-helper":null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){if(/relative/.test(this.element.css("position"))&&h.browser.opera){this.element.css({position:"relative",top:"auto",left:"auto"})}this.element.wrap(h('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle=this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=b.handles||(!h(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all"){this.handles="n,e,s,w,se,sw,ne,nw"}var a=this.handles.split(",");this.handles={};for(var i=0;i<a.length;i++){var c=h.trim(a[i]),n="ui-resizable-"+c;var d=h('<div class="ui-resizable-handle '+n+'"></div>');if(/sw|se|ne|nw/.test(c)){d.css({zIndex:++b.zIndex})}if("se"==c){d.addClass("ui-icon ui-icon-gripsmall-diagonal-se")}this.handles[c]=".ui-resizable-"+c;this.element.append(d)}}this._renderAxis=function(k){k=k||this.element;for(var s in this.handles){if(this.handles[s].constructor==String){this.handles[s]=h(this.handles[s],this.element).show()}if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var r=h(this.handles[s],this.element),l=0;l=/sw|ne|nw|se|n|s/.test(s)?r.outerHeight():r.outerWidth();var j=["padding",/ne|nw|n/.test(s)?"Top":/se|sw|s/.test(s)?"Bottom":/^e$/.test(s)?"Right":"Left"].join("");k.css(j,l);this._proportionallyResize()}if(!h(this.handles[s]).length){continue}}};this._renderAxis(this.element);this._handles=h(".ui-resizable-handle",this.element).disableSelection();this._handles.mouseover(function(){if(!m.resizing){if(this.className){var j=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)}m.axis=j&&j[1]?j[1]:"se"}});if(b.autoHide){this._handles.hide();h(this.element).addClass("ui-resizable-autohide").hover(function(){h(this).removeClass("ui-resizable-autohide");m._handles.show()},function(){if(!m.resizing){h(this).addClass("ui-resizable-autohide");m._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy();var b=function(c){h(c).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){b(this.element);var a=this.element;a.after(this.originalElement.css({position:a.css("position"),width:a.outerWidth(),height:a.outerHeight(),top:a.css("top"),left:a.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);b(this.originalElement);return this},_mouseCapture:function(b){var a=false;for(var c in this.handles){if(h(this.handles[c])[0]==b.target){a=true}}return !this.options.disabled&&a},_mouseStart:function(l){var b=this.options,m=this.element.position(),n=this.element;this.resizing=true;this.documentScroll={top:h(document).scrollTop(),left:h(document).scrollLeft()};if(n.is(".ui-draggable")||(/absolute/).test(n.css("position"))){n.css({position:"absolute",top:m.top,left:m.left})}if(h.browser.opera&&(/relative/).test(n.css("position"))){n.css({position:"relative",top:"auto",left:"auto"})}this._renderProxy();var a=e(this.helper.css("left")),d=e(this.helper.css("top"));if(b.containment){a+=h(b.containment).scrollLeft()||0;d+=h(b.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:a,top:d};this.size=this._helper?{width:n.outerWidth(),height:n.outerHeight()}:{width:n.width(),height:n.height()};this.originalSize=this._helper?{width:n.outerWidth(),height:n.outerHeight()}:{width:n.width(),height:n.height()};this.originalPosition={left:a,top:d};this.sizeDiff={width:n.outerWidth()-n.width(),height:n.outerHeight()-n.height()};this.originalMousePosition={left:l.pageX,top:l.pageY};this.aspectRatio=(typeof b.aspectRatio=="number")?b.aspectRatio:((this.originalSize.width/this.originalSize.height)||1);var c=h(".ui-resizable-"+this.axis).css("cursor");h("body").css("cursor",c=="auto"?this.axis+"-resize":c);n.addClass("ui-resizable-resizing");this._propagate("start",l);return true},_mouseDrag:function(z){var w=this.helper,x=this.options,o={},b=this,u=this.originalMousePosition,d=this.axis;var a=(z.pageX-u.left)||0,c=(z.pageY-u.top)||0;var v=this._change[d];if(!v){return false}var s=v.apply(this,[z,a,c]),t=h.browser.msie&&h.browser.version<7,y=this.sizeDiff;if(this._aspectRatio||z.shiftKey){s=this._updateRatio(s,z)}s=this._respectSize(s,z);this._propagate("resize",z);w.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!this._helper&&this._proportionallyResizeElements.length){this._proportionallyResize()}this._updateCache(s);this._trigger("resize",z,this.ui());return false},_mouseStop:function(q){this.resizing=false;var p=this.options,b=this;if(this._helper){var r=this._proportionallyResizeElements,t=r.length&&(/textarea/i).test(r[0].nodeName),s=t&&h.ui.hasScroll(r[0],"left")?0:b.sizeDiff.height,d=t?0:b.sizeDiff.width;var a={width:(b.helper.width()-d),height:(b.helper.height()-s)},o=(parseInt(b.element.css("left"),10)+(b.position.left-b.originalPosition.left))||null,c=(parseInt(b.element.css("top"),10)+(b.position.top-b.originalPosition.top))||null;if(!p.animate){this.element.css(h.extend(a,{top:c,left:o}))}b.helper.height(b.size.height);b.helper.width(b.size.width);if(this._helper&&!p.animate){this._proportionallyResize()}}h("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",q);if(this._helper){this.helper.remove()}return false},_updateCache:function(b){var a=this.options;this.offset=this.helper.offset();if(f(b.left)){this.position.left=b.left}if(f(b.top)){this.position.top=b.top}if(f(b.height)){this.size.height=b.height}if(f(b.width)){this.size.width=b.width}},_updateRatio:function(c,d){var b=this.options,a=this.position,k=this.size,l=this.axis;if(c.height){c.width=(k.height*this.aspectRatio)}else{if(c.width){c.height=(k.width/this.aspectRatio)}}if(l=="sw"){c.left=a.left+(k.width-c.width);c.top=null}if(l=="nw"){c.top=a.top+(k.height-c.height);c.left=a.left+(k.width-c.width)}return c},_respectSize:function(u,z){var w=this.helper,x=this.options,a=this._aspectRatio||z.shiftKey,b=this.axis,C=f(u.width)&&x.maxWidth&&(x.maxWidth<u.width),o=f(u.height)&&x.maxHeight&&(x.maxHeight<u.height),y=f(u.width)&&x.minWidth&&(x.minWidth>u.width),D=f(u.height)&&x.minHeight&&(x.minHeight>u.height);if(y){u.width=x.minWidth}if(D){u.height=x.minHeight}if(C){u.width=x.maxWidth}if(o){u.height=x.maxHeight}var A=this.originalPosition.left+this.originalSize.width,c=this.position.top+this.size.height;var v=/sw|nw|w/.test(b),B=/nw|ne|n/.test(b);if(y&&v){u.left=A-x.minWidth}if(C&&v){u.left=A-x.maxWidth}if(D&&B){u.top=c-x.minHeight}if(o&&B){u.top=c-x.maxHeight}var d=!u.width&&!u.height;if(d&&!u.left&&u.top){u.top=null}else{if(d&&!u.top&&u.left){u.left=null}}return u},_proportionallyResize:function(){var a=this.options;if(!this._proportionallyResizeElements.length){return}var d=this.helper||this.element;for(var i=0;i<this._proportionallyResizeElements.length;i++){var c=this._proportionallyResizeElements[i];if(!this.borderDif){var l=[c.css("borderTopWidth"),c.css("borderRightWidth"),c.css("borderBottomWidth"),c.css("borderLeftWidth")],b=[c.css("paddingTop"),c.css("paddingRight"),c.css("paddingBottom"),c.css("paddingLeft")];this.borderDif=h.map(l,function(k,q){var j=parseInt(k,10)||0,p=parseInt(b[q],10)||0;return j+p})}if(h.browser.msie&&!(!(h(d).is(":hidden")||h(d).parents(":hidden").length))){continue}c.css({height:(d.height()-this.borderDif[0]-this.borderDif[2])||0,width:(d.width()-this.borderDif[1]-this.borderDif[3])||0})}},_renderProxy:function(){var d=this.element,a=this.options;this.elementOffset=d.offset();if(this._helper){this.helper=this.helper||h('<div style="overflow:hidden;"></div>');var j=h.browser.msie&&h.browser.version<7,c=(j?1:0),b=(j?2:-1);this.helper.addClass(this._helper).css({width:this.element.outerWidth()+b,height:this.element.outerHeight()+b,position:"absolute",left:this.elementOffset.left-c+"px",top:this.elementOffset.top-c+"px",zIndex:++a.zIndex});this.helper.appendTo("body").disableSelection()}else{this.helper=this.element}},_change:{e:function(a,b,c){return{width:this.originalSize.width+b}},w:function(c,k,l){var a=this.options,d=this.originalSize,b=this.originalPosition;return{left:b.left+k,width:d.width-k}},n:function(c,k,l){var a=this.options,d=this.originalSize,b=this.originalPosition;return{top:b.top+l,height:d.height-l}},s:function(a,b,c){return{height:this.originalSize.height+c}},se:function(a,b,c){return h.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[a,b,c]))},sw:function(a,b,c){return h.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[a,b,c]))},ne:function(a,b,c){return h.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[a,b,c]))},nw:function(a,b,c){return h.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[a,b,c]))}},_propagate:function(a,b){h.ui.plugin.call(this,a,[b,this.ui()]);(a!="resize"&&this._trigger(a,b,this.ui()))},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});h.extend(h.ui.resizable,{version:"1.8.11"});h.ui.plugin.add("resizable","alsoResize",{start:function(d,c){var j=h(this).data("resizable"),a=j.options;var b=function(i){h(i).each(function(){var l=h(this);l.data("resizable-alsoresize",{width:parseInt(l.width(),10),height:parseInt(l.height(),10),left:parseInt(l.css("left"),10),top:parseInt(l.css("top"),10),position:l.css("position")})})};if(typeof(a.alsoResize)=="object"&&!a.alsoResize.parentNode){if(a.alsoResize.length){a.alsoResize=a.alsoResize[0];b(a.alsoResize)}else{h.each(a.alsoResize,function(i){b(i)})}}else{b(a.alsoResize)}},resize:function(n,d){var o=h(this).data("resizable"),c=o.options,m=o.originalSize,a=o.originalPosition;var b={height:(o.size.height-m.height)||0,width:(o.size.width-m.width)||0,top:(o.position.top-a.top)||0,left:(o.position.left-a.left)||0},p=function(i,j){h(i).each(function(){var l=h(this),k=h(this).data("resizable-alsoresize"),s={},t=j&&j.length?j:l.parents(d.originalElement[0]).length?["width","height"]:["width","height","top","left"];h.each(t,function(v,q){var r=(k[q]||0)+(b[q]||0);if(r&&r>=0){s[q]=r||null}});if(h.browser.opera&&/relative/.test(l.css("position"))){o._revertToRelativePosition=true;l.css({position:"absolute",top:"auto",left:"auto"})}l.css(s)})};if(typeof(c.alsoResize)=="object"&&!c.alsoResize.nodeType){h.each(c.alsoResize,function(i,j){p(i,j)})}else{p(c.alsoResize)}},stop:function(c,b){var d=h(this).data("resizable"),a=d.options;var j=function(i){h(i).each(function(){var l=h(this);l.css({position:l.data("resizable-alsoresize").position})})};if(d._revertToRelativePosition){d._revertToRelativePosition=false;if(typeof(a.alsoResize)=="object"&&!a.alsoResize.nodeType){h.each(a.alsoResize,function(i){j(i)})}else{j(a.alsoResize)}}h(this).removeData("resizable-alsoresize")}});h.ui.plugin.add("resizable","animate",{stop:function(r,b){var a=h(this).data("resizable"),q=a.options;var s=a._proportionallyResizeElements,v=s.length&&(/textarea/i).test(s[0].nodeName),u=v&&h.ui.hasScroll(s[0],"left")?0:a.sizeDiff.height,d=v?0:a.sizeDiff.width;var t={width:(a.size.width-d),height:(a.size.height-u)},o=(parseInt(a.element.css("left"),10)+(a.position.left-a.originalPosition.left))||null,c=(parseInt(a.element.css("top"),10)+(a.position.top-a.originalPosition.top))||null;a.element.animate(h.extend(t,c&&o?{top:c,left:o}:{}),{duration:q.animateDuration,easing:q.animateEasing,step:function(){var i={width:parseInt(a.element.css("width"),10),height:parseInt(a.element.css("height"),10),top:parseInt(a.element.css("top"),10),left:parseInt(a.element.css("left"),10)};if(s&&s.length){h(s[0]).css({width:i.width,height:i.height})}a._updateCache(i);a._propagate("resize",r)}})}});h.ui.plugin.add("resizable","containment",{start:function(y,a){var A=h(this).data("resizable"),u=A.options,o=A.element;var x=u.containment,p=(x instanceof h)?x.get(0):(/parent/.test(x))?o.parent().get(0):x;if(!p){return}A.containerElement=h(p);if(/document/.test(x)||x==document){A.containerOffset={left:0,top:0};A.containerPosition={left:0,top:0};A.parentData={element:h(document),left:0,top:0,width:h(document).width(),height:h(document).height()||document.body.parentNode.scrollHeight}}else{var c=h(p),v=[];h(["Top","Right","Left","Bottom"]).each(function(i,j){v[i]=e(c.css("padding"+j))});A.containerOffset=c.offset();A.containerPosition=c.position();A.containerSize={height:(c.innerHeight()-v[3]),width:(c.innerWidth()-v[1])};var b=A.containerOffset,z=A.containerSize.height,d=A.containerSize.width,w=(h.ui.hasScroll(p,"left")?p.scrollWidth:d),B=(h.ui.hasScroll(p)?p.scrollHeight:z);A.parentData={element:p,left:b.left,top:b.top,width:w,height:B}}},resize:function(z,b){var C=h(this).data("resizable"),x=C.options,A=C.containerSize,c=C.containerOffset,o=C.size,d=C.position,a=C._aspectRatio||z.shiftKey,B={top:0,left:0},y=C.containerElement;if(y[0]!=document&&(/static/).test(y.css("position"))){B=c}if(d.left<(C._helper?c.left:0)){C.size.width=C.size.width+(C._helper?(C.position.left-c.left):(C.position.left-B.left));if(a){C.size.height=C.size.width/x.aspectRatio}C.position.left=x.helper?c.left:0}if(d.top<(C._helper?c.top:0)){C.size.height=C.size.height+(C._helper?(C.position.top-c.top):C.position.top);if(a){C.size.width=C.size.height*x.aspectRatio}C.position.top=C._helper?c.top:0}C.offset.left=C.parentData.left+C.position.left;C.offset.top=C.parentData.top+C.position.top;var u=Math.abs((C._helper?C.offset.left-B.left:(C.offset.left-B.left))+C.sizeDiff.width),D=Math.abs((C._helper?C.offset.top-B.top:(C.offset.top-c.top))+C.sizeDiff.height);var v=C.containerElement.get(0)==C.element.parent().get(0),w=/relative|absolute/.test(C.containerElement.css("position"));if(v&&w){u-=C.parentData.left}if(u+C.size.width>=C.parentData.width){C.size.width=C.parentData.width-u;if(a){C.size.height=C.size.width/C.aspectRatio}}if(D+C.size.height>=C.parentData.height){C.size.height=C.parentData.height-D;if(a){C.size.width=C.size.height*C.aspectRatio}}},stop:function(x,d){var b=h(this).data("resizable"),w=b.options,s=b.position,o=b.containerOffset,y=b.containerPosition,v=b.containerElement;var u=h(b.helper),a=u.offset(),c=u.outerWidth()-b.sizeDiff.width,t=u.outerHeight()-b.sizeDiff.height;if(b._helper&&!w.animate&&(/relative/).test(v.css("position"))){h(this).css({left:a.left-y.left-o.left,width:c,height:t})}if(b._helper&&!w.animate&&(/static/).test(v.css("position"))){h(this).css({left:a.left-y.left-o.left,width:c,height:t})}}});h.ui.plugin.add("resizable","ghost",{start:function(c,b){var j=h(this).data("resizable"),a=j.options,d=j.size;j.ghost=j.originalElement.clone();j.ghost.css({opacity:0.25,display:"block",position:"relative",height:d.height,width:d.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof a.ghost=="string"?a.ghost:"");j.ghost.appendTo(j.helper)},resize:function(c,b){var d=h(this).data("resizable"),a=d.options;if(d.ghost){d.ghost.css({position:"relative",height:d.size.height,width:d.size.width})}},stop:function(c,b){var d=h(this).data("resizable"),a=d.options;if(d.ghost&&d.helper){d.helper.get(0).removeChild(d.ghost.get(0))}}});h.ui.plugin.add("resizable","grid",{resize:function(v,c){var a=h(this).data("resizable"),s=a.options,o=a.size,r=a.originalSize,q=a.originalPosition,b=a.axis,d=s._aspectRatio||v.shiftKey;s.grid=typeof s.grid=="number"?[s.grid,s.grid]:s.grid;var t=Math.round((o.width-r.width)/(s.grid[0]||1))*(s.grid[0]||1),u=Math.round((o.height-r.height)/(s.grid[1]||1))*(s.grid[1]||1);if(/^(se|s|e)$/.test(b)){a.size.width=r.width+t;a.size.height=r.height+u}else{if(/^(ne)$/.test(b)){a.size.width=r.width+t;a.size.height=r.height+u;a.position.top=q.top-u}else{if(/^(sw)$/.test(b)){a.size.width=r.width+t;a.size.height=r.height+u;a.position.left=q.left-t}else{a.size.width=r.width+t;a.size.height=r.height+u;a.position.top=q.top-u;a.position.left=q.left-t}}}}});var e=function(a){return parseInt(a,10)||0};var f=function(a){return !isNaN(parseInt(a,10))}})(jQuery);
