From e609bebaae7f3f762dd61d92fb0529af9ef5f2d1 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Fri, 15 Apr 2011 16:49:29 +0200 Subject: Custom tooltip animations based on widget-animations branch. --- ui/jquery.ui.tooltip.js | 4 ++-- ui/jquery.ui.widget.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 534b3c947..bff17d7b5 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -91,7 +91,7 @@ $.widget("ui.tooltip", { }, this.options.position ) ).hide(); - tooltip.fadeIn(); + this._show( tooltip, this.options.show ); this._trigger( "open", event ); @@ -111,7 +111,7 @@ $.widget("ui.tooltip", { var tooltip = this._find( target ); target.removeAttr( "aria-describedby" ); - tooltip.fadeOut( function() { + this._hide( tooltip, this.options.hide, function() { $( this ).remove(); }); diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 27d08ccd2..9593c1eaf 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -353,6 +353,26 @@ $.Widget.prototype = { } }; +$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { + $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { + options = options || {}; + var hasOptions = !$.isEmptyObject( options ), + effectName = options.effect || defaultEffect; + options.complete = callback; + + if ( hasOptions && $.effects && $.effects[ effectName ] ) { + element[ method ]( options ); + } else if ( element[ effectName ] ) { + element[ effectName ]( options.duration, options.easing, callback ); + } else { + element[ method ](); + if ( callback ) { + callback.call( element[ 0 ] ); + } + } + }; +}); + // DEPRECATED if ( $.uiBackCompat !== false ) { $.Widget.prototype._getCreateOptions = function() { -- cgit v1.2.3 From 3950a0515d58a8af2840f419bcd5cb8fd28b4de2 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Fri, 15 Apr 2011 16:53:05 +0200 Subject: Stop show animation on hide. Now that we don't reuse the tooltip element, we can safely do that. --- ui/jquery.ui.tooltip.js | 1 + 1 file changed, 1 insertion(+) (limited to 'ui') diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index bff17d7b5..c481f6264 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -111,6 +111,7 @@ $.widget("ui.tooltip", { var tooltip = this._find( target ); target.removeAttr( "aria-describedby" ); + tooltip.stop(); this._hide( tooltip, this.options.hide, function() { $( this ).remove(); }); -- cgit v1.2.3 From b1c8a13a1669dca4c4bde97fe2cc8b76f661b432 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Tue, 19 Apr 2011 14:39:58 -0700 Subject: Draggable: Modified the iframe shims to load prior to dragging. Fixed #7270. --- ui/jquery.ui.draggable.js | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index ff1ad1363..83fe54fda 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -79,6 +79,16 @@ $.widget("ui.draggable", $.ui.mouse, { this.handle = this._getHandle(event); if (!this.handle) return false; + + $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() { + $('
') + .css({ + width: this.offsetWidth+"px", height: this.offsetHeight+"px", + position: "absolute", opacity: "0.001", zIndex: 1000 + }) + .css($(this).offset()) + .appendTo("body"); + }); return true; @@ -212,6 +222,16 @@ $.widget("ui.draggable", $.ui.mouse, { return false; }, + _mouseUp: function(event) { + if (this.options.iframeFix === true) { + $("div.ui-draggable-iframeFix").each(function() { + this.parentNode.removeChild(this); + }); //Remove frame helpers + } + + return $.ui.mouse.prototype._mouseUp.call(this, event); + }, + cancel: function() { if(this.helper.is(".ui-draggable-dragging")) { @@ -616,24 +636,6 @@ $.ui.plugin.add("draggable", "cursor", { } }); -$.ui.plugin.add("draggable", "iframeFix", { - start: function(event, ui) { - var o = $(this).data('draggable').options; - $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() { - $('
') - .css({ - width: this.offsetWidth+"px", height: this.offsetHeight+"px", - position: "absolute", opacity: "0.001", zIndex: 1000 - }) - .css($(this).offset()) - .appendTo("body"); - }); - }, - stop: function(event, ui) { - $("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers - } -}); - $.ui.plugin.add("draggable", "opacity", { start: function(event, ui) { var t = $(ui.helper), o = $(this).data('draggable').options; -- cgit v1.2.3 From 3bb9ab262670328de9eb9a97892e9cf85c55c7d9 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Thu, 21 Apr 2011 14:30:42 +0200 Subject: Tooltip: Add support for delaying showing/hiding. Still need to figure out how to combine that with non-animated show/hide. --- demos/tooltip/custom-animation.html | 6 ++++-- ui/jquery.ui.tooltip.js | 4 ++-- ui/jquery.ui.widget.js | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'ui') diff --git a/demos/tooltip/custom-animation.html b/demos/tooltip/custom-animation.html index d32bba0d2..d0689a0eb 100644 --- a/demos/tooltip/custom-animation.html +++ b/demos/tooltip/custom-animation.html @@ -13,10 +13,12 @@ $(function() { $(".demo").tooltip({ show: { - effect: "slideDown" + effect: "slideDown", + delay: 250 }, hide: { - effect: "slideUp" + effect: "slideUp", + delay: 500 } }); }); diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index c481f6264..bbf58c2a1 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -90,7 +90,7 @@ $.widget("ui.tooltip", { of: target }, this.options.position ) ).hide(); - + tooltip.stop( true ); this._show( tooltip, this.options.show ); this._trigger( "open", event ); @@ -111,7 +111,7 @@ $.widget("ui.tooltip", { var tooltip = this._find( target ); target.removeAttr( "aria-describedby" ); - tooltip.stop(); + tooltip.stop( true ); this._hide( tooltip, this.options.hide, function() { $( this ).remove(); }); diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 9593c1eaf..9634eaa1f 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -359,7 +359,9 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { var hasOptions = !$.isEmptyObject( options ), effectName = options.effect || defaultEffect; options.complete = callback; - + if (options.delay) { + element.delay( options.delay ); + } if ( hasOptions && $.effects && $.effects[ effectName ] ) { element[ method ]( options ); } else if ( element[ effectName ] ) { -- cgit v1.2.3 From 2bf061ea6fd3bad7d6f5a77eebb22b7cc07140e4 Mon Sep 17 00:00:00 2001 From: whittet Date: Wed, 27 Apr 2011 07:21:29 -0700 Subject: Bug fix for another use case, see comment by whittet here: http://bugs.jqueryui.com/ticket/6702 --- 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 131fb50d0..78349669a 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -50,7 +50,7 @@ $.widget("ui.sortable", $.ui.mouse, { this.refresh(); //Let's determine if the items are being displayed horizontally - this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) || (/inline|table-cell/).test(this.items[0].item.css('display')) : false; + this.floating = this.items.length ? o.axis === 'x' || (/left|right/).test(this.items[0].item.css('float')) || (/inline|table-cell/).test(this.items[0].item.css('display')) : false; //Let's determine the parent's offset this.offset = this.element.offset(); -- cgit v1.2.3 From d62074961171ea00deaae34890b78f917d21bf68 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Thu, 28 Apr 2011 10:43:02 -0400 Subject: Draggable: containment now updates dynamically to handle scrolling container. Fixed #4445 containment ignored when scrolling in overflow div --- ui/jquery.ui.draggable.js | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index ff1ad1363..ed49c9d19 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -342,16 +342,19 @@ $.widget("ui.draggable", $.ui.mouse, { ]; if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) { - var ce = $(o.containment)[0]; if(!ce) return; - var co = $(o.containment).offset(); + var c = $(o.containment); + var ce = c[0]; if(!ce) return; + var co = c.offset(); var over = ($(ce).css("overflow") != 'hidden'); this.containment = [ - co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0), - co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0), - co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right, - co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0), + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0), + (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right, + (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom ]; + this.relative_container = c; + } else if(o.containment.constructor == Array) { this.containment = o.containment; } @@ -393,20 +396,31 @@ $.widget("ui.draggable", $.ui.mouse, { */ if(this.originalPosition) { //If we are not dragging yet, we won't check for options - - if(this.containment) { - if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left; - if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top; - if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left; - if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top; + var containment; + if(this.containment) { + if (this.relative_container){ + var co = this.relative_container.offset(); + containment = [ this.containment[0] + co.left, + this.containment[1] + co.top, + this.containment[2] + co.left, + this.containment[3] + co.top ]; + } + else { + containment = this.containment; + } + + if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left; + if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top; + if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left; + if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top; } if(o.grid) { var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; - pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; + pageY = containment ? (!(top - this.offset.click.top < containment[1] || top - this.offset.click.top > containment[3]) ? top : (!(top - this.offset.click.top < containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; - pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; + pageX = containment ? (!(left - this.offset.click.left < containment[0] || left - this.offset.click.left > containment[2]) ? left : (!(left - this.offset.click.left < containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; } } -- cgit v1.2.3 From a03c222f05aa2364189d264377e0a19da4d4c9ad Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Mon, 2 May 2011 13:11:58 +0200 Subject: Tooltip: Overhaul widget animations code to allow delay with plain show/hide --- demos/tooltip/custom-animation.html | 8 +++++--- ui/jquery.ui.widget.js | 21 ++++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'ui') diff --git a/demos/tooltip/custom-animation.html b/demos/tooltip/custom-animation.html index d0689a0eb..ef8857979 100644 --- a/demos/tooltip/custom-animation.html +++ b/demos/tooltip/custom-animation.html @@ -17,8 +17,8 @@ delay: 250 }, hide: { - effect: "slideUp", - delay: 500 + effect: "hide", + delay: 250 } }); }); @@ -47,7 +47,9 @@
-

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

+

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/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 9634eaa1f..a5c59ad3c 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -365,12 +365,23 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { if ( hasOptions && $.effects && $.effects[ effectName ] ) { element[ method ]( options ); } else if ( element[ effectName ] ) { - element[ effectName ]( options.duration, options.easing, callback ); - } else { - element[ method ](); - if ( callback ) { - callback.call( element[ 0 ] ); + if ( /show|hide/.test( effectName ) ) { + element.queue( function() { + element[ effectName ](); + if ( callback ) { + callback.call( element[ 0 ] ); + } + }); + } else { + element[ effectName ]( options.duration, options.easing, callback ); } + } else { + element.queue( function() { + $( this )[ method ](); + if ( callback ) { + callback.call( element[ 0 ] ); + } + }); } }; }); -- cgit v1.2.3 From c9fb4528673f94a3aa338d113b9ebb72f346b900 Mon Sep 17 00:00:00 2001 From: gnarf Date: Mon, 2 May 2011 06:49:59 -0500 Subject: widget: Updating code for show/hide to use new effects API namespace - DRY'ed out a bit as well --- ui/jquery.ui.widget.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 65a9f1ce4..6a9bd3641 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -365,19 +365,10 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { if (options.delay) { element.delay( options.delay ); } - if ( hasOptions && $.effects && $.effects[ effectName ] ) { + if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { element[ method ]( options ); - } else if ( element[ effectName ] ) { - if ( /show|hide/.test( effectName ) ) { - element.queue( function() { - element[ effectName ](); - if ( callback ) { - callback.call( element[ 0 ] ); - } - }); - } else { - element[ effectName ]( options.duration, options.easing, callback ); - } + } else if ( effectName !== method && element[ effectName ] ) { + element[ effectName ]( options.duration, options.easing, callback ); } else { element.queue( function() { $( this )[ method ](); -- cgit v1.2.3 From c13ef9e037d9ba534697f66d213bbb324db85117 Mon Sep 17 00:00:00 2001 From: gnarf Date: Mon, 2 May 2011 07:49:11 -0500 Subject: Widget: show/hide effects added BackCompat --- ui/jquery.ui.widget.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 6a9bd3641..a74e6b77b 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -365,7 +365,7 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { if (options.delay) { element.delay( options.delay ); } - if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { + if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) { element[ method ]( options ); } else if ( effectName !== method && element[ effectName ] ) { element[ effectName ]( options.duration, options.easing, callback ); @@ -384,7 +384,7 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { if ( $.uiBackCompat !== false ) { $.Widget.prototype._getCreateOptions = function() { return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ]; - } + }; } })( jQuery ); -- cgit v1.2.3 From 74d195e39681791545b3026a66bfa3f319237e5a Mon Sep 17 00:00:00 2001 From: adambaratz Date: Fri, 15 Apr 2011 07:23:46 -0700 Subject: Datepicker: bind hover events using delegate. Fixed #7256 - minimize event binding in Datepicker initialization. --- ui/jquery.ui.datepicker.js | 47 ++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index cc27365d3..3437d0bda 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -16,6 +16,7 @@ $.extend($.ui, { datepicker: { version: "@VERSION" } }); var PROP_NAME = 'datepicker'; var dpuuid = new Date().getTime(); +var instActive; /* Date picker manager. Use the singleton instance of this class, $.datepicker, to interact with the date picker. @@ -107,7 +108,7 @@ function Datepicker() { autoSize: false // True to size the input for the date format, false to leave as is }; $.extend(this._defaults, this.regional['']); - this.dpDiv = $('
'); + this.dpDiv = bindHover($('
')); } $.extend(Datepicker.prototype, { @@ -173,7 +174,7 @@ $.extend(Datepicker.prototype, { drawMonth: 0, drawYear: 0, // month being drawn inline: inline, // is datepicker inline or not dpDiv: (!inline ? this.dpDiv : // presentation div - $('
'))}; + bindHover($('
')))}; }, /* Attach the date picker to an input field. */ @@ -674,29 +675,13 @@ $.extend(Datepicker.prototype, { _updateDatepicker: function(inst) { var self = this; var borders = $.datepicker._getBorders(inst.dpDiv); + instActive = inst; // for delegate hover events inst.dpDiv.empty().append(this._generateHTML(inst)); var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6 cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()}) } - inst.dpDiv.find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a') - .bind('mouseout', function(){ - $(this).removeClass('ui-state-hover'); - if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover'); - if(this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover'); - }) - .bind('mouseover', function(){ - if (!self._isDisabledDatepicker( inst.inline ? inst.dpDiv.parent()[0] : inst.input[0])) { - $(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover'); - $(this).addClass('ui-state-hover'); - if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover'); - if(this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover'); - } - }) - .end() - .find('.' + this._dayOverClass + ' a') - .trigger('mouseover') - .end(); + inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover(); var numMonths = this._getNumberOfMonths(inst); var cols = numMonths[1]; var width = 17; @@ -1719,6 +1704,28 @@ $.extend(Datepicker.prototype, { } }); +/* + * Bind hover events for datepicker elements. + * Done via delegate so the binding only occurs once in the lifetime of the parent div. + * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker. + */ +function bindHover(dpDiv) { + var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a'; + return dpDiv.delegate(selector, 'mouseout', function() { + $(this).removeClass('ui-state-hover'); + if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover'); + if (this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover'); + }) + .delegate(selector, 'mouseover', function(){ + if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) { + $(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover'); + $(this).addClass('ui-state-hover'); + if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover'); + if (this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover'); + } + }); +} + /* jQuery extend now ignores nulls! */ function extendRemove(target, props) { $.extend(target, props); -- cgit v1.2.3 From 0496a50238a47463c171219b6370173874193130 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Mon, 2 May 2011 18:21:04 +0200 Subject: Tooltip: Replace offset property with inline my+offset to make it easier to override the offset. Fixes the odd offset in the video player demo. Also doesn't need units. --- demos/tooltip/video-player.html | 2 +- ui/jquery.ui.tooltip.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'ui') diff --git a/demos/tooltip/video-player.html b/demos/tooltip/video-player.html index 73310e349..c890c76b4 100644 --- a/demos/tooltip/video-player.html +++ b/demos/tooltip/video-player.html @@ -32,7 +32,7 @@ $(".demo").tooltip({ position: { my: "center top", - at: "center bottom+5px" + at: "center bottom+5", }, show: { duration: "fast" diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index bbf58c2a1..20638cba5 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -24,9 +24,8 @@ $.widget("ui.tooltip", { return $( this ).attr( "title" ); }, position: { - my: "left center", - at: "right center", - offset: "15 0" + my: "left+15 center", + at: "right center" } }, _create: function() { -- cgit v1.2.3 From 51df02ee4ea02e91919842a169463612176682d5 Mon Sep 17 00:00:00 2001 From: Adam Baratz Date: Mon, 2 May 2011 18:03:14 -0400 Subject: Dialog: remove unneeded DOM manipulations. Fixed #7258 - optimize initialization. --- ui/jquery.ui.dialog.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index c14237b6a..8423d1164 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -86,16 +86,14 @@ $.widget("ui.dialog", { titleId = $.ui.dialog.getTitleId( self.element ), uiDialog = ( self.uiDialog = $( "
" ) ) - .appendTo( document.body ) - .hide() .addClass( uiDialogClasses + options.dialogClass ) .css({ + display: "none", + outline: 0, // TODO: move to stylesheet zIndex: options.zIndex }) // setting tabIndex makes the div focusable .attr( "tabIndex", -1) - // TODO: move to stylesheet - .css( "outline", 0 ) .keydown(function( event ) { if ( options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode && event.keyCode === $.ui.keyCode.ESCAPE ) { @@ -156,6 +154,8 @@ $.widget("ui.dialog", { self._createButtons( options.buttons ); self._isOpen = false; + uiDialog.appendTo( document.body ); + if ( $.fn.bgiframe ) { uiDialog.bgiframe(); } @@ -310,9 +310,14 @@ $.widget("ui.dialog", { // 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 - $( self.element.find( ":tabbable" ).get().concat( - uiDialog.find( ".ui-dialog-buttonpane :tabbable" ).get().concat( - uiDialog.get() ) ) ).eq( 0 ).focus(); + var hasFocus = self.element.find( ":tabbable" ); + if ( !hasFocus.length ) { + hasFocus = uiDialog.find( ".ui-dialog-buttonpane :tabbable" ); + if ( !hasFocus.length ) { + hasFocus = uiDialog; + } + } + hasFocus.eq( 0 ).focus(); self._isOpen = true; self._trigger( "open" ); @@ -322,12 +327,7 @@ $.widget("ui.dialog", { _createButtons: function( buttons ) { var self = this, - hasButtons = false, - uiDialogButtonPane = $( "
" ) - .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ), - uiButtonSet = $( "
" ) - .addClass( "ui-dialog-buttonset" ) - .appendTo( uiDialogButtonPane ); + hasButtons = false; // if we already have a button pane, remove it self.uiDialog.find( ".ui-dialog-buttonpane" ).remove(); @@ -338,6 +338,12 @@ $.widget("ui.dialog", { }); } if ( hasButtons ) { + var uiDialogButtonPane = $( "
" ) + .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ), + uiButtonSet = $( "
" ) + .addClass( "ui-dialog-buttonset" ) + .appendTo( uiDialogButtonPane ); + $.each( buttons, function( name, props ) { props = $.isFunction( props ) ? { click: props, text: name } : -- cgit v1.2.3 From 5e44b3ce8851f62a38ce9211c6721e1050e2dabf Mon Sep 17 00:00:00 2001 From: Jean-Francois Remy Date: Tue, 3 May 2011 04:38:17 -0400 Subject: Position: Handled scrolled windows properly with collision: fit. Fixes #7211 - Position: Collision: fit doesn't work at top of window when scrolled. --- tests/unit/position/position_core.js | 27 ++++++++++++++++++++++----- ui/jquery.ui.position.js | 35 ++++++++++++++++++++++++++--------- 2 files changed, 48 insertions(+), 14 deletions(-) (limited to 'ui') diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index 5a47fe6bb..dbbda8a3b 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -1,5 +1,10 @@ (function( $ ) { +function scrollTopSupport() { + $( window ).scrollTop( 1 ); + return $( window ).scrollTop() === 1; +} + module( "position" ); test( "my, at, of", function() { @@ -161,11 +166,7 @@ test( "of", function() { left: $( window ).width() - 10 }, "window as jQuery object" ); - var scrollTopSupport = (function() { - $( window ).scrollTop( 1 ); - return $( window ).scrollTop() === 1; - }() ); - if ( scrollTopSupport ) { + if ( scrollTopSupport() ) { $( window ).scrollTop( 500 ).scrollLeft( 200 ); $( "#elx" ).position({ my: "right bottom", @@ -311,6 +312,22 @@ test( "collision: fit, with offset", function() { }, { top: 0, left: 0 }, "left top, negative offset" ); }); +test( "collision: fit, window scrolled", function() { + if ( scrollTopSupport() ) { + var win = $( window ); + win.scrollTop( 300 ).scrollLeft( 200 ); + collisionTest({ + collision: "fit", + at: "left-100 top-100" + }, { top: 300, left: 200 }, "top left" ); + collisionTest2({ + collision: "fit", + at: "right+100 bottom+100" + }, { top: 300 + win.height() - 10, left: 200 + win.width() - 10 }, "right bottom" ); + win.scrollTop( 0 ).scrollLeft( 0 ); + } +}); + test( "collision: flip, no offset", function() { collisionTest({ collision: "flip" diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index b6fcc7151..98b8198e2 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -184,20 +184,37 @@ $.ui.position = { fit: { left: function( position, data ) { var win = $( window ), - over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(); - position.left = over > 0 ? - position.left - over : - Math.max( position.left - data.collisionPosition.left, position.left ); + overLeft = win.scrollLeft() - data.collisionPosition.left, + overRight = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(); + + // element is wider than window or too far left -> align with left edge + if ( data.collisionWidth > win.width() || overLeft > 0 ) { + position.left = position.left + overLeft; + // too far right -> align with right edge + } else if ( overRight > 0 ) { + position.left = position.left - overRight; + // adjust based on position and margin + } else { + position.left = Math.max( position.left - data.collisionPosition.left, position.left ); + } }, top: function( position, data ) { var win = $( window ), - over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(); - position.top = over > 0 ? - position.top - over : - Math.max( position.top - data.collisionPosition.top, position.top ); + overTop = win.scrollTop() - data.collisionPosition.top, + overBottom = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(); + + // element is taller than window or too far up -> align with top edge + if ( data.collisionHeight > win.height() || overTop > 0 ) { + position.top = position.top + overTop; + // too far down -> align with bottom edge + } else if ( overBottom > 0 ) { + position.top = position.top - overBottom; + // adjust based on position and margin + } else { + position.top = Math.max( position.top - data.collisionPosition.top, position.top ); + } } }, - flip: { left: function( position, data ) { if ( data.at[ 0 ] === center ) { -- cgit v1.2.3 From 45c727d75e411d0330027162646bbb26c4f671f1 Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 3 May 2011 06:31:12 -0400 Subject: Tabs: Fixed enabled and disabled methods. Fixes #7142 - Tabs: Deprecate enable and disable events. --- tests/unit/tabs/tabs_deprecated.js | 44 ++++++++++++++++++-------------------- ui/jquery.ui.tabs.js | 10 +++++---- 2 files changed, 27 insertions(+), 27 deletions(-) (limited to 'ui') diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index 25877e69c..15df3cd25 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -152,39 +152,37 @@ test('selected', function() { equals(el.tabs('option', 'selected'), 1, 'should select tab'); }); -module("tabs (deprecated): events"); +module( "tabs (deprecated): events" ); -test('enable', function() { - expect(4); +test( "enable", function() { + expect( 3 ); - var uiObj; - el = $('#tabs1').tabs({ + var element = $( "#tabs1" ).tabs({ disabled: [ 0, 1 ], - enable: function (event, ui) { - uiObj = ui; + enable: function ( event, ui ) { + equals( ui.tab, element.find( ".ui-tabs-nav a" )[ 1 ], "ui.tab" ); + equals( ui.panel, element.find( ".ui-tabs-panel" )[ 1 ], "ui.panel" ); + equals( ui.index, 1, "ui.index" ); } }); - el.tabs('enable', 1); - ok(uiObj !== undefined, 'trigger callback'); - equals(uiObj.tab, $('a', el)[1], 'contain tab as DOM anchor element'); - equals(uiObj.panel, $('div', el)[1], 'contain panel as DOM div element'); - equals(uiObj.index, 1, 'contain index'); + element.tabs( "enable", 1 ); + // shouldn't trigger event + element.tabs( "enable", 2 ); }); -test('disable', function() { - expect(4); +test( "disable", function() { + expect( 3 ); - var uiObj; - el = $('#tabs1').tabs({ - disable: function (event, ui) { - uiObj = ui; + var element = $( "#tabs1" ).tabs({ + disable: function ( event, ui ) { + equals( ui.tab, element.find( ".ui-tabs-nav a" )[ 1 ], "ui.tab" ); + equals( ui.panel, element.find( ".ui-tabs-panel" )[ 1 ], "ui.panel" ); + equals( ui.index, 1, "ui.index" ); } }); - el.tabs('disable', 1); - ok(uiObj !== undefined, 'trigger callback'); - equals(uiObj.tab, $('a', el)[1], 'contain tab as DOM anchor element'); - equals(uiObj.panel, $('div', el)[1], 'contain panel as DOM div element'); - equals(uiObj.index, 1, 'contain index'); + element.tabs( "disable", 1 ); + // shouldn't trigger event + element.tabs( "disable", 1 ); }); test('show', function() { diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 7946cc667..39969d655 100755 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -783,10 +783,11 @@ if ( $.uiBackCompat !== false ) { disable = prototype.disable; prototype.enable = function( index ) { - var o = this.options, + var options = this.options, trigger; - if ( index && o.disabled || ($.isArray( o.disabled ) && $.inArray( index, o.disabled ) !== -1 ) ) { + if ( index && options.disabled === true || + ( $.isArray( options.disabled ) && $.inArray( index, options.disabled ) !== -1 ) ) { trigger = true; } @@ -798,10 +799,11 @@ if ( $.uiBackCompat !== false ) { }; prototype.disable = function( index ) { - var o = this.options, + var options = this.options, trigger; - if ( index && !o.disabled || ($.isArray( o.disabled ) && $.inArray( index, o.disabled ) == -1 ) ) { + if ( index && options.disabled === false || + ( $.isArray( options.disabled ) && $.inArray( index, options.disabled ) === -1 ) ) { trigger = true; } -- cgit v1.2.3 From 92bcb2504f61427e5788d0777c5bcc784c32ad7a Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 3 May 2011 07:14:19 -0400 Subject: Tabs: Fixed back-compat for selected option. Fixes #7135 - Tabs: Rename selected option to active. --- tests/unit/tabs/tabs_deprecated.js | 78 +++++++++++++++++++++----------------- ui/jquery.ui.tabs.js | 20 ++++------ 2 files changed, 51 insertions(+), 47 deletions(-) (limited to 'ui') diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index 15df3cd25..e61e6ec29 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -107,49 +107,57 @@ test('spinner', function() { }); }); -test('selected', function() { - expect(10); +test( "selected", function() { + expect( 19 ); - el = $('#tabs1').tabs(); - equals(el.tabs('option', 'selected'), 0, 'should be 0 by default'); + var element = $( "#tabs1" ).tabs(); + equals( element.tabs( "option", "selected" ), 0, "should be 0 by default" ); + tabs_state( element, 1, 0, 0 ); + element.tabs( "destroy" ); - el.tabs('destroy'); - //set a hash in the url - location.hash = '#fragment-2'; - //selection of tab with divs ordered differently than list - el = $('#tabs1').tabs(); - equals(el.tabs('option', 'selected'), 1, 'second tab should be selected'); + location.hash = "#fragment-3"; + element = $( "#tabs1" ).tabs(); + equals( element.tabs( "option", "selected" ), 2, "should be 2 based on URL" ); + tabs_state( element, 0, 0, 1 ); + element.tabs( "destroy" ); - el.tabs('destroy'); - //set a hash in the url - location.hash = '#tabs7-2'; - //selection of tab with divs ordered differently than list - el = $('#tabs7').tabs(); - equals(el.tabs('option', 'selected'), 1, 'second tab should be selected'); + el = $('#tabs1').tabs({ + selected: -1, + collapsible: true + }); + tabs_state( element, 0, 0, 0 ); + equal( element.find( ".ui-tabs-nav .ui-state-active" ).size(), 0, "no tabs selected" ); + strictEqual( element.tabs( "option", "selected" ), -1 ); - el.tabs('destroy'); - el = $('#tabs1').tabs({ selected: -1 }); - equals(el.tabs('option', 'selected'), -1, 'should be -1 for all tabs unselected'); - equals( $('li.ui-tabs-active', el).length, 0, 'no tab should be selected' ); - equals( $('div:hidden', '#tabs1').length, 3, 'all panels should be hidden' ); + element.tabs( "option", "collapsible", false ); + tabs_state( element, 1, 0, 0 ); + equal( element.tabs( "option", "selected" ), 0 ); + element.tabs( "destroy" ); - el.tabs('destroy'); - el.tabs({ selected: 1 }); - equals(el.tabs('option', 'selected'), 1, 'should be specified tab'); + element.tabs({ + selected: -1 + }); + tabs_state( element, 1, 0, 0 ); + strictEqual( element.tabs( "option", "selected" ), 0 ); + element.tabs( "destroy" ); - el.tabs('destroy'); - el.tabs({ selected: 99 }); - equals(el.tabs('option', 'selected'), 0, 'selected should default to zero if given value is out of index'); + element.tabs({ selected: 2 }); + equals( element.tabs( "option", "selected" ), 2 ); + tabs_state( element, 0, 0, 1 ); - el.tabs('destroy'); - el.tabs({ collapsible: true }); - el.tabs('option', 'selected', 0); - equals(el.tabs('option', 'selected'), 0, 'should not collapse tab if value is same as selected'); + element.tabs( "option", "selected", 0 ); + equals( element.tabs( "option", "selected" ), 0 ); + tabs_state( element, 1, 0, 0 ); - el.tabs('destroy'); - el = $('#tabs1').tabs(); - el.tabs('select', 1); - equals(el.tabs('option', 'selected'), 1, 'should select tab'); + element.find( ".ui-tabs-nav a" ).eq( 1 ).click(); + equals( element.tabs( "option", "selected" ), 1 ); + tabs_state( element, 0, 1, 0 ); + + element.tabs( "option", "selected", 10 ); + equals( element.tabs( "option", "selected" ), 1 ); + tabs_state( element, 0, 1, 0 ); + + location.hash = "#"; }); module( "tabs (deprecated): events" ); diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 39969d655..8bef69290 100755 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -948,19 +948,15 @@ if ( $.uiBackCompat !== false ) { }; prototype._setOption = function( key, value ) { - var options = this.options; - if ( key === "selected" ) { - key = "active"; + if ( key !== "selected" ) { + return _setOption.apply( this, arguments ); } - _setOption.apply( this, arguments ); - if ( key === "active" ) { - if ( key === - 1 ) { - key = false; - } - options.selected = options.active; - if ( options.selected === false ) { - options.selected = -1; - } + + var options = this.options; + _setOption.call( this, "active", value === -1 ? false : value ); + options.selected = options.active; + if ( options.selected === false ) { + options.selected = -1; } }; -- cgit v1.2.3 From cbce3585bcd3edb0202839d9533c43d3a6df1d7f Mon Sep 17 00:00:00 2001 From: Scott González Date: Tue, 3 May 2011 07:48:08 -0400 Subject: Tabs: Added tests for deprecated select method. Fixes #7138 - Tabs: Deprecate select method. --- tests/unit/tabs/tabs_deprecated.js | 60 ++++++++++++++++++++++++-------------- ui/jquery.ui.tabs.js | 4 +-- 2 files changed, 40 insertions(+), 24 deletions(-) (limited to 'ui') diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index e61e6ec29..90c43037c 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -338,33 +338,49 @@ test( "remove", function() { equals( element.tabs( "option", "active" ), false ); }); -test('select', function() { - expect(6); +test( "select", function() { + expect( 23 ); - el = $('#tabs1').tabs(); + var element = $( "#tabs1" ).tabs(); + tabs_state( element, 1, 0, 0 ); + element.tabs( "select", 1 ); + tabs_state( element, 0, 1, 0 ); + equals( element.tabs( "option", "active" ), 1, "active" ); + equals( element.tabs( "option", "selected" ), 1, "selected" ); + element.tabs( "destroy" ); - el.tabs('select', 1); - equals(el.tabs('option', 'active'), 1, 'should select tab'); + element.tabs({ collapsible: true }); + tabs_state( element, 1, 0, 0 ); + element.tabs( "select", 0 ); + tabs_state( element, 0, 0, 0 ); + equals( element.tabs( "option", "active" ), false, "active" ); + equals( element.tabs( "option", "selected" ), -1, "selected" ); + element.tabs( "destroy" ); - el.tabs('destroy'); - el.tabs({ collapsible: true }); - el.tabs('select', 0); - equals(el.tabs('option', 'active'), -1, 'should collapse tab passing in the already active tab'); + element.tabs({ collapsible: true }); + element.tabs( "select", -1 ); + tabs_state( element, 0, 0, 0 ); + equals( element.tabs( "option", "active" ), false, "active" ); + equals( element.tabs( "option", "selected" ), -1, "selected" ); + element.tabs( "destroy" ); - el.tabs('destroy'); - el.tabs({ collapsible: true }); - el.tabs('select', -1); - equals(el.tabs('option', 'active'), -1, 'should collapse tab passing in -1'); + element.tabs(); + tabs_state( element, 1, 0, 0 ); + equals( element.tabs( "option", "active" ), 0, "active" ); + equals( element.tabs( "option", "selected" ), 0, "selected" ); + element.tabs( "select", 0 ); + tabs_state( element, 1, 0, 0 ); + equals( element.tabs( "option", "active" ), 0, "active" ); + equals( element.tabs( "option", "selected" ), 0, "selected" ); + element.tabs( "select", -1 ); + tabs_state( element, 1, 0, 0 ); + equals( element.tabs( "option", "active" ), 0, "active" ); + equals( element.tabs( "option", "selected" ), 0, "selected" ); - el.tabs('destroy'); - el.tabs(); - el.tabs('select', 0); - equals(el.tabs('option', 'active'), 0, 'should not collapse tab if collapsible is not set to true'); - el.tabs('select', -1); - equals(el.tabs('option', 'active'), 0, 'should not collapse tab if collapsible is not set to true'); - - el.tabs('select', '#fragment-2'); - equals(el.tabs('option', 'active'), 1, 'should select tab by id'); + element.tabs( "select", "#fragment-2" ); + tabs_state( element, 0, 1, 0 ); + equals( element.tabs( "option", "active" ), 1, "active" ); + equals( element.tabs( "option", "selected" ), 1, "selected" ); }); test( "length", function() { diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 8bef69290..58c181670 100755 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -998,8 +998,8 @@ if ( $.uiBackCompat !== false ) { (function( $, prototype ) { prototype.select = function( index ) { index = this._getIndex( index ); - if ( index == -1 ) { - if ( this.options.collapsible && this.options.selected != -1 ) { + if ( index === -1 ) { + if ( this.options.collapsible && this.options.selected !== -1 ) { index = this.options.selected; } else { return; -- cgit v1.2.3 From 1f3f7bf7872db0dcfbaea0276eea93225d2a8f58 Mon Sep 17 00:00:00 2001 From: gnarf Date: Tue, 3 May 2011 09:16:30 -0400 Subject: Effects (blind): direction now accepts up/down/left/right as well as vertical(up) and horizontal(left) - Fixes #4480 - Invert the blind effect. --- tests/visual/effects.all.html | 20 ++++++++++++---- tests/visual/effects.all.js | 6 +++-- ui/jquery.effects.blind.js | 55 +++++++++++++++++++++++++++++++++---------- 3 files changed, 62 insertions(+), 19 deletions(-) (limited to 'ui') diff --git a/tests/visual/effects.all.html b/tests/visual/effects.all.html index 1bbc7a110..1fc35f700 100644 --- a/tests/visual/effects.all.html +++ b/tests/visual/effects.all.html @@ -26,14 +26,26 @@
  • -
    -

    Blind horizontally

    +
    +

    Blind up

  • -
    -

    Blind vertically

    +
    +

    Blind down

    +
    +
  • + +
  • +
    +

    Blind left

    +
    +
  • + +
  • +
    +

    Blind right

  • diff --git a/tests/visual/effects.all.js b/tests/visual/effects.all.js index 5e47a4f48..3ac8968b3 100644 --- a/tests/visual/effects.all.js +++ b/tests/visual/effects.all.js @@ -33,8 +33,10 @@ $(function() { }) }) - effect("#blindHorizontally", "blind", { direction: "horizontal" }); - effect("#blindVertically", "blind", { direction: "vertical" }); + effect("#blindLeft", "blind", { direction: "left" }); + effect("#blindUp", "blind", { direction: "up" }); + effect("#blindRight", "blind", { direction: "right" }); + effect("#blindDown", "blind", { direction: "down" }); effect("#bounce3times", "bounce", { times: 3 }); diff --git a/ui/jquery.effects.blind.js b/ui/jquery.effects.blind.js index 6b7250789..7a59d8a75 100644 --- a/ui/jquery.effects.blind.js +++ b/ui/jquery.effects.blind.js @@ -11,6 +11,9 @@ * jquery.effects.core.js */ (function( $, undefined ) { + +var rvertical = /up|down|vertical/; +var rpositivemotion = /up|left|vertical|horizontal/; $.effects.effect.blind = function( o ) { @@ -18,31 +21,57 @@ $.effects.effect.blind = function( o ) { // Create element var el = $( this ), - props = [ 'position', 'top', 'bottom', 'left', 'right' ], - mode = $.effects.setMode( el, o.mode || 'hide' ), - direction = o.direction || 'vertical', - ref = ( direction == 'vertical' ) ? 'height' : 'width', + props = [ "position", "top", "bottom", "left", "right" ], + mode = $.effects.setMode( el, o.mode || "hide" ), + direction = o.direction || "up", + vertical = rvertical.test( direction ), + ref = vertical ? "height" : "width", + ref2 = vertical ? "top" : "left", + motion = rpositivemotion.test( direction ), animation = {}, wrapper, distance; $.effects.save( el, props ); el.show(); wrapper = $.effects.createWrapper( el ).css({ - overflow: 'hidden' + overflow: "hidden" }); - animation[ ref ] = ( mode == 'show' ? wrapper[ ref ]() : 0 ); + distance = wrapper[ ref ](); + + animation[ ref ] = ( mode === "show" ? distance : 0 ); + if ( !motion ) { + el + .css( vertical ? "bottom" : "right", 0 ) + .css( vertical ? "top" : "left", "" ) + .css({ position: "absolute" }); + animation[ ref2 ] = ( mode === "show" ) ? 0 : distance; + } // start at 0 if we are showing - ( mode == 'show' && wrapper.css( ref, 0 ) ); + if ( mode == "show" ) { + wrapper.css( ref, 0 ); + if ( ! motion ) { + wrapper.css( ref2, distance ); + } + } // Animate - wrapper.animate( animation, o.duration, o.easing, function() { - ( mode == 'hide' && el.hide() ); - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - $.isFunction( o.complete ) && o.complete.apply( el[ 0 ], arguments ); - el.dequeue(); + wrapper.animate( animation, { + duration: o.duration, + easing: o.easing, + queue: false, + complete: function() { + if ( mode == "hide" ) { + el.hide(); + } + $.effects.restore( el, props ); + $.effects.removeWrapper( el ); + if ( $.isFunction( o.complete ) ) { + o.complete.apply( el[ 0 ], arguments ); + } + el.dequeue(); + } }); }); -- cgit v1.2.3 From a444287642f122b6dc2be09bf5de8522d45d736a Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Tue, 3 May 2011 21:57:25 +0200 Subject: Menu: Restore _destroy - remove tabIndex (gets added), don't remove ID (can get generated, but removing only generated ideas hopefully isn't necessary). May have to fix that later. --- ui/jquery.ui.menu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 0f585d976..0841018af 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -177,7 +177,7 @@ $.widget("ui.menu", { .andSelf() .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) .removeAttr( "role" ) - .removeAttr("id") + .removeAttr("tabIndex") .removeAttr( "aria-labelledby" ) .removeAttr( "aria-expanded" ) .removeAttr( "aria-hidden" ) -- cgit v1.2.3