From a692bf9b70305de5e9893e717fc71e1e74fb86ac Mon Sep 17 00:00:00 2001 From: Nathanael Silverman Date: Wed, 13 Feb 2013 17:34:52 +0100 Subject: [PATCH] Sortable: Inject a CSS rule to style the cursor. Fixed #7389 - sortable: 'cursor' option didn't override CSS cursor settings. --- ui/jquery.ui.sortable.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 211ff272e..c9b503bd0 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -158,7 +158,7 @@ $.widget("ui.sortable", $.ui.mouse, { _mouseStart: function(event, overrideHandle, noActivation) { - var i, + var i, body, o = this.options; this.currentContainer = this; @@ -228,11 +228,14 @@ $.widget("ui.sortable", $.ui.mouse, { this._setContainment(); } - if(o.cursor) { // cursor option - if ($("body").css("cursor")) { - this._storedCursor = $("body").css("cursor"); - } - $("body").css("cursor", o.cursor); + if( o.cursor && o.cursor !== "auto" ) { // cursor option + body = this.document.find( "body" ); + + // support: IE + this.storedCursor = body.css( "cursor" ); + body.css( "cursor", o.cursor ); + + this.storedStylesheet = $( "" ).appendTo( body ); } if(o.opacity) { // opacity option @@ -1178,8 +1181,9 @@ $.widget("ui.sortable", $.ui.mouse, { } //Do what was originally in plugins - if(this._storedCursor) { - $("body").css("cursor", this._storedCursor); + if ( this.storedCursor ) { + this.document.find( "body" ).css( "cursor", this.storedCursor ); + this.storedStylesheet.remove(); } if(this._storedOpacity) { this.helper.css("opacity", this._storedOpacity); -- 2.39.5