]> source.dussan.org Git - jquery-ui.git/commitdiff
Sortable: Inject a CSS rule to style the cursor. Fixed #7389 - sortable: 'cursor...
authorNathanael Silverman <nathanael.silverman@gmail.com>
Wed, 13 Feb 2013 16:34:52 +0000 (17:34 +0100)
committerScott González <scott.gonzalez@gmail.com>
Mon, 18 Feb 2013 15:10:01 +0000 (10:10 -0500)
ui/jquery.ui.sortable.js

index 211ff272e8be2dec76b550038657bf1ff4986555..c9b503bd09b843ed2eed70a95def239e9cfb1215 100644 (file)
@@ -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 = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).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);