Skip to content

Commit 84c8ba0

Browse files
committed
Resizable: Remove uses of self var; use that var.
1 parent 8fcf7ea commit 84c8ba0

File tree

1 file changed

+93
-93
lines changed

1 file changed

+93
-93
lines changed

ui/jquery.ui.resizable.js

Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $.widget("ui.resizable", $.ui.mouse, {
3737
},
3838
_create: function() {
3939

40-
var self = this, o = this.options;
40+
var that = this, o = this.options;
4141
this.element.addClass("ui-resizable");
4242

4343
$.extend(this, {
@@ -158,11 +158,11 @@ $.widget("ui.resizable", $.ui.mouse, {
158158

159159
//Matching axis name
160160
this._handles.mouseover(function() {
161-
if (!self.resizing) {
161+
if (!that.resizing) {
162162
if (this.className)
163163
var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
164164
//Axis, default = se
165-
self.axis = axis && axis[1] ? axis[1] : 'se';
165+
that.axis = axis && axis[1] ? axis[1] : 'se';
166166
}
167167
});
168168

@@ -174,13 +174,13 @@ $.widget("ui.resizable", $.ui.mouse, {
174174
.hover(function() {
175175
if (o.disabled) return;
176176
$(this).removeClass("ui-resizable-autohide");
177-
self._handles.show();
177+
that._handles.show();
178178
},
179179
function(){
180180
if (o.disabled) return;
181-
if (!self.resizing) {
181+
if (!that.resizing) {
182182
$(this).addClass("ui-resizable-autohide");
183-
self._handles.hide();
183+
that._handles.hide();
184184
}
185185
});
186186
}
@@ -276,7 +276,7 @@ $.widget("ui.resizable", $.ui.mouse, {
276276

277277
//Increase performance, avoid regex
278278
var el = this.helper, o = this.options, props = {},
279-
self = this, smp = this.originalMousePosition, a = this.axis;
279+
that = this, smp = this.originalMousePosition, a = this.axis;
280280

281281
var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
282282
var trigger = this._change[a];
@@ -314,22 +314,22 @@ $.widget("ui.resizable", $.ui.mouse, {
314314
_mouseStop: function(event) {
315315

316316
this.resizing = false;
317-
var o = this.options, self = this;
317+
var o = this.options, that = this;
318318

319319
if(this._helper) {
320320
var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
321-
soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
322-
soffsetw = ista ? 0 : self.sizeDiff.width;
321+
soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
322+
soffsetw = ista ? 0 : that.sizeDiff.width;
323323

324-
var s = { width: (self.helper.width() - soffsetw), height: (self.helper.height() - soffseth) },
325-
left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
326-
top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
324+
var s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) },
325+
left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
326+
top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
327327

328328
if (!o.animate)
329329
this.element.css($.extend(s, { top: top, left: left }));
330330

331-
self.helper.height(self.size.height);
332-
self.helper.width(self.size.width);
331+
that.helper.height(that.size.height);
332+
that.helper.width(that.size.width);
333333

334334
if (this._helper && !o.animate) this._proportionallyResize();
335335
}
@@ -547,7 +547,7 @@ $.widget("ui.resizable", $.ui.mouse, {
547547
$.ui.plugin.add("resizable", "alsoResize", {
548548

549549
start: function (event, ui) {
550-
var self = $(this).data("resizable"), o = self.options;
550+
var that = $(this).data("resizable"), o = that.options;
551551

552552
var _store = function (exp) {
553553
$(exp).each(function() {
@@ -568,11 +568,11 @@ $.ui.plugin.add("resizable", "alsoResize", {
568568
},
569569

570570
resize: function (event, ui) {
571-
var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition;
571+
var that = $(this).data("resizable"), o = that.options, os = that.originalSize, op = that.originalPosition;
572572

573573
var delta = {
574-
height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
575-
top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
574+
height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
575+
top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
576576
},
577577

578578
_alsoResize = function (exp, c) {
@@ -605,34 +605,34 @@ $.ui.plugin.add("resizable", "alsoResize", {
605605
$.ui.plugin.add("resizable", "animate", {
606606

607607
stop: function(event, ui) {
608-
var self = $(this).data("resizable"), o = self.options;
608+
var that = $(this).data("resizable"), o = that.options;
609609

610-
var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
611-
soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
612-
soffsetw = ista ? 0 : self.sizeDiff.width;
610+
var pr = that._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
611+
soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
612+
soffsetw = ista ? 0 : that.sizeDiff.width;
613613

614-
var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
615-
left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
616-
top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
614+
var style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
615+
left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
616+
top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
617617

618-
self.element.animate(
618+
that.element.animate(
619619
$.extend(style, top && left ? { top: top, left: left } : {}), {
620620
duration: o.animateDuration,
621621
easing: o.animateEasing,
622622
step: function() {
623623

624624
var data = {
625-
width: parseInt(self.element.css('width'), 10),
626-
height: parseInt(self.element.css('height'), 10),
627-
top: parseInt(self.element.css('top'), 10),
628-
left: parseInt(self.element.css('left'), 10)
625+
width: parseInt(that.element.css('width'), 10),
626+
height: parseInt(that.element.css('height'), 10),
627+
top: parseInt(that.element.css('top'), 10),
628+
left: parseInt(that.element.css('left'), 10)
629629
};
630630

631631
if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
632632

633633
// propagating resize, and updating values for each animation step
634-
self._updateCache(data);
635-
self._propagate("resize", event);
634+
that._updateCache(data);
635+
that._propagate("resize", event);
636636

637637
}
638638
}
@@ -644,17 +644,17 @@ $.ui.plugin.add("resizable", "animate", {
644644
$.ui.plugin.add("resizable", "containment", {
645645

646646
start: function(event, ui) {
647-
var self = $(this).data("resizable"), o = self.options, el = self.element;
647+
var that = $(this).data("resizable"), o = that.options, el = that.element;
648648
var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
649649
if (!ce) return;
650650

651-
self.containerElement = $(ce);
651+
that.containerElement = $(ce);
652652

653653
if (/document/.test(oc) || oc == document) {
654-
self.containerOffset = { left: 0, top: 0 };
655-
self.containerPosition = { left: 0, top: 0 };
654+
that.containerOffset = { left: 0, top: 0 };
655+
that.containerPosition = { left: 0, top: 0 };
656656

657-
self.parentData = {
657+
that.parentData = {
658658
element: $(document), left: 0, top: 0,
659659
width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
660660
};
@@ -665,70 +665,70 @@ $.ui.plugin.add("resizable", "containment", {
665665
var element = $(ce), p = [];
666666
$([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
667667

668-
self.containerOffset = element.offset();
669-
self.containerPosition = element.position();
670-
self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
668+
that.containerOffset = element.offset();
669+
that.containerPosition = element.position();
670+
that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
671671

672-
var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width,
672+
var co = that.containerOffset, ch = that.containerSize.height, cw = that.containerSize.width,
673673
width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
674674

675-
self.parentData = {
675+
that.parentData = {
676676
element: ce, left: co.left, top: co.top, width: width, height: height
677677
};
678678
}
679679
},
680680

681681
resize: function(event, ui) {
682-
var self = $(this).data("resizable"), o = self.options,
683-
ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
684-
pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
682+
var that = $(this).data("resizable"), o = that.options,
683+
ps = that.containerSize, co = that.containerOffset, cs = that.size, cp = that.position,
684+
pRatio = that._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = that.containerElement;
685685

686686
if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
687687

688-
if (cp.left < (self._helper ? co.left : 0)) {
689-
self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left));
690-
if (pRatio) self.size.height = self.size.width / self.aspectRatio;
691-
self.position.left = o.helper ? co.left : 0;
688+
if (cp.left < (that._helper ? co.left : 0)) {
689+
that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
690+
if (pRatio) that.size.height = that.size.width / that.aspectRatio;
691+
that.position.left = o.helper ? co.left : 0;
692692
}
693693

694-
if (cp.top < (self._helper ? co.top : 0)) {
695-
self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top);
696-
if (pRatio) self.size.width = self.size.height * self.aspectRatio;
697-
self.position.top = self._helper ? co.top : 0;
694+
if (cp.top < (that._helper ? co.top : 0)) {
695+
that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
696+
if (pRatio) that.size.width = that.size.height * that.aspectRatio;
697+
that.position.top = that._helper ? co.top : 0;
698698
}
699699

700-
self.offset.left = self.parentData.left+self.position.left;
701-
self.offset.top = self.parentData.top+self.position.top;
700+
that.offset.left = that.parentData.left+that.position.left;
701+
that.offset.top = that.parentData.top+that.position.top;
702702

703-
var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),
704-
hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
703+
var woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width ),
704+
hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
705705

706-
var isParent = self.containerElement.get(0) == self.element.parent().get(0),
707-
isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position'));
706+
var isParent = that.containerElement.get(0) == that.element.parent().get(0),
707+
isOffsetRelative = /relative|absolute/.test(that.containerElement.css('position'));
708708

709-
if(isParent && isOffsetRelative) woset -= self.parentData.left;
709+
if(isParent && isOffsetRelative) woset -= that.parentData.left;
710710

711-
if (woset + self.size.width >= self.parentData.width) {
712-
self.size.width = self.parentData.width - woset;
713-
if (pRatio) self.size.height = self.size.width / self.aspectRatio;
711+
if (woset + that.size.width >= that.parentData.width) {
712+
that.size.width = that.parentData.width - woset;
713+
if (pRatio) that.size.height = that.size.width / that.aspectRatio;
714714
}
715715

716-
if (hoset + self.size.height >= self.parentData.height) {
717-
self.size.height = self.parentData.height - hoset;
718-
if (pRatio) self.size.width = self.size.height * self.aspectRatio;
716+
if (hoset + that.size.height >= that.parentData.height) {
717+
that.size.height = that.parentData.height - hoset;
718+
if (pRatio) that.size.width = that.size.height * that.aspectRatio;
719719
}
720720
},
721721

722722
stop: function(event, ui){
723-
var self = $(this).data("resizable"), o = self.options, cp = self.position,
724-
co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
723+
var that = $(this).data("resizable"), o = that.options, cp = that.position,
724+
co = that.containerOffset, cop = that.containerPosition, ce = that.containerElement;
725725

726-
var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height;
726+
var helper = $(that.helper), ho = helper.offset(), w = helper.outerWidth() - that.sizeDiff.width, h = helper.outerHeight() - that.sizeDiff.height;
727727

728-
if (self._helper && !o.animate && (/relative/).test(ce.css('position')))
728+
if (that._helper && !o.animate && (/relative/).test(ce.css('position')))
729729
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
730730

731-
if (self._helper && !o.animate && (/static/).test(ce.css('position')))
731+
if (that._helper && !o.animate && (/static/).test(ce.css('position')))
732732
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
733733

734734
}
@@ -738,56 +738,56 @@ $.ui.plugin.add("resizable", "ghost", {
738738

739739
start: function(event, ui) {
740740

741-
var self = $(this).data("resizable"), o = self.options, cs = self.size;
741+
var that = $(this).data("resizable"), o = that.options, cs = that.size;
742742

743-
self.ghost = self.originalElement.clone();
744-
self.ghost
743+
that.ghost = that.originalElement.clone();
744+
that.ghost
745745
.css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
746746
.addClass('ui-resizable-ghost')
747747
.addClass(typeof o.ghost == 'string' ? o.ghost : '');
748748

749-
self.ghost.appendTo(self.helper);
749+
that.ghost.appendTo(that.helper);
750750

751751
},
752752

753753
resize: function(event, ui){
754-
var self = $(this).data("resizable"), o = self.options;
755-
if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
754+
var that = $(this).data("resizable"), o = that.options;
755+
if (that.ghost) that.ghost.css({ position: 'relative', height: that.size.height, width: that.size.width });
756756
},
757757

758758
stop: function(event, ui){
759-
var self = $(this).data("resizable"), o = self.options;
760-
if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
759+
var that = $(this).data("resizable"), o = that.options;
760+
if (that.ghost && that.helper) that.helper.get(0).removeChild(that.ghost.get(0));
761761
}
762762

763763
});
764764

765765
$.ui.plugin.add("resizable", "grid", {
766766

767767
resize: function(event, ui) {
768-
var self = $(this).data("resizable"), o = self.options, cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey;
768+
var that = $(this).data("resizable"), o = that.options, cs = that.size, os = that.originalSize, op = that.originalPosition, a = that.axis, ratio = o._aspectRatio || event.shiftKey;
769769
o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
770770
var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1);
771771

772772
if (/^(se|s|e)$/.test(a)) {
773-
self.size.width = os.width + ox;
774-
self.size.height = os.height + oy;
773+
that.size.width = os.width + ox;
774+
that.size.height = os.height + oy;
775775
}
776776
else if (/^(ne)$/.test(a)) {
777-
self.size.width = os.width + ox;
778-
self.size.height = os.height + oy;
779-
self.position.top = op.top - oy;
777+
that.size.width = os.width + ox;
778+
that.size.height = os.height + oy;
779+
that.position.top = op.top - oy;
780780
}
781781
else if (/^(sw)$/.test(a)) {
782-
self.size.width = os.width + ox;
783-
self.size.height = os.height + oy;
784-
self.position.left = op.left - ox;
782+
that.size.width = os.width + ox;
783+
that.size.height = os.height + oy;
784+
that.position.left = op.left - ox;
785785
}
786786
else {
787-
self.size.width = os.width + ox;
788-
self.size.height = os.height + oy;
789-
self.position.top = op.top - oy;
790-
self.position.left = op.left - ox;
787+
that.size.width = os.width + ox;
788+
that.size.height = os.height + oy;
789+
that.position.top = op.top - oy;
790+
that.position.left = op.left - ox;
791791
}
792792
}
793793

0 commit comments

Comments
 (0)