]> source.dussan.org Git - jquery-ui.git/commitdiff
Sortable: Add classes option
authorAlexander Schmitz <arschmitz@gmail.com>
Tue, 24 Feb 2015 21:16:47 +0000 (16:16 -0500)
committerAlexander Schmitz <arschmitz@gmail.com>
Wed, 11 Mar 2015 20:05:18 +0000 (16:05 -0400)
Ref #7053
Ref gh-1411

ui/sortable.js

index f41afa5bf36f6b2ea7a7bdec30571ae866e80224..6d872cbe6e723d0a10fbba58708602ca1b2d93fd 100644 (file)
@@ -84,7 +84,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
 
        _create: function() {
                this.containerCache = {};
-               this.element.addClass("ui-sortable");
+               this._addClass( "ui-sortable" );
 
                //Get the items
                this.refresh();
@@ -111,19 +111,19 @@ return $.widget("ui.sortable", $.ui.mouse, {
        },
 
        _setHandleClassName: function() {
-               this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
+               var that = this;
+               this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
                $.each( this.items, function() {
-                       ( this.instance.options.handle ?
-                               this.item.find( this.instance.options.handle ) : this.item )
-                               .addClass( "ui-sortable-handle" );
+                       that._addClass(
+                               this.instance.options.handle ?
+                                       this.item.find( this.instance.options.handle ) :
+                                       this.item,
+                               "ui-sortable-handle"
+                       );
                });
        },
 
        _destroy: function() {
-               this.element
-                       .removeClass( "ui-sortable ui-sortable-disabled" )
-                       .find( ".ui-sortable-handle" )
-                               .removeClass( "ui-sortable-handle" );
                this._mouseDestroy();
 
                for ( var i = this.items.length - 1; i >= 0; i-- ) {
@@ -308,7 +308,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
 
                this.dragging = true;
 
-               this.helper.addClass("ui-sortable-helper");
+               this._addClass( this.helper, "ui-sortable-helper" );
                this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
                return true;
 
@@ -477,7 +477,8 @@ return $.widget("ui.sortable", $.ui.mouse, {
                        this._mouseUp({ target: null });
 
                        if(this.options.helper === "original") {
-                               this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
+                               this.currentItem.css( this._storedCSS );
+                               this._removeClass( this.currentItem, "ui-sortable-helper" );
                        } else {
                                this.currentItem.show();
                        }
@@ -790,9 +791,11 @@ return $.widget("ui.sortable", $.ui.mouse, {
                                element: function() {
 
                                        var nodeName = that.currentItem[0].nodeName.toLowerCase(),
-                                               element = $( "<" + nodeName + ">", that.document[0] )
-                                                       .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
-                                                       .removeClass("ui-sortable-helper");
+                                               element = $( "<" + nodeName + ">", that.document[0] );
+
+                                               that._addClass( element, "ui-sortable-placeholder",
+                                                               className || that.currentItem[ 0 ].className )
+                                                       ._removeClass( element, "ui-sortable-helper" );
 
                                        if ( nodeName === "tbody" ) {
                                                that._createTrPlaceholder(
@@ -1218,7 +1221,8 @@ return $.widget("ui.sortable", $.ui.mouse, {
                                        this._storedCSS[i] = "";
                                }
                        }
-                       this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
+                       this.currentItem.css( this._storedCSS );
+                       this._removeClass( this.currentItem, "ui-sortable-helper" );
                } else {
                        this.currentItem.show();
                }