r1618 - trunk/ui

r1618 - trunk/ui


Author: eduardolundgren
Date: Thu Jan 15 18:09:45 2009
New Revision: 1618
Modified:
trunk/ui/ui.accordion.js
trunk/ui/ui.dialog.js
trunk/ui/ui.draggable.js
trunk/ui/ui.droppable.js
trunk/ui/ui.progressbar.js
trunk/ui/ui.resizable.js
trunk/ui/ui.selectable.js
trunk/ui/ui.slider.js
trunk/ui/ui.sortable.js
trunk/ui/ui.tabs.js
Log:
Revert changes for #3838 for the release 1.6rc5
Modified: trunk/ui/ui.accordion.js
==============================================================================
--- trunk/ui/ui.accordion.js    (original)
+++ trunk/ui/ui.accordion.js    Thu Jan 15 18:09:45 2009
@@ -12,18 +12,11 @@
*/
(function($) {
-var widgetName = "accordion";
-var classWidgetName = ".accordion";
-
$.widget("ui.accordion", {
    _init: function() {
        var options = this.options;
-        // update widgetName with the name given by the widget factory
-        widgetName = this.widgetName;
-        classWidgetName = '.' + widgetName;
-
        if ( options.navigation ) {
            var current = this.element.find("a").filter(options.navigationFilter);
            if ( current.length ) {
@@ -39,8 +32,8 @@
        this.element.addClass("ui-accordion ui-widget ui-helper-reset");
        var groups = this.element.children().addClass("ui-accordion-group");
        var headers = options.headers =
groups.find("> :first-child").addClass("ui-accordion-header ui-helper-reset
ui-state-default ui-corner-all")
-        .bind("mouseenter." + widgetName, function(){
$(this).addClass('ui-state-hover'); })
-        .bind("mouseleave." + widgetName, function(){
$(this).removeClass('ui-state-hover'); });
+        .bind("mouseenter.accordion", function(){
$(this).addClass('ui-state-hover'); })
+        .bind("mouseleave.accordion", function(){
$(this).removeClass('ui-state-hover'); });
        // wrap content elements in div against animation issues
        
headers.next().wrap("<div></div>").addClass("ui-accordion-content").parent().addClass("ui-accordion-content-wrap
ui-helper-reset ui-widget-content ui-corner-bottom");
@@ -86,15 +79,15 @@
            options.headers.find('a').attr('tabIndex','-1');
        if (options.event) {
-            this.element.bind((options.event) + classWidgetName, clickHandler);
+            this.element.bind((options.event) + ".accordion", clickHandler);
        }
    },
    destroy: function() {
-        this.element.removeClass("ui-accordion ui-widget
ui-helper-reset").removeAttr("role").unbind(classWidgetName);
-        $.removeData(this.element[0], widgetName);
+        this.element.removeClass("ui-accordion ui-widget
ui-helper-reset").removeAttr("role").unbind(".accordion");
+        $.removeData(this.element[0], "accordion");
        var groups =
this.element.children().removeClass("ui-accordion-group "+this.options.selectedClass);
-        var headers =
this.options.headers.unbind(classWidgetName).removeClass("ui-accordion-header
ui-helper-reset ui-state-default ui-corner-all ui-state-active
ui-corner-top")
+        var headers =
this.options.headers.unbind(".accordion").removeClass("ui-accordion-header
ui-helper-reset ui-state-default ui-corner-all ui-state-active
ui-corner-top")
            .removeAttr("role").removeAttr("aria-expanded").removeAttr("tabindex");
        headers.find("a").removeAttr("tabindex");
        headers.children(".ui-icon").remove();
@@ -175,11 +168,11 @@
function completed(cancel) {
    // if removed while animated data can be empty
-    if (!$.data(this, widgetName)) {
+    if (!$.data(this, "accordion")) {
        return;
    }
-    var instance = $.data(this, widgetName);
+    var instance = $.data(this, "accordion");
    var options = instance.options;
    options.running = cancel ? 0 : --options.running;
    if ( options.running ) {
@@ -195,13 +188,13 @@
}
function toggle(toShow, toHide, data, clickedActive, down) {
-    var options = $.data(this, widgetName).options;
+    var options = $.data(this, "accordion").options;
    options.toShow = toShow;
    options.toHide = toHide;
    options.data = data;
    var complete = scopeCallback(completed, this);
-    $.data(this, widgetName)._trigger("changestart", null, options.data);
+    $.data(this, "accordion")._trigger("changestart", null, options.data);
    // count elements to animate
    options.running = toHide.size() === 0 ? toShow.size() : toHide.size();
@@ -270,7 +263,7 @@
}
function clickHandler(event) {
-    var options = $.data(this, widgetName).options;
+    var options = $.data(this, "accordion").options;
    if (options.disabled) {
        return false;
    }
Modified: trunk/ui/ui.dialog.js
==============================================================================
--- trunk/ui/ui.dialog.js    (original)
+++ trunk/ui/ui.dialog.js    Thu Jan 15 18:09:45 2009
@@ -14,9 +14,6 @@
*/
(function($) {
-var widgetName = "dialog";
-var classWidgetName = ".dialog";
-
var setDataSwitch = {
    dragStart: "start.draggable",
    drag: "drag.draggable",
@@ -33,10 +30,6 @@
$.widget("ui.dialog", {
    _init: function() {
-        // update widgetName with the name given by the widget factory
-        widgetName = this.widgetName;
-        classWidgetName = '.' + widgetName;
-
        this.originalTitle = this.element.attr('title');
        this.options.title = this.options.title || this.originalTitle;
@@ -68,7 +61,7 @@
                        && ev.keyCode == $.ui.keyCode.ESCAPE && self.close());
                })
                .attr({
-                    role: widgetName,
+                    role: 'dialog',
                    'aria-labelledby': titleId
                })
                .mousedown(function() {
@@ -159,8 +152,8 @@
        (this.overlay && this.overlay.destroy());
        this.uiDialog.hide();
        this.element
-            .unbind(classWidgetName)
-            .removeData(widgetName)
+            .unbind('.dialog')
+            .removeData('dialog')
            .removeClass('ui-dialog-content ui-widget-content')
            .hide().appendTo('body');
        this.uiDialog.remove();
Modified: trunk/ui/ui.draggable.js
==============================================================================
--- trunk/ui/ui.draggable.js    (original)
+++ trunk/ui/ui.draggable.js    Thu Jan 15 18:09:45 2009
@@ -12,15 +12,9 @@
*/
(function($) {
-var widgetName = "draggable";
-var classWidgetName = ".draggable";
-
$.widget("ui.draggable", $.extend({}, $.ui.mouse, {
    _init: function() {
-        // update widgetName with the name given by the widget factory
-        widgetName = this.widgetName;
-        classWidgetName = '.' + widgetName;
        if (this.options.helper == 'original' && !(/^(?:r|a|
f)/).test(this.element.css("position")))
            this.element[0].style.position = 'relative';
@@ -33,8 +27,8 @@
    },
    destroy: function() {
-        if(!this.element.data(widgetName)) return;
-        
this.element.removeData(widgetName).unbind(classWidgetName).removeClass(this.options.cssNamespace+'-draggable '+this.options.cssNamespace+'-draggable-dragging '+this.options.cssNamespace+'-draggable-disabled');
+        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._mouseDestroy();
    },
@@ -432,10 +426,10 @@
    }
});
-$.ui.plugin.add(widgetName, "connectToSortable", {
+$.ui.plugin.add("draggable", "connectToSortable", {
    start: function(event, ui) {
-        var inst = $(this).data(widgetName);
+        var inst = $(this).data("draggable");
        inst.sortables = [];
        $(ui.options.connectToSortable).each(function() {
            // 'this' points to a string, and should therefore resolved as query,
but instead, if the string is assigned to a variable, it loops through the
strings properties,
@@ -457,7 +451,7 @@
    stop: function(event, ui) {
        //If we are still over the sortable, we fake the stop event of the
sortable, but also remove helper
-        var inst = $(this).data(widgetName);
+        var inst = $(this).data("draggable");
        $.each(inst.sortables, function() {
            if(this.instance.isOver) {
@@ -492,7 +486,7 @@
    },
    drag: function(event, ui) {
-        var inst = $(this).data(widgetName), self = this;
+        var inst = $(this).data("draggable"), self = this;
        var checkPos = function(o) {
            var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
@@ -562,7 +556,7 @@
    }
});
-$.ui.plugin.add(widgetName, "cursor", {
+$.ui.plugin.add("draggable", "cursor", {
    start: function(event, ui) {
        var t = $('body');
        if (t.css("cursor")) ui.options._cursor = t.css("cursor");
@@ -573,7 +567,7 @@
    }
});
-$.ui.plugin.add(widgetName, "iframeFix", {
+$.ui.plugin.add("draggable", "iframeFix", {
    start: function(event, ui) {
        $(ui.options.iframeFix === true ? "iframe" :
ui.options.iframeFix).each(function() {
            $('<div class="ui-draggable-iframeFix" style="background:
#fff;"></div>')
@@ -590,7 +584,7 @@
    }
});
-$.ui.plugin.add(widgetName, "opacity", {
+$.ui.plugin.add("draggable", "opacity", {
    start: function(event, ui) {
        var t = $(ui.helper);
        if(t.css("opacity")) ui.options._opacity = t.css("opacity");
@@ -601,10 +595,10 @@
    }
});
-$.ui.plugin.add(widgetName, "scroll", {
+$.ui.plugin.add("draggable", "scroll", {
    start: function(event, ui) {
        var o = ui.options;
-        var i = $(this).data(widgetName);
+        var i = $(this).data("draggable");
        if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML')
i.overflowOffset = i.scrollParent.offset();
@@ -612,7 +606,7 @@
    drag: function(event, ui) {
        var o = ui.options, scrolled = false;
-        var i = $(this).data(widgetName);
+        var i = $(this).data("draggable");
        if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML')
{
@@ -646,10 +640,10 @@
    }
});
-$.ui.plugin.add(widgetName, "snap", {
+$.ui.plugin.add("draggable", "snap", {
    start: function(event, ui) {
-        var inst = $(this).data(widgetName);
+        var inst = $(this).data("draggable");
        inst.snapElements = [];
        $(ui.options.snap.constructor != String ? ( ui.options.snap.items |
| ':data(draggable)' ) : ui.options.snap).each(function() {
@@ -664,7 +658,7 @@
    },
    drag: function(event, ui) {
-        var inst = $(this).data(widgetName);
+        var inst = $(this).data("draggable");
        var d = ui.options.snapTolerance;
        var x1 = ui.absolutePosition.left, x2 = x1 +
inst.helperProportions.width,
@@ -715,7 +709,7 @@
    }
});
-$.ui.plugin.add(widgetName, "stack", {
+$.ui.plugin.add("draggable", "stack", {
    start: function(event, ui) {
        var group = $.makeArray($(ui.options.stack.group)).sort(function(a,b) {
            return (parseInt($(a).css("zIndex"),10) || ui.options.stack.min) -
(parseInt($(b).css("zIndex"),10) || ui.options.stack.min);
@@ -729,7 +723,7 @@
    }
});
-$.ui.plugin.add(widgetName, "zIndex", {
+$.ui.plugin.add("draggable", "zIndex", {
    start: function(event, ui) {
        var t = $(ui.helper);
        if(t.css("zIndex")) ui.options._zIndex = t.css("zIndex");
Modified: trunk/ui/ui.droppable.js
==============================================================================
--- trunk/ui/ui.droppable.js    (original)
+++ trunk/ui/ui.droppable.js    Thu Jan 15 18:09:45 2009
@@ -13,15 +13,9 @@
*/
(function($) {
-var widgetName = "droppable";
-var classWidgetName = ".droppable";
-
$.widget("ui.droppable", {
    _init: function() {
-        // update widgetName with the name given by the widget factory
-        widgetName = this.widgetName;
-        classWidgetName = '.' + widgetName;
        var o = this.options, accept = o.accept;
        this.isover = 0; this.isout = 1;
@@ -49,8 +43,8 @@
        this.element
        
    .removeClass(this.options.cssNamespace+"-droppable "+this.options.cssNamespace+"-droppable-disabled")
-            .removeData(widgetName)
-            .unbind(classWidgetName);
+            .removeData("droppable")
+            .unbind(".droppable");
    },
    _setData: function(key, value) {
@@ -111,8 +105,8 @@
        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(" + widgetName
+ ")").not("."+draggable.options.cssNamespace+"-draggable-dragging").each(function()
{
-            var inst = $.data(this, widgetName);
+        
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;
            }
@@ -209,9 +203,10 @@
    current: null,
    droppables: { 'default': [] },
    prepareOffsets: function(t, event) {
+
        var m = $.ui.ddmanager.droppables[t.options.scope];
        var type = event ? event.type : null; // workaround for #2317
-        var list = (t.currentItem || t.element).find(":data(" + widgetName
+ ")").andSelf();
+        var list = (t.currentItem ||
t.element).find(":data(droppable)").andSelf();
        droppablesLoop: for (var i = 0; i < m.length; i++) {
@@ -262,9 +257,9 @@
            var parentInstance;
            if (this.options.greedy) {
-                var parent = this.element.parents(':data(' + widgetName + '):eq(0)');
+                var parent = this.element.parents(':data(droppable):eq(0)');
                if (parent.length) {
-                    parentInstance = $.data(parent[0], widgetName);
+                    parentInstance = $.data(parent[0], 'droppable');
                    parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
                }
            }
@@ -294,7 +289,7 @@
* Droppable Extensions
*/
-$.ui.plugin.add(widgetName, "activeClass", {
+$.ui.plugin.add("droppable", "activeClass", {
    activate: function(event, ui) {
        $(this).addClass(ui.options.activeClass);
    },
@@ -306,7 +301,7 @@
    }
});
-$.ui.plugin.add(widgetName, "hoverClass", {
+$.ui.plugin.add("droppable", "hoverClass", {
    over: function(event, ui) {
        $(this).addClass(ui.options.hoverClass);
    },
Modified: trunk/ui/ui.progressbar.js
==============================================================================
--- trunk/ui/ui.progressbar.js    (original)
+++ trunk/ui/ui.progressbar.js    Thu Jan 15 18:09:45 2009
@@ -12,15 +12,9 @@
*/
(function($) {
-var widgetName = "progressbar";
-var classWidgetName = ".progressbar";
-
$.widget("ui.progressbar", {
    _init: function() {
-        // update widgetName with the name given by the widget factory
-        widgetName = this.widgetName;
-        classWidgetName = '.' + widgetName;
        var self = this,
            options = this.options;
@@ -31,7 +25,7 @@
                + " ui-widget-content"
                + " ui-corner-all")
            .attr({
-                role: widgetName,
+                role: "progressbar",
                "aria-valuemin": this._valueMin(),
                "aria-valuemax": this._valueMax(),
                "aria-valuenow": this._value()
@@ -54,8 +48,8 @@
            .removeAttr("aria-valuemin")
            .removeAttr("aria-valuemax")
            .removeAttr("aria-valuenow")
-            .removeData(widgetName)
-            .unbind(classWidgetName);
+            .removeData("progressbar")
+            .unbind(".progressbar");
        this.valueDiv.remove();
Modified: trunk/ui/ui.resizable.js
==============================================================================
--- trunk/ui/ui.resizable.js    (original)
+++ trunk/ui/ui.resizable.js    Thu Jan 15 18:09:45 2009
@@ -12,15 +12,9 @@
*/
(function($) {
-var widgetName = "resizable";
-var classWidgetName = ".resizable";
-
$.widget("ui.resizable", $.extend({}, $.ui.mouse, {
    _init: function() {
-        // update widgetName with the name given by the widget factory
-        widgetName = this.widgetName;
-        classWidgetName = '.' + widgetName;
        var self = this, o = this.options;
@@ -89,7 +83,7 @@
            var oel = this.element; this.element = this.element.parent();
            // store instance on wrapper
-            this.element.data(widgetName, this);
+            this.element.data('resizable', this);
            //Move margins to the wrapper
            this.element.css({ marginLeft: oel.css("marginLeft"), marginTop:
oel.css("marginTop"),
@@ -234,7 +228,7 @@
        var _destroy = function(exp) {
            $(exp).removeClass("ui-resizable ui-resizable-disabled")
-            
    .removeData(widgetName).unbind(classWidgetName).find('.ui-resizable-handle').remove();
+            
    .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
        };
        _destroy(el);
@@ -576,10 +570,10 @@
* Resizable Extensions
*/
-$.ui.plugin.add(widgetName, "alsoResize", {
+$.ui.plugin.add("resizable", "alsoResize", {
    start: function(event, ui) {
-        var o = ui.options, self = $(this).data(widgetName),
+        var o = ui.options, self = $(this).data("resizable"),
        _store = function(exp) {
            $(exp).each(function() {
@@ -599,7 +593,7 @@
    },
    resize: function(event, ui){
-        var o = ui.options, self = $(this).data(widgetName), os =
self.originalSize, op = self.originalPosition;
+        var o = ui.options, self = $(this).data("resizable"), os =
self.originalSize, op = self.originalPosition;
        var delta = {
            height: (self.size.height - os.height) || 0, width: (self.size.width -
os.width) || 0,
@@ -631,10 +625,10 @@
    }
});
-$.ui.plugin.add(widgetName, "animate", {
+$.ui.plugin.add("resizable", "animate", {
    stop: function(event, ui) {
-        var o = ui.options, self = $(this).data(widgetName);
+        var o = ui.options, self = $(this).data("resizable");
        var pr = o.proportionallyResize, ista = pr &&
(/textarea/i).test(pr.get(0).nodeName),
                        soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump
height */ ? 0 : self.sizeDiff.height,
@@ -670,10 +664,10 @@
});
-$.ui.plugin.add(widgetName, "containment", {
+$.ui.plugin.add("resizable", "containment", {
    start: function(event, ui) {
-        var o = ui.options, self = $(this).data(widgetName), el = self.element;
+        var o = ui.options, self = $(this).data("resizable"), el = self.element;
        var oc = o.containment,    ce = (oc instanceof $) ? oc.get(0) :
(/parent/.test(oc)) ? el.parent().get(0) : oc;
        if (!ce) return;
@@ -705,7 +699,7 @@
    },
    resize: function(event, ui) {
-        var o = ui.options, self = $(this).data(widgetName),
+        var o = ui.options, self = $(this).data("resizable"),
                ps = self.containerSize, co = self.containerOffset, cs = self.size, cp
= self.position,
                pRatio = o._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce
= self.containerElement;
@@ -739,7 +733,7 @@
    },
    stop: function(event, ui){
-        var o = ui.options, self = $(this).data(widgetName), cp = self.position,
+        var o = ui.options, self = $(this).data("resizable"), cp = self.position,
                co = self.containerOffset, cop = self.containerPosition, ce =
self.containerElement;
        var helper = $(self.helper), ho = helper.offset(), w =
helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() -
self.sizeDiff.height;
@@ -753,10 +747,10 @@
    }
});
-$.ui.plugin.add(widgetName, "ghost", {
+$.ui.plugin.add("resizable", "ghost", {
    start: function(event, ui) {
-        var o = ui.options, self = $(this).data(widgetName), pr =
o.proportionallyResize, cs = self.size;
+        var o = ui.options, self = $(this).data("resizable"), pr =
o.proportionallyResize, cs = self.size;
        if (!pr) self.ghost = self.element.clone();
        else self.ghost = pr.clone();
@@ -771,23 +765,23 @@
    },
    resize: function(event, ui){
-        var o = ui.options, self = $(this).data(widgetName), pr =
o.proportionallyResize;
+        var o = ui.options, self = $(this).data("resizable"), pr =
o.proportionallyResize;
        if (self.ghost) self.ghost.css({ position: 'relative', height:
self.size.height, width: self.size.width });
    },
    stop: function(event, ui){
-        var o = ui.options, self = $(this).data(widgetName), pr =
o.proportionallyResize;
+        var o = ui.options, self = $(this).data("resizable"), pr =
o.proportionallyResize;
        if (self.ghost && self.helper)
self.helper.get(0).removeChild(self.ghost.get(0));
    }
});
-$.ui.plugin.add(widgetName, "grid", {
+$.ui.plugin.add("resizable", "grid", {
    resize: function(event, ui) {
-        var o = ui.options, self = $(this).data(widgetName), cs = self.size, os
= self.originalSize, op = self.originalPosition, a = self.axis, ratio =
o._aspectRatio || event.shiftKey;
+        var o = ui.options, self = $(this).data("resizable"), cs = self.size, os
= self.originalSize, op = self.originalPosition, a = self.axis, ratio =
o._aspectRatio || event.shiftKey;
        o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
        var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]|
|1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]|
|1);
Modified: trunk/ui/ui.selectable.js
==============================================================================
--- trunk/ui/ui.selectable.js    (original)
+++ trunk/ui/ui.selectable.js    Thu Jan 15 18:09:45 2009
@@ -12,16 +12,9 @@
*/
(function($) {
-var widgetName = "selectable";
-var classWidgetName = ".selectable";
-
$.widget("ui.selectable", $.extend({}, $.ui.mouse, {
    _init: function() {
-        // update widgetName with the name given by the widget factory
-        widgetName = this.widgetName;
-        classWidgetName = '.' + widgetName;
-
        var self = this;
        this.element.addClass(&