From 96f2aa4c72b5f29782b0736ed95468e50d338d6e Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 5 Oct 2012 11:26:49 -0400 Subject: Tooltip: Check if event exists before checking properties in open(). Fixes #8626 - Programatically opening a tooltip with out giving an event results in a javascript error. --- tests/unit/tooltip/tooltip_methods.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js index 0af1e06e9..896e910c6 100644 --- a/tests/unit/tooltip/tooltip_methods.js +++ b/tests/unit/tooltip/tooltip_methods.js @@ -29,6 +29,23 @@ test( "open/close", function() { $.fx.off = false; }); +// #8626 - Calling open() without an event +test( "open/close with tracking", function() { + expect( 3 ); + $.fx.off = true; + var tooltip, + element = $( "#tooltipped1" ).tooltip({ track: true }); + equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" ); + + element.tooltip( "open" ); + tooltip = $( "#" + element.data( "ui-tooltip-id" ) ); + ok( tooltip.is( ":visible" ) ); + + element.tooltip( "close" ); + ok( tooltip.is( ":hidden" ) ); + $.fx.off = false; +}); + test( "enable/disable", function() { expect( 7 ); $.fx.off = true; -- cgit v1.2.3 From 0a31a828319493d6642ce876555e5383106ce039 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 5 Oct 2012 12:52:02 -0400 Subject: Tooltip: Better cleanup on destroy. Fixes #8627 - The Tooltip destroy method is not clearing up the data properties. --- tests/unit/tooltip/tooltip_methods.js | 13 ++++++++++--- ui/jquery.ui.tooltip.js | 18 +++++++++++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js index 896e910c6..c846d216c 100644 --- a/tests/unit/tooltip/tooltip_methods.js +++ b/tests/unit/tooltip/tooltip_methods.js @@ -3,13 +3,20 @@ module( "tooltip: methods" ); test( "destroy", function() { - expect( 2 ); + expect( 3 ); + var element = $( "#tooltipped1" ); + domEqual( "#tooltipped1", function() { - $( "#tooltipped1" ).tooltip().tooltip( "destroy" ); + element.tooltip().tooltip( "destroy" ); }); // make sure that open tooltips are removed on destroy - $( "#tooltipped1" ).tooltip().tooltip( "open" ).tooltip( "destroy" ); + domEqual( "#tooltipped1", function() { + element + .tooltip() + .tooltip( "open", $.Event( "mouseover", { target: element[0] }) ) + .tooltip( "destroy" ); + }); equal( $( ".ui-tooltip" ).length, 0 ); }); diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 32aad6487..980b43868 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -317,8 +317,24 @@ $.widget( "ui.tooltip", { }, _destroy: function() { - $.each( this.tooltips, function( id ) { + var that = this; + + // close open tooltips + $.each( this.tooltips, function( id, element ) { + // Delegate to close method to handle common cleanup + var event = $.Event( "blur" ); + event.target = event.currentTarget = element[0]; + that.close( event, true ); + + // Remove immediately; destroying an open tooltip doesn't use the + // hide animation $( "#" + id ).remove(); + + // Restore the title + if ( element.data( "ui-tooltip-title" ) ) { + element.attr( "title", element.data( "ui-tooltip-title" ) ); + element.removeData( "ui-tooltip-title" ); + } }); } }); -- cgit v1.2.3 From a3f1a34d3b997550a5a8cf4c630e6580cd37cde5 Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 10 Oct 2012 11:45:48 -0400 Subject: Remove use of $.browser; add $.ui.ie and $.ui.ie6 temporarily. --- tests/jquery.simulate.js | 2 +- tests/unit/datepicker/datepicker_core.js | 4 ++-- ui/jquery.ui.core.js | 8 +++++++- ui/jquery.ui.datepicker.js | 2 +- ui/jquery.ui.dialog.js | 4 ++-- ui/jquery.ui.draggable.js | 2 +- ui/jquery.ui.mouse.js | 2 +- ui/jquery.ui.resizable.js | 4 ++-- ui/jquery.ui.sortable.js | 2 +- 9 files changed, 18 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/jquery.simulate.js b/tests/jquery.simulate.js index e281e2fee..790c88c27 100644 --- a/tests/jquery.simulate.js +++ b/tests/jquery.simulate.js @@ -148,7 +148,7 @@ $.extend( $.simulate.prototype, { } // TODO: can we hook into core's logic? - if ( $.browser.msie || $.browser.opera ) { + if ( $.ui.ie || (({}).toString.call( window.opera ) === "[object Opera]") ) { // TODO: is charCode ever <0 ? Can we just use charCode || keyCode? event.keyCode = (options.charCode > 0) ? options.charCode : options.keyCode; event.charCode = undefined; diff --git a/tests/unit/datepicker/datepicker_core.js b/tests/unit/datepicker/datepicker_core.js index 17cefe157..e17b239e5 100644 --- a/tests/unit/datepicker/datepicker_core.js +++ b/tests/unit/datepicker/datepicker_core.js @@ -59,7 +59,7 @@ test('baseStructure', function() { var header, title, table, thead, week, panel, inl, child, inp = init('#inp').focus(), dp = $('#ui-datepicker-div'), - iframe = ($.browser.msie && parseInt($.browser.version, 10) < 7); + iframe = ($.ui.ie6); ok(dp.is(':visible'), 'Structure - datepicker visible'); ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left'); ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month'); @@ -186,7 +186,7 @@ test('customStructure', function() { inp = init('#inp', $.datepicker.regional.he); inp.data('showButtonPanel.datepicker',true); inp.focus(); - iframe = ($.browser.msie && parseInt($.browser.version, 10) < 7); + iframe = ($.ui.ie6); ok(dp.is('.ui-datepicker-rtl'), 'Structure RTL - right-to-left'); header = dp.children(':first'); ok(header.is('div.ui-datepicker-header'), 'Structure RTL - header division'); diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index bb9411dc9..e569eea42 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -69,7 +69,7 @@ $.fn.extend({ scrollParent: function() { var scrollParent; - if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { + if (($.ui.ie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { scrollParent = this.parents().filter(function() { return (/(relative|absolute|fixed)/).test($.css(this,'position')) && (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x')); }).eq(0); @@ -258,6 +258,12 @@ $(function() { // deprecated +(function() { + var uaMatch = /msie ([\w.]+)/.exec( navigator.userAgent.toLowerCase() ) || []; + $.ui.ie = uaMatch.length ? true : false; + $.ui.ie6 = parseFloat( uaMatch[ 1 ], 10 ) === 6; +})(); + $.fn.extend({ disableSelection: function() { return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) + diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 9ea36924b..4643af2eb 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -1605,7 +1605,7 @@ $.extend(Datepicker.prototype, { } html += group; } - html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ? + html += buttonPanel + ($.ui.ie6 && !inst.inline ? '' : ''); inst._keyEvent = false; return html; diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 98bd7fcaa..8593fff85 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -768,7 +768,7 @@ $.extend( $.ui.dialog.overlay, { var scrollHeight, offsetHeight; // handle IE - if ( $.browser.msie ) { + if ( $.ui.ie ) { scrollHeight = Math.max( document.documentElement.scrollHeight, document.body.scrollHeight @@ -793,7 +793,7 @@ $.extend( $.ui.dialog.overlay, { var scrollWidth, offsetWidth; // handle IE - if ( $.browser.msie ) { + if ( $.ui.ie ) { scrollWidth = Math.max( document.documentElement.scrollWidth, document.body.scrollWidth diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 2e33e3311..e110bd8a4 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -318,7 +318,7 @@ $.widget("ui.draggable", $.ui.mouse, { } if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information - || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix + || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.ui.ie)) //Ugly IE fix po = { top: 0, left: 0 }; return { diff --git a/ui/jquery.ui.mouse.js b/ui/jquery.ui.mouse.js index 30546ffc4..f5069d00c 100644 --- a/ui/jquery.ui.mouse.js +++ b/ui/jquery.ui.mouse.js @@ -111,7 +111,7 @@ $.widget("ui.mouse", { _mouseMove: function(event) { // IE mouseup check - mouseup happened when mouse was out of window - if ($.browser.msie && !(document.documentMode >= 9) && !event.button) { + if ($.ui.ie && !(document.documentMode >= 9) && !event.button) { return this._mouseUp(event); } diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js index 724ae9ddf..cc82b8b92 100644 --- a/ui/jquery.ui.resizable.js +++ b/ui/jquery.ui.resizable.js @@ -466,8 +466,8 @@ $.widget("ui.resizable", $.ui.mouse, { this.helper = this.helper || $('
'); // fix ie6 offset TODO: This seems broken - var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0), - pxyoffset = ( ie6 ? 2 : -1 ); + var ie6offset = ($.ui.ie6 ? 1 : 0), + pxyoffset = ( $.ui.ie6 ? 2 : -1 ); this.helper.addClass(this._helper).css({ width: this.element.outerWidth() + pxyoffset, diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 070dff6cd..920e645d4 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -822,7 +822,7 @@ $.widget("ui.sortable", $.ui.mouse, { } if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information - || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix + || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.ui.ie)) //Ugly IE fix po = { top: 0, left: 0 }; return { -- cgit v1.2.3 From 94221c4e5b11496ef927889e1541d84b5746fb31 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 12 Oct 2012 11:07:04 -0400 Subject: Tabs: Use aria-controls instead of the anchor's href to match against location.hash. Fixes #8660 - Tabs: Set initial active tab from location hash for ajax tabs. --- tests/unit/tabs/tabs_options.js | 8 +++++++- ui/jquery.ui.tabs.js | 9 +++++---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js index 5a90ff895..1b468f2b6 100644 --- a/tests/unit/tabs/tabs_options.js +++ b/tests/unit/tabs/tabs_options.js @@ -7,7 +7,7 @@ var disabled = TestHelpers.tabs.disabled, module( "tabs: options" ); test( "{ active: default }", function() { - expect( 4 ); + expect( 6 ); var element = $( "#tabs1" ).tabs(); equal( element.tabs( "option", "active" ), 0, "should be 0 by default" ); @@ -19,6 +19,12 @@ test( "{ active: default }", function() { equal( element.tabs( "option", "active" ), 2, "should be 2 based on URL" ); state( element, 0, 0, 1 ); element.tabs( "destroy" ); + + location.hash = "#custom-id"; + element = $( "#tabs2" ).tabs(); + equal( element.tabs( "option", "active" ), 3, "should be 3 based on URL" ); + state( element, 0, 0, 0, 1, 0 ); + element.tabs( "destroy" ); location.hash = "#"; }); diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index baf55d8dc..7d38fb46e 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -51,7 +51,8 @@ $.widget( "ui.tabs", { var panel, that = this, options = this.options, - active = options.active; + active = options.active, + locationHash = location.hash.substring( 1 ); this.running = false; @@ -80,9 +81,9 @@ $.widget( "ui.tabs", { if ( active === null ) { // check the fragment identifier in the URL - if ( location.hash ) { - this.anchors.each(function( i, anchor ) { - if ( anchor.hash === location.hash ) { + if ( locationHash ) { + this.tabs.each(function( i, tab ) { + if ( $( tab ).attr( "aria-controls" ) === locationHash ) { active = i; return false; } -- cgit v1.2.3