From 3974b55ba5078799df818c78d9273e11d9796ff3 Mon Sep 17 00:00:00 2001 From: Ethan Romba Date: Tue, 10 Jul 2012 01:02:25 -0700 Subject: Resizable: Update CSS dimensions selectively. Fixes #7605 - Setting width and height when only one is changing Resizable: Trigger resize event only when element is resized. Fixes #5545 - Callbacks ignore the grid. Resizable: Added event tests. Fixes #5817 - resize event reports unconstrained ui.size --- ui/jquery.ui.resizable.js | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js index fba9216e1..a27a140b2 100644 --- a/ui/jquery.ui.resizable.js +++ b/ui/jquery.ui.resizable.js @@ -286,8 +286,10 @@ $.widget("ui.resizable", $.ui.mouse, { _mouseDrag: function(event) { //Increase performance, avoid regex - var el = this.helper, - smp = this.originalMousePosition, a = this.axis; + var el = this.helper, props = {}, + smp = this.originalMousePosition, a = this.axis, + prevTop = this.position.top, prevLeft = this.position.left, + prevWidth = this.size.width, prevHeight = this.size.height; var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0; var trigger = this._change[a]; @@ -303,21 +305,32 @@ $.widget("ui.resizable", $.ui.mouse, { data = this._respectSize(data, event); + this._updateCache(data); + // plugins callbacks need to be called first this._propagate("resize", event); - el.css({ - top: this.position.top + "px", left: this.position.left + "px", - width: this.size.width + "px", height: this.size.height + "px" - }); + if (this.position.top !== prevTop) { + props.top = this.position.top + "px"; + } + if (this.position.left !== prevLeft) { + props.left = this.position.left + "px"; + } + if (this.size.width !== prevWidth) { + props.width = this.size.width + "px"; + } + if (this.size.height !== prevHeight) { + props.height = this.size.height + "px"; + } + el.css(props); if (!this._helper && this._proportionallyResizeElements.length) this._proportionallyResize(); - this._updateCache(data); - - // calling the user callback at the end - this._trigger('resize', event, this.ui()); + // Call the user callback if the element was resized + if ( ! $.isEmptyObject(props) ) { + this._trigger('resize', event, this.ui()); + } return false; }, -- cgit v1.2.3 From 2553d61384a89a7aa3fcea2f185c2c7ec45d2bd1 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 13 Nov 2012 19:02:02 -0500 Subject: Accordion: Use .css() to clear the height, instead of .height(). --- ui/jquery.ui.accordion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 4ebc5b549..7914f7c5f 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -346,7 +346,7 @@ $.widget( "ui.accordion", { maxHeight = 0; this.headers.next() .each(function() { - maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() ); + maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() ); }) .height( maxHeight ); } -- cgit v1.2.3 From eca5abd873675f5cc7b96641c723b7e35a4260bc Mon Sep 17 00:00:00 2001 From: Jay Merrifield Date: Tue, 13 Nov 2012 21:07:48 -0500 Subject: Datepicker: Updated the range tests so you can't navigate past the yearRange. Fixes #7362 - Datepicker allows changing year to something outside yearRange --- tests/unit/datepicker/datepicker_options.js | 8 +++++++- ui/jquery.ui.datepicker.js | 14 +++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 9078a2374..7d2b070fa 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -322,9 +322,10 @@ test('miscellaneous', function() { }); test('minMax', function() { - expect( 17 ); + expect( 19 ); var date, inp = TestHelpers.datepicker.init('#inp'), + dp = $('#ui-datepicker-div'), lastYear = new Date(2007, 6 - 1, 4), nextYear = new Date(2009, 6 - 1, 4), minDate = new Date(2008, 2 - 1, 29), @@ -404,6 +405,11 @@ test('minMax', function() { TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 6 - 1, 4), 'Min/max - setDate > min, < max'); inp.datepicker('option', {maxDate: null}).val('01/04/2009').datepicker('option', {minDate: minDate, maxDate: maxDate}); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), maxDate, 'Min/max - setDate > max'); + + inp.datepicker('option', {yearRange: '-0:+1'}).val('01/01/' + new Date().getFullYear()); + ok(dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - previous button disabled at 1/1/minYear"); + inp.datepicker("setDate", "12/30/" + new Date().getFullYear()); + ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - next button disabled at 12/30/maxYear"); }); test('setDate', function() { diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index c7ecafffb..e3c3bd398 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -1742,8 +1742,20 @@ $.extend(Datepicker.prototype, { _isInRange: function(inst, date) { var minDate = this._getMinMaxDate(inst, 'min'); var maxDate = this._getMinMaxDate(inst, 'max'); + var minYear = null; + var maxYear = null; + var years = this._get(inst, 'yearRange'); + if (years){ + var yearSplit = years.split(':'); + var currentYear = new Date().getFullYear(); + minYear = parseInt(yearSplit[0], 10) + currentYear; + maxYear = parseInt(yearSplit[1], 10) + currentYear; + } + return ((!minDate || date.getTime() >= minDate.getTime()) && - (!maxDate || date.getTime() <= maxDate.getTime())); + (!maxDate || date.getTime() <= maxDate.getTime()) && + (!minYear || date.getFullYear() >= minYear) && + (!maxYear || date.getFullYear() <= maxYear)); }, /* Provide the configuration settings for formatting/parsing. */ -- cgit v1.2.3 From 1b503a237e1dc47739a8a451debbc86e169851e3 Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 14 Nov 2012 14:14:25 -0500 Subject: Tooltip: Handle synthetic focusin events. Fixes #8740 - Tooltip: Does not hide consistently with dynamically loaded content. --- tests/unit/tooltip/tooltip_core.js | 27 +++++++++++++++++++++++++++ ui/jquery.ui.tooltip.js | 11 ++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/tests/unit/tooltip/tooltip_core.js b/tests/unit/tooltip/tooltip_core.js index 69936dba2..c3568bffc 100644 --- a/tests/unit/tooltip/tooltip_core.js +++ b/tests/unit/tooltip/tooltip_core.js @@ -107,4 +107,31 @@ test( "tooltip on .ui-state-disabled element", function() { equal( $( ".ui-tooltip" ).length, 0 ); }); +// http://bugs.jqueryui.com/ticket/8740 +asyncTest( "programmatic focus with async content", function() { + expect( 2 ); + var element = $( "#tooltipped1" ).tooltip({ + content: function( response ) { + setTimeout(function() { + response( "test" ); + }); + } + }); + + element.bind( "tooltipopen", function( event ) { + deepEqual( event.originalEvent.type, "focusin" ); + + element.bind( "tooltipclose", function( event ) { + deepEqual( event.originalEvent.type, "focusout" ); + start(); + }); + + setTimeout(function() { + element.blur(); + }); + }); + + element.focus(); +}); + }( jQuery ) ); diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index e5b496bee..ffffe1981 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -188,7 +188,8 @@ $.widget( "ui.tooltip", { _updateContent: function( target, event ) { var content, contentOption = this.options.content, - that = this; + that = this, + eventType = event ? event.type : null; if ( typeof contentOption === "string" ) { return this._open( event, target, contentOption ); @@ -202,6 +203,14 @@ $.widget( "ui.tooltip", { // IE may instantly serve a cached response for ajax requests // delay this call to _open so the other call to _open runs first that._delay(function() { + // jQuery creates a special event for focusin when it doesn't + // exist natively. To improve performance, the native event + // object is reused and the type is changed. Therefore, we can't + // rely on the type being correct after the event finished + // bubbling, so we set it back to the previous value. (#8740) + if ( event ) { + event.type = eventType; + } this._open( event, target, response ); }); }); -- cgit v1.2.3 From ca0df6b9007a13dabdf7e78acb3d30bdb0928a97 Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 14 Nov 2012 14:42:36 -0500 Subject: Tooltip: Removed logic for handling tracking tooltips which gain focus while open (we no longer mix events). Fixes #8799 - Tooltip: tracking fails on nested elements. --- ui/jquery.ui.tooltip.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index ffffe1981..2ccd61f46 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -138,20 +138,8 @@ $.widget( "ui.tooltip", { // but always pointing at the same event target .closest( this.options.items ); - // No element to show a tooltip for - if ( !target.length ) { - return; - } - - // If the tooltip is open and we're tracking then reposition the tooltip. - // This makes sure that a tracking tooltip doesn't obscure a focused element - // if the user was hovering when the element gained focused. - if ( this.options.track && target.data( "ui-tooltip-id" ) ) { - this._find( target ).position( $.extend({ - of: target - }, this.options.position ) ); - // Stop tracking (#8622) - this._off( this.document, "mousemove" ); + // No element to show a tooltip for or the tooltip is already open + if ( !target.length || target.data( "ui-tooltip-id" ) ) { return; } -- cgit v1.2.3 From 3d96f20506bd20f4cdbf5c1dc33149ad6ea5f62c Mon Sep 17 00:00:00 2001 From: Scott González Date: Wed, 14 Nov 2012 15:06:37 -0500 Subject: Datepicker: Fixed firstDay in Faroese locale. Fixes #8815 - Datepicker: Faroese locale has incorrect firstDay. --- ui/i18n/jquery.ui.datepicker-fo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/i18n/jquery.ui.datepicker-fo.js b/ui/i18n/jquery.ui.datepicker-fo.js index 9c848a04b..cb0e3def7 100644 --- a/ui/i18n/jquery.ui.datepicker-fo.js +++ b/ui/i18n/jquery.ui.datepicker-fo.js @@ -15,7 +15,7 @@ jQuery(function($){ dayNamesMin: ['Su','Má','Tý','Mi','Hó','Fr','Le'], weekHeader: 'Vk', dateFormat: 'dd-mm-yy', - firstDay: 0, + firstDay: 1, isRTL: false, showMonthAfterYear: false, yearSuffix: ''}; -- cgit v1.2.3