Skip to content

Commit bc8e750

Browse files
dekajpmikesherov
authored andcommitted
Resizable: remove redundant comments and whitespace
1 parent 20f0646 commit bc8e750

File tree

1 file changed

+15
-42
lines changed

1 file changed

+15
-42
lines changed

ui/jquery.ui.resizable.js

+15-42
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ $.widget("ui.resizable", $.ui.mouse, {
5353

5454
_hasScroll: function( el, a ) {
5555

56-
//If overflow is hidden, the element might have extra content, but the user wants to hide it
5756
if ( $( el ).css( "overflow" ) === "hidden") {
5857
return false;
5958
}
@@ -89,10 +88,9 @@ $.widget("ui.resizable", $.ui.mouse, {
8988
_helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
9089
});
9190

92-
//Wrap the element if it cannot hold child nodes
91+
// Wrap the element if it cannot hold child nodes
9392
if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
9493

95-
//Create a wrapper element and set the wrapper to the new current internal element
9694
this.element.wrap(
9795
$("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
9896
position: this.element.css("position"),
@@ -103,30 +101,26 @@ $.widget("ui.resizable", $.ui.mouse, {
103101
})
104102
);
105103

106-
//Overwrite the original this.element
107104
this.element = this.element.parent().data(
108105
"ui-resizable", this.element.resizable( "instance" )
109106
);
110107

111108
this.elementIsWrapper = true;
112109

113-
//Move margins to the wrapper
114110
this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
115111
this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
116-
117-
//Prevent Safari textarea resize
112+
// support: Safari
113+
// Prevent Safari textarea resize
118114
this.originalResizeStyle = this.originalElement.css("resize");
119115
this.originalElement.css("resize", "none");
120116

121-
//Push the actual element to our proportionallyResize internal array
122117
this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
123118

119+
// support: IE9
124120
// avoid IE jump (hard set the margin)
125121
this.originalElement.css({ margin: this.originalElement.css("margin") });
126122

127-
// fix handlers offset
128123
this._proportionallyResize();
129-
130124
}
131125

132126
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, {
145139
hname = "ui-resizable-"+handle;
146140
axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
147141

148-
// Apply zIndex to all handles - see #7960
149142
axis.css({ zIndex: o.zIndex });
150143

151-
//TODO : What's going on here?
144+
// TODO : What's going on here?
152145
if ("se" === handle) {
153146
axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
154147
}
155148

156-
//Insert into internal handles object and append to element
157149
this.handles[handle] = ".ui-resizable-"+handle;
158150
this.element.append(axis);
159151
}
@@ -172,15 +164,12 @@ $.widget("ui.resizable", $.ui.mouse, {
172164
this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
173165
}
174166

175-
//Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
176167
if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
177168

178169
axis = $(this.handles[i], this.element);
179170

180-
//Checking the correct pad and border
181171
padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
182172

183-
//The padding type i have to apply...
184173
padPos = [ "padding",
185174
/ne|nw|n/.test(i) ? "Top" :
186175
/se|sw|s/.test(i) ? "Bottom" :
@@ -192,31 +181,28 @@ $.widget("ui.resizable", $.ui.mouse, {
192181

193182
}
194183

195-
//TODO: What's that good for? There's not anything to be executed left
184+
// TODO: What's that good for? There's not anything to be executed left
196185
if(!$(this.handles[i]).length) {
197186
continue;
198187
}
199188
}
200189
};
201190

202-
//TODO: make renderAxis a prototype function
191+
// TODO: make renderAxis a prototype function
203192
this._renderAxis(this.element);
204193

205194
this._handles = $(".ui-resizable-handle", this.element)
206195
.disableSelection();
207196

208-
//Matching axis name
209197
this._handles.mouseover(function() {
210198
if (!that.resizing) {
211199
if (this.className) {
212200
axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
213201
}
214-
//Axis, default = se
215202
that.axis = axis && axis[1] ? axis[1] : "se";
216203
}
217204
});
218205

219-
//If we want to auto hide the elements
220206
if (o.autoHide) {
221207
this._handles.hide();
222208
$(this.element)
@@ -239,7 +225,6 @@ $.widget("ui.resizable", $.ui.mouse, {
239225
});
240226
}
241227

242-
//Initialize the mouse interaction
243228
this._mouseInit();
244229

245230
},
@@ -254,7 +239,7 @@ $.widget("ui.resizable", $.ui.mouse, {
254239
.removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
255240
};
256241

257-
//TODO: Unwrap at same DOM position
242+
// TODO: Unwrap at same DOM position
258243
if (this.elementIsWrapper) {
259244
_destroy(this.element);
260245
wrapper = this.element;
@@ -297,7 +282,7 @@ $.widget("ui.resizable", $.ui.mouse, {
297282

298283
this.resizing = true;
299284

300-
// bugfix for http://dev.jquery.com/ticket/1749
285+
// Bugfix for http://bugs.jqueryui.com/ticket/1749
301286
if ( (/absolute/).test( el.css("position") ) ) {
302287
el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
303288
} else if (el.is(".ui-draggable")) {
@@ -314,7 +299,6 @@ $.widget("ui.resizable", $.ui.mouse, {
314299
curtop += $(o.containment).scrollTop() || 0;
315300
}
316301

317-
//Store needed variables
318302
this.offset = this.helper.offset();
319303
this.position = { left: curleft, top: curtop };
320304
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, {
323307
this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
324308
this.originalMousePosition = { left: event.pageX, top: event.pageY };
325309

326-
//Aspect Ratio
327310
this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
328311

329312
cursor = $(".ui-resizable-" + this.axis).css("cursor");
@@ -336,7 +319,6 @@ $.widget("ui.resizable", $.ui.mouse, {
336319

337320
_mouseDrag: function(event) {
338321

339-
//Increase performance, avoid regex
340322
var data,
341323
el = this.helper, props = {},
342324
smp = this.originalMousePosition,
@@ -358,10 +340,8 @@ $.widget("ui.resizable", $.ui.mouse, {
358340
return false;
359341
}
360342

361-
// Calculate the attrs that will be change
362343
data = trigger.apply(this, [event, dx, dy]);
363344

364-
// Put this in the mouseDrag handler since the user can start pressing shift while resizing
365345
this._updateVirtualBoundaries(event.shiftKey);
366346
if (this._aspectRatio || event.shiftKey) {
367347
data = this._updateRatio(data, event);
@@ -371,7 +351,6 @@ $.widget("ui.resizable", $.ui.mouse, {
371351

372352
this._updateCache(data);
373353

374-
// plugins callbacks need to be called first
375354
this._propagate("resize", event);
376355

377356
if ( this.position.top !== this.prevPosition.top ) {
@@ -386,15 +365,14 @@ $.widget("ui.resizable", $.ui.mouse, {
386365
if ( this.size.height !== this.prevSize.height ) {
387366
props.height = this.size.height + "px";
388367
}
389-
el.css(props);
368+
el.css( props );
390369

391-
if (!this._helper && this._proportionallyResizeElements.length) {
370+
if ( !this._helper && this._proportionallyResizeElements.length ) {
392371
this._proportionallyResize();
393372
}
394373

395-
// Call the user callback if the element was resized
396-
if ( ! $.isEmptyObject(props) ) {
397-
this._trigger("resize", event, this.ui());
374+
if ( !$.isEmptyObject( props ) ) {
375+
this._trigger( "resize", event, this.ui() );
398376
}
399377

400378
return false;
@@ -455,8 +433,6 @@ $.widget("ui.resizable", $.ui.mouse, {
455433
};
456434

457435
if(this._aspectRatio || forceAspectRatio) {
458-
// We want to create an enclosing box whose aspect ration is the requested one
459-
// First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
460436
pMinWidth = b.minHeight * this.aspectRatio;
461437
pMinHeight = b.minWidth / this.aspectRatio;
462438
pMaxWidth = b.maxHeight * this.aspectRatio;
@@ -553,7 +529,7 @@ $.widget("ui.resizable", $.ui.mouse, {
553529
data.top = dh - o.maxHeight;
554530
}
555531

556-
// fixing jump error on top/left - bug #2330
532+
// Fixing jump error on top/left - bug #2330
557533
if (!data.width && !data.height && !data.left && data.top) {
558534
data.top = null;
559535
} else if (!data.width && !data.height && !data.top && data.left) {
@@ -753,10 +729,7 @@ $.ui.plugin.add( "resizable", "containment", {
753729
width: $( document ).width(),
754730
height: $( document ).height() || document.body.parentNode.scrollHeight
755731
};
756-
}
757-
758-
// i'm a node, so compute top, left, right, bottom
759-
else {
732+
} else {
760733
element = $( ce );
761734
p = [];
762735
$([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {

0 commit comments

Comments
 (0)