diff options
author | Felix Nagel <info@felixnagel.com> | 2012-10-03 22:37:03 +0200 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2012-10-03 22:37:03 +0200 |
commit | cca4e77a95eb7024c204f4d0719baa2ef6195ed2 (patch) | |
tree | 732a8e171647d9b25b1b2988f09dccc5d182bad7 /ui | |
parent | 5e12c54be1813e1f627d3214c11d7520fb46c647 (diff) | |
parent | e8bdf468614e59309b4a02ad4f6c29c1d06083c1 (diff) | |
download | jquery-ui-cca4e77a95eb7024c204f4d0719baa2ef6195ed2.tar.gz jquery-ui-cca4e77a95eb7024c204f4d0719baa2ef6195ed2.zip |
Merge branch 'master' into selectmenu
Diffstat (limited to 'ui')
34 files changed, 132 insertions, 101 deletions
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index de9e1a3cb..48e880a05 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Accordion + * http://api.jqueryui.com/accordion/ * * Depends: * jquery.ui.core.js @@ -16,20 +16,12 @@ var uid = 0, hideProps = {}, - showProps = {}, - showPropsAdjust = {}; + showProps = {}; hideProps.height = hideProps.paddingTop = hideProps.paddingBottom = hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide"; showProps.height = showProps.paddingTop = showProps.paddingBottom = showProps.borderTopWidth = showProps.borderBottomWidth = "show"; -$.extend( showPropsAdjust, showProps, { accordionHeight: "show" } ); - -$.fx.step.accordionHeight = function( fx ) { - var elem = $( fx.elem ), - data = elem.data( "ui-accordion-height" ); - elem.height( data.total - elem.outerHeight() - data.toHide.outerHeight() + elem.height() ); -}; $.widget( "ui.accordion", { version: "@VERSION", @@ -485,12 +477,12 @@ $.widget( "ui.accordion", { _animate: function( toShow, toHide, data ) { var total, easing, duration, that = this, + adjust = 0, down = toShow.length && ( !toHide.length || ( toShow.index() < toHide.index() ) ), animate = this.options.animate || {}, options = down && animate.down || animate, complete = function() { - toShow.removeData( "ui-accordion-height" ); that._toggleComplete( data ); }; @@ -512,15 +504,29 @@ $.widget( "ui.accordion", { } total = toShow.show().outerHeight(); - toHide.animate( hideProps, duration, easing ); + toHide.animate( hideProps, { + duration: duration, + easing: easing, + step: function( now, fx ) { + fx.now = Math.round( now ); + } + }); toShow .hide() - .data( "ui-accordion-height", { - total: total, - toHide: toHide - }) - .animate( this.options.heightStyle === "content" ? showProps : showPropsAdjust, - duration, easing, complete ); + .animate( showProps, { + duration: duration, + easing: easing, + complete: complete, + step: function( now, fx ) { + fx.now = Math.round( now ); + if ( fx.prop !== "height" ) { + adjust += fx.now; + } else if ( that.options.heightStyle !== "content" ) { + fx.now = Math.round( total - toHide.outerHeight() - adjust ); + adjust = 0; + } + } + }); }, _toggleComplete: function( data ) { diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 80778f908..f181e9180 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Autocomplete + * http://api.jqueryui.com/autocomplete/ * * Depends: * jquery.ui.core.js diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 5c3fb7589..5ae526488 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Button + * http://api.jqueryui.com/button/ * * Depends: * jquery.ui.core.js diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index daa0c16e2..bb9411dc9 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI + * http://api.jqueryui.com/category/ui-core/ */ (function( $, undefined ) { diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index f72b15d1f..9ea36924b 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Datepicker + * http://api.jqueryui.com/datepicker/ * * Depends: * jquery.ui.core.js diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 66c7f4dff..77424047c 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Dialog + * http://api.jqueryui.com/dialog/ * * Depends: * jquery.ui.core.js @@ -170,6 +170,25 @@ $.widget("ui.dialog", { if ( $.fn.bgiframe ) { uiDialog.bgiframe(); } + + // prevent tabbing out of modal dialogs + this._on( uiDialog, { keydown: function( event ) { + if ( !options.modal || event.keyCode !== $.ui.keyCode.TAB ) { + return; + } + + var tabbables = $( ":tabbable", uiDialog ), + first = tabbables.filter( ":first" ), + last = tabbables.filter( ":last" ); + + if ( event.target === last[0] && !event.shiftKey ) { + first.focus( 1 ); + return false; + } else if ( event.target === first[0] && event.shiftKey ) { + last.focus( 1 ); + return false; + } + }}); }, _init: function() { @@ -197,7 +216,8 @@ $.widget("ui.dialog", { } next = oldPosition.parent.children().eq( oldPosition.index ); - if ( next.length ) { + // Don't try to place the dialog next to itself (#8613) + if ( next.length && next[ 0 ] !== this.element[ 0 ] ) { next.before( this.element ); } else { oldPosition.parent.append( this.element ); @@ -225,7 +245,6 @@ $.widget("ui.dialog", { if ( this.overlay ) { this.overlay.destroy(); } - this._off( this.uiDialog, "keypress" ); if ( this.options.hide ) { this.uiDialog.hide( this.options.hide, function() { @@ -309,27 +328,6 @@ $.widget("ui.dialog", { this.overlay = options.modal ? new $.ui.dialog.overlay( this ) : null; this.moveToTop( true ); - // prevent tabbing out of modal dialogs - if ( options.modal ) { - this._on( uiDialog, { keydown: function( event ) { - if ( event.keyCode !== $.ui.keyCode.TAB ) { - return; - } - - var tabbables = $( ":tabbable", uiDialog ), - first = tabbables.filter( ":first" ), - last = tabbables.filter( ":last" ); - - if ( event.target === last[0] && !event.shiftKey ) { - first.focus( 1 ); - return false; - } else if ( event.target === first[0] && event.shiftKey ) { - last.focus( 1 ); - return false; - } - }}); - } - // 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 hasFocus = this.element.find( ":tabbable" ); diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index b693dccae..2e33e3311 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Draggables + * http://api.jqueryui.com/draggable/ * * Depends: * jquery.ui.core.js @@ -229,11 +229,10 @@ $.widget("ui.draggable", $.ui.mouse, { }, _mouseUp: function(event) { - if (this.options.iframeFix === true) { - $("div.ui-draggable-iframeFix").each(function() { - this.parentNode.removeChild(this); - }); //Remove frame helpers - } + //Remove frame helpers + $("div.ui-draggable-iframeFix").each(function() { + this.parentNode.removeChild(this); + }); //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003) if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event); diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index a99ec50a3..93e74d211 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Droppables + * http://api.jqueryui.com/droppable/ * * Depends: * jquery.ui.core.js diff --git a/ui/jquery.ui.effect-blind.js b/ui/jquery.ui.effect-blind.js index c4ff12fdc..0ee31c078 100644 --- a/ui/jquery.ui.effect-blind.js +++ b/ui/jquery.ui.effect-blind.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/Blind + * http://api.jqueryui.com/blind-effect/ * * Depends: * jquery.ui.effect.js diff --git a/ui/jquery.ui.effect-bounce.js b/ui/jquery.ui.effect-bounce.js index 8a03f4f88..d36b0660f 100644 --- a/ui/jquery.ui.effect-bounce.js +++ b/ui/jquery.ui.effect-bounce.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/Bounce + * http://api.jqueryui.com/bounce-effect/ * * Depends: * jquery.ui.effect.js diff --git a/ui/jquery.ui.effect-clip.js b/ui/jquery.ui.effect-clip.js index 0cef7e0ca..ce4402b52 100644 --- a/ui/jquery.ui.effect-clip.js +++ b/ui/jquery.ui.effect-clip.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/Clip + * http://api.jqueryui.com/clip-effect/ * * Depends: * jquery.ui.effect.js diff --git a/ui/jquery.ui.effect-drop.js b/ui/jquery.ui.effect-drop.js index ce02dd3fd..bd196ec73 100644 --- a/ui/jquery.ui.effect-drop.js +++ b/ui/jquery.ui.effect-drop.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/Drop + * http://api.jqueryui.com/drop-effect/ * * Depends: * jquery.ui.effect.js diff --git a/ui/jquery.ui.effect-explode.js b/ui/jquery.ui.effect-explode.js index 76e92fac3..b31efc8c1 100644 --- a/ui/jquery.ui.effect-explode.js +++ b/ui/jquery.ui.effect-explode.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/Explode + * http://api.jqueryui.com/explode-effect/ * * Depends: * jquery.ui.effect.js diff --git a/ui/jquery.ui.effect-fade.js b/ui/jquery.ui.effect-fade.js index 5f5fcbfae..00d823260 100644 --- a/ui/jquery.ui.effect-fade.js +++ b/ui/jquery.ui.effect-fade.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/Fade + * http://api.jqueryui.com/fade-effect/ * * Depends: * jquery.ui.effect.js diff --git a/ui/jquery.ui.effect-fold.js b/ui/jquery.ui.effect-fold.js index 1e0e475f5..893a27e2c 100644 --- a/ui/jquery.ui.effect-fold.js +++ b/ui/jquery.ui.effect-fold.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/Fold + * http://api.jqueryui.com/fold-effect/ * * Depends: * jquery.ui.effect.js diff --git a/ui/jquery.ui.effect-highlight.js b/ui/jquery.ui.effect-highlight.js index 2ae5729dc..0b0dbd988 100644 --- a/ui/jquery.ui.effect-highlight.js +++ b/ui/jquery.ui.effect-highlight.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/Highlight + * http://api.jqueryui.com/highlight-effect/ * * Depends: * jquery.ui.effect.js diff --git a/ui/jquery.ui.effect-pulsate.js b/ui/jquery.ui.effect-pulsate.js index d1e74ea8e..de78894be 100644 --- a/ui/jquery.ui.effect-pulsate.js +++ b/ui/jquery.ui.effect-pulsate.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/Pulsate + * http://api.jqueryui.com/pulsate-effect/ * * Depends: * jquery.ui.effect.js diff --git a/ui/jquery.ui.effect-scale.js b/ui/jquery.ui.effect-scale.js index 4283fe842..933530a67 100644 --- a/ui/jquery.ui.effect-scale.js +++ b/ui/jquery.ui.effect-scale.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/Scale + * http://api.jqueryui.com/scale-effect/ * * Depends: * jquery.ui.effect.js diff --git a/ui/jquery.ui.effect-shake.js b/ui/jquery.ui.effect-shake.js index 9ae3968d6..4c2f9817e 100644 --- a/ui/jquery.ui.effect-shake.js +++ b/ui/jquery.ui.effect-shake.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/Shake + * http://api.jqueryui.com/shake-effect/ * * Depends: * jquery.ui.effect.js diff --git a/ui/jquery.ui.effect-slide.js b/ui/jquery.ui.effect-slide.js index 5f0aa1e45..5037256e0 100644 --- a/ui/jquery.ui.effect-slide.js +++ b/ui/jquery.ui.effect-slide.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/Slide + * http://api.jqueryui.com/slide-effect/ * * Depends: * jquery.ui.effect.js diff --git a/ui/jquery.ui.effect-transfer.js b/ui/jquery.ui.effect-transfer.js index ddf8139b6..0bfffd7fb 100644 --- a/ui/jquery.ui.effect-transfer.js +++ b/ui/jquery.ui.effect-transfer.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/Transfer + * http://api.jqueryui.com/transfer-effect/ * * Depends: * jquery.ui.effect.js diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js index 8ad9b34e3..d5d306783 100644 --- a/ui/jquery.ui.effect.js +++ b/ui/jquery.ui.effect.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Effects/ + * http://api.jqueryui.com/category/effects-core/ */ ;(jQuery.effects || (function($, undefined) { diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 333bc9a38..5d401da53 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Menu + * http://api.jqueryui.com/menu/ * * Depends: * jquery.ui.core.js @@ -72,17 +72,23 @@ $.widget( "ui.menu", { event.preventDefault(); }, "click .ui-menu-item:has(a)": function( event ) { - var target = $( event.target ); - if ( !mouseHandled && target.closest( ".ui-menu-item" ).not( ".ui-state-disabled" ).length ) { + var target = $( event.target ).closest( ".ui-menu-item" ); + if ( !mouseHandled && target.not( ".ui-state-disabled" ).length ) { mouseHandled = true; this.select( event ); // Open submenu on click - if ( this.element.has( ".ui-menu" ).length ) { + if ( target.has( ".ui-menu" ).length ) { this.expand( event ); - } else if ( !this.element.is(":focus") ) { + } else if ( !this.element.is( ":focus" ) ) { // Redirect focus to the menu - this.element.focus(); + this.element.trigger( "focus", [ true ] ); + + // If the active item is on the top level, let it stay active. + // Otherwise, blur the active item since it is no longer visible. + if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) { + clearTimeout( this.timer ); + } } } }, @@ -95,12 +101,14 @@ $.widget( "ui.menu", { }, mouseleave: "collapseAll", "mouseleave .ui-menu": "collapseAll", - focus: function( event ) { + focus: function( event, keepActiveItem ) { // If there's already an active item, keep it active // If not, activate the first item var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 ); - this.focus( event, item ); + if ( !keepActiveItem ) { + this.focus( event, item ); + } }, blur: function( event ) { this._delay(function() { @@ -195,7 +203,7 @@ $.widget( "ui.menu", { this.collapse( event ); break; case $.ui.keyCode.RIGHT: - if ( !this.active.is( ".ui-state-disabled" ) ) { + if ( this.active && !this.active.is( ".ui-state-disabled" ) ) { this.expand( event ); } break; @@ -587,12 +595,11 @@ $.widget( "ui.menu", { }, select: function( event ) { - // Save active reference before collapseAll triggers blur - var ui = { - // Selecting a menu item removes the active item causing multiple clicks to be missing an item - item: this.active || $( event.target ).closest( ".ui-menu-item" ) - }; - if ( !ui.item.has( ".ui-menu" ).length ) { + // TODO: It should never be possible to not have an active item at this + // point, but the tests don't trigger mouseenter before click. + this.active = this.active || $( event.target ).closest( ".ui-menu-item" ); + var ui = { item: this.active }; + if ( !this.active.has( ".ui-menu" ).length ) { this.collapseAll( event, true ); } this._trigger( "select", event, ui ); diff --git a/ui/jquery.ui.mouse.js b/ui/jquery.ui.mouse.js index a08566b90..30546ffc4 100644 --- a/ui/jquery.ui.mouse.js +++ b/ui/jquery.ui.mouse.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Mouse + * http://api.jqueryui.com/mouse/ * * Depends: * jquery.ui.widget.js diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 2e2fe215a..5b595a8c0 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Position + * http://api.jqueryui.com/position/ */ (function( $, undefined ) { diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index 7f1ebf77d..cb561ebc6 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Progressbar + * http://api.jqueryui.com/progressbar/ * * Depends: * jquery.ui.core.js diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js index 584f3a234..724ae9ddf 100644 --- a/ui/jquery.ui.resizable.js +++ b/ui/jquery.ui.resizable.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Resizables + * http://api.jqueryui.com/resizable/ * * Depends: * jquery.ui.core.js diff --git a/ui/jquery.ui.selectable.js b/ui/jquery.ui.selectable.js index 95bc92faa..80e32ca7a 100644 --- a/ui/jquery.ui.selectable.js +++ b/ui/jquery.ui.selectable.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Selectables + * http://api.jqueryui.com/selectable/ * * Depends: * jquery.ui.core.js diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index 0434d8075..f24982878 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Slider + * http://api.jqueryui.com/slider/ * * Depends: * jquery.ui.core.js diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 0b10cffc2..070dff6cd 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Sortables + * http://api.jqueryui.com/sortable/ * * Depends: * jquery.ui.core.js diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 11377f6a6..23cce18ef 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Spinner + * http://api.jqueryui.com/spinner/ * * Depends: * jquery.ui.core.js diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 7631366d6..506ee27d7 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Tabs + * http://api.jqueryui.com/tabs/ * * Depends: * jquery.ui.core.js @@ -102,7 +102,7 @@ $.widget( "ui.tabs", { // handle numbers: negative, out of range if ( active !== false ) { - active = this.tabs.eq( active ).index(); + active = this.tabs.index( this.tabs.eq( active ) ); if ( active === -1 ) { active = options.collapsible ? false : 0; } diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 9f0a8a810..f38379f21 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -6,6 +6,8 @@ * Released under the MIT license. * http://jquery.org/license * + * http://api.jqueryui.com/tooltip/ + * * Depends: * jquery.ui.core.js * jquery.ui.widget.js @@ -73,13 +75,22 @@ $.widget( "ui.tooltip", { }, _setOption: function( key, value ) { + var that = this; + if ( key === "disabled" ) { this[ value ? "_disable" : "_enable" ](); this.options[ key ] = value; // disable element style changes return; } + this._super( key, value ); + + if ( key === "content" ) { + $.each( this.tooltips, function( id, element ) { + that._updateContent( element ); + }); + } }, _disable: function() { @@ -114,9 +125,7 @@ $.widget( "ui.tooltip", { }, open: function( event ) { - var content, - that = this, - target = $( event ? event.target : this.element ) + var target = $( event ? event.target : this.element ) .closest( this.options.items ); // No element to show a tooltip for @@ -140,19 +149,31 @@ $.widget( "ui.tooltip", { target.data( "tooltip-open", true ); - content = this.options.content.call( target[0], function( response ) { + this._updateContent( target, event ); + }, + + _updateContent: function( target, event ) { + var content, + contentOption = this.options.content, + that = this; + + if ( typeof contentOption === "string" ) { + return this._open( event, target, contentOption ); + } + + content = contentOption.call( target[0], function( response ) { // ignore async response if tooltip was closed already if ( !target.data( "tooltip-open" ) ) { return; } // IE may instantly serve a cached response for ajax requests // delay this call to _open so the other call to _open runs first - setTimeout(function() { - that._open( event, target, response ); - }, 1 ); + that._delay(function() { + this._open( event, target, response ); + }); }); if ( content ) { - that._open( event, target, content ); + this._open( event, target, content ); } }, diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 924d10bc2..a125dd5ac 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -6,7 +6,7 @@ * Released under the MIT license. * http://jquery.org/license * - * http://docs.jquery.com/UI/Widget + * http://api.jqueryui.com/jQuery.widget/ */ (function( $, undefined ) { |