From 8e8a7b015f4f5a76c187dfca9af7519ae356bb16 Mon Sep 17 00:00:00 2001 From: kborchers Date: Mon, 16 May 2011 16:25:03 -0500 Subject: Sortable: Changed to check the parent's length so that the dom position of the removed element is not updated. Fixed #4088 - Unable to remove() ui.draggable (sortable item) immediately after the drop callback. --- ui/jquery.ui.sortable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 78349669a..a8084412f 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -983,7 +983,7 @@ $.widget("ui.sortable", $.ui.mouse, { // We first have to update the dom position of the actual currentItem // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088) - if(!this._noFinalSort && this.currentItem[0].parentNode) this.placeholder.before(this.currentItem); + if(!this._noFinalSort && this.currentItem.parent().length) this.placeholder.before(this.currentItem); this._noFinalSort = null; if(this.helper[0] == this.currentItem[0]) { -- cgit v1.2.3 From 63b89b7884d72d026f67c29eb234ebc1be738aa0 Mon Sep 17 00:00:00 2001 From: "Richard D. Worth" Date: Tue, 24 May 2011 07:43:44 -0700 Subject: README: Fixed code samples to be (markdown) indented properly with 4 spaces instead of 2. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ace5fe2de..547f2886b 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,13 @@ When looking at pull requests, first check for [proper commit messages](http://w Unless everything is fine and you can merge directly via GitHub's interface, fetch the remote first: - git remote add [username] [his-fork.git] -f + git remote add [username] [his-fork.git] -f If you want just one commit and edit the commit message: - git cherry-pick -e [sha-of-commit] + git cherry-pick -e [sha-of-commit] If it should go to the stable brach, cherry-pick it to stable: - git checkout 1-8-stable - git cherry-pick -x [sha-of-commit] + git checkout 1-8-stable + git cherry-pick -x [sha-of-commit] -- cgit v1.2.3 From af35f0bbc9064ec66bee19c730bf4cb9de2834db Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 20 May 2011 16:25:04 -0400 Subject: Spinner: Changed casing of option numberformat -> numberFormat. --- demos/spinner/currency.html | 2 +- demos/spinner/decimal.html | 2 +- tests/unit/spinner/spinner_defaults.js | 2 +- tests/unit/spinner/spinner_options.js | 14 +++++++------- ui/jquery.ui.spinner.js | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/demos/spinner/currency.html b/demos/spinner/currency.html index 8288e4c3d..1e9b37d08 100644 --- a/demos/spinner/currency.html +++ b/demos/spinner/currency.html @@ -27,7 +27,7 @@ max: 2500, step: 25, start: 1000, - numberformat: "C" + numberFormat: "C" }); }); diff --git a/demos/spinner/decimal.html b/demos/spinner/decimal.html index 0a38fc51f..cdc659298 100644 --- a/demos/spinner/decimal.html +++ b/demos/spinner/decimal.html @@ -18,7 +18,7 @@ $(function() { $("#spinner").spinner({ step: 0.01, - numberformat: "n" + numberFormat: "n" }); $("#culture").change(function() { diff --git a/tests/unit/spinner/spinner_defaults.js b/tests/unit/spinner/spinner_defaults.js index f6081b1f3..c9a7d5f62 100644 --- a/tests/unit/spinner/spinner_defaults.js +++ b/tests/unit/spinner/spinner_defaults.js @@ -4,7 +4,7 @@ commonWidgetTests( "spinner", { incremental: true, max: null, min: null, - numberformat: null, + numberFormat: null, page: 10, step: null, value: null, diff --git a/tests/unit/spinner/spinner_options.js b/tests/unit/spinner/spinner_options.js index 3db7e5c55..398780ad2 100644 --- a/tests/unit/spinner/spinner_options.js +++ b/tests/unit/spinner/spinner_options.js @@ -5,26 +5,26 @@ module("spinner: options"); -test("numberformat, number", function() { +test("numberFormat, number", function() { var el = $("#spin").spinner({ value: "1", - numberformat: "n" + numberFormat: "n" }); equal(el.val(), "1.00"); }); -test("numberformat, number, simple", function() { +test("numberFormat, number, simple", function() { var el = $("#spin").spinner({ value: "1", - numberformat: "n0" + numberFormat: "n0" }); equal(el.val(), "1"); }); -test("numberformat, currency", function() { +test("numberFormat, currency", function() { var el = $("#spin").spinner({ value: "1", - numberformat: "C" + numberFormat: "C" }); equal(el.val(), "$1.00"); }); @@ -111,7 +111,7 @@ test("step, 2", function() { test("step, 0.7", function() { var el = $("#spin").spinner({ step: 0.7, - numberformat: "n1" + numberFormat: "n1" }); equals(el.val(), "0.0", "value initialized to"); diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 2709175b5..0a0ebb37e 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -20,7 +20,7 @@ $.widget( "ui.spinner", { incremental: true, max: null, min: null, - numberformat: null, + numberFormat: null, page: 10, step: null, value: null @@ -318,13 +318,13 @@ $.widget( "ui.spinner", { _parse: function( val ) { if ( typeof val === "string" ) { - val = $.global && this.options.numberformat ? $.global.parseFloat( val ) : +val; + val = $.global && this.options.numberFormat ? $.global.parseFloat( val ) : +val; } return isNaN( val ) ? null : val; }, _format: function( num ) { - this.element.val( $.global && this.options.numberformat ? $.global.format( num, this.options.numberformat ) : num ); + this.element.val( $.global && this.options.numberFormat ? $.global.format( num, this.options.numberFormat ) : num ); }, destroy: function() { -- cgit v1.2.3 From 129d5c75aca94ae636ba6396124c4938e43a50f3 Mon Sep 17 00:00:00 2001 From: tomykaira Date: Wed, 25 May 2011 15:52:53 -0400 Subject: effects.blind: Save the wrapper status if already wrapped. Fixes #6245 - position: absolute is lost when .stop() is used with .show('blind'). --- ui/jquery.effects.blind.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/jquery.effects.blind.js b/ui/jquery.effects.blind.js index 7a59d8a75..8ef544faa 100644 --- a/ui/jquery.effects.blind.js +++ b/ui/jquery.effects.blind.js @@ -31,7 +31,12 @@ $.effects.effect.blind = function( o ) { animation = {}, wrapper, distance; - $.effects.save( el, props ); + // if already wrapped, the wrapper's properties are my property. #6245 + if ( el.parent().is( ".ui-effects-wrapper" ) ) { + $.effects.save( el.parent(), props ); + } else { + $.effects.save( el, props ); + } el.show(); wrapper = $.effects.createWrapper( el ).css({ overflow: "hidden" -- cgit v1.2.3 From 7d232f753428d68ade9b73f091579811cf90eb96 Mon Sep 17 00:00:00 2001 From: tomykaira Date: Fri, 20 May 2011 10:25:34 +0900 Subject: effects.scale: fix: calculate top / left by outerHeight / Width. Fixed #6096 - effects.scale origin bottom bug --- ui/jquery.effects.scale.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index b5c49ce7c..00f0151af 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -54,7 +54,9 @@ $.effects.effect.scale = function( o ) { origin = o.origin, original = { height: el.height(), - width: el.width() + width: el.width(), + outerHeight: el.outerHeight(), + outerWidth: el.outerWidth() }, factor = { y: direction != 'horizontal' ? (percent / 100) : 1, @@ -74,7 +76,9 @@ $.effects.effect.scale = function( o ) { options.from = o.from || ( mode == 'show' ? { height: 0, width: 0 } : original ); options.to = { height: original.height * factor.y, - width: original.width * factor.x + width: original.width * factor.x, + outerHeight: original.outerHeight * factor.y, + outerWidth: original.outerWidth * factor.x }; if ( options.fade ) { // Fade option to support puff @@ -122,21 +126,14 @@ $.effects.effect.size = function( o ) { } original = { height: el.height(), - width: el.width() + width: el.width(), + outerHeight: el.outerHeight(), + outerWidth: el.outerWidth() }; el.from = o.from || original; el.to = o.to || original; - // Adjust - if (origin) { // Calculate baseline shifts - baseline = $.effects.getBaseline( origin, original ); - el.from.top = ( original.height - el.from.height ) * baseline.y; - el.from.left = ( original.width - el.from.width ) * baseline.x; - el.to.top = ( original.height - el.to.height ) * baseline.y; - el.to.left = ( original.width - el.to.width ) * baseline.x; - } - // Set scaling factor factor = { from: { @@ -183,6 +180,16 @@ $.effects.effect.size = function( o ) { $.effects.createWrapper( el ); el.css( 'overflow', 'hidden' ).css( el.from ); + // Adjust + if (origin) { // Calculate baseline shifts + baseline = $.effects.getBaseline( origin, original ); + el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y; + el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x; + el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y; + el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x; + } + el.css( el.from ); // set top & left + // Animate if ( scale == 'content' || scale == 'both' ) { // Scale the children -- cgit v1.2.3 From de3fc0050ee672ce155f0dd65ee9ecdfd818c063 Mon Sep 17 00:00:00 2001 From: "Richard D. Worth" Date: Thu, 26 May 2011 04:58:15 -0400 Subject: Simulate: account for document scroll in findCenter function. Fixes #6859 - Jquery.Simulate drag behaves incorrect when container scrolled --- tests/jquery.simulate.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/jquery.simulate.js b/tests/jquery.simulate.js index a88b6cbe4..bb82624d3 100644 --- a/tests/jquery.simulate.js +++ b/tests/jquery.simulate.js @@ -123,10 +123,10 @@ $.extend($.simulate.prototype, { this.simulateEvent(target, "click", coord); }, findCenter: function(el) { - var el = $(this.target), o = el.offset(); + var el = $(this.target), o = el.offset(), d = $(document); return { - x: o.left + el.outerWidth() / 2, - y: o.top + el.outerHeight() / 2 + x: o.left + el.outerWidth() / 2 - d.scrollLeft(), + y: o.top + el.outerHeight() / 2 - d.scrollTop() }; } }); -- cgit v1.2.3 From c49dbe0f0120dec9922d5cb6459a93d33ef41579 Mon Sep 17 00:00:00 2001 From: Glenn Goodrich Date: Thu, 26 May 2011 11:28:17 -0400 Subject: Button: modified the event bindings for focus and blur. Fixed #6711 - checkbox/radio button do not show focused state when using Keyboard Navigation --- tests/unit/button/button_tickets.js | 8 ++++++++ ui/jquery.ui.button.js | 16 +++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/unit/button/button_tickets.js b/tests/unit/button/button_tickets.js index 79bbfeb5c..9a7ccae43 100644 --- a/tests/unit/button/button_tickets.js +++ b/tests/unit/button/button_tickets.js @@ -20,6 +20,14 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) ); }); +test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() { + var check = $( "#check" ).button(), + label = $( "label[for='check']" ); + ok( !label.is( ".ui-state-focus" ) ); + check.focus(); + ok( label.is( ".ui-state-focus" ) ); +}); + test( "#7092 - button creation that requires a matching label does not find label in all cases", function() { var group = $( "" ); group.find( "input:checkbox" ).button(); diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index a95dddc6c..3f3b90e92 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -95,19 +95,21 @@ $.widget( "ui.button", { } $( this ).removeClass( hoverClass ); }) - .bind( "focus.button", function() { - // no need to check disabled, focus won't be triggered anyway - $( this ).addClass( focusClass ); - }) - .bind( "blur.button", function() { - $( this ).removeClass( focusClass ); - }) .bind( "click.button", function( event ) { if ( options.disabled ) { event.stopImmediatePropagation(); } }); + this.element + .bind( "focus.button", function() { + // no need to check disabled, focus won't be triggered anyway + self.buttonElement.addClass( focusClass ); + }) + .bind( "blur.button", function() { + self.buttonElement.removeClass( focusClass ); + }); + if ( toggleButton ) { this.element.bind( "change.button", function() { if ( clickDragged ) { -- cgit v1.2.3 From 597a313ab67bc10627d9c17c941776514ea5bd7c Mon Sep 17 00:00:00 2001 From: Andrew Powell Date: Thu, 26 May 2011 12:22:40 -0400 Subject: Button: adding event.preventDefault. Fixes #5945 - Disabled buttons still allow clicks --- ui/jquery.ui.button.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 3f3b90e92..32e00e9e0 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -97,6 +97,7 @@ $.widget( "ui.button", { }) .bind( "click.button", function( event ) { if ( options.disabled ) { + event.preventDefault(); event.stopImmediatePropagation(); } }); -- cgit v1.2.3 From 981e96948f45e5c5c32d005e379a5030c98c3d8d Mon Sep 17 00:00:00 2001 From: Jeff Remy Date: Thu, 26 May 2011 19:08:58 -0400 Subject: Resizable: correct aspectRatio handling with min/max dimensions. Fixed #4951 - Resizable with aspectRatio true & a maxWidth doesn't obey ratio once hit max width. --- ui/jquery.ui.resizable.js | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js index e0579ef84..de24e94dd 100644 --- a/ui/jquery.ui.resizable.js +++ b/ui/jquery.ui.resizable.js @@ -293,6 +293,8 @@ $.widget("ui.resizable", $.ui.mouse, { // Calculate the attrs that will be change var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff; + // Put this in the mouseDrag handler since the user can start pressing shift while resizing + this._updateVirtualBoundaries(event.shiftKey); if (this._aspectRatio || event.shiftKey) data = this._updateRatio(data, event); @@ -351,6 +353,32 @@ $.widget("ui.resizable", $.ui.mouse, { }, + _updateVirtualBoundaries: function(forceAspectRatio) { + var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b; + + b = { + minWidth: isNumber(o.minWidth) ? o.minWidth : 0, + maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity, + minHeight: isNumber(o.minHeight) ? o.minHeight : 0, + maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity + }; + + if(this._aspectRatio || forceAspectRatio) { + // We want to create an enclosing box whose aspect ration is the requested one + // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension + pMinWidth = b.minHeight * this.aspectRatio; + pMinHeight = b.minWidth / this.aspectRatio; + pMaxWidth = b.maxHeight * this.aspectRatio; + pMaxHeight = b.maxWidth / this.aspectRatio; + + if(pMinWidth > b.minWidth) b.minWidth = pMinWidth; + if(pMinHeight > b.minHeight) b.minHeight = pMinHeight; + if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth; + if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight; + } + this._vBoundaries = b; + }, + _updateCache: function(data) { var o = this.options; this.offset = this.helper.offset(); @@ -364,8 +392,8 @@ $.widget("ui.resizable", $.ui.mouse, { var o = this.options, cpos = this.position, csize = this.size, a = this.axis; - if (data.height) data.width = (csize.height * this.aspectRatio); - else if (data.width) data.height = (csize.width / this.aspectRatio); + if (isNumber(data.height)) data.width = (data.height * this.aspectRatio); + else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio); if (a == 'sw') { data.left = cpos.left + (csize.width - data.width); @@ -381,7 +409,7 @@ $.widget("ui.resizable", $.ui.mouse, { _respectSize: function(data, event) { - var el = this.helper, o = this.options, pRatio = this._aspectRatio || event.shiftKey, a = this.axis, + var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis, ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height); -- cgit v1.2.3 From c7eae7b264112919462cb1b8b7ce115d3b24265d Mon Sep 17 00:00:00 2001 From: David Murdoch Date: Thu, 26 May 2011 19:29:11 -0400 Subject: Dialog: Make close() a noop if the dialog is already closed. Fixes #7327 - Dialog box size and close animation bugs. --- ui/jquery.ui.dialog.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index dc2849155..8d5f4f56f 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -190,6 +190,10 @@ $.widget("ui.dialog", { }, close: function( event ) { + if ( !this._isOpen ) { + return self; + } + var self = this, maxZ, thisZ; @@ -197,13 +201,13 @@ $.widget("ui.dialog", { return; } + self._isOpen = false; + if ( self.overlay ) { self.overlay.destroy(); } self.uiDialog.unbind( "keypress.ui-dialog" ); - self._isOpen = false; - if ( self.options.hide ) { self.uiDialog.hide( self.options.hide, function() { self._trigger( "close", event ); -- cgit v1.2.3 From e34dbfeef013313dead74e39bea8adaa848310d4 Mon Sep 17 00:00:00 2001 From: Jay Merrifield Date: Thu, 26 May 2011 23:30:56 -0400 Subject: Dialog: Removed the height() tinkering which stops the dialog from shrinking. Fixes #5916 - Dialog: shrinks on drag in IE in standards mode, worse in quirksmode. --- ui/jquery.ui.dialog.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 8d5f4f56f..84b2dd3b3 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -373,8 +373,7 @@ $.widget("ui.dialog", { _makeDraggable: function() { var self = this, options = self.options, - doc = $( document ), - heightBeforeDrag; + doc = $( document ); function filteredUi( ui ) { return { @@ -388,9 +387,7 @@ $.widget("ui.dialog", { handle: ".ui-dialog-titlebar", containment: "document", start: function( event, ui ) { - heightBeforeDrag = options.height === "auto" ? "auto" : $( this ).height(); $( this ) - .height( $( this ).height() ) .addClass( "ui-dialog-dragging" ); self._trigger( "dragStart", event, filteredUi( ui ) ); }, @@ -403,8 +400,7 @@ $.widget("ui.dialog", { ui.position.top - doc.scrollTop() ]; $( this ) - .removeClass( "ui-dialog-dragging" ) - .height( heightBeforeDrag ); + .removeClass( "ui-dialog-dragging" ); self._trigger( "dragStop", event, filteredUi( ui ) ); $.ui.dialog.overlay.resize(); } -- cgit v1.2.3 From 09e88d6220af2f90197c826ac3a31a0ca97f2c8f Mon Sep 17 00:00:00 2001 From: Jay Merrifield Date: Thu, 26 May 2011 23:42:51 -0400 Subject: Mouse: Optimize the cancel locator, works around a bug where .add(event.target) in IE8 can take a long time when there are multiple siblings. Fixes #7118 - IE Bug Large ComboBox (Dialog) --- ui/jquery.ui.mouse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.ui.mouse.js b/ui/jquery.ui.mouse.js index 0bd38db85..2fb1389f2 100644 --- a/ui/jquery.ui.mouse.js +++ b/ui/jquery.ui.mouse.js @@ -58,7 +58,7 @@ $.widget("ui.mouse", { var self = this, btnIsLeft = (event.which == 1), - elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false); + elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).closest(this.options.cancel).length : false); if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { return true; } -- cgit v1.2.3 From be7da0239a5dbcd1a1458a5b642dc366fe626efe Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 27 May 2011 08:32:48 -0400 Subject: Autocomplete demos: Coding standards. --- demos/autocomplete/categories.html | 4 ++-- demos/autocomplete/combobox.html | 15 +++++++++++---- demos/autocomplete/custom-data.html | 8 ++++---- demos/autocomplete/default.html | 2 +- demos/autocomplete/folding.html | 2 +- demos/autocomplete/maxheight.html | 4 ++-- demos/autocomplete/multiple-remote.html | 6 ++++-- demos/autocomplete/multiple.html | 2 +- demos/autocomplete/remote-jsonp.html | 10 ++++++---- demos/autocomplete/remote-with-cache.html | 6 ++++-- demos/autocomplete/remote.html | 10 ++++++---- 11 files changed, 42 insertions(+), 27 deletions(-) diff --git a/demos/autocomplete/categories.html b/demos/autocomplete/categories.html index 17ec6495d..d2a1bc5bd 100644 --- a/demos/autocomplete/categories.html +++ b/demos/autocomplete/categories.html @@ -47,7 +47,7 @@ { label: "andreas andersson", category: "People" }, { label: "andreas johnson", category: "People" } ]; - + $( "#search" ).catcomplete({ delay: 0, source: data @@ -59,7 +59,7 @@
- +
diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html index 5fb3ffef9..b228c1cbb 100644 --- a/demos/autocomplete/combobox.html +++ b/demos/autocomplete/combobox.html @@ -14,9 +14,16 @@ - +
- +
diff --git a/demos/autocomplete/multiple-remote.html b/demos/autocomplete/multiple-remote.html index 9351e8f3b..16472a36c 100644 --- a/demos/autocomplete/multiple-remote.html +++ b/demos/autocomplete/multiple-remote.html @@ -12,7 +12,9 @@ - - - - - - + + + + + + + -
-

Tooltips can be attached to any element. When you hover - the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip. -

-

But as it's not a native tooltip, it can be styled. Any themes built with - ThemeRoller - will also style tooltip's accordingly.

-

Tooltip's are also useful for form elements, to show some additional information in the context of each field.

-

-

Click the field to see the tooltip; when you tab out of the field, it gets hidden.

+

Tooltips can be attached to any element. When you hover +the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.

+

But as it's not a native tooltip, it can be styled. Any themes built with +ThemeRoller +will also style tooltips accordingly.

+

Tooltips are also useful for form elements, to show some additional information in the context of each field.

+

+

Hover the field to see the tooltip.

-

This demo shows how to customize animations. The tooltip is shown, after a delay of 250ms, using a slide down animation, and hidden, after another delay, without an animation.

-
- - diff --git a/demos/tooltip/default.html b/demos/tooltip/default.html index 9d5502f2b..cfb61f2eb 100644 --- a/demos/tooltip/default.html +++ b/demos/tooltip/default.html @@ -1,48 +1,47 @@ - jQuery UI Tooltip - Default demo - - - - - - - - + + + + + +
-

Tooltips can be attached to any element. When you hover - the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip. -

-

But as it's not a native tooltip, it can be styled. Any themes built with - ThemeRoller - will also style tooltip's accordingly.

-

Tooltip's are also useful for form elements, to show some additional information in the context of each field.

-

-

Click the field to see the tooltip; when you tab out of the field, it gets hidden.

+

Tooltips can be attached to any element. When you hover +the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.

+

But as it's not a native tooltip, it can be styled. Any themes built with +ThemeRoller +will also style tooltips accordingly.

+

Tooltips are also useful for form elements, to show some additional information in the context of each field.

+

+

Hover the field to see the tooltip.

-

Hover the links above or use the tab key to cycle the focus on each element.

-
- - diff --git a/demos/tooltip/forms.html b/demos/tooltip/forms.html index 983b56bdf..0f91736b2 100644 --- a/demos/tooltip/forms.html +++ b/demos/tooltip/forms.html @@ -1,71 +1,87 @@ + jQuery UI Tooltip - Default demo - - - - - - - - - + + + + + + + + -
-
-
-
- - - ? -
-
- - - ? -
-
- - - ? -
-
-
+
+
+
+ + + ? +
+
+ + + ? +
+
+ + + ? +
+
+
-

Use the button below to display the help texts. Click again to hide them. Default hover and focus events are removed to show tooltip only programmatically.

-

A fixed width is defined in CSS to make the tooltips look consistent when displayed all at once.

-
- - diff --git a/demos/tooltip/index.html b/demos/tooltip/index.html index 4ad189ed2..460c494e3 100644 --- a/demos/tooltip/index.html +++ b/demos/tooltip/index.html @@ -1,8 +1,9 @@ + jQuery UI Tooltip Demos - + diff --git a/demos/tooltip/tracking.html b/demos/tooltip/tracking.html index dd5dc9d92..4cddb4437 100644 --- a/demos/tooltip/tracking.html +++ b/demos/tooltip/tracking.html @@ -1,64 +1,64 @@ - jQuery UI Tooltip - Default demo - - - - - - - - + + + + + + + -
-

Tooltips can be attached to any element. When you hover - the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip. -

-

But as it's not a native tooltip, it can be styled. Any themes built with - ThemeRoller - will also style tooltip's accordingly.

-

Tooltip's are also useful for form elements, to show some additional information in the context of each field.

-

-

Click the field to see the tooltip; when you tab out of the field, it gets hidden.

+

Tooltips can be attached to any element. When you hover +the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.

+

But as it's not a native tooltip, it can be styled. Any themes built with +ThemeRoller +will also style tooltips accordingly.

+

Tooltips are also useful for form elements, to show some additional information in the context of each field.

+

+

Hover the field to see the tooltip.

-

Here the tooltips are positioned relative to the mouse, and follow the mouse while it moves above the element.

-
- - diff --git a/demos/tooltip/video-player.html b/demos/tooltip/video-player.html index 56003ab5a..e0db0575d 100644 --- a/demos/tooltip/video-player.html +++ b/demos/tooltip/video-player.html @@ -1,64 +1,102 @@ + jQuery UI Tooltip - Video Player demo - - - - - - - - - - - - - + + + + + + + + + + + + -
-
Here Be Video (HTML5?)
-
- - - - -
- - - -
- - +
Here Be Video (HTML5?)
+
+ + + + +
+ + +
-
+ + +
-

A fake video player with like/share/stats button, each with a custom-styled tooltip.

-
- - -- cgit v1.2.3 From d4f6f17c8de859bcc4b76e15e523fb8b74703afe Mon Sep 17 00:00:00 2001 From: Scott González Date: Sat, 28 May 2011 10:18:39 -0400 Subject: Tooltip: Changed custom animation demo and changed the logic for showing tooltips so custom position options can perform animations. --- demos/tooltip/custom-animation.html | 40 +++++++++++++++++++++---------------- ui/jquery.ui.tooltip.js | 13 ++++++++---- ui/jquery.ui.widget.js | 2 +- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/demos/tooltip/custom-animation.html b/demos/tooltip/custom-animation.html index 23fa9aefe..b8f012d91 100644 --- a/demos/tooltip/custom-animation.html +++ b/demos/tooltip/custom-animation.html @@ -9,25 +9,35 @@ + + - @@ -35,14 +45,10 @@
-

Tooltips can be attached to any element. When you hover -the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.

-

But as it's not a native tooltip, it can be styled. Any themes built with -ThemeRoller -will also style tooltips accordingly.

-

Tooltips are also useful for form elements, to show some additional information in the context of each field.

-

-

Hover the field to see the tooltip.

+

There are various ways to customize the animation of a tooltip.

+

You can use the show and +hide options.

+

You can also use the position option.

diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index b781174c9..c0aaa4fbe 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -90,11 +90,16 @@ $.widget("ui.tooltip", { target.attr( "aria-describedby", tooltip.attr( "id" ) ); } tooltip.find( ".ui-tooltip-content" ).html( content ); - tooltip.position( $.extend({ - of: target - }, this.options.position ) ).hide(); + tooltip + .stop( true ) + .position( $.extend({ + of: target, + using: function( pos ) { + // we only want to hide if there's no custom using defined + $( this ).css( pos ).hide(); + } + }, this.options.position ) ); - tooltip.stop( true ); this._show( tooltip, this.options.show ); this._trigger( "open", event ); diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 4167fd4e5..3bf735cd3 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -379,7 +379,7 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { var hasOptions = !$.isEmptyObject( options ), effectName = options.effect || defaultEffect; options.complete = callback; - if (options.delay) { + if ( options.delay ) { element.delay( options.delay ); } if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) { -- cgit v1.2.3 From d43118dfbab9591caa5181a9e50608921d19bd5b Mon Sep 17 00:00:00 2001 From: Scott González Date: Sat, 28 May 2011 11:43:57 -0400 Subject: Tooltip: Cleanup. --- ui/jquery.ui.tooltip.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index c0aaa4fbe..756fe0f7b 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -16,7 +16,7 @@ var increments = 0; -$.widget("ui.tooltip", { +$.widget( "ui.tooltip", { options: { tooltipClass: null, items: "[title]", @@ -56,7 +56,8 @@ $.widget("ui.tooltip", { target.data( "tooltip-title", target.attr( "title" ) ); } var content = this.options.content.call( target[0], function( response ) { - // IE may instantly serve a cached response, need to give it a chance to finish with _open before that + // 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() { // when undefined, it got removeAttr, then ignore (ajax response) // initially its an empty string, so not undefined @@ -64,7 +65,7 @@ $.widget("ui.tooltip", { if ( target.attr( "aria-describedby" ) !== undefined ) { that._open( event, target, response ); } - }, 13 ); + }, 1 ); }); if ( content ) { that._open( event, target, content ); @@ -127,6 +128,7 @@ $.widget("ui.tooltip", { $( this ).remove(); }); + // TODO: why isn't click unbound here? target.unbind( "mouseleave.tooltip blur.tooltip" ); this._trigger( "close", event ); @@ -149,7 +151,7 @@ $.widget("ui.tooltip", { _find: function( target ) { var id = target.attr( "aria-describedby" ); - return id ? $( document.getElementById( id ) ) : $(); + return id ? $( "#" + id ) : $(); } }); -- cgit v1.2.3 From 73c6f349fcdd83d838df91e5ce4bc524e8dd989d Mon Sep 17 00:00:00 2001 From: Scott González Date: Sat, 28 May 2011 13:30:00 -0400 Subject: Tooltip tests: Coding standards. --- tests/unit/tooltip/tooltip.html | 60 ++++++++++++++++------------------ tests/unit/tooltip/tooltip_core.js | 10 ++---- tests/unit/tooltip/tooltip_defaults.js | 2 +- tests/unit/tooltip/tooltip_events.js | 48 ++++++++++++--------------- tests/unit/tooltip/tooltip_methods.js | 26 ++++++--------- tests/unit/tooltip/tooltip_options.js | 53 +++++++++++++----------------- 6 files changed, 87 insertions(+), 112 deletions(-) diff --git a/tests/unit/tooltip/tooltip.html b/tests/unit/tooltip/tooltip.html index 189c75261..d540504ab 100644 --- a/tests/unit/tooltip/tooltip.html +++ b/tests/unit/tooltip/tooltip.html @@ -1,30 +1,29 @@ - + - + jQuery UI Tooltip Test Suite - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -32,16 +31,15 @@

-
    -
- +
    -
    - anchor - - span -
    + +
    + anchor + + span
    +
    diff --git a/tests/unit/tooltip/tooltip_core.js b/tests/unit/tooltip/tooltip_core.js index 247927df4..055a2927f 100644 --- a/tests/unit/tooltip/tooltip_core.js +++ b/tests/unit/tooltip/tooltip_core.js @@ -1,11 +1,7 @@ -/* - * tooltip_core.js - */ +(function( $ ) { +module( "tooltip: core" ); -(function($) { -module("tooltip: core"); - -})(jQuery); +}( jQuery ) ); diff --git a/tests/unit/tooltip/tooltip_defaults.js b/tests/unit/tooltip/tooltip_defaults.js index 5f304f497..317ba1aa0 100644 --- a/tests/unit/tooltip/tooltip_defaults.js +++ b/tests/unit/tooltip/tooltip_defaults.js @@ -2,7 +2,7 @@ commonWidgetTests( "tooltip", { defaults: { disabled: false, items: "[title]", - content: $.ui.tooltip.prototype.options.content, + content: function() {}, position: { my: "left+15 center", at: "right center" diff --git a/tests/unit/tooltip/tooltip_events.js b/tests/unit/tooltip/tooltip_events.js index 5c915ae30..287c39073 100644 --- a/tests/unit/tooltip/tooltip_events.js +++ b/tests/unit/tooltip/tooltip_events.js @@ -1,54 +1,48 @@ -/* - * tooltip_events.js - */ -(function($) { +(function( $ ) { -module("tooltip: events"); +module( "tooltip: events" ); -test("programmatic triggers", function() { - expect(2); - var e = $("#tooltipped1").tooltip({ - open: function(event, ui) { +test( "programmatic triggers", function() { + expect( 2 ); + var element = $( "#tooltipped1" ).tooltip({ + open: function( event, ui ) { same( event.type, "tooltipopen" ); }, - close: function(event, ui) { + close: function( event, ui ) { same( event.type, "tooltipclose" ); } }); - e.tooltip("open").tooltip("close"); - e.tooltip("destroy"); + element.tooltip( "open" ).tooltip( "close" ); }); -test("mouse events", function() { - expect(4); - var e = $("#tooltipped1").tooltip({ - open: function(event, ui) { +test( "mouse events", function() { + expect( 4 ); + var element = $( "#tooltipped1" ).tooltip({ + open: function( event, ui ) { same( event.type, "tooltipopen" ); same( event.originalEvent.type, "mouseover" ); }, - close: function(event, ui) { + close: function( event, ui ) { same( event.type, "tooltipclose" ); same( event.originalEvent.type, "mouseleave" ); } }); - e.trigger("mouseover").trigger("mouseleave"); - e.tooltip("destroy"); + element.trigger( "mouseover" ).trigger( "mouseleave" ); }); -test("focus events", function() { - expect(4); - var e = $("#tooltipped1").tooltip({ - open: function(event, ui) { +test( "focus events", function() { + expect( 4 ); + var element = $( "#tooltipped1" ).tooltip({ + open: function( event, ui ) { same( event.type, "tooltipopen" ); same( event.originalEvent.type, "focusin" ); }, - close: function(event, ui) { + close: function( event, ui ) { same( event.type, "tooltipclose" ); same( event.originalEvent.type, "blur" ); } }); - e.trigger("focus").trigger("blur"); - e.tooltip("destroy"); + element.trigger( "focus" ).trigger( "blur" ); }); -})(jQuery); +}( jQuery ) ); diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js index 496a5fdb7..cb99ea457 100644 --- a/tests/unit/tooltip/tooltip_methods.js +++ b/tests/unit/tooltip/tooltip_methods.js @@ -1,22 +1,17 @@ -/* - * tooltip_methods.js - */ -(function($) { - +(function( $ ) { -module("tooltip: methods"); +module( "tooltip: methods" ); -test("destroy", function() { - var beforeHtml = $("#tooltipped1").parent().html(); - var afterHtml = $("#tooltipped1").tooltip().tooltip("destroy").parent().html(); +test( "destroy", function() { + var beforeHtml = $( "#tooltipped1" ).parent().html(); + var afterHtml = $( "#tooltipped1" ).tooltip().tooltip( "destroy" ).parent().html(); equal( afterHtml, beforeHtml ); }); -test("open", function() { - var e = $("#tooltipped1").tooltip(); - e.tooltip("open"); - ok( $(".ui-tooltip").is(":visible") ); - $(":ui-tooltip").tooltip("destroy"); +test( "open", function() { + var element = $( "#tooltipped1" ).tooltip(); + element.tooltip( "open" ); + ok( $( ".ui-tooltip" ).is( ":visible" ) ); }); /* @@ -29,5 +24,4 @@ test("widget", function() { }); */ - -})(jQuery); +}( jQuery ) ); diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js index 37a468489..c9f92c527 100644 --- a/tests/unit/tooltip/tooltip_options.js +++ b/tests/unit/tooltip/tooltip_options.js @@ -1,48 +1,41 @@ -/* - * tooltip_options.js - */ -(function($) { - -module("tooltip: options", { - teardown: function() { - $(":ui-tooltip").tooltip("destroy"); - } -}); +(function( $ ) { +module( "tooltip: options" ); -test("option: items", function() { - var event = $.Event("mouseenter"); - event.target = $("[data-tooltip]"); - $("#qunit-fixture").tooltip({ +test( "items", function() { + var event = $.Event( "mouseenter" ); + event.target = $( "[data-tooltip]" )[ 0 ]; + var element = $( "#qunit-fixture" ).tooltip({ items: "[data-tooltip]", content: function() { - return $(this).attr("data-tooltip"); + return $( this ).attr( "data-tooltip" ); } - }).tooltip("open", event); - same( $( "#" + $("#fixture-span").attr("aria-describedby") ).text(), "text" ); + }).tooltip( "open", event ); + same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "text" ); + element.tooltip( "destroy" ); }); -test("content: default", function() { - $("#tooltipped1").tooltip().tooltip("open"); - same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "anchortitle" ); +test( "content: default", function() { + var element = $( "#tooltipped1" ).tooltip().tooltip("open"); + same( $( "#" + element.attr( "aria-describedby" ) ).text(), "anchortitle" ); }); -test("content: return string", function() { - $("#tooltipped1").tooltip({ +test( "content: return string", function() { + var element = $( "#tooltipped1" ).tooltip({ content: function() { return "customstring"; } - }).tooltip("open"); - same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring" ); + }).tooltip( "open" ); + same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" ); }); -test("content: return jQuery", function() { - $("#tooltipped1").tooltip({ +test( "content: return jQuery", function() { + var element = $( "#tooltipped1" ).tooltip({ content: function() { - return $("
    ").html("customstring"); + return $( "
    " ).html( "customstring" ); } - }).tooltip("open"); - same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring" ); + }).tooltip( "open" ); + same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" ); }); /* @@ -63,4 +56,4 @@ test("content: callback string", function() { }); */ -})(jQuery); +}( jQuery ) ); -- cgit v1.2.3 From 2f3284811c867408652bea044849085bda923b34 Mon Sep 17 00:00:00 2001 From: Scott González Date: Sat, 28 May 2011 15:25:05 -0400 Subject: Tooltip: Proper handled of disabled option. --- ui/jquery.ui.tooltip.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 756fe0f7b..56e5fa5c2 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -36,13 +36,13 @@ $.widget( "ui.tooltip", { }); }, - enable: function() { - this.options.disabled = false; - }, - - disable: function() { + _setOption: function( key, value ) { // only set option, disable element style changes - this.options.disabled = true; + if ( key === "disabled" ) { + this.options[ key ] = value; + return; + } + this._super( "_setOption", key, value ); }, open: function( event ) { -- cgit v1.2.3 From 6a5b21fda2730a0650e0144658d47b9b01bffc64 Mon Sep 17 00:00:00 2001 From: Scott González Date: Sat, 28 May 2011 15:39:55 -0400 Subject: All: Moved version numbers into prototypes. Fixed #7436 - Widget: Store version numbers on instances. --- ui/jquery.ui.accordion.js | 2 +- ui/jquery.ui.autocomplete.js | 2 +- ui/jquery.ui.button.js | 3 +-- ui/jquery.ui.dialog.js | 3 +-- ui/jquery.ui.draggable.js | 5 +---- ui/jquery.ui.droppable.js | 5 +---- ui/jquery.ui.menu.js | 3 +-- ui/jquery.ui.menubar.js | 1 + ui/jquery.ui.mouse.js | 1 + ui/jquery.ui.popup.js | 1 + ui/jquery.ui.progressbar.js | 5 +---- ui/jquery.ui.resizable.js | 5 +---- ui/jquery.ui.selectable.js | 5 +---- ui/jquery.ui.slider.js | 6 +----- ui/jquery.ui.sortable.js | 5 +---- ui/jquery.ui.spinner.js | 3 +-- ui/jquery.ui.tabs.js | 5 +---- ui/jquery.ui.tooltip.js | 3 +-- ui/jquery.ui.widget.js | 2 +- 19 files changed, 19 insertions(+), 46 deletions(-) diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index c6b33befb..7602ae9bc 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -15,6 +15,7 @@ // TODO: use ui-accordion-header-active class and fix styling $.widget( "ui.accordion", { + version: "@VERSION", options: { active: 0, animated: "slide", @@ -432,7 +433,6 @@ $.widget( "ui.accordion", { }); $.extend( $.ui.accordion, { - version: "@VERSION", animations: { slide: function( options, additions ) { var showOverflow = options.toShow.css( "overflow" ), diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 4619949fb..e39b4649e 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -19,6 +19,7 @@ var requestIndex = 0; $.widget( "ui.autocomplete", { + version: "@VERSION", defaultElement: "", options: { appendTo: "body", @@ -475,7 +476,6 @@ $.widget( "ui.autocomplete", { }); $.extend( $.ui.autocomplete, { - version: "@VERSION", escapeRegex: function( value ) { return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); }, diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 32e00e9e0..482cdc24c 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -41,6 +41,7 @@ var lastActive, startXPos, startYPos, clickDragged, }; $.widget( "ui.button", { + version: "@VERSION", defaultElement: "
    -- cgit v1.2.3 From 133fba2ad9b588233f7c7303619ac42351f08926 Mon Sep 17 00:00:00 2001 From: Scott González Date: Sun, 29 May 2011 19:21:31 -0400 Subject: Tooltip: Don't close tooltips on mouseleave if the element is still focused. --- tests/unit/tooltip/tooltip_events.js | 26 ++++++++++++++++++++++++++ ui/jquery.ui.tooltip.js | 7 +++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/unit/tooltip/tooltip_events.js b/tests/unit/tooltip/tooltip_events.js index 515760b28..61026882e 100644 --- a/tests/unit/tooltip/tooltip_events.js +++ b/tests/unit/tooltip/tooltip_events.js @@ -47,4 +47,30 @@ test( "focus events", function() { element.trigger( "blur" ); }); +test( "mixed events", function() { + expect( 2 ); + var element = $( "#tooltipped1" ).tooltip(); + + element.one( "tooltipopen", function( event ) { + same( event.originalEvent.type, "focusin" ); + }); + element[0].focus(); + + element.one( "tooltipopen", function() { + ok( false, "open triggered while already open" ); + }); + element.trigger( "mouseover" ); + + element.bind( "tooltipclose", function( event ) { + ok( false, "close triggered while still focused" ); + }); + element.trigger( "mouseleave" ); + element.unbind( "tooltipclose" ); + + element.one( "tooltipclose", function( event ) { + same( event.originalEvent.type, "blur" ); + }); + element[0].blur(); +}); + }( jQuery ) ); diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index c5d9508f7..44398a871 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -56,7 +56,8 @@ $.widget( "ui.tooltip", { target = $( event ? event.target : this.element ) .closest( this.options.items ); - if ( !target.length ) { + // if aria-describedby exists, then the tooltip is already open + if ( !target.length || target.attr( "aria-describedby" ) ) { return; } @@ -131,7 +132,9 @@ $.widget( "ui.tooltip", { target.attr( "title", target.data( "tooltip-title" ) ); } - if ( this.options.disabled ) { + // don't close if the element has focus + // this prevents the tooltip from closing if you hover while focused + if ( this.options.disabled || document.activeElement === target[0] ) { return; } -- cgit v1.2.3 From 0fc41bcc4d7f084463a8b68f225789964b009d0d Mon Sep 17 00:00:00 2001 From: Scott González Date: Sun, 29 May 2011 19:28:35 -0400 Subject: Tooltip: Use bgiframe if available --- ui/jquery.ui.tooltip.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 44398a871..7722e6472 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -164,6 +164,9 @@ $.widget( "ui.tooltip", { .addClass( "ui-tooltip-content" ) .appendTo( tooltip ); tooltip.appendTo( document.body ); + if ( $.fn.bgiframe ) { + tooltip.bgiframe(); + } this.tooltips[ id ] = true; return tooltip; }, -- cgit v1.2.3 From b6cda3dfeeca692fd14e5ecbde93286507e5c560 Mon Sep 17 00:00:00 2001 From: Scott González Date: Sun, 29 May 2011 19:41:57 -0400 Subject: Tooltip: Added some comments. --- ui/jquery.ui.tooltip.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 7722e6472..8aba5974a 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -83,6 +83,9 @@ $.widget( "ui.tooltip", { } // if we have a title, clear it to prevent the native tooltip + // we do this before the disabled check to prevent native tooltips + // even when disabled + // TODO: the above doesn't work since ._bind() does a disabled check // we have to check first to avoid defining a title if none exists // (we don't want to cause an element to start matching [title]) // TODO: document why we don't use .removeAttr() @@ -90,7 +93,6 @@ $.widget( "ui.tooltip", { target.attr( "title", "" ); } - // TODO: why is this check after we clear the title? if ( this.options.disabled ) { return; } -- cgit v1.2.3 From 76586076ecc85fac044c02995c938a46aa1dbab2 Mon Sep 17 00:00:00 2001 From: Scott González Date: Sun, 29 May 2011 20:15:24 -0400 Subject: Tooltip demo: Removing stray periods. --- demos/tooltip/delegation-mixbag.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/tooltip/delegation-mixbag.html b/demos/tooltip/delegation-mixbag.html index 951d089f4..5b1fa4119 100644 --- a/demos/tooltip/delegation-mixbag.html +++ b/demos/tooltip/delegation-mixbag.html @@ -55,7 +55,7 @@
    St. Stephen's Cathedral @@ -65,7 +65,7 @@
    Tower Bridge -- cgit v1.2.3 From 8c085cd27ce5d2c765a2d762a863e52d1fc6308c Mon Sep 17 00:00:00 2001 From: Scott González Date: Sun, 29 May 2011 20:50:21 -0400 Subject: Tooltip: Fixed handling of disabled tooltips. --- tests/unit/tooltip/tooltip_methods.js | 26 +++++++++++++++ ui/jquery.ui.tooltip.js | 61 ++++++++++++++++++++++++----------- 2 files changed, 69 insertions(+), 18 deletions(-) diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js index b1b319d96..798d55896 100644 --- a/tests/unit/tooltip/tooltip_methods.js +++ b/tests/unit/tooltip/tooltip_methods.js @@ -28,6 +28,32 @@ test( "open/close", function() { $.fx.off = false; }); +test( "enable/disable", function() { + expect( 7 ); + $.fx.off = true; + var element = $( "#tooltipped1" ).tooltip(); + equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" ); + + element.tooltip( "open" ); + var tooltip = $( "#" + element.attr( "aria-describedby" ) ); + ok( tooltip.is( ":visible" ) ); + + element.tooltip( "disable" ); + equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" ); + equal( tooltip.attr( "title" ), "", "title removed on disable" ); + + element.tooltip( "open" ); + equal( $( ".ui-tooltip" ).length, 0, "open does nothing when disabled" ); + + element.tooltip( "enable" ); + equal( element.attr( "title" ), "anchortitle", "title restored on enable" ); + + element.tooltip( "open" ); + tooltip = $( "#" + element.attr( "aria-describedby" ) ); + ok( tooltip.is( ":visible" ) ); + $.fx.off = false; +}); + /* TODO currently tooltip doesn't override widget can't return anything useful if no element is kept around and there's no useful reference diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 8aba5974a..d30e49c66 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -42,14 +42,46 @@ $.widget( "ui.tooltip", { }, _setOption: function( key, value ) { - // only set option, disable element style changes if ( key === "disabled" ) { + this[ value ? "_disable" : "_enable" ](); this.options[ key ] = value; + // disable element style changes return; } this._super( "_setOption", key, value ); }, + _disable: function() { + var that = this; + + // close open tooltips + $.each( this.tooltips, function( id, element ) { + var event = $.Event( "blur" ); + event.target = event.currentTarget = element[0]; + that.close( event, true ); + }); + + // remove title attributes to prevent native tooltips + this.element.find( this.options.items ).andSelf().each(function() { + var element = $( this ); + if ( element.is( "[title]" ) ) { + element + .data( "tooltip-title", element.attr( "title" ) ) + .attr( "title", "" ); + } + }); + }, + + _enable: function() { + // restore title attributes + this.element.find( this.options.items ).andSelf().each(function() { + var element = $( this ); + if ( element.data( "tooltip-title" ) ) { + element.attr( "title", element.data( "tooltip-title" ) ); + } + }); + }, + open: function( event ) { var content, that = this, @@ -83,9 +115,6 @@ $.widget( "ui.tooltip", { } // if we have a title, clear it to prevent the native tooltip - // we do this before the disabled check to prevent native tooltips - // even when disabled - // TODO: the above doesn't work since ._bind() does a disabled check // we have to check first to avoid defining a title if none exists // (we don't want to cause an element to start matching [title]) // TODO: document why we don't use .removeAttr() @@ -93,14 +122,10 @@ $.widget( "ui.tooltip", { target.attr( "title", "" ); } - if ( this.options.disabled ) { - return; - } - // ajaxy tooltip can update an existing one var tooltip = this._find( target ); if ( !tooltip.length ) { - tooltip = this._tooltip(); + tooltip = this._tooltip( target ); target.attr( "aria-describedby", tooltip.attr( "id" ) ); } tooltip.find( ".ui-tooltip-content" ).html( content ); @@ -124,22 +149,22 @@ $.widget( "ui.tooltip", { }); }, - close: function( event ) { + close: function( event, force ) { var that = this, target = $( event ? event.currentTarget : this.element ), tooltip = this._find( target ); - // only set title if we had one before (see comment in _open()) - if ( target.data( "tooltip-title" ) ) { - target.attr( "title", target.data( "tooltip-title" ) ); - } - // don't close if the element has focus // this prevents the tooltip from closing if you hover while focused - if ( this.options.disabled || document.activeElement === target[0] ) { + if ( !force && document.activeElement === target[0] ) { return; } + // only set title if we had one before (see comment in _open()) + if ( target.data( "tooltip-title" ) ) { + target.attr( "title", target.data( "tooltip-title" ) ); + } + target.removeAttr( "aria-describedby" ); tooltip.stop( true ); @@ -153,7 +178,7 @@ $.widget( "ui.tooltip", { this._trigger( "close", event ); }, - _tooltip: function() { + _tooltip: function( element ) { var id = "ui-tooltip-" + increments++, tooltip = $( "
    " ) .attr({ @@ -169,7 +194,7 @@ $.widget( "ui.tooltip", { if ( $.fn.bgiframe ) { tooltip.bgiframe(); } - this.tooltips[ id ] = true; + this.tooltips[ id ] = element; return tooltip; }, -- cgit v1.2.3 From 27a4fdd8ed4fe7733ea139022c04bd7ef8033cba Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Mon, 30 May 2011 20:08:58 +0200 Subject: Spinner: disable text selection on buttons (plus minmal whitespace cleanup) --- ui/jquery.ui.spinner.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 4a23aca53..b4cefc982 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -63,6 +63,7 @@ $.widget( "ui.spinner", { // add buttons .append( self._buttonHtml() ) // add behaviours + .disableSelection() // TODO: user ._hoverable .hover(function() { if ( !options.disabled ) { @@ -252,7 +253,7 @@ $.widget( "ui.spinner", { this.counter > 20 ? this.counter > 100 ? this.counter > 200 - ? 100 + ? 100 : 10 : 2 : 1); -- cgit v1.2.3