From f24bc0fb1f63e7f5e38014d7191a4fe69d4179f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 15 Jul 2010 10:26:00 -0400 Subject: [PATCH 01/30] Widget: Deep extend options when creating a new plugin. Fixes #5830 - Widget: Using inheritance overwrites the base classes options. --- tests/unit/widget/widget.html | 3 +- .../unit/widget/{widget.js => widget_core.js} | 0 tests/unit/widget/widget_tickets.js | 46 +++++++++++++++++++ ui/jquery.ui.widget.js | 2 +- 4 files changed, 49 insertions(+), 2 deletions(-) rename tests/unit/widget/{widget.js => widget_core.js} (100%) create mode 100644 tests/unit/widget/widget_tickets.js diff --git a/tests/unit/widget/widget.html b/tests/unit/widget/widget.html index c3c3b0875..9e02880c4 100644 --- a/tests/unit/widget/widget.html +++ b/tests/unit/widget/widget.html @@ -13,7 +13,8 @@ - + + diff --git a/tests/unit/widget/widget.js b/tests/unit/widget/widget_core.js similarity index 100% rename from tests/unit/widget/widget.js rename to tests/unit/widget/widget_core.js diff --git a/tests/unit/widget/widget_tickets.js b/tests/unit/widget/widget_tickets.js new file mode 100644 index 000000000..47303dc9c --- /dev/null +++ b/tests/unit/widget/widget_tickets.js @@ -0,0 +1,46 @@ +/* + * widget unit tests + */ +(function($) { + +module('widget: tickets'); + +test('#5830 - Widget: Using inheritance overwrites the base classes options', function() { + $.widget( "ui.testWidgetBase", { + options: { + obj: { + key1: "foo", + key2: "bar" + }, + arr: [ "testing" ] + } + }); + + $.widget( "ui.testWidgetExtension", $.ui.testWidgetBase, { + options: { + obj: { + key1: "baz" + }, + arr: [ "alpha", "beta" ] + } + }); + + same( $.ui.testWidgetBase.prototype.options.obj, { + key1: "foo", + key2: "bar" + }, "base class option object not overridden"); + same( $.ui.testWidgetBase.prototype.options.arr, [ "testing" ], + "base class option array not overridden"); + + same( $.ui.testWidgetExtension.prototype.options.obj, { + key1: "baz", + key2: "bar" + }, "extension class option object extends base"); + same( $.ui.testWidgetExtension.prototype.options.arr, [ "alpha", "beta" ], + "extension class option array overwrites base"); + + delete $.ui.testWidgetBase; + delete $.ui.testWidgetExtension; +}); + +})(jQuery); diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 1014c607a..265489866 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -57,7 +57,7 @@ $.widget = function( name, base, prototype ) { // basePrototype[ key ] = $.extend( {}, val ); // } // }); - basePrototype.options = $.extend( {}, basePrototype.options ); + basePrototype.options = $.extend( true, {}, basePrototype.options ); $[ namespace ][ name ].prototype = $.extend( true, basePrototype, { namespace: namespace, widgetName: name, From 05368115bb40b6123048e6b144b5a04ecde68d79 Mon Sep 17 00:00:00 2001 From: JustinMacCarthy Date: Fri, 16 Jul 2010 01:16:07 +0800 Subject: [PATCH 02/30] added empty test for containment by array option --- tests/unit/draggable/draggable_options.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 78f6c563e..8ba77fb93 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -202,6 +202,10 @@ test("{ containment: Selector }", function() { ok(false, 'missing test - untested code is broken code'); }); +test("{ containment: [x1, y1, x2, y2] }", function() { + ok(false, 'missing test - untested code is broken code'); +}); + test("{ cursor: 'auto' }, default", function() { equals(draggable_defaults.cursor, 'auto'); From 2366a81740cab689161d4072ee2f5bf1cd9fcf65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 16 Jul 2010 08:50:40 -0400 Subject: [PATCH 03/30] Dialog: Fixed tests for position option. --- tests/unit/dialog/dialog_options.js | 48 +++++++++++++---------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index b5eda1fcf..cda16aadc 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -242,8 +242,8 @@ test("modal", function() { test("position, default center on window", function() { var el = $('
').dialog(); - var offset = el.parent().offset(); - // use .position() instead to avoid replicating center-logic? + var dialog = el.dialog('widget'); + var offset = dialog.offset(); same(offset.left, Math.floor($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft()); same(offset.top, Math.floor($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop()); el.remove(); @@ -251,16 +251,16 @@ test("position, default center on window", function() { test("position, top on window", function() { var el = $('
').dialog({ position: "top" }); - var dialog = el.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); - same(offset.left, Math.floor($(window).width() / 2 - dialog.outerWidth() / 2)); + same(offset.left, Math.floor($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft()); same(offset.top, $(window).scrollTop()); el.remove(); }); test("position, left on window", function() { var el = $('
').dialog({ position: "left" }); - var dialog = el.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); same(offset.left, 0); same(offset.top, Math.floor($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop()); @@ -269,27 +269,27 @@ test("position, left on window", function() { test("position, right bottom on window", function() { var el = $('
').dialog({ position: "right bottom" }); - var dialog = el.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); - same(offset.left, $(window).width() - dialog.outerWidth()); + same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft()); same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop()); el.remove(); }); test("position, right bottom on window w/array", function() { var el = $('
').dialog({ position: ["right", "bottom"] }); - var dialog = el.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); - same(offset.left, $(window).width() - dialog.outerWidth()); + same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft()); same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop()); el.remove(); }); test("position, offset from top left w/array", function() { var el = $('
').dialog({ position: [10, 10] }); - var dialog = el.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); - same(offset.left, 10); + same(offset.left, 10 + $(window).scrollLeft()); same(offset.top, 10 + $(window).scrollTop()); el.remove(); }); @@ -302,10 +302,10 @@ test("position, right bottom at right bottom via ui.position args", function() { } }); - var dialog = el.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); - same(offset.left, $(window).width() - dialog.outerWidth()); + same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft()); same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop()); el.remove(); }); @@ -317,22 +317,21 @@ test("position, at another element", function() { left: 600, height: 10, width: 10 - }); + }).appendTo('body'); var el = $('
').dialog({ position: { my: "left top", - at: "top left", + at: "left top", of: parent } }); - var dialog = el.closest('.ui-dialog'); + var dialog = el.dialog('widget'); var offset = dialog.offset(); - var parentOffset = parent.offset(); - same(offset.left, parentOffset.left); - same(offset.top, parentOffset.top); + same(offset.left, 600); + same(offset.top, 400); el.dialog('option', 'position', { my: "left top", @@ -340,18 +339,15 @@ test("position, at another element", function() { of: parent }); - same(offset.left, parentOffset.left + parent.outerWidth()); - same(offset.top, parentOffset.top + parent.outerHeight()); + var offset = dialog.offset(); + + same(offset.left, 610); + same(offset.top, 410); el.remove(); parent.remove(); }); - -test("position, others", function() { - ok(false, 'missing test - untested code is broken code'); -}); - test("resizable", function() { expect(4); From 4ad7154beeaf4d299c4d879c88cbc235b65dceef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 16 Jul 2010 08:54:50 -0400 Subject: [PATCH 04/30] Dialog: Fixed whitespace. --- ui/jquery.ui.dialog.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index dc2559e9d..df896e7ea 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -59,6 +59,7 @@ $.widget("ui.dialog", { width: 300, zIndex: 1000 }, + _create: function() { this.originalTitle = this.element.attr('title'); // #5742 - .attr() might return a DOMElement @@ -177,6 +178,7 @@ $.widget("ui.dialog", { uiDialog.bgiframe(); } }, + _init: function() { if ( this.options.autoOpen ) { this.open(); @@ -203,7 +205,7 @@ $.widget("ui.dialog", { return self; }, - + widget: function() { return this.uiDialog; }, @@ -258,12 +260,12 @@ $.widget("ui.dialog", { var self = this, options = self.options, saveScroll; - + if ((options.modal && !force) || (!options.stack && !options.modal)) { return self._trigger('focus', event); } - + if (options.zIndex > $.ui.dialog.maxZ) { $.ui.dialog.maxZ = options.zIndex; } @@ -305,11 +307,11 @@ $.widget("ui.dialog", { if (event.keyCode !== $.ui.keyCode.TAB) { return; } - + var tabbables = $(':tabbable', this), first = tabbables.filter(':first'), last = tabbables.filter(':last'); - + if (event.target === last[0] && !event.shiftKey) { first.focus(1); return false; @@ -461,7 +463,6 @@ $.widget("ui.dialog", { } }, - _position: function(position) { var myAt = [], offset = [0, 0], @@ -484,14 +485,14 @@ $.widget("ui.dialog", { myAt[i] = offsetPosition; } }); - + position = { my: myAt.join(" "), at: myAt.join(" "), offset: offset.join(" ") }; } - + position = $.extend({}, $.ui.dialog.prototype.options.position, position); } else { position = $.ui.dialog.prototype.options.position; @@ -516,7 +517,7 @@ $.widget("ui.dialog", { uiDialog = self.uiDialog, isResizable = uiDialog.is(':data(resizable)'), resize = false; - + switch (key) { //handling of deprecated beforeclose (vs beforeClose) option //Ticket #4669 http://dev.jqueryui.com/ticket/4669 From bf947d17567f971d52e88013609caf17f0a96d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 16 Jul 2010 09:37:31 -0400 Subject: [PATCH 05/30] Class animation demos: Don't chain id and class selectors together in CSS since IE6 doesn't understand chained rules. --- demos/addClass/default.html | 2 +- demos/removeClass/default.html | 2 +- demos/switchClass/default.html | 4 ++-- demos/toggleClass/default.html | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/demos/addClass/default.html b/demos/addClass/default.html index 1bb33b362..e2d9a79b0 100644 --- a/demos/addClass/default.html +++ b/demos/addClass/default.html @@ -11,7 +11,7 @@ .toggler { width: 500px; height: 200px; position: relative;} #button { padding: .5em 1em; text-decoration: none; } #effect { width: 240px; padding: 1em; font-size: 1.2em; border: 1px solid #000; background: #eee; color: #333; } - #effect.newClass { text-indent: 40px; letter-spacing: .4em; width: 410px; height: 100px; padding: 30px; margin: 10px; font-size: 1.6em; } + .newClass { text-indent: 40px; letter-spacing: .4em; width: 410px; height: 100px; padding: 30px; margin: 10px; font-size: 1.6em; } From fde8c64fd37d6700e174ccf5ea1574e418db2c1e Mon Sep 17 00:00:00 2001 From: Tiago Freire Date: Fri, 16 Jul 2010 13:37:54 -0300 Subject: [PATCH 10/30] Tabs: Added ability to reference tabs by href. Fixes #3171 - have option to remove tab by href content, not just by index. --- ui/jquery.ui.tabs.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 2d258d1d2..27754e539 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -413,6 +413,20 @@ $.widget("ui.tabs", { }, + _getIndex: function(index) { + // meta-function to give users option to provide a href string instead of a numerical index. + // also sanitizes numerical indexes to valid values. + if (typeof(index) == 'string') { + index = this.anchors.index(this.anchors.filter('[href$=' + index + ']')); + index = (index ==-1?NaN:index); + }else if (typeof(index) != 'number') { + index = NaN; + }else if (index > this.anchors.length) { + index = this.anchors.length; + } + return index; + }, + destroy: function() { var o = this.options; @@ -512,6 +526,7 @@ $.widget("ui.tabs", { }, remove: function(index) { + index = this._getIndex(index); var o = this.options, $li = this.lis.eq(index).remove(), $panel = this.panels.eq(index).remove(); @@ -532,6 +547,7 @@ $.widget("ui.tabs", { }, enable: function(index) { + index = this._getIndex(index); var o = this.options; if ($.inArray(index, o.disabled) == -1) { return; @@ -546,6 +562,7 @@ $.widget("ui.tabs", { }, disable: function(index) { + index = this._getIndex(index); var self = this, o = this.options; if (index != o.selected) { // cannot disable already selected tab this.lis.eq(index).addClass('ui-state-disabled'); @@ -561,9 +578,7 @@ $.widget("ui.tabs", { }, select: function(index) { - if (typeof index == 'string') { - index = this.anchors.index(this.anchors.filter('[href$=' + index + ']')); - } + index = this._getIndex(index); else if (index === null) { // usage of null is deprecated, TODO remove in next release index = -1; } @@ -576,6 +591,7 @@ $.widget("ui.tabs", { }, load: function(index) { + index = this._getIndex(index); var self = this, o = this.options, a = this.anchors.eq(index)[0], url = $.data(a, 'load.tabs'); this.abort(); From f448c79c01ef192fd71dce6ac5279e7795a8e417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 16 Jul 2010 13:40:11 -0400 Subject: [PATCH 11/30] Accordion: Use .addClass() instead of .toggleClass() during init so the classes can be added by the user. --- ui/jquery.ui.accordion.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index fd6331026..1d13e9566 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -79,7 +79,9 @@ $.widget("ui.accordion", { } } - this.active = this._findActive(this.active || o.active).toggleClass("ui-state-default").toggleClass("ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top"); + this.active = this._findActive(this.active || o.active) + .addClass("ui-state-default ui-state-active") + .toggleClass("ui-corner-all ui-corner-top"); this.active.next().addClass('ui-accordion-content-active'); //Append icon elements From 369474f3151f694a6523732b17887c67ef654550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 16 Jul 2010 10:45:26 -0700 Subject: [PATCH 12/30] Button performance test: Don't use alert(). --- tests/visual/button/button_performance.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/visual/button/button_performance.html b/tests/visual/button/button_performance.html index 8b8ca2730..2785580a9 100644 --- a/tests/visual/button/button_performance.html +++ b/tests/visual/button/button_performance.html @@ -19,7 +19,7 @@ var start = +new Date(); $("button").button(); var end = +new Date(); - alert( "Time to initialize: " + (end - start) + "ms" ); + $("

").text( "Time to initialize: " + (end - start) + "ms" ).prependTo("body"); }); From ba749ba6836d4889f18166a1207d5eeccddf7083 Mon Sep 17 00:00:00 2001 From: Diego Date: Thu, 10 Jun 2010 12:01:56 -0300 Subject: [PATCH 13/30] Datepicker: Fixed pt-BR translation. Fixes #5363 - Error in datepicker translation for pt-BR. --- ui/i18n/jquery.ui.datepicker-pt-BR.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/i18n/jquery.ui.datepicker-pt-BR.js b/ui/i18n/jquery.ui.datepicker-pt-BR.js index 38818637d..3cc8c796c 100644 --- a/ui/i18n/jquery.ui.datepicker-pt-BR.js +++ b/ui/i18n/jquery.ui.datepicker-pt-BR.js @@ -10,9 +10,9 @@ jQuery(function($){ 'Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'], monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun', 'Jul','Ago','Set','Out','Nov','Dez'], - dayNames: ['Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sabado'], - dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sab'], - dayNamesMin: ['Dom','Seg','Ter','Qua','Qui','Sex','Sab'], + dayNames: ['Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sábado'], + dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'], + dayNamesMin: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'], weekHeader: 'Sm', dateFormat: 'dd/mm/yy', firstDay: 0, From 325a262b14aa41be9bda584d770eedbde47297b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 16 Jul 2010 14:12:06 -0400 Subject: [PATCH 14/30] Autocomplete: Use .outerWidth() for determining the size of the menu. Fixes #5832 - Autocomplete: menu has incorrect width. --- ui/jquery.ui.autocomplete.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 1a51baa8d..3fa196ecb 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -276,9 +276,13 @@ $.widget( "ui.autocomplete", { collision: "none" }); - menuWidth = ul.width( "" ).width(); - textWidth = this.element.width(); - ul.width( Math.max( menuWidth, textWidth ) ); + menuWidth = ul.width( "" ).outerWidth(); + textWidth = this.element.outerWidth(); + ul.width( Math.max( menuWidth, textWidth ) + - ( parseFloat( ul.css("paddingLeft") ) || 0 ) + - ( parseFloat( ul.css("paddingRight") ) || 0 ) + - ( parseFloat( ul.css("borderLeftWidth") ) || 0 ) + - ( parseFloat( ul.css("borderRightWidth") ) || 0 ) ); }, _renderMenu: function( ul, items ) { From 9d01ab564525f9112c2488ad257637593062b70d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Holger=20R=C3=BCprich?= Date: Mon, 5 Jul 2010 06:29:09 +0800 Subject: [PATCH 15/30] Sortable: Return an empty URL param for empty sortable lists. Fixed #5794 - sortable("serialize", {key: "foo[]"}) returns an empty string for an empty list --- ui/jquery.ui.sortable.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index a51f543c5..6cc2434e8 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -409,6 +409,10 @@ $.widget("ui.sortable", $.ui.mouse, { if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2])); }); + if(!str.length && o.key) { + str.push(o.key + '='); + } + return str.join('&'); }, From 64d90b4a710d520a44408ccfa8df1100b0b95b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 16 Jul 2010 16:57:04 -0400 Subject: [PATCH 16/30] Dialog: Adjusted logic for finding the first tabbable element. Fixes #5767 - On open, the first tabbable element inside the dialog was never being focused in favor of the dialog container. --- ui/jquery.ui.dialog.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index df896e7ea..ae96b2d8b 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -324,12 +324,9 @@ $.widget("ui.dialog", { // set focus to the first tabbable element in the content area or the first button // if there are no tabbable elements, set focus on the dialog itself - $([]) - .add(uiDialog.find('.ui-dialog-content :tabbable:first')) - .add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first')) - .add(uiDialog) - .filter(':first') - .focus(); + $(self.element.find(':tabbable').get().concat( + uiDialog.find('.ui-dialog-buttonpane :tabbable').get().concat( + uiDialog.get()))).eq(0).focus(); self._trigger('open'); self._isOpen = true; From eaddfedd668c3397ed3c39d733d57d9c78466633 Mon Sep 17 00:00:00 2001 From: Tiago Freire Date: Fri, 16 Jul 2010 18:10:57 -0300 Subject: [PATCH 17/30] Tabs: Fixed a broken commit for #3171. --- ui/jquery.ui.tabs.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 27754e539..2a12cb540 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -579,13 +579,9 @@ $.widget("ui.tabs", { select: function(index) { index = this._getIndex(index); - else if (index === null) { // usage of null is deprecated, TODO remove in next release - index = -1; - } - if (index == -1 && this.options.collapsible) { + if (isNaN(index) && this.options.collapsible) { index = this.options.selected; } - this.anchors.eq(index).trigger(this.options.event + '.tabs'); return this; }, From 7e03d4ea9deee68e928651ef80c6c673c479b88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 16 Jul 2010 20:20:28 -0400 Subject: [PATCH 18/30] Tabs: Updated tests. --- tests/unit/tabs/tabs.html | 3 ++- tests/unit/tabs/tabs_methods.js | 11 +---------- ui/jquery.ui.tabs.js | 10 +++------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/tests/unit/tabs/tabs.html b/tests/unit/tabs/tabs.html index 269f47ed5..211237569 100644 --- a/tests/unit/tabs/tabs.html +++ b/tests/unit/tabs/tabs.html @@ -15,7 +15,8 @@ - + + diff --git a/tests/unit/tabs/tabs_methods.js b/tests/unit/tabs/tabs_methods.js index 3eb627830..3812c3e91 100644 --- a/tests/unit/tabs/tabs_methods.js +++ b/tests/unit/tabs/tabs_methods.js @@ -97,7 +97,7 @@ test('remove', function() { }); test('select', function() { - expect(9); + expect(6); el = $('#tabs1').tabs(); @@ -114,21 +114,12 @@ test('select', function() { el.tabs('select', -1); equals(el.tabs('option', 'selected'), -1, 'should collapse tab passing in -1'); - el.tabs('destroy'); - el.tabs({ collapsible: true }); - el.tabs('select', null); - equals(el.tabs('option', 'selected'), -1, 'should collapse tab passing in null (deprecated)'); - el.tabs('select', null); - equals(el.tabs('option', 'selected'), -1, 'should not select tab passing in null a second time (deprecated)'); - el.tabs('destroy'); el.tabs(); el.tabs('select', 0); equals(el.tabs('option', 'selected'), 0, 'should not collapse tab if collapsible is not set to true'); el.tabs('select', -1); equals(el.tabs('option', 'selected'), 0, 'should not collapse tab if collapsible is not set to true'); - el.tabs('select', null); - equals(el.tabs('option', 'selected'), 0, 'should not collapse tab if collapsible is not set to true'); el.tabs('select', '#fragment-2'); equals(el.tabs('option', 'selected'), 1, 'should select tab by id'); diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 2a12cb540..592f1a866 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -416,14 +416,10 @@ $.widget("ui.tabs", { _getIndex: function(index) { // meta-function to give users option to provide a href string instead of a numerical index. // also sanitizes numerical indexes to valid values. - if (typeof(index) == 'string') { + if (typeof index == 'string') { index = this.anchors.index(this.anchors.filter('[href$=' + index + ']')); - index = (index ==-1?NaN:index); - }else if (typeof(index) != 'number') { - index = NaN; - }else if (index > this.anchors.length) { - index = this.anchors.length; } + return index; }, @@ -579,7 +575,7 @@ $.widget("ui.tabs", { select: function(index) { index = this._getIndex(index); - if (isNaN(index) && this.options.collapsible) { + if (index == -1 && this.options.collapsible) { index = this.options.selected; } this.anchors.eq(index).trigger(this.options.event + '.tabs'); From 5435c50765e89f5cfb1c164dda6642c2149dc4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Sat, 17 Jul 2010 18:50:47 -0400 Subject: [PATCH 19/30] Tabs: Fixed select method handling for index of -1. --- ui/jquery.ui.tabs.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 592f1a866..5555b95f5 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -575,8 +575,12 @@ $.widget("ui.tabs", { select: function(index) { index = this._getIndex(index); - if (index == -1 && this.options.collapsible) { - index = this.options.selected; + if (index == -1) { + if (this.options.collapsible && this.options.selected != -1) { + index = this.options.selected; + } else { + return this; + } } this.anchors.eq(index).trigger(this.options.event + '.tabs'); return this; From 612838a1518c8cdc80b5bace5d925f89c1e791a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 19 Jul 2010 09:28:04 -0400 Subject: [PATCH 20/30] Autocomplete: Added position option. Fixes #5153 - Autocomplete position option. --- .../unit/autocomplete/autocomplete_defaults.js | 7 ++++++- ui/jquery.ui.autocomplete.js | 17 ++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/unit/autocomplete/autocomplete_defaults.js b/tests/unit/autocomplete/autocomplete_defaults.js index c6017d62c..8dad15e8f 100644 --- a/tests/unit/autocomplete/autocomplete_defaults.js +++ b/tests/unit/autocomplete/autocomplete_defaults.js @@ -6,7 +6,12 @@ var autocomplete_defaults = { delay: 300, disabled: false, minLength: 1, - source: undefined + position: { + my: "left top", + at: "left bottom", + collision: "none" + }, + source: null }; commonWidgetTests('autocomplete', { defaults: autocomplete_defaults }); diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 3fa196ecb..1391643ba 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -16,8 +16,14 @@ $.widget( "ui.autocomplete", { options: { + delay: 300, minLength: 1, - delay: 300 + position: { + my: "left top", + at: "left bottom", + collision: "none" + }, + source: null }, _create: function() { var self = this, @@ -269,12 +275,9 @@ $.widget( "ui.autocomplete", { // TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate this.menu.deactivate(); this.menu.refresh(); - this.menu.element.show().position({ - my: "left top", - at: "left bottom", - of: this.element, - collision: "none" - }); + this.menu.element.show().position( $.extend({ + of: this.element + }, this.options.position )); menuWidth = ul.width( "" ).outerWidth(); textWidth = this.element.outerWidth(); From fe71d5d0a05b1e45055da8fdd39085999e5b43b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 19 Jul 2010 09:41:21 -0400 Subject: [PATCH 21/30] Autocomplete: Removed styling for .ui-autocomplete-loading from the theme - added to individual demos. Fixes #5385 - Autocomplete: Inconsistent default styling while loading results. We will need to undo this change when ThemeRoller supports generating loading images. --- demos/autocomplete/multiple-remote.html | 3 +++ demos/autocomplete/remote-jsonp.html | 3 +++ demos/autocomplete/remote-with-cache.html | 3 +++ demos/autocomplete/remote.html | 3 +++ demos/autocomplete/xml.html | 3 +++ themes/base/jquery.ui.autocomplete.css | 1 - 6 files changed, 15 insertions(+), 1 deletion(-) diff --git a/demos/autocomplete/multiple-remote.html b/demos/autocomplete/multiple-remote.html index 2046db614..88284aa0d 100644 --- a/demos/autocomplete/multiple-remote.html +++ b/demos/autocomplete/multiple-remote.html @@ -10,6 +10,9 @@ + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+

+When displaying a long list of options, you can simply set the max-height for the autocomplete menu to prevent the menu from growing too large. Try typing "a" or "s" above to get a long list of results that you can scroll through. +

+
+ + + From 53489b502dc51edb7707de80ead77549bd529e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 19 Jul 2010 14:36:40 -0400 Subject: [PATCH 27/30] Autocomplete: Don't update the value of the text field until after setting focus. Fixes #5639 - Cursor jumps to beginning on select. --- ui/jquery.ui.autocomplete.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 3f010c1f4..c25a8884f 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -132,9 +132,12 @@ $.widget( "ui.autocomplete", { } }, selected: function( event, ui ) { - var item = ui.item.data( "item.autocomplete" ); + var item = ui.item.data( "item.autocomplete" ), + setValue = false; if ( false !== self._trigger( "select", event, { item: item } ) ) { - self.element.val( item.value ); + // #5639 - if we set the value before setting focus + // the cursor will move to the beginning of the field in IE + setValue = true; } self.close( event ); // only trigger when focus was lost (click on menu) @@ -144,6 +147,9 @@ $.widget( "ui.autocomplete", { self.previous = previous; } self.selectedItem = item; + if ( setValue ) { + self.element.val( item.value ); + } }, blur: function( event, ui ) { if ( self.menu.element.is(":visible") ) { From 7deb873c51ede9fb5e8b23949ccc4dda58650770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 19 Jul 2010 15:35:47 -0400 Subject: [PATCH 28/30] Autocompelte demos: Renamed the scrollable demo so the title fits on one line in the sidebar. --- demos/autocomplete/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/autocomplete/index.html b/demos/autocomplete/index.html index c866ba199..02b899a2e 100644 --- a/demos/autocomplete/index.html +++ b/demos/autocomplete/index.html @@ -13,7 +13,7 @@
  • Remote datasource
  • Remote with caching
  • Remote JSONP datasource
  • -
  • Scrollable results (max-height)
  • +
  • Scrollable results
  • Combobox
  • Custom data and display
  • XML data parsed once
  • From 1f2cfb942f8ac5549b1fe3172501e3486415530e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 19 Jul 2010 15:45:30 -0400 Subject: [PATCH 29/30] Autocomplete: Render items as text, not HTML. Fixes #5275 - suggestions are not html-encoded. As noted in the ticket, it's probably better to default to unstyled items to prevent problems. Users can still implement their own rendering method as shown in the custom data and display demo. --- demos/autocomplete/combobox.html | 6 ++++++ demos/autocomplete/search.php | 4 ++-- ui/jquery.ui.autocomplete.js | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html index 10d165392..4cc98d8f9 100644 --- a/demos/autocomplete/combobox.html +++ b/demos/autocomplete/combobox.html @@ -54,6 +54,12 @@ minLength: 0 }) .addClass("ui-widget ui-widget-content ui-corner-left"); + input.data("autocomplete")._renderItem = function( ul, item) { + return $( "
  • " ) + .data( "item.autocomplete", item ) + .append( "" + item.label + "" ) + .appendTo( ul ); + }; $("") .attr("tabIndex", -1) .attr("title", "Show All Items") diff --git a/demos/autocomplete/search.php b/demos/autocomplete/search.php index 01206489a..8fa9d28f8 100644 --- a/demos/autocomplete/search.php +++ b/demos/autocomplete/search.php @@ -3,8 +3,8 @@ $q = strtolower($_GET["term"]); if (!$q) return; $items = array( -"Great Bittern"=>"Botaurus stellaris", -"Little Grebe"=>"Tachybaptus ruficollis", +"Great Bittern"=>"Botaurus stellaris", +"Little Grebe"=>"Tachybaptus ruficollis", "Black-necked Grebe"=>"Podiceps nigricollis", "Little Bittern"=>"Ixobrychus minutus", "Black-crowned Night Heron"=>"Nycticorax nycticorax", diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index c25a8884f..27bfe941c 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -304,7 +304,7 @@ $.widget( "ui.autocomplete", { _renderItem: function( ul, item) { return $( "
  • " ) .data( "item.autocomplete", item ) - .append( "" + item.label + "" ) + .append( $( "" ).text( item.label ) ) .appendTo( ul ); }, From 5debdb08d7702e9c04b4efa883c68d350576d710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 19 Jul 2010 21:53:19 -0400 Subject: [PATCH 30/30] Autocomplete: Added link to accent folding demo. Fixes #5219 - Autocomplete: Support for accent-folding. --- demos/autocomplete/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/autocomplete/index.html b/demos/autocomplete/index.html index 02b899a2e..9d5ba3a87 100644 --- a/demos/autocomplete/index.html +++ b/demos/autocomplete/index.html @@ -18,6 +18,7 @@
  • Custom data and display
  • XML data parsed once
  • Categories
  • +
  • Accent folding
  • Multiple values
  • Multiple, remote