]> source.dussan.org Git - jquery-ui.git/commitdiff
draggable,droppable,sortable: properly implemented cssNamespace option across plugins...
authorPaul Bakaus <paul.bakaus@googlemail.com>
Wed, 7 Jan 2009 17:43:15 +0000 (17:43 +0000)
committerPaul Bakaus <paul.bakaus@googlemail.com>
Wed, 7 Jan 2009 17:43:15 +0000 (17:43 +0000)
ui/ui.draggable.js
ui/ui.droppable.js
ui/ui.sortable.js

index cac4941cabf1319dbe5af7eb86ecd857ab4f16c8..99494bef471c7004bf55da54cad76d8c31f3337f 100644 (file)
@@ -20,7 +20,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
                        this.element[0].style.position = 'relative';
 
                (this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-draggable"));
-               (this.options.disabled && this.element.addClass('ui-draggable-disabled'));
+               (this.options.disabled && this.element.addClass(this.options.cssNamespace+'-draggable-disabled'));
 
                this._mouseInit();
 
@@ -28,7 +28,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
 
        destroy: function() {
                if(!this.element.data('draggable')) return;
-               this.element.removeData("draggable").unbind(".draggable").removeClass('ui-draggable ui-draggable-dragging ui-draggable-disabled');
+               this.element.removeData("draggable").unbind(".draggable").removeClass(this.options.cssNamespace+'-draggable '+this.options.cssNamespace+'-draggable-dragging '+this.options.cssNamespace+'-draggable-disabled');
                this._mouseDestroy();
        },
 
@@ -36,7 +36,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
 
                var o = this.options;
 
-               if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
+               if (this.helper || o.disabled || $(event.target).is('.'+this.options.cssNamespace+'-resizable-handle'))
                        return false;
 
                //Quit if we're not on a valid handle
@@ -111,7 +111,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
                if ($.ui.ddmanager && !o.dropBehaviour)
                        $.ui.ddmanager.prepareOffsets(this, event);
 
-               this.helper.addClass("ui-draggable-dragging");
+               this.helper.addClass(o.cssNamespace+"-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;
        },
@@ -328,7 +328,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
        },
 
        _clear: function() {
-               this.helper.removeClass("ui-draggable-dragging");
+               this.helper.removeClass(this.options.cssNamespace+"-draggable-dragging");
                if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
                //if($.ui.ddmanager) $.ui.ddmanager.current = null;
                this.helper = null;
index ae6f861c2b819fc969c38c33a062a67330169a90..1d2f27e75821ec27dc8e21531483df3ba51ab839 100644 (file)
@@ -42,7 +42,7 @@ $.widget("ui.droppable", {
                                drop.splice(i, 1);
 
                this.element
-                       .removeClass("ui-droppable-disabled")
+                       .removeClass(this.options.cssNamespace+"-droppable "+this.options.cssNamespace+"-droppable-disabled")
                        .removeData("droppable")
                        .unbind(".droppable");
        },
@@ -105,7 +105,7 @@ $.widget("ui.droppable", {
                if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
 
                var childrenIntersection = false;
-               this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
+               this.element.find(":data(droppable)").not("."+draggable.options.cssNamespace+"-draggable-dragging").each(function() {
                        var inst = $.data(this, 'droppable');
                        if(inst.options.greedy && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)) {
                                childrenIntersection = true; return false;
index 39f1a8b34a08d789eab80f36ec9dc2a76f5137a6..58e36191cec382c94bf7a658ac6a698561119d16 100644 (file)
@@ -17,7 +17,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
 
                var o = this.options;
                this.containerCache = {};
-               this.element.addClass("ui-sortable");
+               (this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-sortable"));
 
                //Get the items
                this.refresh();
@@ -35,7 +35,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
 
        destroy: function() {
                this.element
-                       .removeClass("ui-sortable ui-sortable-disabled")
+                       .removeClass(this.options.cssNamespace+"-sortable "+this.options.cssNamespace+"-sortable-disabled")
                        .removeData("sortable")
                        .unbind(".sortable");
                this._mouseDestroy();
@@ -169,7 +169,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
 
                this.dragging = true;
 
-               this.helper.addClass('ui-sortable-helper');
+               this.helper.addClass(o.cssNamespace+'-sortable-helper');
                this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
                return true;
 
@@ -270,7 +270,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
                        this._mouseUp();
 
                        if(this.options.helper == "original")
-                               this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
+                               this.currentItem.css(this._storedCSS).removeClass(this.options.cssNamespace+"-sortable-helper");
                        else
                                this.currentItem.show();
 
@@ -422,13 +422,13 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
                                for (var j = cur.length - 1; j >= 0; j--){
                                        var inst = $.data(cur[j], 'sortable');
                                        if(inst && inst != this && !inst.options.disabled) {
-                                               queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper"), inst]);
+                                               queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not("."+inst.options.cssNamespace+"-sortable-helper"), inst]);
                                        }
                                };
                        };
                }
 
-               queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper"), this]);
+               queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not("."+this.options.cssNamespace+"-sortable-helper"), this]);
 
                for (var i = queries.length - 1; i >= 0; i--){
                        queries[i][0].each(function() {
@@ -552,8 +552,8 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
                                element: function() {
 
                                        var el = $(document.createElement(self.currentItem[0].nodeName))
-                                               .addClass(className || self.currentItem[0].className+" ui-sortable-placeholder")
-                                               .removeClass('ui-sortable-helper')[0];
+                                               .addClass(className || self.currentItem[0].className+" "+self.options.cssNamespace+"-sortable-placeholder")
+                                               .removeClass(self.options.cssNamespace+'-sortable-helper')[0];
 
                                        if(!className) {
                                                el.style.visibility = "hidden";
@@ -823,12 +823,12 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
                        for(var i in this._storedCSS) {
                                if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
                        }
-                       this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
+                       this.currentItem.css(this._storedCSS).removeClass(this.options.cssNamespace+"-sortable-helper");
                } else {
                        this.currentItem.show();
                }
 
-               if(this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) this._propagate("update", event, null, noPropagation); //Trigger update callback if the DOM position has changed
+               if(this.domPosition.prev != this.currentItem.prev().not("."+this.options.cssNamespace+"-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) this._propagate("update", event, null, noPropagation); //Trigger update callback if the DOM position has changed
                if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
                        this._propagate("remove", event, null, noPropagation);
                        for (var i = this.containers.length - 1; i >= 0; i--){
@@ -896,6 +896,7 @@ $.extend($.ui.sortable, {
                accurateIntersection: true,
                appendTo: "parent",
                cancel: ":input,option",
+               cssNamespace: 'ui',
                delay: 0,
                distance: 1,
                dropOnEmpty: true,