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(-) (limited to 'ui') 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 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(-) (limited to 'ui') 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(-) (limited to 'ui') 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(-) (limited to 'ui') 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 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(-) (limited to 'ui') 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(+) (limited to 'ui') 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(-) (limited to 'ui') 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(-) (limited to 'ui') 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(-) (limited to 'ui') 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(-) (limited to 'ui') 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 8a972f5cce2b84a431a700201cdf649edd2f4ac7 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 27 May 2011 08:35:18 -0400 Subject: Autocomplete: Whitespace. --- demos/autocomplete/search.php | 2 ++ ui/jquery.ui.autocomplete.js | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'ui') diff --git a/demos/autocomplete/search.php b/demos/autocomplete/search.php index cbe78a52a..835772dee 100644 --- a/demos/autocomplete/search.php +++ b/demos/autocomplete/search.php @@ -1,4 +1,6 @@ Date: Fri, 27 May 2011 12:01:42 -0500 Subject: Droppable: Added dragStart and dragStop to ddmanager and call them from draggable to recalculate droppable positions after a drag causes a scroll. Fixes #5003 - Scroll on Droppable Demo Breaks Demo --- ui/jquery.ui.draggable.js | 7 +++++++ ui/jquery.ui.droppable.js | 11 +++++++++++ 2 files changed, 18 insertions(+) (limited to 'ui') diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index c16833eb0..f8c187a7a 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -163,6 +163,10 @@ $.widget("ui.draggable", $.ui.mouse, { this.helper.addClass("ui-draggable-dragging"); this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position + + //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003) + if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event); + return true; }, @@ -229,6 +233,9 @@ $.widget("ui.draggable", $.ui.mouse, { }); //Remove frame helpers } + //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003) + if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event); + return $.ui.mouse.prototype._mouseUp.call(this, event); }, diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index b8a93cd46..58a1c4bc1 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -238,6 +238,12 @@ $.ui.ddmanager = { return dropped; }, + dragStart: function( draggable, event ) { + //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003) + draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() { + if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event ); + }); + }, drag: function(draggable, event) { //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse. @@ -279,6 +285,11 @@ $.ui.ddmanager = { } }); + }, + dragStop: function( draggable, event ) { + draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" ); + //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003) + if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event ); } }; -- cgit v1.2.3 From e7be72ff06d4152245a674c37abc7e8577bfc7a1 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 27 May 2011 20:05:20 -0400 Subject: Tooltip: Coding standards. --- ui/jquery.ui.tooltip.js | 84 ++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 39 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index a8a44f1c0..b781174c9 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -12,7 +12,7 @@ * jquery.ui.widget.js * jquery.ui.position.js */ -(function($) { +(function( $ ) { var increments = 0; @@ -28,63 +28,68 @@ $.widget("ui.tooltip", { at: "right center" } }, + _create: function() { - this._bind( { + this._bind({ mouseover: "open", focusin: "open" }); }, - + enable: function() { this.options.disabled = false; }, - + disable: function() { // only set option, disable element style changes this.options.disabled = true; }, - - open: function(event) { - var target = $(event && event.target || this.element).closest(this.options.items); + + open: function( event ) { + var target = $( event ? event.target : this.element ).closest( this.options.items ); if ( !target.length ) { return; } - var self = this; - if ( !target.data("tooltip-title") ) { - target.data("tooltip-title", target.attr("title")); + + var that = this; + if ( !target.data( "tooltip-title" ) ) { + target.data( "tooltip-title", target.attr( "title" ) ); } - var content = this.options.content.call(target[0], function(response) { + 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 setTimeout(function() { // when undefined, it got removeAttr, then ignore (ajax response) - // intially its an empty string, so not undefined + // initially its an empty string, so not undefined // TODO is there a better approach to enable ajax tooltips to have two updates? - if (target.attr( "aria-describedby" ) !== undefined) { - self._open(event, target, response); + if ( target.attr( "aria-describedby" ) !== undefined ) { + that._open( event, target, response ); } - }, 13); + }, 13 ); }); - if (content) { - self._open(event, target, content); + if ( content ) { + that._open( event, target, content ); } }, - + _open: function( event, target, content ) { - if ( !content ) + if ( !content ) { return; + } - target.attr("title", ""); + target.attr( "title", "" ); - if ( this.options.disabled ) + // TODO: why is this check after we clear the title? + if ( this.options.disabled ) { return; + } // ajaxy tooltip can update an existing one var tooltip = this._find( target ); - if (!tooltip.length) { + if ( !tooltip.length ) { tooltip = this._tooltip(); target.attr( "aria-describedby", tooltip.attr( "id" ) ); } - tooltip.find(".ui-tooltip-content").html( content ); + tooltip.find( ".ui-tooltip-content" ).html( content ); tooltip.position( $.extend({ of: target }, this.options.position ) ).hide(); @@ -100,36 +105,37 @@ $.widget("ui.tooltip", { click: "close" }); }, - + close: function( event ) { - var target = $( event && event.currentTarget || this.element ); + var target = $( event ? event.currentTarget : this.element ); target.attr( "title", target.data( "tooltip-title" ) ); - - if ( this.options.disabled ) + + if ( this.options.disabled ) { return; + } var tooltip = this._find( target ); target.removeAttr( "aria-describedby" ); - + tooltip.stop( true ); this._hide( tooltip, this.options.hide, function() { $( this ).remove(); }); - + target.unbind( "mouseleave.tooltip blur.tooltip" ); - + this._trigger( "close", event ); }, _tooltip: function() { - var tooltip = $( "
" ) - .attr( "id", "ui-tooltip-" + increments++ ) - .attr( "role", "tooltip" ) - .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content" ); - if (this.options.tooltipClass) { - tooltip.addClass(this.options.tooltipClass); - } - $( "
" ) + var tooltip = $( "
" ) + .attr({ + id: "ui-tooltip-" + increments++, + role: "tooltip" + }) + .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content" + + ( this.options.tooltipClass || "" ) ); + $( "
" ) .addClass( "ui-tooltip-content" ) .appendTo( tooltip ); tooltip.appendTo( document.body ); @@ -144,4 +150,4 @@ $.widget("ui.tooltip", { $.ui.tooltip.version = "@VERSION"; -})(jQuery); \ No newline at end of file +}( jQuery ) ); -- 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(-) (limited to 'ui') 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(-) (limited to 'ui') 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 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(-) (limited to 'ui') 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(-) (limited to 'ui') 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: "