📄 ui.resizable.min.js
字号:
(function(A){A.fn.extend({resizable:function(C,D){var B=Array.prototype.slice.call(arguments,1);return this.each(function(){if(typeof C=="string"){var E=A.data(this,"resizable");if(E){E[C].apply(E,B)}}else{if(!A(this).is(".ui-resizable")){new A.ui.resizable(this,C)}}})}});A.ui.resizable=function(E,H){var O=this;this.element=A(E);A.data(E,"resizable",this);var S=this.element.css("position");this.element.addClass("ui-resizable").css({position:/static/.test(S)?"relative":S});this.options=A.extend({preventDefault:true,transparent:false,minWidth:10,minHeight:10,aspectRatio:false,disableSelection:true,preserveCursor:true,autohide:false,knobHandles:false},H);this.options._aspectRatio=!!(this.options.aspectRatio);this.options.proxy=this.options.proxy||this.options.ghost?"proxy":null;this.options.proxy=this.options.proxy||this.options.animate?"proxy":null;this.options.knobHandles=this.options.knobHandles===true?"ui-resizable-knob-handle":this.options.knobHandles;A(E).bind("setData.resizable",function(X,W,Y){O.options[W]=Y}).bind("getData.resizable",function(X,W){return O.options[W]});var P=this.options;var J="1px solid #DEDEDE";P.defaultTheme={"ui-resizable":{display:"block"},"ui-resizable-handle":{position:"absolute",background:"#F2F2F2",fontSize:"0.1px"},"ui-resizable-n":{cursor:"n-resize",height:"4px",left:"0px",right:"0px",borderTop:J},"ui-resizable-s":{cursor:"s-resize",height:"4px",left:"0px",right:"0px",borderBottom:J},"ui-resizable-e":{cursor:"e-resize",width:"4px",top:"0px",bottom:"0px",borderRight:J},"ui-resizable-w":{cursor:"w-resize",width:"4px",top:"0px",bottom:"0px",borderLeft:J},"ui-resizable-se":{cursor:"se-resize",width:"4px",height:"4px",borderRight:J,borderBottom:J},"ui-resizable-sw":{cursor:"sw-resize",width:"4px",height:"4px",borderBottom:J,borderLeft:J},"ui-resizable-ne":{cursor:"ne-resize",width:"4px",height:"4px",borderRight:J,borderTop:J},"ui-resizable-nw":{cursor:"nw-resize",width:"4px",height:"4px",borderLeft:J,borderTop:J}};P.knobTheme={"ui-resizable-handle":{background:"#F2F2F2",border:"1px solid #808080",height:"8px",width:"8px"},"ui-resizable-n":{cursor:"n-resize",top:"-4px",left:"45%"},"ui-resizable-s":{cursor:"s-resize",bottom:"-4px",left:"45%"},"ui-resizable-e":{cursor:"e-resize",right:"-4px",top:"45%"},"ui-resizable-w":{cursor:"w-resize",left:"-4px",top:"45%"},"ui-resizable-se":{cursor:"se-resize",right:"-4px",bottom:"-4px"},"ui-resizable-sw":{cursor:"sw-resize",left:"-4px",bottom:"-4px"},"ui-resizable-nw":{cursor:"nw-resize",left:"-4px",top:"-4px"},"ui-resizable-ne":{cursor:"ne-resize",right:"-4px",top:"-4px"}};if(!P.proxy&&(this.element.css("position")=="static"||this.element.css("position")==="")){this.element.css("position","relative")}P._nodeName=E.nodeName;if(P._nodeName.match(/textarea|input|select|button|img/i)){var B=this.element;if(/relative/.test(B.css("position"))&&A.browser.opera){B.css({position:"relative",top:"auto",left:"auto"})}B.wrap(A('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:B.css("position"),width:B.outerWidth(),height:B.outerHeight(),top:B.css("top"),left:B.css("left")}));var L=this.element;E=E.parentNode;this.element=A(E);this.element.css({marginLeft:L.css("marginLeft"),marginTop:L.css("marginTop"),marginRight:L.css("marginRight"),marginBottom:L.css("marginBottom")});L.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});if(A.browser.safari&&P.preventDefault){L.css("resize","none")}P.proportionallyResize=L.css({position:"static",zoom:1,display:"block"});this.element.css({margin:L.css("margin")});this._proportionallyResize()}if(!P.handles){P.handles=!A(".ui-resizable-handle",E).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(P.handles.constructor==String){if(P.handles=="all"){P.handles="n,e,s,w,se,sw,ne,nw"}var Q=P.handles.split(",");P.handles={};P.zIndex=P.zIndex||1000;var I={handle:"position: absolute; display: none; overflow:hidden;",n:"top: 0pt; width:100%;",e:"right: 0pt; height:100%;",s:"bottom: 0pt; width:100%;",w:"left: 0pt; height:100%;",se:"bottom: 0pt; right: 0px;",sw:"bottom: 0pt; left: 0px;",ne:"top: 0pt; right: 0px;",nw:"top: 0pt; left: 0px;"};for(var T=0;T<Q.length;T++){var U=jQuery.trim(Q[T]),N=P.defaultTheme,G="ui-resizable-"+U,D=!A.ui.css(G)&&!P.knobHandles,R=A.ui.css("ui-resizable-knob-handle"),V=A.extend(N[G],N["ui-resizable-handle"]),C=A.extend(P.knobTheme[G],!R?P.knobTheme["ui-resizable-handle"]:{});var M=/sw|se|ne|nw/.test(U)?{zIndex:++P.zIndex}:{};var K=(D?I[U]:""),F=A(['<div class="ui-resizable-handle ',G,'" style="',K,I.handle,'"></div>'].join("")).css(M);P.handles[U]=".ui-resizable-"+U;this.element.append(F.css(D?V:{}).css(P.knobHandles?C:{}).addClass(P.knobHandles?"ui-resizable-knob-handle":"").addClass(P.knobHandles))}if(P.knobHandles){this.element.addClass("ui-resizable-knob").css(!A.ui.css("ui-resizable-knob")?{}:{})}}this._renderAxis=function(a){a=a||this.element;for(var X in P.handles){if(P.handles[X].constructor==String){P.handles[X]=A(P.handles[X],E).show()}if(P.transparent){P.handles[X].css({opacity:0})}if(this.element.is(".ui-wrapper")&&P._nodeName.match(/textarea|input|select|button/i)){var Y=A(P.handles[X],E),Z=0;Z=/sw|ne|nw|se|n|s/.test(X)?Y.outerHeight():Y.outerWidth();var W=["padding",/ne|nw|n/.test(X)?"Top":/se|sw|s/.test(X)?"Bottom":/^e$/.test(X)?"Right":"Left"].join("");if(!P.transparent){a.css(W,Z)}this._proportionallyResize()}if(!A(P.handles[X]).length){continue}}};this._renderAxis(this.element);P._handles=A(".ui-resizable-handle",O.element);if(P.disableSelection){P._handles.each(function(W,X){A.ui.disableSelection(X)})}P._handles.mouseover(function(){if(!P.resizing){if(this.className){var W=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)}O.axis=P.axis=W&&W[1]?W[1]:"se"}});if(P.autohide){P._handles.hide();A(O.element).addClass("ui-resizable-autohide").hover(function(){A(this).removeClass("ui-resizable-autohide");P._handles.show()},function(){if(!P.resizing){A(this).addClass("ui-resizable-autohide");P._handles.hide()}})}this.element.mouseInteraction({executor:this,delay:0,distance:0,dragPrevention:["input","textarea","button","select","option"],start:this.start,stop:this.stop,drag:this.drag,condition:function(X){if(this.disabled){return false}for(var W in this.options.handles){if(A(this.options.handles[W])[0]==X.target){return true}}return false}})};A.extend(A.ui.resizable.prototype,{plugins:{},ui:function(){return{instance:this,axis:this.options.axis,options:this.options}},_renderProxy:function(){var C=this.element,F=this.options;this.elementOffset=C.offset();if(F.proxy){this.helper=this.helper||A('<div style="overflow:hidden;"></div>');var B=A.browser.msie&&A.browser.version<7,D=(B?1:0),E=(B?2:-1);this.helper.addClass(F.proxy).css({width:C.outerWidth()+E,height:C.outerHeight()+E,position:"absolute",left:this.elementOffset.left-D+"px",top:this.elementOffset.top-D+"px",zIndex:++F.zIndex});this.helper.appendTo("body");if(F.disableSelection){A.ui.disableSelection(this.helper.get(0))}}else{this.helper=C}},propagate:function(C,B){A.ui.plugin.call(this,C,[B,this.ui()]);this.element.triggerHandler(C=="resize"?C:["resize",C].join(""),[B,this.ui()],this.options[C])},destroy:function(){var D=this.element,C=D.children(".ui-resizable").get(0),B=function(E){A(E).removeClass("ui-resizable ui-resizable-disabled").removeMouseInteraction().removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};B(D);if(D.is(".ui-wrapper")&&C){D.parent().append(A(C).css({position:D.css("position"),width:D.outerWidth(),height:D.outerHeight(),top:D.css("top"),left:D.css("left")})).end().remove();B(C)}},enable:function(){this.element.removeClass("ui-resizable-disabled");this.disabled=false},disable:function(){this.element.addClass("ui-resizable-disabled");this.disabled=true},start:function(I){var C=this.options,B=this.element.position(),D=this.element,H=function(M){return parseInt(M,10)||0},G=A.browser.msie&&A.browser.version<7;C.resizing=true;C.documentScroll={top:A(document).scrollTop(),left:A(document).scrollLeft()};if(D.is(".ui-draggable")||(/absolute/).test(D.css("position"))){var J=A.browser.msie&&!C.containment&&(/absolute/).test(D.css("position"))&&!(/relative/).test(D.parent().css("position"));var K=J?C.documentScroll.top:0,F=J?C.documentScroll.left:0;D.css({position:"absolute",top:(B.top+K),left:(B.left+F)})}if(/relative/.test(D.css("position"))&&A.browser.opera){D.css({position:"relative",top:"auto",left:"auto"})}this._renderProxy();var L=H(this.helper.css("left")),E=H(this.helper.css("top"));this.offset=this.helper.offset();this.position={left:L,top:E};this.size=C.proxy||G?{width:D.outerWidth(),height:D.outerHeight()}:{width:D.width(),height:D.height()};this.originalSize=C.proxy||G?{width:D.outerWidth(),height:D.outerHeight()}:{width:D.width(),height:D.height()};this.originalPosition={left:L,top:E};this.sizeDiff={width:D.outerWidth()-D.width(),height:D.outerHeight()-D.height()};this.originalMousePosition={left:I.pageX,top:I.pageY};C.aspectRatio=(typeof C.aspectRatio=="number")?C.aspectRatio:((this.originalSize.height/this.originalSize.width)||1);if(C.preserveCursor){A("body").css("cursor",this.axis+"-resize")}this.propagate("start",I);return false},stop:function(J){this.options.resizing=false;var F=this.options,I=function(M){return parseInt(M,10)||0},L=this;if(F.proxy){var E=F.proportionallyResize,B=E&&/textarea/i.test(E.get(0).nodeName),C=B&&A.ui.hasScroll(E.get(0),"left")?0:L.sizeDiff.height,H=B?0:L.sizeDiff.width;var D={width:(L.size.width-H),height:(L.size.height-C)},G=parseInt(L.element.css("left"),10)+(L.position.left-L.originalPosition.left),K=parseInt(L.element.css("top"),10)+(L.position.top-L.originalPosition.top);if(!F.animate){this.element.css(A.extend(D,{top:K,left:G}))}if(F.proxy&&!F.animate){this._proportionallyResize()}this.helper.remove()}if(F.preserveCursor){A("body").css("cursor","auto")}this.propagate("stop",J);return false},drag:function(I){var D=this.helper,C=this.options,J={},M=this,F=this.originalMousePosition,K=this.axis;var N=(I.pageX-F.left)||0,L=(I.pageY-F.top)||0;var E=this.change[K];if(!E){return false}var H=E.apply(this,[I,N,L]),G=A.browser.msie&&A.browser.version<7,B=this.sizeDiff;if(C._aspectRatio||I.shiftKey){H=this._updateRatio(H,I)}H=this._respectSize(H,I);this.propagate("resize",I);D.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!C.proxy&&C.proportionallyResize){this._proportionallyResize()}this._updateCache(H);return false},_updateCache:function(B){var C=this.options;this.offset=this.helper.offset();if(B.left){this.position.left=B.left}if(B.top){this.position.top=B.top}if(B.height){this.size.height=B.height}if(B.width){this.size.width=B.width}},_updateRatio:function(D,E){var F=this.options,G=this.position,C=this.size,B=this.axis;if(D.height){D.width=Math.round(C.height/F.aspectRatio)}else{if(D.width){D.height=Math.round(C.width*F.aspectRatio)}}if(B=="sw"){D.left=G.left+(C.width-D.width);D.top=null}if(B=="nw"){D.top=G.top+(C.height-D.height);D.left=G.left+(C.width-D.width)}return D},_respectSize:function(H,I){var F=this.helper,E=this.options,N=E._aspectRatio||I.shiftKey,M=this.axis,P=H.width&&E.maxWidth&&E.maxWidth<H.width,J=H.height&&E.maxHeight&&E.maxHeight<H.height,D=H.width&&E.minWidth&&E.minWidth>H.width,O=H.height&&E.minHeight&&E.minHeight>H.height;if(D){H.width=E.minWidth}if(O){H.height=E.minHeight}if(P){H.width=E.maxWidth}if(J){H.height=E.maxHeight}var C=this.originalPosition.left+this.originalSize.width,L=this.position.top+this.size.height;var G=/sw|nw|w/.test(M),B=/nw|ne|n/.test(M);if(D&&G){H.left=C-E.minWidth}if(P&&G){H.left=C-E.maxWidth}if(O&&B){H.top=L-E.minHeight}if(J&&B){H.top=L-E.maxHeight}var K=!H.width&&!H.height;if(K&&!H.left&&H.top){H.top=null}else{if(K&&!H.top&&H.left){H.left=null}}return H},_proportionallyResize:function(){var F=this.options;if(!F.proportionallyResize){return }var D=F.proportionallyResize,C=this.helper||this.element;if(!F.borderDif){var B=[D.css("borderTopWidth"),D.css("borderRightWidth"),D.css("borderBottomWidth"),D.css("borderLeftWidth")],E=[D.css("paddingTop"),D.css("paddingRight"),D.css("paddingBottom"),D.css("paddingLeft")];F.borderDif=A.map(B,function(G,I){var H=parseInt(G,10)||0,J=parseInt(E[I],10)||0;return H+J})}D.css({height:(C.height()-F.borderDif[0]-F.borderDif[2])+"px",width:(C.width()-F.borderDif[1]-F.borderDif[3])+"px"})},change:{e:function(D,C,B){return{width:this.originalSize.width+C}},w:function(F,C,B){var G=this.options,D=this.originalSize,E=this.originalPosition;return{left:E.left+C,width:D.width-C}},n:function(F,C,B){var G=this.options,D=this.originalSize,E=this.originalPosition;return{top:E.top+B,height:D.height-B}},s:function(D,C,B){return{height:this.originalSize.height+B}},se:function(D,C,B){return A.extend(this.change.s.apply(this,arguments),this.change.e.apply(this,[D,C,B]))},sw:function(D,C,B){return A.extend(this.change.s.apply(this,arguments),this.change.w.apply(this,[D,C,B]))},ne:function(D,C,B){return A.extend(this.change.n.apply(this,arguments),this.change.e.apply(this,[D,C,B]))},nw:function(D,C,B){return A.extend(this.change.n.apply(this,arguments),this.change.w.apply(this,[D,C,B]))}}});A.ui.plugin.add("resizable","containment",{start:function(I,K){var E=K.options,M=K.instance,G=M.element;var C=E.containment,F=(C instanceof jQuery)?C.get(0):(/parent/.test(C))?G.parent().get(0):C;if(!F){return }if(/document/.test(C)||C==document){M.containerOffset={left:0,top:0};M.parentData={element:A(document),left:0,top:0,width:A(document).width(),height:A(document).height()||document.body.parentNode.scrollHeight}}else{M.containerOffset=A(F).offset(),M.containerSize={height:A(F).innerHeight(),width:A(F).innerWidth()};var J=M.containerOffset,B=M.containerSize.height,H=M.containerSize.width,D=(A.ui.hasScroll(F,"left")?F.scrollWidth:H),L=(A.ui.hasScroll(F)?F.scrollHeight:B);M.parentData={element:F,left:J.left,top:J.top,width:D,height:L}}},resize:function(F,I){var C=I.options,L=I.instance,B=L.containerSize,H=L.containerOffset,E=L.size,G=L.position,J=C._aspectRatio||F.shiftKey;if(G.left<(C.proxy?H.left:0)){L.size.width=L.size.width+(C.proxy?(L.position.left-H.left):L.position.left);if(J){L.size.height=L.size.width*C.aspectRatio}L.position.left=C.proxy?H.left:0}if(G.top<(C.proxy?H.top:0)){L.size.height=L.size.height+(C.proxy?(L.position.top-H.top):L.position.top);if(J){L.size.width=L.size.height/C.aspectRatio}L.position.top=C.proxy?H.top:0}var D=(C.proxy?L.offset.left-H.left:L.position.left)+L.sizeDiff.width,K=(C.proxy?L.offset.top-H.top:L.position.top)+L.sizeDiff.height;if(D+L.size.width>=L.parentData.width){L.size.width=L.parentData.width-D;if(J){L.size.height=L.size.width*C.aspectRatio}}if(K+L.size.height>=L.parentData.height){L.size.height=L.parentData.height-K;if(J){L.size.width=L.size.height/C.aspectRatio}}}});A.ui.plugin.add("resizable","grid",{resize:function(H,J){var D=J.options,L=J.instance,G=L.size,E=L.originalSize,F=L.originalPosition,K=L.axis,I=D._aspectRatio||H.shiftKey;D.grid=typeof D.grid=="number"?[D.grid,D.grid]:D.grid;var C=Math.round((G.width-E.width)/D.grid[0])*D.grid[0],B=Math.round((G.height-E.height)/D.grid[1])*D.grid[1];if(/^(se|s|e)$/.test(K)){L.size.width=E.width+C;L.size.height=E.height+B}else{if(/^(ne)$/.test(K)){L.size.width=E.width+C;L.size.height=E.height+B;L.position.top=F.top-B}else{if(/^(sw)$/.test(K)){L.size.width=E.width+C;L.size.height=E.height+B;L.position.left=F.left-C}else{L.size.width=E.width+C;L.size.height=E.height+B;L.position.top=F.top-B;L.position.left=F.left-C}}}}});A.ui.plugin.add("resizable","animate",{stop:function(I,K){var F=K.options,L=K.instance;var E=F.proportionallyResize,B=E&&/textarea/i.test(E.get(0).nodeName),C=B&&A.ui.hasScroll(E.get(0),"left")?0:L.sizeDiff.height,H=B?0:L.sizeDiff.width;var D={width:(L.size.width-H),height:(L.size.height-C)},G=parseInt(L.element.css("left"),10)+(L.position.left-L.originalPosition.left),J=parseInt(L.element.css("top"),10)+(L.position.top-L.originalPosition.top);L.element.animate(A.extend(D,{top:J,left:G}),{duration:F.animateDuration||"slow",easing:F.animateEasing||"swing",step:function(){if(E){E.css({width:L.element.css("width"),height:L.element.css("height")})}}})}});A.ui.plugin.add("resizable","ghost",{start:function(E,D){var F=D.options,B=D.instance,G=F.proportionallyResize,C=B.size;if(!G){B.ghost=B.element.clone()}else{B.ghost=G.clone()}B.ghost.css({opacity:0.25,display:"block",position:"relative",height:C.height,width:C.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof F.ghost=="string"?F.ghost:"");B.ghost.appendTo(B.helper)},resize:function(D,C){var E=C.options,B=C.instance,F=E.proportionallyResize;if(B.ghost){B.ghost.css({position:"relative",height:B.size.height,width:B.size.width})}},stop:function(D,C){var E=C.options,B=C.instance,F=E.proportionallyResize;if(B.ghost&&B.helper){B.helper.get(0).removeChild(B.ghost.get(0))}}})})(jQuery);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -