From eef633e32a20ad93355060a8eef4b2129cf0bc5c Mon Sep 17 00:00:00 2001 From: Alex Rhea Date: Tue, 3 Jan 2012 13:00:02 -0500 Subject: [PATCH 01/27] Bug fix for isLocal function in jQuery Tabs. isLocal function was not compatible with HTML5 push state as the url could have changed since the page was loaded as in cases with Backbone.js --- ui/jquery.ui.tabs.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 5c9fc1326..3e022af4a 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -18,18 +18,13 @@ function getNextTabId() { return ++tabId; } -var isLocal = (function() { - var rhash = /#.*$/, - currentPage = location.href.replace( rhash, "" ); - - return function( anchor ) { - // clone the node to work around IE 6 not normalizing the href property - // if it's manually set, i.e., a.href = "#foo" kills the normalization - anchor = anchor.cloneNode( false ); - return anchor.hash.length > 1 && - anchor.href.replace( rhash, "" ) === currentPage; - }; -})(); +var isLocal = function( anchor ) { + var rhash = /#.*$/; + // clone the node to work around IE 6 not normalizing the href property + // if it's manually set, i.e., a.href = "#foo" kills the normalization + anchor = anchor.cloneNode( false ); + return anchor.hash.length > 1 && anchor.href.replace( rhash, "" ) === location.href.replace( rhash, "" ); +}; $.widget( "ui.tabs", { version: "@VERSION", From 3c4e40d8d770ac117969b2cb011ac3d7402a134a Mon Sep 17 00:00:00 2001 From: Alex Rhea Date: Tue, 3 Jan 2012 13:18:13 -0500 Subject: [PATCH 02/27] Removed regex from function and split return into two lines. --- ui/jquery.ui.tabs.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 3e022af4a..0429363f2 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -13,17 +13,19 @@ */ (function( $, undefined ) { -var tabId = 0; +var tabId = 0, + rhash = /#.*$/; + function getNextTabId() { return ++tabId; } var isLocal = function( anchor ) { - var rhash = /#.*$/; // clone the node to work around IE 6 not normalizing the href property // if it's manually set, i.e., a.href = "#foo" kills the normalization anchor = anchor.cloneNode( false ); - return anchor.hash.length > 1 && anchor.href.replace( rhash, "" ) === location.href.replace( rhash, "" ); + return anchor.hash.length > 1 && + anchor.href.replace( rhash, "" ) === location.href.replace( rhash, "" ); }; $.widget( "ui.tabs", { From 370bc00150f1f77275a861a3c15138b488061871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Wed, 11 Jan 2012 19:58:46 +0100 Subject: [PATCH 03/27] Menubar/Popup: Remove remaining artifact (trigger option) from menu. Missed that before --- ui/jquery.ui.menu.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 06b7ec440..83ea3c3c0 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -24,8 +24,7 @@ $.widget( "ui.menu", { position: { my: "left top", at: "right top" - }, - trigger: null + } }, _create: function() { this.activeMenu = this.element; From e2d9b02c56ee92fa92913b451598b59a385db609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 12 Jan 2012 08:59:34 -0500 Subject: [PATCH 04/27] Simulate: Define getters for pageX and pageY in mouse events if they come through as 0. Fixes #7324 - simulate mouse events broken for IE 9. --- tests/jquery.simulate.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/jquery.simulate.js b/tests/jquery.simulate.js index a37302c46..a8740e6b8 100644 --- a/tests/jquery.simulate.js +++ b/tests/jquery.simulate.js @@ -45,7 +45,7 @@ $.extend( $.simulate.prototype, { } }, mouseEvent: function( type, options ) { - var evt; + var evt, eventDoc, doc, body; var e = $.extend({ bubbles: true, cancelable: (type !== "mousemove"), @@ -71,6 +71,30 @@ $.extend( $.simulate.prototype, { e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget || document.body.parentNode ); + + // IE 9+ creates events with pageX and pageY set to 0. + // Trying to modify the properties throws an error, + // so we define getters to return the correct values. + if ( evt.pageX === 0 && evt.pageY === 0 && Object.defineProperty ) { + eventDoc = evt.relatedTarget.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + Object.defineProperty( evt, "pageX", { + get: function() { + return e.clientX + + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - + ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + } + }); + Object.defineProperty( evt, "pageY", { + get: function() { + return e.clientY + + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - + ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + }); + } } else if ( document.createEventObject ) { evt = document.createEventObject(); $.extend( evt, e ); From 82cf9e297fd78730dadd9a486d6871eca72455dd Mon Sep 17 00:00:00 2001 From: ryanolton Date: Thu, 12 Jan 2012 11:22:48 -0500 Subject: [PATCH 05/27] =?UTF-8?q?Datepicker:=20added=20check=20to=20accoun?= =?UTF-8?q?t=20for=20multiple=20pickers=20on=20one=20page.=20Fixed=20#5818?= =?UTF-8?q?=20=E2=80=93=20multiple=20DatePickers=20won't=20trigger=20close?= =?UTF-8?q?=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/jquery.ui.datepicker.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 45ddf8678..5915d4027 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -233,7 +233,10 @@ $.extend(Datepicker.prototype, { inst.trigger.click(function() { if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0]) $.datepicker._hideDatepicker(); - else + else if ($.datepicker._datepickerShowing && $.datepicker._lastInput != input[0]) { + $.datepicker._hideDatepicker(); + $.datepicker._showDatepicker(input[0]); + } else $.datepicker._showDatepicker(input[0]); return false; }); From c0dfa1173c7427622a9f7573b173211f6b594a5f Mon Sep 17 00:00:00 2001 From: clear00 <386@mail.com> Date: Fri, 13 Jan 2012 05:01:01 +0900 Subject: [PATCH 06/27] Datepicker i18n: Fix monthNames, monthNamesShort, dayNames, showMonthAfterYear on the Korean translation . Fixed #8010 - Datepicker i18n: Fix some issues on the Korean translation --- ui/i18n/jquery.ui.datepicker-ko.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/i18n/jquery.ui.datepicker-ko.js b/ui/i18n/jquery.ui.datepicker-ko.js index 5b3531652..04112424d 100644 --- a/ui/i18n/jquery.ui.datepicker-ko.js +++ b/ui/i18n/jquery.ui.datepicker-ko.js @@ -1,23 +1,23 @@ /* Korean initialisation for the jQuery calendar extension. */ -/* Written by DaeKwon Kang (ncrash.dk@gmail.com). */ +/* Written by DaeKwon Kang (ncrash.dk@gmail.com), Edited by Genie. */ jQuery(function($){ $.datepicker.regional['ko'] = { closeText: '닫기', prevText: '이전달', nextText: '다음달', currentText: '오늘', - monthNames: ['1월(JAN)','2월(FEB)','3월(MAR)','4월(APR)','5월(MAY)','6월(JUN)', - '7월(JUL)','8월(AUG)','9월(SEP)','10월(OCT)','11월(NOV)','12월(DEC)'], - monthNamesShort: ['1월(JAN)','2월(FEB)','3월(MAR)','4월(APR)','5월(MAY)','6월(JUN)', - '7월(JUL)','8월(AUG)','9월(SEP)','10월(OCT)','11월(NOV)','12월(DEC)'], - dayNames: ['일','월','화','수','목','금','토'], + monthNames: ['1월','2월','3월','4월','5월','6월', + '7월','8월','9월','10월','11월','12월'], + monthNamesShort: ['1월','2월','3월','4월','5월','6월', + '7월','8월','9월','10월','11월','12월'], + dayNames: ['일요일','월요일','화요일','수요일','목요일','금요일','토요일'], dayNamesShort: ['일','월','화','수','목','금','토'], dayNamesMin: ['일','월','화','수','목','금','토'], weekHeader: 'Wk', dateFormat: 'yy-mm-dd', firstDay: 0, isRTL: false, - showMonthAfterYear: false, + showMonthAfterYear: true, yearSuffix: '년'}; $.datepicker.setDefaults($.datepicker.regional['ko']); }); \ No newline at end of file From eee63a2e2435a6ecbcd0daa15f41b7bd5901e307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 12 Jan 2012 16:49:50 -0500 Subject: [PATCH 07/27] Datepicker i18n (nl-BE): Removed BOM. --- ui/i18n/jquery.ui.datepicker-nl-BE.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/i18n/jquery.ui.datepicker-nl-BE.js b/ui/i18n/jquery.ui.datepicker-nl-BE.js index 56207cb04..7b3cdf425 100644 --- a/ui/i18n/jquery.ui.datepicker-nl-BE.js +++ b/ui/i18n/jquery.ui.datepicker-nl-BE.js @@ -1,4 +1,4 @@ -/* Dutch (Belgium) initialisation for the jQuery UI date picker plugin. */ +/* Dutch (Belgium) initialisation for the jQuery UI date picker plugin. */ /* David De Sloovere @DavidDeSloovere */ jQuery(function($){ $.datepicker.regional['nl-BE'] = { @@ -20,4 +20,4 @@ jQuery(function($){ showMonthAfterYear: false, yearSuffix: ''}; $.datepicker.setDefaults($.datepicker.regional['nl-BE']); -}); \ No newline at end of file +}); From 3a1031e58b717b042d39dcccfdbe1d293cdbecf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 18 Jan 2012 16:37:04 -0500 Subject: [PATCH 08/27] Button: Properly handle disabled option on init. Fixes #8028 - Getting unset disabled option on button widget returns jQuery object, not default value. --- ui/jquery.ui.button.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 18a950563..1c3cf2c64 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -58,7 +58,9 @@ $.widget( "ui.button", { .bind( "reset.button", formResetHandler ); if ( typeof this.options.disabled !== "boolean" ) { - this.options.disabled = this.element.prop( "disabled" ); + this.options.disabled = !!this.element.prop( "disabled" ); + } else { + this.element.prop( "disabled", this.options.disabled ); } this._determineButtonType(); @@ -74,10 +76,6 @@ $.widget( "ui.button", { options.label = this.buttonElement.html(); } - if ( this.element.is( ":disabled" ) ) { - options.disabled = true; - } - this.buttonElement .addClass( baseClasses ) .attr( "role", "button" ) From 13eca299a9a7fb9767a9685f50d4242cc3ad7d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 18 Jan 2012 16:51:43 -0500 Subject: [PATCH 09/27] Menu tests: Removed trigger option. --- tests/unit/menu/menu_defaults.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/unit/menu/menu_defaults.js b/tests/unit/menu/menu_defaults.js index 3d7ec297f..bf41fb999 100644 --- a/tests/unit/menu/menu_defaults.js +++ b/tests/unit/menu/menu_defaults.js @@ -1,12 +1,11 @@ commonWidgetTests( "menu", { defaults: { disabled: false, + menus: "ul", position: { my: "left top", at: "right top" }, - menus: "ul", - trigger: null, // callbacks create: null From 07ec849f623699c87fc7ecc3770ea11ad9ba8e4e Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Wed, 18 Jan 2012 18:58:43 -0500 Subject: [PATCH 10/27] Position: Update fullname reference; jQuery => $. Fixes #8029 - Position: There is a reference to the global jQuery variable. --- ui/jquery.ui.position.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 9a520f845..00976bf79 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -37,7 +37,7 @@ $.position = { div.remove(); - return w1 - w2; + return w1 - w2; }, getScrollInfo: function(within) { var notWindow = within[0] !== window, @@ -401,12 +401,12 @@ $.ui.position = { } }, flipfit: { - left: function() { - $.ui.position.flip.left.apply( this, arguments ); + left: function() { + $.ui.position.flip.left.apply( this, arguments ); $.ui.position.fit.left.apply( this, arguments ); }, - top: function() { - $.ui.position.flip.top.apply( this, arguments ); + top: function() { + $.ui.position.flip.top.apply( this, arguments ); $.ui.position.fit.top.apply( this, arguments ); } } @@ -415,7 +415,7 @@ $.ui.position = { // fraction support test (function () { var testElement, testElementParent, testElementStyle, offsetLeft, i - body = document.getElementsByTagName( "body" )[ 0 ], + body = document.getElementsByTagName( "body" )[ 0 ], div = document.createElement( "div" ); //Create a "fake body" for testing based on method used in jQuery.support @@ -429,7 +429,7 @@ $.ui.position = { background: "none" }; if ( body ) { - jQuery.extend( testElementStyle, { + $.extend( testElementStyle, { position: "absolute", left: "-1000px", top: "-1000px" From 956c2cd2a5a44d40a9b2fb0a8c05f765fa302c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 19 Jan 2012 21:37:21 -0500 Subject: [PATCH 11/27] Core: Access offsetHeight on div for support tests to avoid a layout bug in IE 9. Fixes #8026 - minHeight support test affects page layout in IE 9. --- ui/jquery.ui.core.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index f0cf89ba7..d777d6d49 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -223,6 +223,11 @@ $(function() { var body = document.body, div = body.appendChild( div = document.createElement( "div" ) ); + // access offsetHeight before setting the style to prevent a layout bug + // in IE 9 which causes the elemnt to continue to take up space even + // after it is removed from the DOM (#8026) + div.offsetHeight; + $.extend( div.style, { minHeight: "100px", height: "auto", From ba6916f22ac3fac993975abc0f86d6cb0bf9c08d Mon Sep 17 00:00:00 2001 From: SpoonNZ Date: Fri, 20 Jan 2012 16:54:47 +1300 Subject: [PATCH 12/27] Sortable: Added a variable to track if initialization is complete. Fixes #4759 - a major optimization is possible in sortable(). --- ui/jquery.ui.sortable.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 62d227a3d..600569451 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -17,6 +17,7 @@ $.widget("ui.sortable", $.ui.mouse, { version: "@VERSION", widgetEventPrefix: "sort", + ready: false, options: { appendTo: "parent", axis: false, @@ -58,6 +59,9 @@ $.widget("ui.sortable", $.ui.mouse, { //Initialize mouse events for interaction this._mouseInit(); + + //We're ready to go + this.ready = true }, @@ -571,7 +575,7 @@ $.widget("ui.sortable", $.ui.mouse, { var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]]; var connectWith = this._connectWith(); - if(connectWith) { + if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down for (var i = connectWith.length - 1; i >= 0; i--){ var cur = $(connectWith[i]); for (var j = cur.length - 1; j >= 0; j--){ From b7af203c8e9db1d253bca7aeb66350280402ca1c Mon Sep 17 00:00:00 2001 From: stojce Date: Mon, 5 Dec 2011 09:59:42 +0100 Subject: [PATCH 13/27] Datepicker i18n: Fixed Macedonian date format. Fixes #8040 - Datepicker: Macedonian locale has incorrect date format. --- ui/i18n/jquery.ui.datepicker-mk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/i18n/jquery.ui.datepicker-mk.js b/ui/i18n/jquery.ui.datepicker-mk.js index 554ad20ba..1e602427a 100644 --- a/ui/i18n/jquery.ui.datepicker-mk.js +++ b/ui/i18n/jquery.ui.datepicker-mk.js @@ -14,7 +14,7 @@ jQuery(function($){ dayNamesShort: ['Нед','Пон','Вто','Сре','Чет','Пет','Саб'], dayNamesMin: ['Не','По','Вт','Ср','Че','Пе','Са'], weekHeader: 'Сед', - dateFormat: 'dd/mm/yy', + dateFormat: 'dd.mm.yy', firstDay: 1, isRTL: false, showMonthAfterYear: false, From 0cf6bc042938a11abc09ed4e575c8792585607ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Sat, 21 Jan 2012 08:04:39 -0500 Subject: [PATCH 14/27] Tabs: Move logic for finding the tab list into its own function to allow overriding for rare usage scenarios. --- ui/jquery.ui.tabs.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 0429363f2..168aa0ee5 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -209,7 +209,7 @@ $.widget( "ui.tabs", { _processTabs: function() { var self = this; - this.list = this.element.find( "ol,ul" ).eq( 0 ); + this.list = this._getList(); this.lis = $( " > li:has(a[href])", this.list ); this.anchors = this.lis.map(function() { return $( "a", this )[ 0 ]; @@ -241,6 +241,11 @@ $.widget( "ui.tabs", { }); }, + // allow overriding how to find the list for rare usage scenarios (#7715) + _getList: function() { + return this.element.find( "ol,ul" ).eq( 0 ); + }, + _createPanel: function( id ) { return $( "
" ) .attr( "id", id ) From da89fcbc07f236d43e6a1edd98603beea6e245b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Sat, 21 Jan 2012 08:45:41 -0500 Subject: [PATCH 15/27] Widget: Added _getCreateEventData(). Fixes #8045 - Widget: Ability to provide event data for create event. --- tests/unit/widget/widget_core.js | 15 +++++++++++++++ ui/jquery.ui.widget.js | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 2e55ad703..df83abe91 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -261,6 +261,21 @@ test( "._getCreateOptions()", function() { $( "
" ).testWidget({ option2: "value2" }); }); +test( "._getCreateEventData()", function() { + expect( 1 ); + var data = { foo: "bar" }; + $.widget( "ui.testWidget", { + _getCreateEventData: function() { + return data; + } + }); + $( "
" ).testWidget({ + create: function( event, ui ) { + strictEqual( ui, data, "event data" ); + } + }); +}); + test( "re-init", function() { var div = $( "
" ), actions = []; diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 5c8560bfd..ad03e6f44 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -204,10 +204,11 @@ $.Widget.prototype = { } this._create(); - this._trigger( "create" ); + this._trigger( "create", null, this._getCreateEventData() ); this._init(); }, _getCreateOptions: $.noop, + _getCreateEventData: $.noop, _create: $.noop, _init: $.noop, From 6800e1a2f97a7d8aaf20d065aa2ce517528e5068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Sat, 21 Jan 2012 08:46:02 -0500 Subject: [PATCH 16/27] Tabs: Pass tab and panel in create event. Fixes #7868 - Tabs: Provide tab and panel details in create event. --- tests/unit/tabs/tabs_events.js | 39 ++++++++++++++++++++++++++++++++++ ui/jquery.ui.tabs.js | 7 ++++++ 2 files changed, 46 insertions(+) diff --git a/tests/unit/tabs/tabs_events.js b/tests/unit/tabs/tabs_events.js index f5cde180b..333578907 100644 --- a/tests/unit/tabs/tabs_events.js +++ b/tests/unit/tabs/tabs_events.js @@ -2,6 +2,45 @@ module( "tabs: events" ); +test( "create", function() { + expect( 10 ); + + var element = $( "#tabs1" ), + tabs = element.find( "ul a" ), + panels = element.children( "div" ); + + element.tabs({ + create: function( event, ui ) { + equals( ui.tab.size(), 1, "tab size" ); + strictEqual( ui.tab[ 0 ], tabs[ 0 ], "tab" ); + equals( ui.panel.size(), 1, "panel size" ); + strictEqual( ui.panel[ 0 ], panels[ 0 ], "panel" ); + } + }); + element.tabs( "destroy" ); + + element.tabs({ + active: 2, + create: function( event, ui ) { + equals( ui.tab.size(), 1, "tab size" ); + strictEqual( ui.tab[ 0 ], tabs[ 2 ], "tab" ); + equals( ui.panel.size(), 1, "panel size" ); + strictEqual( ui.panel[ 0 ], panels[ 2 ], "panel" ); + } + }); + element.tabs( "destroy" ); + + element.tabs({ + active: false, + collapsible: true, + create: function( event, ui ) { + equals( ui.tab.size(), 0, "tab size" ); + equals( ui.panel.size(), 0, "panel size" ); + } + }); + element.tabs( "destroy" ); +}); + test( "beforeActivate", function() { expect( 38 ); diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 168aa0ee5..7a701405c 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -120,6 +120,13 @@ $.widget( "ui.tabs", { } }, + _getCreateEventData: function() { + return { + tab: this.active, + panel: !this.active.length ? $() : this._getPanelForTab( this.active ) + }; + }, + _setOption: function( key, value ) { if ( key == "active" ) { // _activate() will handle invalid values and update this.options From 8c5c6e0a32a1e87cab575cbb265873fccbd416df Mon Sep 17 00:00:00 2001 From: kborchers Date: Sun, 22 Jan 2012 11:24:49 -0600 Subject: [PATCH 17/27] Menu: Added check for the disabled option on create. --- ui/jquery.ui.menu.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 83ea3c3c0..ebfd5087c 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -45,6 +45,9 @@ $.widget( "ui.menu", { event.preventDefault(); } }, this)); + if ( this.options.disabled ) { + this.element.addClass( "ui-state-disabled" ); + } this._bind({ // Prevent focus from sticking to links inside menu after clicking // them (focus should always stay on UL during navigation). From 4f15e66f5373170caf307237b9a8b2c505ae3dbf Mon Sep 17 00:00:00 2001 From: kborchers Date: Sun, 22 Jan 2012 11:26:41 -0600 Subject: [PATCH 18/27] Menu: Added unit tests for the enable, disable and refresh methods as well as the disabled option. Cleaned up some variable names in unit tests. --- tests/unit/menu/menu_core.js | 28 ++++++++++++++-------------- tests/unit/menu/menu_events.js | 12 ++++++------ tests/unit/menu/menu_methods.js | 30 ++++++++++++++++++++++++++++++ tests/unit/menu/menu_options.js | 28 ++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 20 deletions(-) diff --git a/tests/unit/menu/menu_core.js b/tests/unit/menu/menu_core.js index c0feae75c..bccf4a1f2 100644 --- a/tests/unit/menu/menu_core.js +++ b/tests/unit/menu/menu_core.js @@ -9,27 +9,27 @@ module("menu: core"); test("accessibility", function () { expect(5); - var ac = $('#menu1').menu(); + var menu = $('#menu1').menu(); var item0 = $("li:eq(0) a"); - ok( ac.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all"), "menu class"); - equals( ac.attr("role"), "menu", "main role"); - ok( !ac.attr("aria-activedescendant"), "aria attribute not yet active"); + ok( menu.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all"), "menu class"); + equals( menu.attr("role"), "menu", "main role"); + ok( !menu.attr("aria-activedescendant"), "aria attribute not yet active"); - var item = ac.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end(); - ac.menu( "focus", $.Event(), item ); - equals( ac.attr("aria-activedescendant"), "xid", "aria attribute, id from dom"); + var item = menu.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end(); + menu.menu( "focus", $.Event(), item ); + equals( menu.attr("aria-activedescendant"), "xid", "aria attribute, id from dom"); - var item = ac.find( "li:last" ); - ac.menu( "focus", $.Event(), item ); - equals( ac.attr("aria-activedescendant"), "menu1-4", "aria attribute, generated id"); + var item = menu.find( "li:last" ); + menu.menu( "focus", $.Event(), item ); + equals( menu.attr("aria-activedescendant"), "menu1-4", "aria attribute, generated id"); }); test("items class and role", function () { - var ac = $('#menu1').menu(); - expect(1 + 5 * $("li",ac).length); - ok( ($("li",ac).length > 0 ), "number of menu items"); - $("li",ac).each(function(item) { + var menu = $('#menu1').menu(); + expect(1 + 5 * $("li",menu).length); + ok( ($("li",menu).length > 0 ), "number of menu items"); + $("li",menu).each(function(item) { ok( $(this).hasClass("ui-menu-item"), "menu item ("+ item + ") class for item"); equals( $(this).attr("role"), "presentation", "menu item ("+ item + ") role"); equals( $("a", this).attr("role"), "menuitem", "menu item ("+ item + ") role"); diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js index 9e68e0c67..8df43fa21 100644 --- a/tests/unit/menu/menu_events.js +++ b/tests/unit/menu/menu_events.js @@ -7,7 +7,7 @@ module("menu: events"); test("handle click on menu", function() { expect(1); - var ac = $('#menu1').menu({ + var menu = $('#menu1').menu({ select: function(event, ui) { menu_log(); } @@ -15,15 +15,15 @@ test("handle click on menu", function() { menu_log("click",true); menu_click($('#menu1'),"1"); menu_log("afterclick"); - menu_click( ac,"2"); + menu_click( menu,"2"); menu_click($('#menu1'),"3"); - menu_click( ac,"1"); + menu_click( menu,"1"); equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid."); }); test("handle click on custom item menu", function() { expect(1); - var ac = $('#menu5').menu({ + var menu = $('#menu5').menu({ select: function(event, ui) { menu_log(); }, @@ -32,9 +32,9 @@ test("handle click on custom item menu", function() { menu_log("click",true); menu_click($('#menu5'),"1"); menu_log("afterclick"); - menu_click( ac,"2"); + menu_click( menu,"2"); menu_click($('#menu5'),"3"); - menu_click( ac,"1"); + menu_click( menu,"1"); equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid."); }); diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js index 0ecaf7328..3bcab3361 100644 --- a/tests/unit/menu/menu_methods.js +++ b/tests/unit/menu/menu_methods.js @@ -5,6 +5,36 @@ module("menu: methods"); +test( "enable/disable", function() { + expect( 3 ); + var menu = $( "#menu1" ).menu({ + select: function(event, ui) { + menu_log(); + } + }); + menu.menu("disable"); + ok(menu.is(".ui-state-disabled"),"Missing ui-state-disabled class"); + menu_log("click",true); + menu_click(menu,"1"); + menu_log("afterclick"); + menu.menu("enable"); + ok(menu.not(".ui-state-disabled"),"Has ui-state-disabled class"); + menu_log("click"); + menu_click(menu,"1"); + menu_log("afterclick"); + equals( $("#log").html(), "afterclick,1,click,afterclick,click,", "Click order not valid."); +}); + +test( "refresh", function() { + expect( 3 ); + var menu = $( "#menu1" ).menu(); + equals(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items"); + menu.append("
  • test item
  • ").menu("refresh"); + equals(menu.find(".ui-menu-item").length,6,"Incorrect number of menu items"); + menu.find(".ui-menu-item:last").remove().end().menu("refresh"); + equals(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items"); +}); + test("destroy", function() { domEqual("#menu1", function() { $("#menu1").menu().menu("destroy"); diff --git a/tests/unit/menu/menu_options.js b/tests/unit/menu/menu_options.js index 03822fd74..479aab0d1 100644 --- a/tests/unit/menu/menu_options.js +++ b/tests/unit/menu/menu_options.js @@ -5,6 +5,34 @@ module("menu: options"); +test( "{ disabled: true }", function() { + expect( 2 ); + var menu = $( "#menu1" ).menu({ + disabled: true, + select: function(event, ui) { + menu_log(); + } + }); + ok(menu.is(".ui-state-disabled"),"Missing ui-state-disabled class"); + menu_log("click",true); + menu_click(menu,"1"); + menu_log("afterclick"); + equals( $("#log").html(), "afterclick,click,", "Click order not valid."); +}); +test( "{ disabled: false }", function() { + expect( 2 ); + var menu = $( "#menu1" ).menu({ + disabled: false, + select: function(event, ui) { + menu_log(); + } + }); + ok(menu.not(".ui-state-disabled"),"Has ui-state-disabled class"); + menu_log("click",true); + menu_click(menu,"1"); + menu_log("afterclick"); + equals( $("#log").html(), "afterclick,1,click,", "Click order not valid."); +}); })(jQuery); From ba4335712226ecfd66d34ddc93def2433af82f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Sat, 28 Jan 2012 07:44:58 -0500 Subject: [PATCH 19/27] Demos: Specify the dataType when loading the demo and docs files. Fixes #8069 - UI demos fail from local file:// in Firefox 9 - bad tags, bad calls in demo sources. --- demos/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/index.html b/demos/index.html index 76ddcd3da..cba4641a3 100644 --- a/demos/index.html +++ b/demos/index.html @@ -225,9 +225,9 @@ return false; }); }); - }); + }, "html" ); } - }); + }, "html" ); } function updateDemoNotes() { From 6074b0698a01ec52c30eae91dbeb883e8f5432e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 31 Jan 2012 08:54:21 -0500 Subject: [PATCH 20/27] Accordion: Use ui-accordion-header-active class. --- themes/base/jquery.ui.accordion.css | 6 +++--- ui/jquery.ui.accordion.js | 13 ++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/themes/base/jquery.ui.accordion.css b/themes/base/jquery.ui.accordion.css index dfc98c226..c69118384 100644 --- a/themes/base/jquery.ui.accordion.css +++ b/themes/base/jquery.ui.accordion.css @@ -9,10 +9,10 @@ */ /* IE/Win - Fix animation bug - #4615 */ .ui-accordion { width: 100%; } -.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; } -.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; } +.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 2px; zoom: 1; } +.ui-accordion .ui-accordion-header-active { border-bottom: 0; } .ui-accordion .ui-accordion-heading { display: block; font-size: 1em; padding: .5em .5em .5em .7em; } .ui-accordion-icons .ui-accordion-heading { padding-left: 2.2em; } .ui-accordion .ui-accordion-header .ui-accordion-header-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; } -.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; } +.ui-accordion .ui-accordion-content { padding: 1em 2.2em; overflow: auto; display: none; zoom: 1; } .ui-accordion .ui-accordion-content-active { display: block; } diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 127099d59..48d61448d 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -13,7 +13,6 @@ */ (function( $, undefined ) { -// TODO: use ui-accordion-header-active class and fix styling $.widget( "ui.accordion", { version: "@VERSION", options: { @@ -58,7 +57,7 @@ $.widget( "ui.accordion", { options.active += this.headers.length; } self.active = self._findActive( options.active ) - .addClass( "ui-state-default ui-state-active" ) + .addClass( "ui-accordion-header-active ui-state-active" ) .toggleClass( "ui-corner-all" ) .toggleClass( "ui-corner-top" ); self.active.next().addClass( "ui-accordion-content-active" ); @@ -131,7 +130,7 @@ $.widget( "ui.accordion", { // clean up headers this.headers .unbind( ".accordion" ) - .removeClass( "ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" ) + .removeClass( "ui-accordion-header ui-accordion-header-active ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" ) .removeAttr( "role" ) .removeAttr( "aria-expanded" ) .removeAttr( "aria-selected" ) @@ -335,15 +334,15 @@ $.widget( "ui.accordion", { // switch classes active - .removeClass( "ui-state-active ui-corner-top" ) - .addClass( "ui-state-default ui-corner-all" ) + .removeClass( "ui-accordion-header-active ui-state-active ui-corner-top" ) + .addClass( "ui-corner-all" ) .children( ".ui-accordion-header-icon" ) .removeClass( options.icons.activeHeader ) .addClass( options.icons.header ); if ( !clickedIsActive ) { clicked - .removeClass( "ui-state-default ui-corner-all" ) - .addClass( "ui-state-active ui-corner-top" ) + .removeClass( "ui-corner-all" ) + .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" ) .children( ".ui-accordion-header-icon" ) .removeClass( options.icons.header ) .addClass( options.icons.activeHeader ); From ecddf469d7924d88d72e57a4806996fc50fa50ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 31 Jan 2012 10:42:01 -0500 Subject: [PATCH 21/27] Accordion: Reset overflowX and overflowY after animations to fix overflow in Opera <11.6. Fixes #6971 - Accordion animation bug in Opera 11.01 with jQuery 1.4.3+. --- ui/jquery.ui.accordion.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 48d61448d..a019ca127 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -438,7 +438,11 @@ $.extend( $.ui.accordion, { } var showOverflow = options.toShow.css( "overflow" ), + showOverflowX = options.toHide.css( "overflowX" ), + showOverflowY = options.toHide.css( "overflowY" ), hideOverflow = options.toHide.css( "overflow" ), + hideOverflowX = options.toHide.css( "overflowX" ), + hideOverflowY = options.toHide.css( "overflowY" ), percentDone = 0, showProps = {}, hideProps = {}, @@ -521,9 +525,15 @@ $.extend( $.ui.accordion, { complete: function() { options.toShow.css({ width: originalWidth, - overflow: showOverflow + overflow: showOverflow, + overflowX: showOverflowX, + overflowY: showOverflowY + }); + options.toHide.css({ + overflow: hideOverflow, + overflowX: hideOverflowX, + overflowY: hideOverflowY }); - options.toHide.css( "overflow", hideOverflow ); options.complete(); } }); From 3919256abd7b91dcc8437c245f98d623103f97e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 31 Jan 2012 11:46:31 -0500 Subject: [PATCH 22/27] Accordion: Pass header and content in create event. Fixes #7869 - Accordion: Provide header and content details in create event. --- tests/unit/accordion/accordion_events.js | 39 ++++++++++++++++++++++++ ui/jquery.ui.accordion.js | 7 +++++ 2 files changed, 46 insertions(+) diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js index 12acf2a44..b5c3ea228 100644 --- a/tests/unit/accordion/accordion_events.js +++ b/tests/unit/accordion/accordion_events.js @@ -2,6 +2,45 @@ module( "accordion: events", accordion_setupTeardown() ); +test( "create", function() { + expect( 10 ); + + var element = $( "#list1" ), + headers = element.children( "h3" ), + contents = headers.next(); + + element.accordion({ + create: function( event, ui ) { + equals( ui.header.size(), 1, "header size" ); + strictEqual( ui.header[ 0 ], headers[ 0 ], "header" ); + equals( ui.content.size(), 1, "content size" ); + strictEqual( ui.content[ 0 ], contents[ 0 ], "content" ); + } + }); + element.accordion( "destroy" ); + + element.accordion({ + active: 2, + create: function( event, ui ) { + equals( ui.header.size(), 1, "header size" ); + strictEqual( ui.header[ 0 ], headers[ 2 ], "header" ); + equals( ui.content.size(), 1, "content size" ); + strictEqual( ui.content[ 0 ], contents[ 2 ], "content" ); + } + }); + element.accordion( "destroy" ); + + element.accordion({ + active: false, + collapsible: true, + create: function( event, ui ) { + equals( ui.header.size(), 0, "header size" ); + equals( ui.content.size(), 0, "content size" ); + } + }); + element.accordion( "destroy" ); +}); + test( "beforeActivate", function() { expect( 38 ); var element = $( "#list1" ).accordion({ diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index a019ca127..97549cb10 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -103,6 +103,13 @@ $.widget( "ui.accordion", { this._setupEvents( options.event ); }, + _getCreateEventData: function() { + return { + header: this.active, + content: !this.active.length ? $() : this.active.next() + }; + }, + _createIcons: function() { var icons = this.options.icons; if ( icons ) { From 5a55d68eca60b52cbd1ae1ab48a6c9b1f8817ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 31 Jan 2012 12:48:00 -0500 Subject: [PATCH 23/27] Accordion: Moved the ui-accordion-icons class to the headers to properly style nested accordions with varying settings of icons and no icons. Fixes #7880 - Nested accordion. --- themes/base/jquery.ui.accordion.css | 4 +++- ui/jquery.ui.accordion.js | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/themes/base/jquery.ui.accordion.css b/themes/base/jquery.ui.accordion.css index c69118384..0a07f0309 100644 --- a/themes/base/jquery.ui.accordion.css +++ b/themes/base/jquery.ui.accordion.css @@ -12,7 +12,9 @@ .ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 2px; zoom: 1; } .ui-accordion .ui-accordion-header-active { border-bottom: 0; } .ui-accordion .ui-accordion-heading { display: block; font-size: 1em; padding: .5em .5em .5em .7em; } -.ui-accordion-icons .ui-accordion-heading { padding-left: 2.2em; } +.ui-accordion-icons a.ui-accordion-heading { padding-left: 2.2em; } +.ui-accordion-noicons a.ui-accordion-heading { padding-left: .7em; } +.ui-accordion-icons .ui-accordion-icons a.ui-accordion-heading { padding-left: 2.2em; } .ui-accordion .ui-accordion-header .ui-accordion-header-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; } .ui-accordion .ui-accordion-content { padding: 1em 2.2em; overflow: auto; display: none; zoom: 1; } .ui-accordion .ui-accordion-content-active { display: block; } diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 97549cb10..6c486c7b1 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -119,13 +119,15 @@ $.widget( "ui.accordion", { this.active.children( ".ui-accordion-header-icon" ) .removeClass( icons.header ) .addClass( icons.activeHeader ); - this.element.addClass( "ui-accordion-icons" ); + this.headers.addClass( "ui-accordion-icons" ); } }, _destroyIcons: function() { - this.headers.children( ".ui-accordion-header-icon" ).remove(); - this.element.removeClass( "ui-accordion-icons" ); + this.headers + .removeClass( "ui-accordion-icons" ) + .children( ".ui-accordion-header-icon" ) + .remove(); }, _destroy: function() { From 8f521f9d9e354a160df116df02b6c1e29d9fa458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 31 Jan 2012 13:09:28 -0500 Subject: [PATCH 24/27] Accordion: Fixed styling for nested accordions. --- themes/base/jquery.ui.accordion.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/base/jquery.ui.accordion.css b/themes/base/jquery.ui.accordion.css index 0a07f0309..5255bdd26 100644 --- a/themes/base/jquery.ui.accordion.css +++ b/themes/base/jquery.ui.accordion.css @@ -10,7 +10,8 @@ /* IE/Win - Fix animation bug - #4615 */ .ui-accordion { width: 100%; } .ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 2px; zoom: 1; } -.ui-accordion .ui-accordion-header-active { border-bottom: 0; } +.ui-accordion .ui-accordion-header-active, +.ui-accordion .ui-accordion .ui-accordion-header-active { border-bottom: 0; } .ui-accordion .ui-accordion-heading { display: block; font-size: 1em; padding: .5em .5em .5em .7em; } .ui-accordion-icons a.ui-accordion-heading { padding-left: 2.2em; } .ui-accordion-noicons a.ui-accordion-heading { padding-left: .7em; } From 853b515e5c6f02dff1a4693eaf6c16d8bafc1395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 31 Jan 2012 13:11:20 -0500 Subject: [PATCH 25/27] Accordion: Adjusted tests for icons: false. --- tests/unit/accordion/accordion_options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js index a60bb27e1..8206b1d62 100644 --- a/tests/unit/accordion/accordion_options.js +++ b/tests/unit/accordion/accordion_options.js @@ -255,7 +255,7 @@ test( "{ icons: false }", function() { var element = $( "#list1" ); function icons( on ) { deepEqual( element.find( "span.ui-icon").length, on ? 3 : 0 ); - deepEqual( element.hasClass( "ui-accordion-icons" ), on ); + deepEqual( element.find( ".ui-accordion-header.ui-accordion-icons" ).length, on ? 3 : 0 ); } element.accordion(); icons( true ); From 66c7dfd377d91bd5867ce1a9b607e8ed25955241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 31 Jan 2012 14:07:17 -0500 Subject: [PATCH 26/27] Accordion demo: Clear out originalEvent in hoverintent special event. Fixes #6028 - Accordion: Hoverintent demo throws an error in IE. --- demos/accordion/hoverintent.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/demos/accordion/hoverintent.html b/demos/accordion/hoverintent.html index 09360d62d..184951cf2 100644 --- a/demos/accordion/hoverintent.html +++ b/demos/accordion/hoverintent.html @@ -50,6 +50,10 @@ if ( ( Math.abs( pX - cX ) + Math.abs( pY - cY ) ) < cfg.sensitivity ) { clear(); event.type = "hoverintent"; + // prevent accessing the original event since the new event + // is fired asynchronously and the old event is no longer + // usable (#6028) + event.originalEvent = {}; jQuery.event.handle.apply( self, args ); } else { pX = cX; From 62a70da959e71a2d5c8ecc27548ea38733ec3128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 31 Jan 2012 14:21:18 -0500 Subject: [PATCH 27/27] Autocomplete: Added test for close method. --- tests/unit/autocomplete/autocomplete_core.js | 4 ---- tests/unit/autocomplete/autocomplete_methods.js | 11 +++++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/unit/autocomplete/autocomplete_core.js b/tests/unit/autocomplete/autocomplete_core.js index d98f56abf..bc61b9100 100644 --- a/tests/unit/autocomplete/autocomplete_core.js +++ b/tests/unit/autocomplete/autocomplete_core.js @@ -162,8 +162,4 @@ test( "allow form submit on enter when menu is not active", function() { } })(); -(function() { - -})(); - }( jQuery ) ); diff --git a/tests/unit/autocomplete/autocomplete_methods.js b/tests/unit/autocomplete/autocomplete_methods.js index 3fe035d28..1600d73dc 100644 --- a/tests/unit/autocomplete/autocomplete_methods.js +++ b/tests/unit/autocomplete/autocomplete_methods.js @@ -9,15 +9,19 @@ test( "destroy", function() { }); }); -test( "search", function() { - expect( 3 ); +test( "search, close", function() { + expect( 6 ); var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ], element = $( "#autocomplete" ).autocomplete({ source: data, minLength: 0 }), menu = element.autocomplete( "widget" ); + + ok( menu.is( ":hidden" ), "menu is hidden on init" ); + element.autocomplete( "search" ); + ok( menu.is( ":visible" ), "menu is visible after search" ); equal( menu.find( ".ui-menu-item" ).length, data.length, "all items for a blank search" ); element.val( "has" ).autocomplete( "search" ); @@ -25,6 +29,9 @@ test( "search", function() { element.autocomplete( "search", "ja" ); equal( menu.find( ".ui-menu-item" ).length, 2, "only java and javascript for 'ja'" ); + + element.autocomplete( "close" ); + ok( menu.is( ":hidden" ), "menu is hidden after close" ); }); }( jQuery ) );