Skip to content

Commit a692bf9

Browse files
ngsilvermanscottgonzalez
authored andcommitted
Sortable: Inject a CSS rule to style the cursor. Fixed #7389 - sortable: 'cursor' option didn't override CSS cursor settings.
1 parent f78c8ca commit a692bf9

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

ui/jquery.ui.sortable.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ $.widget("ui.sortable", $.ui.mouse, {
158158

159159
_mouseStart: function(event, overrideHandle, noActivation) {
160160

161-
var i,
161+
var i, body,
162162
o = this.options;
163163

164164
this.currentContainer = this;
@@ -228,11 +228,14 @@ $.widget("ui.sortable", $.ui.mouse, {
228228
this._setContainment();
229229
}
230230

231-
if(o.cursor) { // cursor option
232-
if ($("body").css("cursor")) {
233-
this._storedCursor = $("body").css("cursor");
234-
}
235-
$("body").css("cursor", o.cursor);
231+
if( o.cursor && o.cursor !== "auto" ) { // cursor option
232+
body = this.document.find( "body" );
233+
234+
// support: IE
235+
this.storedCursor = body.css( "cursor" );
236+
body.css( "cursor", o.cursor );
237+
238+
this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
236239
}
237240

238241
if(o.opacity) { // opacity option
@@ -1178,8 +1181,9 @@ $.widget("ui.sortable", $.ui.mouse, {
11781181
}
11791182

11801183
//Do what was originally in plugins
1181-
if(this._storedCursor) {
1182-
$("body").css("cursor", this._storedCursor);
1184+
if ( this.storedCursor ) {
1185+
this.document.find( "body" ).css( "cursor", this.storedCursor );
1186+
this.storedStylesheet.remove();
11831187
}
11841188
if(this._storedOpacity) {
11851189
this.helper.css("opacity", this._storedOpacity);

0 commit comments

Comments
 (0)