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