From bc8e75059c7a222ede8f5fddd88098581e5ee3ce Mon Sep 17 00:00:00 2001 From: Jyoti Deka Date: Sun, 15 Dec 2013 13:04:08 -0500 Subject: [PATCH] Resizable: remove redundant comments and whitespace --- ui/jquery.ui.resizable.js | 57 +++++++++++---------------------------- 1 file changed, 15 insertions(+), 42 deletions(-) diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js index afdf1ff25..66ee69a57 100644 --- a/ui/jquery.ui.resizable.js +++ b/ui/jquery.ui.resizable.js @@ -53,7 +53,6 @@ $.widget("ui.resizable", $.ui.mouse, { _hasScroll: function( el, a ) { - //If overflow is hidden, the element might have extra content, but the user wants to hide it if ( $( el ).css( "overflow" ) === "hidden") { return false; } @@ -89,10 +88,9 @@ $.widget("ui.resizable", $.ui.mouse, { _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null }); - //Wrap the element if it cannot hold child nodes + // Wrap the element if it cannot hold child nodes if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) { - //Create a wrapper element and set the wrapper to the new current internal element this.element.wrap( $("
").css({ position: this.element.css("position"), @@ -103,30 +101,26 @@ $.widget("ui.resizable", $.ui.mouse, { }) ); - //Overwrite the original this.element this.element = this.element.parent().data( "ui-resizable", this.element.resizable( "instance" ) ); this.elementIsWrapper = true; - //Move margins to the wrapper 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}); - - //Prevent Safari textarea resize + // support: Safari + // Prevent Safari textarea resize this.originalResizeStyle = this.originalElement.css("resize"); this.originalElement.css("resize", "none"); - //Push the actual element to our proportionallyResize internal array this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" })); + // support: IE9 // avoid IE jump (hard set the margin) this.originalElement.css({ margin: this.originalElement.css("margin") }); - // fix handlers offset this._proportionallyResize(); - } this.handles = o.handles || (!$(".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" }); @@ -145,15 +139,13 @@ $.widget("ui.resizable", $.ui.mouse, { hname = "ui-resizable-"+handle; axis = $("
"); - // Apply zIndex to all handles - see #7960 axis.css({ zIndex: o.zIndex }); - //TODO : What's going on here? + // TODO : What's going on here? if ("se" === handle) { axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se"); } - //Insert into internal handles object and append to element this.handles[handle] = ".ui-resizable-"+handle; this.element.append(axis); } @@ -172,15 +164,12 @@ $.widget("ui.resizable", $.ui.mouse, { this.handles[i] = this.element.children( this.handles[ i ] ).first().show(); } - //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls) if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) { axis = $(this.handles[i], this.element); - //Checking the correct pad and border padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth(); - //The padding type i have to apply... padPos = [ "padding", /ne|nw|n/.test(i) ? "Top" : /se|sw|s/.test(i) ? "Bottom" : @@ -192,31 +181,28 @@ $.widget("ui.resizable", $.ui.mouse, { } - //TODO: What's that good for? There's not anything to be executed left + // TODO: What's that good for? There's not anything to be executed left if(!$(this.handles[i]).length) { continue; } } }; - //TODO: make renderAxis a prototype function + // TODO: make renderAxis a prototype function this._renderAxis(this.element); this._handles = $(".ui-resizable-handle", this.element) .disableSelection(); - //Matching axis name this._handles.mouseover(function() { if (!that.resizing) { if (this.className) { axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i); } - //Axis, default = se that.axis = axis && axis[1] ? axis[1] : "se"; } }); - //If we want to auto hide the elements if (o.autoHide) { this._handles.hide(); $(this.element) @@ -239,7 +225,6 @@ $.widget("ui.resizable", $.ui.mouse, { }); } - //Initialize the mouse interaction this._mouseInit(); }, @@ -254,7 +239,7 @@ $.widget("ui.resizable", $.ui.mouse, { .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove(); }; - //TODO: Unwrap at same DOM position + // TODO: Unwrap at same DOM position if (this.elementIsWrapper) { _destroy(this.element); wrapper = this.element; @@ -297,7 +282,7 @@ $.widget("ui.resizable", $.ui.mouse, { this.resizing = true; - // bugfix for http://dev.jquery.com/ticket/1749 + // Bugfix for http://bugs.jqueryui.com/ticket/1749 if ( (/absolute/).test( el.css("position") ) ) { el.css({ position: "absolute", top: el.css("top"), left: el.css("left") }); } else if (el.is(".ui-draggable")) { @@ -314,7 +299,6 @@ $.widget("ui.resizable", $.ui.mouse, { curtop += $(o.containment).scrollTop() || 0; } - //Store needed variables this.offset = this.helper.offset(); this.position = { left: curleft, top: curtop }; this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() }; @@ -323,7 +307,6 @@ $.widget("ui.resizable", $.ui.mouse, { this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() }; this.originalMousePosition = { left: event.pageX, top: event.pageY }; - //Aspect Ratio this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1); cursor = $(".ui-resizable-" + this.axis).css("cursor"); @@ -336,7 +319,6 @@ $.widget("ui.resizable", $.ui.mouse, { _mouseDrag: function(event) { - //Increase performance, avoid regex var data, el = this.helper, props = {}, smp = this.originalMousePosition, @@ -358,10 +340,8 @@ $.widget("ui.resizable", $.ui.mouse, { return false; } - // Calculate the attrs that will be change data = trigger.apply(this, [event, dx, dy]); - // Put this in the mouseDrag handler since the user can start pressing shift while resizing this._updateVirtualBoundaries(event.shiftKey); if (this._aspectRatio || event.shiftKey) { data = this._updateRatio(data, event); @@ -371,7 +351,6 @@ $.widget("ui.resizable", $.ui.mouse, { this._updateCache(data); - // plugins callbacks need to be called first this._propagate("resize", event); if ( this.position.top !== this.prevPosition.top ) { @@ -386,15 +365,14 @@ $.widget("ui.resizable", $.ui.mouse, { if ( this.size.height !== this.prevSize.height ) { props.height = this.size.height + "px"; } - el.css(props); + el.css( props ); - if (!this._helper && this._proportionallyResizeElements.length) { + if ( !this._helper && this._proportionallyResizeElements.length ) { this._proportionallyResize(); } - // Call the user callback if the element was resized - if ( ! $.isEmptyObject(props) ) { - this._trigger("resize", event, this.ui()); + if ( !$.isEmptyObject( props ) ) { + this._trigger( "resize", event, this.ui() ); } return false; @@ -455,8 +433,6 @@ $.widget("ui.resizable", $.ui.mouse, { }; if(this._aspectRatio || forceAspectRatio) { - // We want to create an enclosing box whose aspect ration is the requested one - // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension pMinWidth = b.minHeight * this.aspectRatio; pMinHeight = b.minWidth / this.aspectRatio; pMaxWidth = b.maxHeight * this.aspectRatio; @@ -553,7 +529,7 @@ $.widget("ui.resizable", $.ui.mouse, { data.top = dh - o.maxHeight; } - // fixing jump error on top/left - bug #2330 + // Fixing jump error on top/left - bug #2330 if (!data.width && !data.height && !data.left && data.top) { data.top = null; } else if (!data.width && !data.height && !data.top && data.left) { @@ -753,10 +729,7 @@ $.ui.plugin.add( "resizable", "containment", { width: $( document ).width(), height: $( document ).height() || document.body.parentNode.scrollHeight }; - } - - // i'm a node, so compute top, left, right, bottom - else { + } else { element = $( ce ); p = []; $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) { -- 2.39.5