Skip to content

Commit f0ae041

Browse files
committed
Resizable: Add classes option
1 parent 526e2f2 commit f0ae041

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

tests/unit/resizable/resizable_common.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ TestHelpers.commonWidgetTests( "resizable", {
77
aspectRatio: false,
88
autoHide: false,
99
cancel: "input,textarea,button,select,option",
10+
classes: {},
1011
containment: false,
1112
delay: 0,
1213
disabled: false,

ui/resizable.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ $.widget("ui.resizable", $.ui.mouse, {
3535
animateEasing: "swing",
3636
aspectRatio: false,
3737
autoHide: false,
38+
classes: {},
3839
containment: false,
3940
ghost: false,
4041
grid: false,
@@ -88,7 +89,7 @@ $.widget("ui.resizable", $.ui.mouse, {
8889
var n, i, handle, axis, hname,
8990
that = this,
9091
o = this.options;
91-
this.element.addClass("ui-resizable");
92+
this._addClass( "ui-resizable" );
9293

9394
$.extend(this, {
9495
_aspectRatio: !!(o.aspectRatio),
@@ -173,13 +174,14 @@ $.widget("ui.resizable", $.ui.mouse, {
173174

174175
handle = $.trim(n[i]);
175176
hname = "ui-resizable-" + handle;
176-
axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
177+
axis = $("<div>");
178+
this._addClass( axis, "ui-resizable-handle " + hname );
177179

178180
axis.css({ zIndex: o.zIndex });
179181

180182
// TODO : What's going on here?
181183
if ("se" === handle) {
182-
axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
184+
this._addClass( axis, null, "ui-icon ui-icon-gripsmall-diagonal-se" );
183185
}
184186

185187
this.handles[handle] = ".ui-resizable-" + handle;
@@ -241,21 +243,21 @@ $.widget("ui.resizable", $.ui.mouse, {
241243

242244
if (o.autoHide) {
243245
this._handles.hide();
246+
this._addClass( "ui-resizable-autohide" );
244247
$(this.element)
245-
.addClass("ui-resizable-autohide")
246248
.mouseenter(function() {
247249
if (o.disabled) {
248250
return;
249251
}
250-
$(this).removeClass("ui-resizable-autohide");
252+
that._removeClass( $( this ), "ui-resizable-autohide" );
251253
that._handles.show();
252254
})
253255
.mouseleave(function() {
254256
if (o.disabled) {
255257
return;
256258
}
257259
if (!that.resizing) {
258-
$(this).addClass("ui-resizable-autohide");
260+
that._addClass( $( this ), "ui-resizable-autohide" );
259261
that._handles.hide();
260262
}
261263
});
@@ -272,7 +274,6 @@ $.widget("ui.resizable", $.ui.mouse, {
272274
var wrapper,
273275
_destroy = function(exp) {
274276
$(exp)
275-
.removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
276277
.removeData("resizable")
277278
.removeData("ui-resizable")
278279
.unbind(".resizable")
@@ -366,7 +367,7 @@ $.widget("ui.resizable", $.ui.mouse, {
366367
cursor = $(".ui-resizable-" + this.axis).css("cursor");
367368
$("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
368369

369-
el.addClass("ui-resizable-resizing");
370+
this._addClass( "ui-resizable-resizing" );
370371
this._propagate("start", event);
371372
return true;
372373
},
@@ -450,7 +451,7 @@ $.widget("ui.resizable", $.ui.mouse, {
450451

451452
$("body").css("cursor", "auto");
452453

453-
this.element.removeClass("ui-resizable-resizing");
454+
this._removeClass( "ui-resizable-resizing" );
454455

455456
this._propagate("stop", event);
456457

@@ -679,7 +680,8 @@ $.widget("ui.resizable", $.ui.mouse, {
679680

680681
this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
681682

682-
this.helper.addClass(this._helper).css({
683+
this._addClass( this.helper, this._helper );
684+
this.helper.css({
683685
width: this.element.outerWidth() - 1,
684686
height: this.element.outerHeight() - 1,
685687
position: "absolute",
@@ -1072,9 +1074,9 @@ $.ui.plugin.add("resizable", "ghost", {
10721074
margin: 0,
10731075
left: 0,
10741076
top: 0
1075-
})
1076-
.addClass("ui-resizable-ghost")
1077-
.addClass(typeof o.ghost === "string" ? o.ghost : "");
1077+
});
1078+
this._addClass( that.ghost, "ui-resizable-ghost",
1079+
typeof o.ghost === "string" ? o.ghost : "" );
10781080

10791081
that.ghost.appendTo(that.helper);
10801082

0 commit comments

Comments
 (0)