]> source.dussan.org Git - jquery-ui.git/commitdiff
Updated all widgets to use proper data keys when getting plugin instances.
authorScott González <scott.gonzalez@gmail.com>
Fri, 9 Nov 2012 18:28:13 +0000 (13:28 -0500)
committerScott González <scott.gonzalez@gmail.com>
Fri, 9 Nov 2012 18:28:13 +0000 (13:28 -0500)
12 files changed:
tests/unit/autocomplete/autocomplete_core.js
tests/unit/dialog/dialog_events.js
tests/unit/draggable/draggable_events.js
tests/unit/tabs/tabs_core.js
tests/unit/tabs/tabs_options.js
ui/jquery.ui.autocomplete.js
ui/jquery.ui.button.js
ui/jquery.ui.dialog.js
ui/jquery.ui.draggable.js
ui/jquery.ui.droppable.js
ui/jquery.ui.resizable.js
ui/jquery.ui.sortable.js

index f2062cacda566b34a47f3e5aacd0a02c1b9e12b7..845a3b19de6c1b9af0a6c76fb74dc8f1e0120275 100644 (file)
@@ -99,7 +99,7 @@ test( "allow form submit on enter when menu is not active", function() {
                                delay: 0,
                                minLength: 0
                        });
-               element.data( "autocomplete" )._move = function() {
+               element.data( "ui-autocomplete" )._move = function() {
                        didMove = true;
                };
                element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } );
@@ -114,7 +114,7 @@ test( "allow form submit on enter when menu is not active", function() {
                                delay: 0,
                                minLength: 0
                        });
