]> source.dussan.org Git - jquery-ui.git/commitdiff
Fixed #4036 (draggable: cssNamespace option should be removed, addClasses option...
authorRichard Worth <rdworth@gmail.com>
Mon, 2 Feb 2009 06:45:50 +0000 (06:45 +0000)
committerRichard Worth <rdworth@gmail.com>
Mon, 2 Feb 2009 06:45:50 +0000 (06:45 +0000)
tests/unit/draggable/draggable_defaults.js
tests/unit/draggable/draggable_options.js
ui/ui.draggable.js

index 493ed9087a74ba510d883694543160dff2a25144..4b0aaca19248d7fe76638740f9c57012f0c20b2c 100644 (file)
@@ -3,6 +3,7 @@
  */
 
 var draggable_defaults = {
+       addClasses: true,
        appendTo: "parent",
        axis: false,
        cancel: ":input,option",
index d5709576dd835ec458ddb1aa0e4548e004410c45..7039b3c56d58b3aab155a04268b8bd8f98e2524a 100644 (file)
@@ -23,6 +23,18 @@ var margin = function(el, side) { return parseInt(el.css('margin-' + side)); }
 
 module("draggable: options");
 
+test("{ addClasses: true }, default", function() {
+       equals(draggable_defaults.addClasses, true);
+
+       el = $("<div></div>").draggable({ addClasses: true });
+       ok(el.is(".ui-draggable"), "'ui-draggable' class added");
+});
+
+test("{ addClasses: false }", function() {
+       el = $("<div></div>").draggable({ addClasses: false });
+       ok(!el.is(".ui.draggable"), "'ui-draggable' class not added");
+});
+
 test("{ appendTo: 'parent' }, default", function() {
        equals(draggable_defaults.appendTo, "parent");
 
index 2fc541f952a32ec78ba46c9019d75e17da4d1e5d..58c000eae9331e619cd2645cd8152207b30091e2 100644 (file)
@@ -19,8 +19,8 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
                if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
                        this.element[0].style.position = 'relative';
 
-               (this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-draggable"));
-               (this.options.disabled && this.element.addClass(this.options.cssNamespace+'-draggable-disabled'));
+               (this.options.addClasses && this.element.addClass("ui-draggable"));
+               (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
 
                this._mouseInit();
 
@@ -28,7 +28,12 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
 
        destroy: function() {
                if(!this.element.data('draggable')) return;
-               this.element.removeData("draggable").unbind(".draggable").removeClass(this.options.cssNamespace+'-draggable '+this.options.cssNamespace+'-draggable-dragging '+this.options.cssNamespace+'-draggable-disabled');
+               this.element
+                       .removeData("draggable")
+                       .unbind(".draggable")
+                       .removeClass("ui-draggable"
+                               + " ui-draggable-dragging"
+                               + " ui-draggable-disabled");
                this._mouseDestroy();
        },
 
@@ -36,7 +41,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
 
                var o = this.options;
 
-               if (this.helper || o.disabled || $(event.target).is('.'+this.options.cssNamespace+'-resizable-handle'))
+               if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
                        return false;
 
                //Quit if we're not on a valid handle
@@ -113,7 +118,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
                if ($.ui.ddmanager && !o.dropBehaviour)
                        $.ui.ddmanager.prepareOffsets(this, event);
 
-               this.helper.addClass(o.cssNamespace+"-draggable-dragging");
+               this.helper.addClass("ui-draggable-dragging");
                this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
                return true;
        },
@@ -365,7 +370,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
        },
 
        _clear: function() {
-               this.helper.removeClass(this.options.cssNamespace+"-draggable-dragging");
+               this.helper.removeClass("ui-draggable-dragging");
                if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
                //if($.ui.ddmanager) $.ui.ddmanager.current = null;
                this.helper = null;
@@ -398,12 +403,12 @@ $.extend($.ui.draggable, {
        version: "@VERSION",
        eventPrefix: "drag",
        defaults: {
+               addClasses: true,
                appendTo: "parent",
                axis: false,
                cancel: ":input,option",
                connectToSortable: false,
                containment: false,
-               cssNamespace: "ui",
                cursor: "auto",
                cursorAt: false,
                delay: 0,