aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorgnarf <gnarf@gnarf.net>2011-05-04 01:38:41 -0500
committergnarf <gnarf@gnarf.net>2011-05-04 01:38:41 -0500
commitd61e0656c59761cf9729d2aacbc16d74e576a440 (patch)
tree436fa7641aa06435fcbf49b3f3d88caf849a99f6 /ui
parentc5c65dbac60463d04a6c34a3c0e3e9ce5a846a43 (diff)
parentf5ee22c74a2e0e48b686a94838e12cbb9b45c99c (diff)
downloadjquery-ui-d61e0656c59761cf9729d2aacbc16d74e576a440.tar.gz
jquery-ui-d61e0656c59761cf9729d2aacbc16d74e576a440.zip
Merge branch 'master' into effects-unit
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.effects.blind.js55
-rw-r--r--ui/jquery.ui.datepicker.js47
-rw-r--r--ui/jquery.ui.dialog.js32
-rw-r--r--ui/jquery.ui.draggable.js80
-rw-r--r--ui/jquery.ui.menu.js2
-rw-r--r--ui/jquery.ui.position.js35
-rw-r--r--ui/jquery.ui.sortable.js2
-rwxr-xr-xui/jquery.ui.tabs.js34
-rw-r--r--ui/jquery.ui.tooltip.js12
-rw-r--r--ui/jquery.ui.widget.js26
10 files changed, 211 insertions, 114 deletions
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();
+ }
});
});
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 = $('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>');
+ this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
}
$.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
- $('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))};
+ bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')))};
},
/* 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);
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 = $( "<div>" ) )
- .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 = $( "<div>" )
- .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ),
- uiButtonSet = $( "<div>" )
- .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 = $( "<div>" )
+ .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ),
+ uiButtonSet = $( "<div>" )
+ .addClass( "ui-dialog-buttonset" )
+ .appendTo( uiDialogButtonPane );
+
$.each( buttons, function( name, props ) {
props = $.isFunction( props ) ?
{ click: props, text: name } :
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js
index ff1ad1363..774ea4380 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() {
+ $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
+ .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")) {
@@ -342,16 +362,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 +416,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;
}
}
@@ -616,24 +650,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() {
- $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
- .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;
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" )
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 ) {
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();
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js
index 7946cc667..58c181670 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;
}
@@ -946,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;
}
};
@@ -1000,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;
diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js
index 534b3c947..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() {
@@ -90,8 +89,8 @@ $.widget("ui.tooltip", {
of: target
}, this.options.position ) ).hide();
-
- tooltip.fadeIn();
+ tooltip.stop( true );
+ this._show( tooltip, this.options.show );
this._trigger( "open", event );
@@ -111,7 +110,8 @@ $.widget("ui.tooltip", {
var tooltip = this._find( target );
target.removeAttr( "aria-describedby" );
- tooltip.fadeOut( function() {
+ 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 55b9f7984..a74e6b77b 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -356,11 +356,35 @@ $.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 (options.delay) {
+ element.delay( options.delay );
+ }
+ 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 );
+ } else {
+ element.queue( function() {
+ $( this )[ method ]();
+ if ( callback ) {
+ callback.call( element[ 0 ] );
+ }
+ });
+ }
+ };
+});
+
// DEPRECATED
if ( $.uiBackCompat !== false ) {
$.Widget.prototype._getCreateOptions = function() {
return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
- }
+ };
}
})( jQuery );