-               element.data( "autocomplete" )._move = function() {
+               element.data( "ui-autocomplete" )._move = function() {
                        ok( true, "repsond to arrow" );
                };
                element.autocomplete( "search" );
index c5090d8f6737be34f46fe86fb8258987bb9adeb8..ee7a8bcb3e3c65fcaebc7d2b7f952f8d8552ee49 100644 (file)
@@ -11,7 +11,7 @@ test("open", function() {
        var el = $("<div></div>");
        el.dialog({
                open: function(ev, ui) {
-                       ok(el.data("dialog")._isOpen, "interal _isOpen flag is set");
+                       ok(el.data("ui-dialog")._isOpen, "interal _isOpen flag is set");
                        ok(true, 'autoOpen: true fires open callback');
                        equal(this, el[0], "context of callback");
                        equal(ev.type, 'dialogopen', 'event type in callback');
@@ -30,7 +30,7 @@ test("open", function() {
                        deepEqual(ui, {}, 'ui hash in callback');
                }
        }).bind('dialogopen', function(ev, ui) {
-               ok(el.data("dialog")._isOpen, "interal _isOpen flag is set");
+               ok(el.data("ui-dialog")._isOpen, "interal _isOpen flag is set");
                ok(true, 'dialog("open") fires open event');
                equal(this, el[0], 'context of event');
                deepEqual(ui, {}, 'ui hash in event');
index 6b1136cb044f2e20d81b9bdcba23a3185119a722..5eab97713c40efa14bd2d1aa9e49db4a677e82cc 100644 (file)
@@ -79,7 +79,7 @@ test("stopping the stop callback", function() {
 
        TestHelpers.draggable.drag(el, 10, 10);
 
-       ok($("#draggable2").data('draggable').helper, "the clone should not be deleted if the stop callback is stopped");
+       ok($("#draggable2").data('ui-draggable').helper, "the clone should not be deleted if the stop callback is stopped");
 
 
 });
index 6307c44887397fcd72c715f993dda464da7beb9f..20364a37db92c7a340fde102baf464b07bb59773 100644 (file)
@@ -33,7 +33,7 @@ test( "nested list", function() {
        expect( 1 );
 
        var element = $( "#tabs6" ).tabs();
-       equal( element.data( "tabs" ).anchors.length, 2, "should contain 2 tab" );
+       equal( element.data( "ui-tabs" ).anchors.length, 2, "should contain 2 tab" );
 });
 
 test( "disconnected from DOM", function() {
@@ -155,7 +155,7 @@ asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER",
                panels = element.find( ".ui-tabs-panel" ),
                keyCode = $.ui.keyCode;
 
-       element.data( "tabs" ).delay = 50;
+       element.data( "ui-tabs" ).delay = 50;
 
        equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
        tabs.eq( 0 ).simulate( "focus" );
@@ -306,7 +306,7 @@ asyncTest( "keyboard support - CTRL navigation", function() {
                panels = element.find( ".ui-tabs-panel" ),
                keyCode = $.ui.keyCode;
 
-       element.data( "tabs" ).delay = 50;
+       element.data( "ui-tabs" ).delay = 50;
 
        equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
        tabs.eq( 0 ).simulate( "focus" );
index c320c9d4674b53806d2e666502a714e03146a5cb..f6e89e84f80a8db663cf1a6190a54d2b37489e49 100644 (file)
@@ -290,7 +290,7 @@ test( "hide and show: false", function() {
                        show: false,
                        hide: false
                }),
-               widget = element.data( "tabs" ),
+               widget = element.data( "ui-tabs" ),
                panels = element.find( ".ui-tabs-panel" );
        widget._show = function() {
                ok( false, "_show() called" );
@@ -311,7 +311,7 @@ asyncTest( "hide and show - animation", function() {
                        show: "drop",
                        hide: 2000
                }),
-               widget = element.data( "tabs" ),
+               widget = element.data( "ui-tabs" ),
                panels = element.find( ".ui-tabs-panel" );
        widget._show = function( element, options, callback ) {
                strictEqual( element[ 0 ], panels[ 1 ], "correct element in _show()" );
index 1da5a6b256f68bf511d9ea505b6f7fe3446b7efa..f5ab57bd422b01000b46286db4c50f1149a52b7e 100644 (file)
@@ -190,7 +190,7 @@ $.widget( "ui.autocomplete", {
                        })
                        .zIndex( this.element.zIndex() + 1 )
                        .hide()
-                       .data( "menu" );
+                       .data( "ui-menu" );
 
                this._on( this.menu.element, {
                        mousedown: function( event ) {
index f253464df6a7acae2f4e20cb54acbc5ccb2cc270..6d7b94a38f4c75a59069e249b8ed9ca557dd1367 100644 (file)
@@ -358,7 +358,7 @@ $.widget( "ui.button", {
 $.widget( "ui.buttonset", {
        version: "@VERSION",
        options: {
-               items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(button)"
+               items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
        },
 
        _create: function() {
index 203618fc25dcd2f92825ae3a6b0bfed659988f57..07c5c7cb6afd12b938205cc0b99afcf40a18c9a7 100644 (file)
@@ -516,7 +516,7 @@ $.widget("ui.dialog", {
                if ( resize ) {
                        this._size();
                }
-               if ( this.uiDialog.is( ":data(resizable)" ) ) {
+               if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
                        this.uiDialog.resizable( "option", resizableOptions );
                }
        },
@@ -546,7 +546,7 @@ $.widget("ui.dialog", {
                                }
                                break;
                        case "draggable":
-                               isDraggable = uiDialog.is( ":data(draggable)" );
+                               isDraggable = uiDialog.is( ":data(ui-draggable)" );
                                if ( isDraggable && !value ) {
                                        uiDialog.draggable( "destroy" );
                                }
@@ -560,7 +560,7 @@ $.widget("ui.dialog", {
                                break;
                        case "resizable":
                                // currently resizable, becoming non-resizable
-                               isResizable = uiDialog.is( ":data(resizable)" );
+                               isResizable = uiDialog.is( ":data(ui-resizable)" );
                                if ( isResizable && !value ) {
                                        uiDialog.resizable( "destroy" );
                                }
@@ -621,7 +621,7 @@ $.widget("ui.dialog", {
                        this.element.height( Math.max( options.height - nonContentHeight, 0 ) );
                }
 
-               if (this.uiDialog.is( ":data(resizable)" ) ) {
+               if (this.uiDialog.is( ":data(ui-resizable)" ) ) {
                        this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
                }
        }
index 7a6d8e2e66884ce60a5aac8ec68d78e6bd202c2a..1f3c8d52cc5f548306703b73619fc5a19bc76455 100644 (file)
@@ -506,11 +506,11 @@ $.widget("ui.draggable", $.ui.mouse, {
 $.ui.plugin.add("draggable", "connectToSortable", {
        start: function(event, ui) {
 
-               var inst = $(this).data("draggable"), o = inst.options,
+               var inst = $(this).data("ui-draggable"), o = inst.options,
                        uiSortable = $.extend({}, ui, { item: inst.element });
                inst.sortables = [];
                $(o.connectToSortable).each(function() {
-                       var sortable = $.data(this, 'sortable');
+                       var sortable = $.data(this, 'ui-sortable');
                        if (sortable && !sortable.options.disabled) {
                                inst.sortables.push({
                                        instance: sortable,
@@ -525,7 +525,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
        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("draggable"),
+               var inst = $(this).data("ui-draggable"),
                        uiSortable = $.extend({}, ui, { item: inst.element });
 
                $.each(inst.sortables, function() {
@@ -558,7 +558,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
        },
        drag: function(event, ui) {
 
-               var inst = $(this).data("draggable"), that = this;
+               var inst = $(this).data("ui-draggable"), that = this;
 
                $.each(inst.sortables, function() {
 
@@ -592,7 +592,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
                                        //Now we fake the start of dragging for the sortable instance,
                                        //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
                                        //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
-                                       this.instance.currentItem = $(that).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
+                                       this.instance.currentItem = $(that).clone().removeAttr('id').appendTo(this.instance.element).data("ui-sortable-item", true);
                                        this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
                                        this.instance.options.helper = function() { return ui.helper[0]; };
 
@@ -652,36 +652,36 @@ $.ui.plugin.add("draggable", "connectToSortable", {
 
 $.ui.plugin.add("draggable", "cursor", {
        start: function() {
-               var t = $('body'), o = $(this).data('draggable').options;
+               var t = $('body'), o = $(this).data('ui-draggable').options;
                if (t.css("cursor")) o._cursor = t.css("cursor");
                t.css("cursor", o.cursor);
        },
        stop: function() {
-               var o = $(this).data('draggable').options;
+               var o = $(this).data('ui-draggable').options;
                if (o._cursor) $('body').css("cursor", o._cursor);
        }
 });
 
 $.ui.plugin.add("draggable", "opacity", {
        start: function(event, ui) {
-               var t = $(ui.helper), o = $(this).data('draggable').options;
+               var t = $(ui.helper), o = $(this).data('ui-draggable').options;
                if(t.css("opacity")) o._opacity = t.css("opacity");
                t.css('opacity', o.opacity);
        },
        stop: function(event, ui) {
-               var o = $(this).data('draggable').options;
+               var o = $(this).data('ui-draggable').options;
                if(o._opacity) $(ui.helper).css('opacity', o._opacity);
        }
 });
 
 $.ui.plugin.add("draggable", "scroll", {
        start: function() {
-               var i = $(this).data("draggable");
+               var i = $(this).data("ui-draggable");
                if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
        },
        drag: function( event ) {
 
-               var i = $(this).data("draggable"), o = i.options, scrolled = false;
+               var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
 
                if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
 
@@ -726,10 +726,10 @@ $.ui.plugin.add("draggable", "scroll", {
 $.ui.plugin.add("draggable", "snap", {
        start: function() {
 
-               var i = $(this).data("draggable"), o = i.options;
+               var i = $(this).data("ui-draggable"), o = i.options;
                i.snapElements = [];
 
-               $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
+               $(o.snap.constructor != String ? ( o.snap.items || ':data(ui-draggable)' ) : o.snap).each(function() {
                        var $t = $(this); var $o = $t.offset();
                        if(this != i.element[0]) i.snapElements.push({
                                item: this,
@@ -741,7 +741,7 @@ $.ui.plugin.add("draggable", "snap", {
        },
        drag: function(event, ui) {
 
-               var inst = $(this).data("draggable"), o = inst.options;
+               var inst = $(this).data("ui-draggable"), o = inst.options;
                var d = o.snapTolerance;
 
                var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
@@ -795,7 +795,7 @@ $.ui.plugin.add("draggable", "snap", {
 $.ui.plugin.add("draggable", "stack", {
        start: function() {
 
-               var o = $(this).data("draggable").options;
+               var o = $(this).data("ui-draggable").options;
 
                var group = $.makeArray($(o.stack)).sort(function(a,b) {
                        return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
@@ -814,12 +814,12 @@ $.ui.plugin.add("draggable", "stack", {
 
 $.ui.plugin.add("draggable", "zIndex", {
        start: function(event, ui) {
-               var t = $(ui.helper), o = $(this).data("draggable").options;
+               var t = $(ui.helper), o = $(this).data("ui-draggable").options;
                if(t.css("zIndex")) o._zIndex = t.css("zIndex");
                t.css('zIndex', o.zIndex);
        },
        stop: function(event, ui) {
-               var o = $(this).data("draggable").options;
+               var o = $(this).data("ui-draggable").options;
                if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
        }
 });
index 7a346dab5dd704a6b73b716697103d824b470826..f27d56b85d1ba58e94a36685310400edc6d2d283 100644 (file)
@@ -110,8 +110,8 @@ $.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() {
-                       var inst = $.data(this, 'droppable');
+               this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
+                       var inst = $.data(this, 'ui-droppable');
                        if(
                                inst.options.greedy
                                && !inst.options.disabled
@@ -193,7 +193,7 @@ $.ui.ddmanager = {
 
                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(droppable)").andSelf();
+               var list = (t.currentItem || t.element).find(":data(ui-droppable)").andSelf();
 
                droppablesLoop: for (var i = 0; i < m.length; i++) {
 
@@ -257,12 +257,12 @@ $.ui.ddmanager = {
                        if (this.options.greedy) {
                                // find droppable parents with same scope
                                var scope = this.options.scope;
-                               var parent = this.element.parents(':data(droppable)').filter(function () {
-                                       return $.data(this, 'droppable').options.scope === scope;
+                               var parent = this.element.parents(':data(ui-droppable)').filter(function () {
+                                       return $.data(this, 'ui-droppable').options.scope === scope;
                                });
 
                                if (parent.length) {
-                                       parentInstance = $.data(parent[0], 'droppable');
+                                       parentInstance = $.data(parent[0], 'ui-droppable');
                                        parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
                                }
                        }
index c701c06be6f39bda201d7f8da852272265f00c62..fba9216e131788a5a26d3518c767db5b350cafb8 100644 (file)
@@ -75,7 +75,7 @@ $.widget("ui.resizable", $.ui.mouse, {
 
                        //Overwrite the original this.element
                        this.element = this.element.parent().data(
-                               "resizable", this.element.data('resizable')
+                               "ui-resizable", this.element.data('ui-resizable')
                        );
 
                        this.elementIsWrapper = true;
@@ -549,12 +549,12 @@ $.widget("ui.resizable", $.ui.mouse, {
 $.ui.plugin.add("resizable", "alsoResize", {
 
        start: function () {
-               var that = $(this).data("resizable"), o = that.options;
+               var that = $(this).data("ui-resizable"), o = that.options;
 
                var _store = function (exp) {
                        $(exp).each(function() {
                                var el = $(this);
-                               el.data("resizable-alsoresize", {
+                               el.data("ui-resizable-alsoresize", {
                                        width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
                                        left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10)
                                });
@@ -570,7 +570,7 @@ $.ui.plugin.add("resizable", "alsoResize", {
        },
 
        resize: function (event, ui) {
-               var that = $(this).data("resizable"), o = that.options, os = that.originalSize, op = that.originalPosition;
+               var that = $(this).data("ui-resizable"), o = that.options, os = that.originalSize, op = that.originalPosition;
 
                var delta = {
                        height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
@@ -579,7 +579,7 @@ $.ui.plugin.add("resizable", "alsoResize", {
 
                _alsoResize = function (exp, c) {
                        $(exp).each(function() {
-                               var el = $(this), start = $(this).data("resizable-alsoresize"), style = {},
+                               var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
                                        css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
 
                                $.each(css, function (i, prop) {
@@ -607,7 +607,7 @@ $.ui.plugin.add("resizable", "alsoResize", {
 $.ui.plugin.add("resizable", "animate", {
 
        stop: function( event ) {
-               var that = $(this).data("resizable"), o = that.options;
+               var that = $(this).data("ui-resizable"), o = that.options;
 
                var pr = that._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
                                        soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
@@ -646,7 +646,7 @@ $.ui.plugin.add("resizable", "animate", {
 $.ui.plugin.add("resizable", "containment", {
 
        start: function() {
-               var that = $(this).data("resizable"), o = that.options, el = that.element;
+               var that = $(this).data("ui-resizable"), o = that.options, el = that.element;
                var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
                if (!ce) return;
 
@@ -681,7 +681,7 @@ $.ui.plugin.add("resizable", "containment", {
        },
 
        resize: function( event ) {
-               var that = $(this).data("resizable"), o = that.options,
+               var that = $(this).data("ui-resizable"), o = that.options,
                        co = that.containerOffset, cp = that.position,
                        pRatio = that._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = that.containerElement;
 
@@ -722,7 +722,7 @@ $.ui.plugin.add("resizable", "containment", {
        },
 
        stop: function(){
-               var that = $(this).data("resizable"), o = that.options,
+               var that = $(this).data("ui-resizable"), o = that.options,
                                co = that.containerOffset, cop = that.containerPosition, ce = that.containerElement;
 
                var helper = $(that.helper), ho = helper.offset(), w = helper.outerWidth() - that.sizeDiff.width, h = helper.outerHeight() - that.sizeDiff.height;
@@ -740,7 +740,7 @@ $.ui.plugin.add("resizable", "ghost", {
 
        start: function() {
 
-               var that = $(this).data("resizable"), o = that.options, cs = that.size;
+               var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
 
                that.ghost = that.originalElement.clone();
                that.ghost
@@ -753,12 +753,12 @@ $.ui.plugin.add("resizable", "ghost", {
        },
 
        resize: function(){
-               var that = $(this).data("resizable");
+               var that = $(this).data("ui-resizable");
                if (that.ghost) that.ghost.css({ position: 'relative', height: that.size.height, width: that.size.width });
        },
 
        stop: function() {
-               var that = $(this).data("resizable");
+               var that = $(this).data("ui-resizable");
                if (that.ghost && that.helper) that.helper.get(0).removeChild(that.ghost.get(0));
        }
 
@@ -767,7 +767,7 @@ $.ui.plugin.add("resizable", "ghost", {
 $.ui.plugin.add("resizable", "grid", {
 
        resize: function() {
-               var that = $(this).data("resizable"), o = that.options, cs = that.size, os = that.originalSize, op = that.originalPosition, a = that.axis;
+               var that = $(this).data("ui-resizable"), o = that.options, cs = that.size, os = that.originalSize, op = that.originalPosition, a = that.axis;
                o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
                var gridX = (o.grid[0]||1), gridY = (o.grid[1]||1),
                        ox = Math.round((cs.width - os.width) / gridX) * gridX, oy = Math.round((cs.height - os.height) / gridY) * gridY,
index a95c80c68d7cc2aa3d3244400291f8a349f55411..a98e46632102f981acb46c6a4b7d017a3d380bbd 100644 (file)
@@ -541,7 +541,7 @@ $.widget("ui.sortable", $.ui.mouse, {
                        for (var i = connectWith.length - 1; i >= 0; i--){
                                var cur = $(connectWith[i]);
                                for (var j = cur.length - 1; j >= 0; j--){
-                                       var inst = $.data(cur[j], this.widgetName);
+                                       var inst = $.data(cur[j], this.widgetFullName);
                                        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").not('.ui-sortable-placeholder'), inst]);
                                        }
@@ -587,7 +587,7 @@ $.widget("ui.sortable", $.ui.mouse, {
                        for (var i = connectWith.length - 1; i >= 0; i--){
                                var cur = $(connectWith[i]);
                                for (var j = cur.length - 1; j >= 0; j--){
-                                       var inst = $.data(cur[j], this.widgetName);
+                                       var inst = $.data(cur[j], this.widgetFullName);
                                        if(inst && inst != this && !inst.options.disabled) {
                                                queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
                                                this.containers.push(inst);