aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.effects.bounce.js21
-rw-r--r--ui/jquery.effects.core.js281
-rw-r--r--ui/jquery.effects.fade.js17
-rw-r--r--ui/jquery.effects.pulsate.js18
-rw-r--r--ui/jquery.effects.scale.js10
-rw-r--r--ui/jquery.effects.shake.js58
-rw-r--r--ui/jquery.ui.accordion.js6
-rw-r--r--ui/jquery.ui.autocomplete.js1
-rw-r--r--ui/jquery.ui.button.js49
-rw-r--r--ui/jquery.ui.datepicker.js41
-rw-r--r--ui/jquery.ui.dialog.js12
-rw-r--r--ui/jquery.ui.draggable.js13
-rw-r--r--ui/jquery.ui.menu.js19
-rw-r--r--ui/jquery.ui.slider.js50
-rw-r--r--ui/jquery.ui.spinner.js367
-rw-r--r--ui/jquery.ui.tabs.js207
-rw-r--r--ui/jquery.ui.widget.js29
17 files changed, 628 insertions, 571 deletions
diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js
index bb386a4f4..9e1117ce9 100644
--- a/ui/jquery.effects.bounce.js
+++ b/ui/jquery.effects.bounce.js
@@ -79,10 +79,8 @@ $.effects.effect.bounce = function(o) {
upAnim = {};
upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
- // add the finish callback to the last animation if we aren't hiding
el.animate( upAnim, speed, easing )
- .animate( downAnim, speed, easing,
- ( ( i === times - 1 ) && !hide ) ? finish : undefined );
+ .animate( downAnim, speed, easing );
distance = hide ? distance * 2 : distance / 2;
}
@@ -92,24 +90,25 @@ $.effects.effect.bounce = function(o) {
upAnim = { opacity: 0 };
upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
- el.animate( upAnim, speed, easing, function(){
- el.hide();
- finish();
- });
+ el.animate( upAnim, speed, easing );
}
-
- function finish() {
+
+ el.queue( function( next ) {
+ if ( hide ) {
+ el.hide();
+ }
$.effects.restore( el, props );
$.effects.removeWrapper( el );
if ( o.complete ) {
o.complete.apply( el[ 0 ] );
}
- }
+ next();
+ });
// inject all the animations we just queued to be first in line (after "inprogress")
if ( queuelen > 1) {
queue.splice.apply( queue,
- [ 1, 0 ].concat( queue.splice( queuelen, anims ) ) );
+ [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
}
next();
diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js
index 581fb0861..638119579 100644
--- a/ui/jquery.effects.core.js
+++ b/ui/jquery.effects.core.js
@@ -20,8 +20,8 @@ $.effects = {
/******************************************************************************/
// override the animation for color styles
-$.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor',
- 'borderRightColor', 'borderTopColor', 'borderColor', 'color', 'outlineColor'],
+$.each(["backgroundColor", "borderBottomColor", "borderLeftColor",
+ "borderRightColor", "borderTopColor", "borderColor", "color", "outlineColor"],
function(i, attr) {
$.fx.step[attr] = function(fx) {
if (!fx.colorInit) {
@@ -30,10 +30,10 @@ function(i, attr) {
fx.colorInit = true;
}
- fx.elem.style[attr] = 'rgb(' +
- Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' +
- Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' +
- Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')';
+ fx.elem.style[attr] = "rgb(" +
+ Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + "," +
+ Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + "," +
+ Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ")";
};
});
@@ -46,7 +46,7 @@ function getRGB(color) {
var result;
// Check if we're already dealing with an array of colors
- if ( color && color.constructor == Array && color.length == 3 )
+ if ( color && color.constructor === Array && color.length === 3 )
return color;
// Look for rgb(num,num,num)
@@ -67,7 +67,7 @@ function getRGB(color) {
// Look for rgba(0, 0, 0, 0) == transparent in Safari 3
if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
- return colors['transparent'];
+ return colors["transparent"];
// Otherwise, we're most likely dealing with a named color
return colors[$.trim(color).toLowerCase()];
@@ -80,7 +80,7 @@ function getColor(elem, attr) {
color = $.curCSS(elem, attr);
// Keep going until we find an element that has color, or we hit the body
- if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") )
+ if ( color != "" && color !== "transparent" || $.nodeName(elem, "body") )
break;
attr = "backgroundColor";
@@ -146,7 +146,7 @@ var colors = {
/****************************** CLASS ANIMATIONS ******************************/
/******************************************************************************/
-var classAnimationActions = [ 'add', 'remove', 'toggle' ],
+var classAnimationActions = [ "add", "remove", "toggle" ],
shorthandStyles = {
border: 1,
borderBottom: 1,
@@ -157,7 +157,18 @@ var classAnimationActions = [ 'add', 'remove', 'toggle' ],
borderWidth: 1,
margin: 1,
padding: 1
+ },
+ // prefix used for storing data on .data()
+ dataSpace = "ec.storage.";
+
+$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function(_, prop) {
+ $.fx.step[ prop ] = function( fx ) {
+ if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
+ jQuery.style( fx.elem, prop, fx.end );
+ fx.setAttr = true;
+ }
};
+});
function getElementStyles() {
var style = document.defaultView
@@ -173,55 +184,34 @@ function getElementStyles() {
len = style.length;
while ( len-- ) {
key = style[ len ];
- if ( typeof style[ key ] == 'string' ) {
- camelCase = key.replace( /\-(\w)/g, function( all, letter ) {
- return letter.toUpperCase();
- });
- newStyle[ camelCase ] = style[ key ];
+ if ( typeof style[ key ] === "string" ) {
+ newStyle[ $.camelCase( key ) ] = style[ key ];
}
}
} else {
for ( key in style ) {
- if ( typeof style[ key ] === 'string' ) {
+ if ( typeof style[ key ] === "string" ) {
newStyle[ key ] = style[ key ];
}
}
}
-
+
return newStyle;
}
-function filterStyles( styles ) {
- var name, value;
- for ( name in styles ) {
- value = styles[ name ];
- if (
- // ignore null and undefined values
- value == null ||
- // ignore functions (when does this occur?)
- $.isFunction( value ) ||
- // shorthand styles that need to be expanded
- name in shorthandStyles ||
- // ignore scrollbars (break in IE)
- ( /scrollbar/ ).test( name ) ||
-
- // only colors or values that can be converted to numbers
- ( !( /color/i ).test( name ) && isNaN( parseFloat( value ) ) )
- ) {
- delete styles[ name ];
- }
- }
-
- return styles;
-}
function styleDifference( oldStyle, newStyle ) {
- var diff = { _: 0 }, // http://dev.jquery.com/ticket/5459
- name;
+ var diff = {},
+ name, value;
for ( name in newStyle ) {
- if ( oldStyle[ name ] != newStyle[ name ] ) {
- diff[ name ] = newStyle[ name ];
+ value = newStyle[ name ];
+ if ( oldStyle[ name ] != value ) {
+ if ( !shorthandStyles[ name ] ) {
+ if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
+ diff[ name ] = value;
+ }
+ }
}
}
@@ -229,48 +219,77 @@ function styleDifference( oldStyle, newStyle ) {
}
$.effects.animateClass = function( value, duration, easing, callback ) {
- if ( $.isFunction( easing ) ) {
- callback = easing;
- easing = null;
- }
-
- return this.queue(function() {
- var that = $( this ),
- originalStyleAttr = that.attr( 'style' ) || ' ',
- originalStyle = filterStyles( getElementStyles.call( this ) ),
- newStyle,
- className = that.attr( 'class' );
+ var o = $.speed( duration, easing, callback );
+
+ return this.queue( function() {
+ var animated = $( this ),
+ baseClass = animated.attr( "class" ),
+ finalClass,
+ allAnimations = o.children ? animated.find( "*" ).andSelf() : animated;
+
+ // map the animated objects to store the original styles.
+ allAnimations = allAnimations.map(function() {
+ var el = $( this );
+ return {
+ el: el,
+ originalStyleAttr: el.attr( "style" ) || " ",
+ start: getElementStyles.call( this )
+ };
+ });
+ // apply class change
$.each( classAnimationActions, function(i, action) {
if ( value[ action ] ) {
- that[ action + 'Class' ]( value[ action ] );
+ animated[ action + "Class" ]( value[ action ] );
}
});
- newStyle = filterStyles( getElementStyles.call( this ) );
- that.attr( 'class', className );
-
- that.animate( styleDifference( originalStyle, newStyle ), {
- queue: false,
- duration: duration,
- easing: easing,
- complete: function() {
- $.each( classAnimationActions, function( i, action ) {
- if ( value[ action ] ) {
- that[ action + 'Class' ]( value[ action ] );
- }
- });
- // work around bug in IE by clearing the cssText before setting it
- if ( typeof that.attr( 'style' ) == 'object' ) {
- that.attr( 'style' ).cssText = '';
- that.attr( 'style' ).cssText = originalStyleAttr;
- } else {
- that.attr( 'style', originalStyleAttr );
+ finalClass = animated.attr( "class" );
+
+ // map all animated objects again - calculate new styles and diff
+ allAnimations = allAnimations.map(function() {
+ this.end = getElementStyles.call( this.el[ 0 ] );
+ this.diff = styleDifference( this.start, this.end );
+ return this;
+ });
+
+ // apply original class
+ animated.attr( "class", baseClass );
+
+ // map all animated objects again - this time collecting a promise
+ allAnimations = allAnimations.map(function() {
+ var styleInfo = this,
+ dfd = $.Deferred();
+
+ this.el.animate( this.diff, {
+ duration: o.duration,
+ easing: o.easing,
+ queue: false,
+ complete: function() {
+ dfd.resolve( styleInfo );
}
- if ( callback ) {
- callback.apply( this, arguments );
+ });
+ return dfd.promise();
+ });
+
+ // once all animations have completed:
+ $.when.apply( $, allAnimations.get() ).done(function() {
+
+ // set the final class
+ animated.attr( "class", finalClass );
+
+ // for each animated element
+ $.each( arguments, function() {
+ if ( typeof this.el.attr( "style" ) === "object" ) {
+ this.el.attr( "style" ).cssText = "";
+ this.el.attr( "style" ).cssText = this.originalStyleAttr;
+ } else {
+ this.el.attr( "style", this.originalStyleAttr );
}
- $.dequeue( this );
- }
+ });
+
+ // this is guarnteed to be there if you use jQuery.speed()
+ // it also handles dequeuing the next anim...
+ o.complete.call( animated[ 0 ] );
});
});
};
@@ -278,21 +297,21 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
$.fn.extend({
_addClass: $.fn.addClass,
addClass: function( classNames, speed, easing, callback ) {
- return speed ?
+ return speed ?
$.effects.animateClass.apply( this, [{ add: classNames }, speed, easing, callback ]) :
this._addClass(classNames);
},
_removeClass: $.fn.removeClass,
removeClass: function( classNames, speed, easing, callback ) {
- return speed ?
+ return speed ?
$.effects.animateClass.apply( this, [{ remove: classNames }, speed, easing, callback ]) :
this._removeClass(classNames);
},
_toggleClass: $.fn.toggleClass,
toggleClass: function( classNames, force, speed, easing, callback ) {
- if ( typeof force == "boolean" || force === undefined ) {
+ if ( typeof force === "boolean" || force === undefined ) {
if ( !speed ) {
// without speed parameter;
return this._toggleClass( classNames, force );
@@ -300,15 +319,15 @@ $.fn.extend({
return $.effects.animateClass.apply( this, [( force ? { add:classNames } : { remove:classNames }), speed, easing, callback ]);
}
} else {
- // without switch parameter;
+ // without force parameter;
return $.effects.animateClass.apply( this, [{ toggle: classNames }, force, speed, easing ]);
}
},
switchClass: function( remove, add, speed, easing, callback) {
- return $.effects.animateClass.apply( this, [{
- add: add,
- remove: remove
+ return $.effects.animateClass.apply( this, [{
+ add: add,
+ remove: remove
}, speed, easing, callback ]);
}
});
@@ -326,7 +345,7 @@ $.extend( $.effects, {
save: function( element, set ) {
for( var i=0; i < set.length; i++ ) {
if ( set[ i ] !== null ) {
- element.data( "ec.storage." + set[ i ], element[ 0 ].style[ set[ i ] ] );
+ element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
}
}
},
@@ -335,32 +354,32 @@ $.extend( $.effects, {
restore: function( element, set ) {
for( var i=0; i < set.length; i++ ) {
if ( set[ i ] !== null ) {
- element.css( set[ i ], element.data( "ec.storage." + set[ i ] ) );
+ element.css( set[ i ], element.data( dataSpace + set[ i ] ) );
}
}
},
setMode: function( el, mode ) {
- if (mode == 'toggle') {
- mode = el.is( ':hidden' ) ? 'show' : 'hide';
+ if (mode === "toggle") {
+ mode = el.is( ":hidden" ) ? "show" : "hide";
}
return mode;
},
// Translates a [top,left] array into a baseline value
// this should be a little more flexible in the future to handle a string & hash
- getBaseline: function( origin, original ) {
+ getBaseline: function( origin, original ) {
var y, x;
switch ( origin[ 0 ] ) {
- case 'top': y = 0; break;
- case 'middle': y = 0.5; break;
- case 'bottom': y = 1; break;
+ case "top": y = 0; break;
+ case "middle": y = 0.5; break;
+ case "bottom": y = 1; break;
default: y = origin[ 0 ] / original.height;
};
switch ( origin[ 1 ] ) {
- case 'left': x = 0; break;
- case 'center': x = 0.5; break;
- case 'right': x = 1; break;
+ case "left": x = 0; break;
+ case "center": x = 0.5; break;
+ case "right": x = 1; break;
default: x = origin[ 1 ] / original.width;
};
return {
@@ -373,7 +392,7 @@ $.extend( $.effects, {
createWrapper: function( element ) {
// if the element is already wrapped, return it
- if ( element.parent().is( '.ui-effects-wrapper' )) {
+ if ( element.parent().is( ".ui-effects-wrapper" )) {
return element.parent();
}
@@ -381,14 +400,14 @@ $.extend( $.effects, {
var props = {
width: element.outerWidth(true),
height: element.outerHeight(true),
- 'float': element.css( 'float' )
+ "float": element.css( "float" )
},
- wrapper = $( '<div></div>' )
- .addClass( 'ui-effects-wrapper' )
+ wrapper = $( "<div></div>" )
+ .addClass( "ui-effects-wrapper" )
.css({
- fontSize: '100%',
- background: 'transparent',
- border: 'none',
+ fontSize: "100%",
+ background: "transparent",
+ border: "none",
margin: 0,
padding: 0
});
@@ -397,26 +416,26 @@ $.extend( $.effects, {
wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element
// transfer positioning properties to the wrapper
- if ( element.css( 'position' ) == 'static' ) {
- wrapper.css({ position: 'relative' });
- element.css({ position: 'relative' });
+ if ( element.css( "position" ) === "static" ) {
+ wrapper.css({ position: "relative" });
+ element.css({ position: "relative" });
} else {
$.extend( props, {
- position: element.css( 'position' ),
- zIndex: element.css( 'z-index' )
+ position: element.css( "position" ),
+ zIndex: element.css( "z-index" )
});
- $.each([ 'top', 'left', 'bottom', 'right' ], function(i, pos) {
+ $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
props[ pos ] = element.css( pos );
if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
- props[ pos ] = 'auto';
+ props[ pos ] = "auto";
}
});
element.css({
- position: 'relative',
+ position: "relative",
top: 0,
left: 0,
- right: 'auto',
- bottom: 'auto'
+ right: "auto",
+ bottom: "auto"
});
}
@@ -424,7 +443,7 @@ $.extend( $.effects, {
},
removeWrapper: function( element ) {
- if ( element.parent().is( '.ui-effects-wrapper' ) )
+ if ( element.parent().is( ".ui-effects-wrapper" ) )
return element.parent().replaceWith( element );
return element;
},
@@ -463,7 +482,7 @@ function _normalizeArguments( effect, options, speed, callback ) {
}
// catch (effect, speed, ?)
- if ( $.type( options ) == 'number' || $.fx.speeds[ options ]) {
+ if ( $.type( options ) === "number" || $.fx.speeds[ options ]) {
callback = speed;
speed = options;
options = {};
@@ -479,9 +498,9 @@ function _normalizeArguments( effect, options, speed, callback ) {
if ( options ) {
$.extend( effect, options );
}
-
+
speed = speed || options.duration;
- effect.duration = $.fx.off ? 0 : typeof speed == 'number'
+ effect.duration = $.fx.off ? 0 : typeof speed === "number"
? speed : speed in $.fx.speeds ? $.fx.speeds[ speed ] : $.fx.speeds._default;
effect.complete = callback || options.complete;
@@ -494,7 +513,7 @@ function standardSpeed( speed ) {
if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
return true;
}
-
+
// invalid strings - treat as "normal" speed
if ( typeof speed === "string" && !$.effects.effect[ speed ] ) {
// TODO: remove in 2.0 (#7115)
@@ -503,7 +522,7 @@ function standardSpeed( speed ) {
}
return true;
}
-
+
return false;
}
@@ -549,7 +568,7 @@ $.fn.extend({
return this._show.apply( this, arguments );
} else {
var args = _normalizeArguments.apply( this, arguments );
- args.mode = 'show';
+ args.mode = "show";
return this.effect.call( this, args );
}
},
@@ -560,7 +579,7 @@ $.fn.extend({
return this._hide.apply( this, arguments );
} else {
var args = _normalizeArguments.apply( this, arguments );
- args.mode = 'hide';
+ args.mode = "hide";
return this.effect.call( this, args );
}
},
@@ -572,7 +591,7 @@ $.fn.extend({
return this.__toggle.apply( this, arguments );
} else {
var args = _normalizeArguments.apply( this, arguments );
- args.mode = 'toggle';
+ args.mode = "toggle";
return this.effect.call( this, args );
}
},
@@ -582,7 +601,7 @@ $.fn.extend({
var style = this.css( key ),
val = [];
- $.each( [ 'em', 'px', '%', 'pt' ], function( i, unit ) {
+ $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
if ( style.indexOf( unit ) > 0 )
val = [ parseFloat( style ), unit ];
});
@@ -637,7 +656,7 @@ $.fn.extend({
$.easing.jswing = $.easing.swing;
$.extend( $.easing, {
- def: 'easeOutQuad',
+ def: "easeOutQuad",
swing: function ( x, t, b, c, d ) {
return $.easing[ $.easing.def ]( x, t, b, c, d );
},
@@ -718,9 +737,9 @@ $.extend( $.easing, {
a = c;
if ( t == 0 ) return b;
if ( ( t /= d ) == 1 ) return b+c;
- if ( a < Math.abs( c ) ) {
- a = c;
- s = p / 4;
+ if ( a < Math.abs( c ) ) {
+ a = c;
+ s = p / 4;
} else {
s = p / ( 2 * Math.PI ) * Math.asin( c / a );
}
@@ -733,8 +752,8 @@ $.extend( $.easing, {
if ( t == 0 ) return b;
if ( ( t /= d ) == 1 ) return b+c;
if ( a < Math.abs( c ) ) {
- a = c;
- s = p / 4;
+ a = c;
+ s = p / 4;
} else {
s = p / ( 2 * Math.PI ) * Math.asin( c / a );
}
@@ -746,7 +765,7 @@ $.extend( $.easing, {
a = c;
if ( t == 0 ) return b;
if ( ( t /= d / 2 ) == 2 ) return b+c;
- if ( a < Math.abs( c ) ) {
+ if ( a < Math.abs( c ) ) {
a = c;
s = p / 4;
} else {
diff --git a/ui/jquery.effects.fade.js b/ui/jquery.effects.fade.js
index 5fa0319c0..ff1cba5f8 100644
--- a/ui/jquery.effects.fade.js
+++ b/ui/jquery.effects.fade.js
@@ -13,19 +13,26 @@
(function( $, undefined ) {
$.effects.effect.fade = function( o ) {
- return this.queue( function() {
+ return this.queue( function( next ) {
var el = $( this ),
- mode = $.effects.setMode( el, o.mode || 'hide' );
+ mode = $.effects.setMode( el, o.mode || 'toggle' ),
+ hide = mode === "hide";
+ el.show();
el.animate({
- opacity: mode
+ opacity: hide ? 0 : 1
}, {
queue: false,
duration: o.duration,
easing: o.easing,
complete: function() {
- $.isFunction( o.complete ) && o.complete.apply( this, arguments );
- el.dequeue();
+ if ( hide ) {
+ el.hide();
+ }
+ if ( o.complete ) {
+ o.complete.call( this );
+ }
+ next();
}
});
});
diff --git a/ui/jquery.effects.pulsate.js b/ui/jquery.effects.pulsate.js
index 3325c251f..a0ddf51fd 100644
--- a/ui/jquery.effects.pulsate.js
+++ b/ui/jquery.effects.pulsate.js
@@ -15,11 +15,12 @@
$.effects.effect.pulsate = function( o ) {
return this.queue( function( next ) {
var elem = $( this ),
- mode = $.effects.setMode( elem, o.mode || "effect" ),
- show = mode === "show" || elem.is( ":hidden" ),
+ mode = $.effects.setMode( elem, o.mode || "show" ),
+ show = mode === "show",
+ hide = mode === "hide",
showhide = ( show || mode === "hide" ),
- // showing or hiding adds an extra "half" animation
+ // showing or hiding leaves of the "last" animation
anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
duration = o.duration / anims,
animateTo = 0,
@@ -27,7 +28,7 @@ $.effects.effect.pulsate = function( o ) {
queuelen = queue.length,
i;
- if ( show ) {
+ if ( show || !elem.is(':visible')) {
elem.css( "opacity", 0 ).show();
animateTo = 1;
}
@@ -42,19 +43,22 @@ $.effects.effect.pulsate = function( o ) {
elem.animate({
opacity: animateTo
- }, duration, o.easing, function() {
- if ( animateTo === 0 ) {
+ }, duration, o.easing);
+
+ elem.queue( function( next ) {
+ if ( hide ) {
elem.hide();
}
if ( o.complete ) {
o.complete.apply( this );
}
+ next();
});
// We just queued up "anims" animations, we need to put them next in the queue
if ( queuelen > 1) {
queue.splice.apply( queue,
- [ 1, 0 ].concat( queue.splice( queuelen, anims ) ) );
+ [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
}
next();
});
diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js
index 8f25ca9a8..843aa2241 100644
--- a/ui/jquery.effects.scale.js
+++ b/ui/jquery.effects.scale.js
@@ -25,6 +25,7 @@ $.effects.effect.puff = function( o ) {
$.extend(o, {
effect: 'scale',
+ queue: false,
fade: true,
mode: mode,
percent: mode == 'hide' ? percent : 100,
@@ -36,13 +37,13 @@ $.effects.effect.puff = function( o ) {
}
});
- elem.effect( o ).dequeue();
+ elem.effect( o );
});
};
$.effects.effect.scale = function( o ) {
- return this.queue( function() {
+ return this[ o.queue === false ? "each" : "queue" ]( function() {
// Create element
var el = $( this ),
@@ -62,6 +63,7 @@ $.effects.effect.scale = function( o ) {
// We are going to pass this effect to the size effect:
options.effect = "size";
+ options.queue = false;
// Set default origin and restore for show/hide
if ( mode != 'effect' ) {
@@ -87,14 +89,14 @@ $.effects.effect.scale = function( o ) {
};
// Animate
- el.effect(options).dequeue();
+ el.effect(options);
});
};
$.effects.effect.size = function( o ) {
- return this.queue( function() {
+ return this[ o.queue === false ? "each" : "queue" ]( function() {
// Create element
var el = $( this ),
props = [ 'position', 'top', 'bottom', 'left', 'right', 'width', 'height', 'overflow', 'opacity' ],
diff --git a/ui/jquery.effects.shake.js b/ui/jquery.effects.shake.js
index a1ba1577c..550329ca4 100644
--- a/ui/jquery.effects.shake.js
+++ b/ui/jquery.effects.shake.js
@@ -17,46 +17,60 @@ $.effects.effect.shake = function( o ) {
return this.queue( function() {
var el = $( this ),
- props = [ 'position', 'top', 'bottom', 'left', 'right' ],
- mode = $.effects.setMode( el, o.mode || 'effect' ),
- direction = o.direction || 'left',
+ props = [ "position", "top", "bottom", "left", "right" ],
+ mode = $.effects.setMode( el, o.mode || "effect" ),
+ direction = o.direction || "left",
distance = o.distance || 20,
times = o.times || 3,
- speed = o.duration || 140,
- ref = (direction == 'up' || direction == 'down') ? 'top' : 'left',
- motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg',
+ anims = times * 2 + 1,
+ speed = o.duration,
+ ref = (direction == "up" || direction == "down") ? "top" : "left",
+ motion = (direction == "up" || direction == "left") ? "pos" : "neg",
animation = {},
animation1 = {},
animation2 = {},
- i;
+ i,
- // Adjust
- $.effects.save( el, props );
- el.show();
- $.effects.createWrapper( el ); // Create Wrapper
+ // we will need to re-assemble the queue to stack our animations in place
+ queue = el.queue(),
+ queuelen = queue.length;
+
+
+ $.effects.save( el, props );
+ el.show();
+ $.effects.createWrapper( el );
// Animation
- animation[ ref ] = ( motion == 'pos' ? '-=' : '+=' ) + distance;
- animation1[ ref ] = ( motion == 'pos' ? '+=' : '-=' ) + distance * 2;
- animation2[ ref ] = ( motion == 'pos' ? '-=' : '+=' ) + distance * 2;
+ animation[ ref ] = ( motion == "pos" ? "-=" : "+=" ) + distance;
+ animation1[ ref ] = ( motion == "pos" ? "+=" : "-=" ) + distance * 2;
+ animation2[ ref ] = ( motion == "pos" ? "-=" : "+=" ) + distance * 2;
// Animate
el.animate( animation, speed, o.easing );
// Shakes
- for ( i = 1; i < times; i++ ) {
+ for ( i = 1; i < times; i++ ) {
el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
};
el
.animate( animation1, speed, o.easing )
- .animate( animation, speed / 2, o.easing, function() {
+ .animate( animation, speed / 2, o.easing )
+ .queue( function( next ) {
+ if ( mode === "hide" ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ $.isFunction( o.complete ) && o.complete.apply( this, arguments );
+ next();
+ });
- // Last shake
- $.effects.restore( el, props );
- $.effects.removeWrapper( el );
- $.isFunction( o.complete ) && o.complete.apply( this, arguments );
- })
- .dequeue();
+ // inject all the animations we just queued to be first in line (after "inprogress")
+ if ( queuelen > 1) {
+ queue.splice.apply( queue,
+ [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
+ }
+ el.dequeue();
});
};
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index 0cc1f9e2a..c6b33befb 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -486,9 +486,11 @@ $.extend( $.ui.accordion, {
$.each( fxAttrs, function( i, prop ) {
hideProps[ prop ] = "hide";
- var parts = ( "" + $.css( options.toShow[0], prop ) ).match( /^([\d+-.]+)(.*)$/ );
+ var parts = ( "" + $.css( options.toShow[0], prop ) ).match( /^([\d+-.]+)(.*)$/ ),
+ // work around bug when a panel has no height - #7335
+ propVal = prop === "height" && parts[ 1 ] === "0" ? 1 : parts[ 1 ];
showProps[ prop ] = {
- value: parts[ 1 ],
+ value: propVal,
unit: parts[ 2 ] || "px"
};
});
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 4be4774d9..f6573174a 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -380,7 +380,6 @@ $.widget( "ui.autocomplete", {
this.menu.element.hide();
this.menu.blur();
this._trigger( "close", event );
- this.menu.isNewMenu = true;
}
},
diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js
index 031ac2091..a95dddc6c 100644
--- a/ui/jquery.ui.button.js
+++ b/ui/jquery.ui.button.js
@@ -13,17 +13,15 @@
*/
(function( $, undefined ) {
-var lastActive,
+var lastActive, startXPos, startYPos, clickDragged,
baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
stateClasses = "ui-state-hover ui-state-active ",
typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
- formResetHandler = function( event ) {
- $( ":ui-button", event.target.form ).each(function() {
- var inst = $( this ).data( "button" );
- setTimeout(function() {
- inst.refresh();
- }, 1 );
- });
+ formResetHandler = function() {
+ var buttons = $( this ).find( ":ui-button" );
+ setTimeout(function() {
+ buttons.button( "refresh" );
+ }, 1 );
},
radioGroup = function( radio ) {
var name = radio.name,
@@ -112,13 +110,36 @@ $.widget( "ui.button", {
if ( toggleButton ) {
this.element.bind( "change.button", function() {
+ if ( clickDragged ) {
+ return;
+ }
self.refresh();
});
+ // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
+ // prevents issue where button state changes but checkbox/radio checked state
+ // does not in Firefox (see ticket #6970)
+ this.buttonElement
+ .bind( "mousedown.button", function( event ) {
+ if ( options.disabled ) {
+ return;
+ }
+ clickDragged = false;
+ startXPos = event.pageX;
+ startYPos = event.pageY;
+ })
+ .bind( "mouseup.button", function( event ) {
+ if ( options.disabled ) {
+ return;
+ }
+ if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
+ clickDragged = true;
+ }
+ });
}
if ( this.type === "checkbox" ) {
this.buttonElement.bind( "click.button", function() {
- if ( options.disabled ) {
+ if ( options.disabled || clickDragged ) {
return false;
}
$( this ).toggleClass( "ui-state-active" );
@@ -126,7 +147,7 @@ $.widget( "ui.button", {
});
} else if ( this.type === "radio" ) {
this.buttonElement.bind( "click.button", function() {
- if ( options.disabled ) {
+ if ( options.disabled || clickDragged ) {
return false;
}
$( this ).addClass( "ui-state-active" );
@@ -185,6 +206,7 @@ $.widget( "ui.button", {
// $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
// be overridden by individual plugins
this._setOption( "disabled", options.disabled );
+ this._resetButton();
},
_determineButtonType: function() {
@@ -250,6 +272,7 @@ $.widget( "ui.button", {
} else {
this.element.removeAttr( "disabled" );
}
+ return;
}
this._resetButton();
},
@@ -352,6 +375,8 @@ $.widget( "ui.buttonset", {
},
refresh: function() {
+ var ltr = this.element.css( "direction" ) === "ltr";
+
this.buttons = this.element.find( this.options.items )
.filter( ":ui-button" )
.button( "refresh" )
@@ -364,10 +389,10 @@ $.widget( "ui.buttonset", {
})
.removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
.filter( ":first" )
- .addClass( "ui-corner-left" )
+ .addClass( ltr ? "ui-corner-left" : "ui-corner-right" )
.end()
.filter( ":last" )
- .addClass( "ui-corner-right" )
+ .addClass( ltr ? "ui-corner-right" : "ui-corner-left" )
.end()
.end();
},
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index 12323672a..4c73bdfd8 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -364,6 +364,8 @@ $.extend(Datepicker.prototype, {
else if (nodeName == 'div' || nodeName == 'span') {
var inline = $target.children('.' + this._inlineClass);
inline.children().removeClass('ui-state-disabled');
+ inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
+ removeAttr("disabled");
}
this._disabledInputs = $.map(this._disabledInputs,
function(value) { return (value == target ? null : value); }); // delete entry
@@ -387,6 +389,8 @@ $.extend(Datepicker.prototype, {
else if (nodeName == 'div' || nodeName == 'span') {
var inline = $target.children('.' + this._inlineClass);
inline.children().addClass('ui-state-disabled');
+ inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
+ attr("disabled", "disabled");
}
this._disabledInputs = $.map(this._disabledInputs,
function(value) { return (value == target ? null : value); }); // delete entry
@@ -455,7 +459,8 @@ $.extend(Datepicker.prototype, {
inst.settings.maxDate = this._formatDate(inst, maxDate);
this._attachments($(target), inst);
this._autoSize(inst);
- this._setDateDatepicker(target, date);
+ this._setDate(inst, date);
+ this._updateAlternate(inst);
this._updateDatepicker(inst);
}
},
@@ -609,6 +614,9 @@ $.extend(Datepicker.prototype, {
return;
var inst = $.datepicker._getInst(input);
if ($.datepicker._curInst && $.datepicker._curInst != inst) {
+ if ( $.datepicker._datepickerShowing ) {
+ $.datepicker._triggerOnClose($.datepicker._curInst);
+ }
$.datepicker._curInst.dpDiv.stop(true, true);
}
var beforeShow = $.datepicker._get(inst, 'beforeShow');
@@ -702,7 +710,7 @@ $.extend(Datepicker.prototype, {
var origyearshtml = inst.yearshtml;
setTimeout(function(){
//assure that inst.yearshtml didn't change.
- if( origyearshtml === inst.yearshtml ){
+ if( origyearshtml === inst.yearshtml && inst.yearshtml ){
inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
}
origyearshtml = inst.yearshtml = null;
@@ -754,6 +762,14 @@ $.extend(Datepicker.prototype, {
return [position.left, position.top];
},
+ /* Trigger custom callback of onClose. */
+ _triggerOnClose: function(inst) {
+ var onClose = this._get(inst, 'onClose');
+ if (onClose)
+ onClose.apply((inst.input ? inst.input[0] : null),
+ [(inst.input ? inst.input.val() : ''), inst]);
+ },
+
/* Hide the date picker from view.
@param input element - the input field attached to the date picker */
_hideDatepicker: function(input) {
@@ -776,10 +792,7 @@ $.extend(Datepicker.prototype, {
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
if (!showAnim)
postProcess();
- var onClose = this._get(inst, 'onClose');
- if (onClose)
- onClose.apply((inst.input ? inst.input[0] : null),
- [(inst.input ? inst.input.val() : ''), inst]); // trigger custom callback
+ $.datepicker._triggerOnClose(inst);
this._datepickerShowing = false;
this._lastInput = null;
if (this._inDialog) {
@@ -1069,6 +1082,9 @@ $.extend(Datepicker.prototype, {
checkLiteral();
}
}
+ if (iValue < value.length){
+ throw "Extra/unparsed characters found in date: " + value.substring(iValue);
+ }
if (year == -1)
year = new Date().getFullYear();
else if (year < 100)
@@ -1180,7 +1196,7 @@ $.extend(Datepicker.prototype, {
break;
case 'o':
output += formatNumber('o',
- (date.getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000, 3);
+ Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
break;
case 'm':
output += formatNumber('m', date.getMonth() + 1, 2);
@@ -1601,14 +1617,9 @@ $.extend(Datepicker.prototype, {
'>' + year + '</option>';
}
inst.yearshtml += '</select>';
- //when showing there is no need for later update
- if( ! $.browser.mozilla ){
- html += inst.yearshtml;
- inst.yearshtml = null;
- } else {
- // will be replaced later with inst.yearshtml
- html += '<select class="ui-datepicker-year"><option value="' + drawYear + '" selected="selected">' + drawYear + '</option></select>';
- }
+
+ html += inst.yearshtml;
+ inst.yearshtml = null;
}
}
html += this._get(inst, 'yearSuffix');
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index 2138a9a58..dc2849155 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -281,10 +281,10 @@ $.widget("ui.dialog", {
options = self.options,
uiDialog = self.uiDialog;
- self.overlay = options.modal ? new $.ui.dialog.overlay( self ) : null;
self._size();
self._position( options.position );
uiDialog.show( options.show );
+ self.overlay = options.modal ? new $.ui.dialog.overlay( self ) : null;
self.moveToTop( true );
// prevent tabbing out of modal dialogs
@@ -742,7 +742,7 @@ $.extend( $.ui.dialog.overlay, {
$( [ document, window ] ).unbind( ".dialog-overlay" );
}
- $el.remove();
+ $el.height( 0 ).width( 0 ).remove();
// adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
var maxZ = 0;
@@ -755,8 +755,8 @@ $.extend( $.ui.dialog.overlay, {
height: function() {
var scrollHeight,
offsetHeight;
- // handle IE 6
- if ( $.browser.msie && $.browser.version < 7 ) {
+ // handle IE
+ if ( $.browser.msie ) {
scrollHeight = Math.max(
document.documentElement.scrollHeight,
document.body.scrollHeight
@@ -780,8 +780,8 @@ $.extend( $.ui.dialog.overlay, {
width: function() {
var scrollWidth,
offsetWidth;
- // handle IE 6
- if ( $.browser.msie && $.browser.version < 7 ) {
+ // handle IE
+ if ( $.browser.msie ) {
scrollWidth = Math.max(
document.documentElement.scrollWidth,
document.body.scrollWidth
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js
index 774ea4380..c16833eb0 100644
--- a/ui/jquery.ui.draggable.js
+++ b/ui/jquery.ui.draggable.js
@@ -261,7 +261,7 @@ $.widget("ui.draggable", $.ui.mouse, {
_createHelper: function(event) {
var o = this.options;
- var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element);
+ var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
if(!helper.parents('body').length)
helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
@@ -355,8 +355,8 @@ $.widget("ui.draggable", $.ui.mouse, {
var o = this.options;
if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
if(o.containment == 'document' || o.containment == 'window') this.containment = [
- (o.containment == 'document' ? 0 : $(window).scrollLeft()) - this.offset.relative.left - this.offset.parent.left,
- (o.containment == 'document' ? 0 : $(window).scrollTop()) - this.offset.relative.top - this.offset.parent.top,
+ o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
+ o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
(o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
(o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
];
@@ -436,10 +436,11 @@ $.widget("ui.draggable", $.ui.mouse, {
}
if(o.grid) {
- var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
+ //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
+ var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
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];
+ var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
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;
}
@@ -580,7 +581,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
//Now we fake the start of dragging for the sortable instance,
//by cloning the list group item, appending it to the sortable and using it as inst.currentItem
//We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
- this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
+ this.instance.currentItem = $(self).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
this.instance.options.helper = function() { return ui.helper[0]; };
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index 3cc25062c..41b2e7a1a 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -18,7 +18,6 @@ var idIncrement = 0;
$.widget("ui.menu", {
defaultElement: "<ul>",
delay: 150,
- isNewMenu: true,
options: {
position: {
my: "left top",
@@ -46,8 +45,6 @@ $.widget("ui.menu", {
if ( !item.length ) {
return;
}
- // temporary
- event.preventDefault();
// it's possible to click an item without hovering it (#7085)
if ( !self.active || ( self.active[ 0 ] !== item[ 0 ] ) ) {
self.focus( event, item );
@@ -55,8 +52,7 @@ $.widget("ui.menu", {
self.select( event );
})
.bind( "mouseover.menu", function( event ) {
- if ( self.options.disabled || self.isNewMenu ) {
- self.isNewMenu = false;
+ if ( self.options.disabled ) {
return;
}
var target = $( event.target ).closest( ".ui-menu-item" );
@@ -237,15 +233,15 @@ $.widget("ui.menu", {
if ( this._hasScroll() ) {
var borderTop = parseFloat( $.curCSS( this.element[0], "borderTopWidth", true) ) || 0,
- paddingtop = parseFloat( $.curCSS( this.element[0], "paddingTop", true) ) || 0,
- offset = item.offset().top - this.element.offset().top - borderTop - paddingtop,
- scroll = this.element.attr( "scrollTop" ),
+ paddingTop = parseFloat( $.curCSS( this.element[0], "paddingTop", true) ) || 0,
+ offset = item.offset().top - this.element.offset().top - borderTop - paddingTop,
+ scroll = this.element.scrollTop(),
elementHeight = this.element.height(),
itemHeight = item.height();
if ( offset < 0 ) {
- this.element.attr( "scrollTop", scroll + offset );
+ this.element.scrollTop( scroll + offset );
} else if ( offset + itemHeight > elementHeight ) {
- this.element.attr( "scrollTop", scroll + offset - elementHeight + itemHeight );
+ this.element.scrollTop( scroll + offset - elementHeight + itemHeight );
}
}
@@ -410,7 +406,8 @@ $.widget("ui.menu", {
},
_hasScroll: function() {
- return this.element.height() < this.element.attr( "scrollHeight" );
+ // TODO: just use .prop() when we drop support for jQuery <1.6
+ return this.element.height() < this.element[ $.fn.prop ? "prop" : "attr" ]( "scrollHeight" );
},
select: function( event ) {
diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js
index eb6545f62..f0b01d7c0 100644
--- a/ui/jquery.ui.slider.js
+++ b/ui/jquery.ui.slider.js
@@ -36,7 +36,11 @@ $.widget( "ui.slider", $.ui.mouse, {
_create: function() {
var self = this,
- o = this.options;
+ o = this.options,
+ existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
+ handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
+ handleCount = ( o.values && o.values.length ) || 1,
+ handles = [];
this._keySliding = false;
this._mouseSliding = false;
@@ -50,57 +54,35 @@ $.widget( "ui.slider", $.ui.mouse, {
" ui-slider-" + this.orientation +
" ui-widget" +
" ui-widget-content" +
- " ui-corner-all" );
-
- if ( o.disabled ) {
- this.element.addClass( "ui-slider-disabled ui-disabled" );
- }
+ " ui-corner-all" +
+ ( o.disabled ? " ui-slider-disabled ui-disabled" : "" ) );
this.range = $([]);
if ( o.range ) {
if ( o.range === true ) {
- this.range = $( "<div></div>" );
if ( !o.values ) {
o.values = [ this._valueMin(), this._valueMin() ];
}
if ( o.values.length && o.values.length !== 2 ) {
o.values = [ o.values[0], o.values[0] ];
}
- } else {
- this.range = $( "<div></div>" );
- }
-
- this.range
- .appendTo( this.element )
- .addClass( "ui-slider-range" );
-
- if ( o.range === "min" || o.range === "max" ) {
- this.range.addClass( "ui-slider-range-" + o.range );
}
- // note: this isn't the most fittingly semantic framework class for this element,
- // but worked best visually with a variety of themes
- this.range.addClass( "ui-widget-header" );
- }
-
- if ( $( ".ui-slider-handle", this.element ).length === 0 ) {
- $( "<a href='#'></a>" )
+ this.range = $( "<div></div>" )
.appendTo( this.element )
- .addClass( "ui-slider-handle" );
+ .addClass( "ui-slider-range" +
+ // note: this isn't the most fittingly semantic framework class for this element,
+ // but worked best visually with a variety of themes
+ " ui-widget-header" +
+ ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) );
}
- if ( o.values && o.values.length ) {
- while ( $(".ui-slider-handle", this.element).length < o.values.length ) {
- $( "<a href='#'></a>" )
- .appendTo( this.element )
- .addClass( "ui-slider-handle" );
- }
+ for ( var i = existingHandles.length; i < handleCount; i += 1 ) {
+ handles.push( handle );
}
- this.handles = $( ".ui-slider-handle", this.element )
- .addClass( "ui-state-default" +
- " ui-corner-all" );
+ this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( self.element ) );
this.handle = this.handles.eq( 0 );
diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js
index b8cca7dcd..2709175b5 100644
--- a/ui/jquery.ui.spinner.js
+++ b/ui/jquery.ui.spinner.js
@@ -11,11 +11,11 @@
* jquery.ui.core.js
* jquery.ui.widget.js
*/
-(function($) {
+(function( $ ) {
-$.widget('ui.spinner', {
+$.widget( "ui.spinner", {
defaultElement: "<input>",
- widgetEventPrefix: "spin",
+ widgetEventPrefix: "spin",
options: {
incremental: true,
max: null,
@@ -25,218 +25,227 @@ $.widget('ui.spinner', {
step: null,
value: null
},
-
+
_create: function() {
this._draw();
this._markupOptions();
this._mousewheel();
this._aria();
},
-
+
_markupOptions: function() {
- var _this = this;
+ var that = this;
$.each({
min: -Number.MAX_VALUE,
max: Number.MAX_VALUE,
step: 1
- }, function(attr, defaultValue) {
- if (_this.options[attr] === null) {
- var value = _this.element.attr(attr);
- _this.options[attr] = typeof value == "string" && value.length > 0 ? _this._parse(value) : defaultValue;
+ }, function( attr, defaultValue ) {
+ if ( that.options[ attr ] === null ) {
+ var value = that.element.attr( attr );
+ that.options[ attr ] = typeof value === "string" && value.length > 0 ?
+ that._parse( value ) :
+ defaultValue;
}
});
- this.value(this.options.value !== null ? this.options.value : this.element.val() || 0);
+ this.value( this.options.value !== null ? this.options.value : this.element.val() || 0 );
},
-
+
_draw: function() {
var self = this,
options = self.options;
var uiSpinner = this.uiSpinner = self.element
- .addClass('ui-spinner-input')
- .attr('autocomplete', 'off')
- .wrap(self._uiSpinnerHtml())
+ .addClass( "ui-spinner-input" )
+ .attr( "autocomplete", "off" )
+ .wrap( self._uiSpinnerHtml() )
.parent()
// add buttons
- .append(self._buttonHtml())
+ .append( self._buttonHtml() )
// add behaviours
+ // TODO: user ._hoverable
.hover(function() {
- if (!options.disabled) {
- $(this).addClass('ui-state-hover');
+ if ( !options.disabled ) {
+ $( this ).addClass( "ui-state-hover" );
}
self.hovered = true;
}, function() {
- $(this).removeClass('ui-state-hover');
+ $( this ).removeClass( "ui-state-hover" );
self.hovered = false;
});
+ // TODO: use ._bind()
this.element
.attr( "role", "spinbutton" )
- .bind('keydown.spinner', function(event) {
- if (self.options.disabled) {
+ .bind( "keydown.spinner", function( event ) {
+ if ( options.disabled ) {
return;
}
- if (self._start(event)) {
- return self._keydown(event);
+ if ( self._start( event ) ) {
+ return self._keydown( event );
}
return true;
})
- .bind('keyup.spinner', function(event) {
- if (self.options.disabled) {
+ .bind( "keyup.spinner", function( event ) {
+ if ( options.disabled ) {
return;
}
- if (self.spinning) {
- self._stop(event);
- self._change(event);
+ if ( self.spinning ) {
+ self._stop( event );
+ self._change( event );
}
})
- .bind('focus.spinner', function() {
- uiSpinner.addClass('ui-state-active');
+ .bind( "focus.spinner", function() {
+ uiSpinner.addClass( "ui-state-active" );
self.focused = true;
})
- .bind('blur.spinner', function(event) {
- self.value(self.element.val());
- if (!self.hovered) {
- uiSpinner.removeClass('ui-state-active');
- }
+ .bind( "blur.spinner", function( event ) {
+ self.value( self.element.val() );
+ if ( !self.hovered ) {
+ uiSpinner.removeClass( "ui-state-active" );
+ }
self.focused = false;
});
// button bindings
- this.buttons = uiSpinner.find('.ui-spinner-button')
- .attr("tabIndex", -1)
+ this.buttons = uiSpinner.find( ".ui-spinner-button" )
+ .attr( "tabIndex", -1 )
.button()
- .removeClass("ui-corner-all")
- .bind('mousedown', function(event) {
- if (self.options.disabled) {
+ .removeClass( "ui-corner-all" )
+ .bind( "mousedown", function( event ) {
+ if ( options.disabled ) {
return;
}
- if (self._start(event) === false) {
+ if ( self._start( event ) === false ) {
return false;
}
- self._repeat(null, $(this).hasClass('ui-spinner-up') ? 1 : -1, event);
+ self._repeat( null, $( this ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
})
- .bind('mouseup', function(event) {
- if (self.options.disabled) {
+ .bind( "mouseup", function( event ) {
+ if ( options.disabled ) {
return;
}
- if (self.spinning) {
- self._stop(event);
- self._change(event);
+ if ( self.spinning ) {
+ self._stop( event );
+ self._change( event );
}
})
- .bind("mouseenter", function() {
- if (self.options.disabled) {
+ .bind( "mouseenter", function() {
+ if ( self.options.disabled ) {
return;
}
// button will add ui-state-active if mouse was down while mouseleave and kept down
- if ($(this).hasClass("ui-state-active")) {
- if (self._start(event) === false) {
+ if ( $( this ).hasClass( "ui-state-active" ) ) {
+ if ( self._start( event ) === false ) {
return false;
}
- self._repeat(null, $(this).hasClass('ui-spinner-up') ? 1 : -1, event);
+ self._repeat( null, $( this ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
}
})
- .bind("mouseleave", function() {
- if (self.spinning) {
- self._stop(event);
- self._change(event);
+ .bind( "mouseleave", function() {
+ if ( self.spinning ) {
+ self._stop( event );
+ self._change( event );
}
});
-
+
// disable spinner if element was already disabled
- if (options.disabled) {
+ if ( options.disabled ) {
this.disable();
}
},
-
- _keydown: function(event) {
- var o = this.options,
- KEYS = $.ui.keyCode;
-
- switch (event.keyCode) {
- case KEYS.UP:
- this._repeat(null, 1, event);
+
+ _keydown: function( event ) {
+ var options = this.options,
+ keyCode = $.ui.keyCode;
+
+ switch ( event.keyCode ) {
+ case keyCode.UP:
+ this._repeat( null, 1, event );
return false;
- case KEYS.DOWN:
- this._repeat(null, -1, event);
+ case keyCode.DOWN:
+ this._repeat( null, -1, event );
return false;
- case KEYS.PAGE_UP:
- this._repeat(null, this.options.page, event);
+ case keyCode.PAGE_UP:
+ this._repeat( null, options.page, event );
return false;
- case KEYS.PAGE_DOWN:
- this._repeat(null, -this.options.page, event);
+ case keyCode.PAGE_DOWN:
+ this._repeat( null, -options.page, event );
return false;
-
- case KEYS.ENTER:
- this.value(this.element.val());
+ case keyCode.ENTER:
+ this.value( this.element.val() );
}
-
+
return true;
},
-
+
_mousewheel: function() {
// need the delta normalization that mousewheel plugin provides
- if (!$.fn.mousewheel) {
+ if ( !$.fn.mousewheel ) {
return;
}
var self = this;
- this.element.bind("mousewheel.spinner", function(event, delta) {
- if (self.options.disabled || !delta) {
+ this.element.bind( "mousewheel.spinner", function( event, delta ) {
+ if ( self.options.disabled || !delta ) {
return;
}
- if (!self.spinning && !self._start(event)) {
+ if ( !self.spinning && !self._start( event ) ) {
return false;
}
- self._spin((delta > 0 ? 1 : -1) * self.options.step, event);
- clearTimeout(self.timeout);
+ self._spin( (delta > 0 ? 1 : -1) * self.options.step, event );
+ clearTimeout( self.timeout );
self.timeout = setTimeout(function() {
- if (self.spinning) {
- self._stop(event);
- self._change(event);
+ if ( self.spinning ) {
+ self._stop( event );
+ self._change( event );
}
}, 100);
event.preventDefault();
});
},
-
+
_uiSpinnerHtml: function() {
- return '<span class="ui-spinner ui-state-default ui-widget ui-widget-content ui-corner-all"></span>';
+ return "<span class='ui-spinner ui-state-default ui-widget ui-widget-content ui-corner-all'></span>";
},
-
+
_buttonHtml: function() {
- return '<a class="ui-spinner-button ui-spinner-up ui-corner-tr"><span class="ui-icon ui-icon-triangle-1-n">&#9650;</span></a>' +
- '<a class="ui-spinner-button ui-spinner-down ui-corner-br"><span class="ui-icon ui-icon-triangle-1-s">&#9660;</span></a>';
+ return "" +
+ "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
+ "<span class='ui-icon ui-icon-triangle-1-n'>&#9650;</span>" +
+ "</a>" +
+ "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
+ "<span class='ui-icon ui-icon-triangle-1-s'>&#9660;</span>" +
+ "</a>";
},
-
- _start: function(event) {
- if (!this.spinning && this._trigger('start', event) !== false) {
- if (!this.counter) {
- this.counter = 1;
- }
- this.spinning = true;
- return true;
+
+ _start: function( event ) {
+ if ( !this.spinning && this._trigger( "start", event ) === false ) {
+ return false;
+ }
+
+ if ( !this.counter ) {
+ this.counter = 1;
}
- return false;
+ this.spinning = true;
+ return true;
},
-
- _repeat: function(i, steps, event) {
+
+ _repeat: function( i, steps, event ) {
var self = this;
i = i || 500;
- clearTimeout(this.timer);
+ clearTimeout( this.timer );
this.timer = setTimeout(function() {
- self._repeat(40, steps, event);
- }, i);
-
- self._spin(steps * self.options.step, event);
+ self._repeat( 40, steps, event );
+ }, i );
+
+ self._spin( steps * self.options.step, event );
},
-
- _spin: function(step, event) {
- if (!this.counter) {
+
+ _spin: function( step, event ) {
+ if ( !this.counter ) {
this.counter = 1;
}
-
+
// TODO refactor, maybe figure out some non-linear math
var newVal = this.value() + step * (this.options.incremental &&
this.counter > 20
@@ -246,49 +255,51 @@ $.widget('ui.spinner', {
: 10
: 2
: 1);
-
- if (this._trigger('spin', event, { value: newVal }) !== false) {
- this.value(newVal);
- this.counter++;
+
+ if ( this._trigger( "spin", event, { value: newVal } ) !== false) {
+ this.value( newVal );
+ this.counter++;
}
},
-
- _stop: function(event) {
+
+ _stop: function( event ) {
this.counter = 0;
- if (this.timer) {
- window.clearTimeout(this.timer);
+ if ( this.timer ) {
+ clearTimeout( this.timer );
}
this.element.focus();
this.spinning = false;
- this._trigger('stop', event);
+ this._trigger( "stop", event );
},
-
- _change: function(event) {
- this._trigger('change', event);
+
+ _change: function( event ) {
+ this._trigger( "change", event );
},
-
- _setOption: function(key, value) {
- if (key == 'value') {
- value = this._parse(value);
- if (value < this.options.min) {
+
+ _setOption: function( key, value ) {
+ if ( key === "value") {
+ value = this._parse( value );
+ if ( value < this.options.min ) {
value = this.options.min;
}
- if (value > this.options.max) {
+ if ( value > this.options.max ) {
value = this.options.max;
}
}
- if (key == 'disabled') {
- if (value) {
- this.element.attr("disabled", true);
- this.buttons.button("disable");
+
+ if ( key === "disabled" ) {
+ if ( value ) {
+ this.element.attr( "disabled", true );
+ this.buttons.button( "disable" );
} else {
- this.element.removeAttr("disabled");
- this.buttons.button("enable");
+ this.element.removeAttr( "disabled" );
+ this.buttons.button( "enable" );
}
}
+
this._super( "_setOption", key, value );
},
-
+
_setOptions: function( options ) {
this._super( "_setOptions", options );
if ( "value" in options ) {
@@ -296,62 +307,62 @@ $.widget('ui.spinner', {
}
this._aria();
},
-
+
_aria: function() {
- this.element
- .attr('aria-valuemin', this.options.min)
- .attr('aria-valuemax', this.options.max)
- .attr('aria-valuenow', this.options.value);
+ this.element.attr({
+ "aria-valuemin": this.options.min,
+ "aria-valuemax": this.options.max,
+ "aria-valuenow": this.options.value
+ });
},
-
- _parse: function(val) {
- var input = val;
- if (typeof val == 'string') {
- val = $.global && this.options.numberformat ? $.global.parseFloat(val) : +val;
+
+ _parse: function( val ) {
+ if ( typeof val === "string" ) {
+ val = $.global && this.options.numberformat ? $.global.parseFloat( val ) : +val;
}
- return isNaN(val) ? null : val;
+ return isNaN( val ) ? null : val;
},
-
- _format: function(num) {
- this.element.val( $.global && this.options.numberformat ? $.global.format(num, this.options.numberformat) : num );
+
+ _format: function( num ) {
+ this.element.val( $.global && this.options.numberformat ? $.global.format( num, this.options.numberformat ) : num );
},
-
+
destroy: function() {
this.element
- .removeClass('ui-spinner-input')
- .removeAttr('disabled')
- .removeAttr('autocomplete')
- .removeAttr('role')
- .removeAttr('aria-valuemin')
- .removeAttr('aria-valuemax')
- .removeAttr('aria-valuenow');
+ .removeClass( "ui-spinner-input" )
+ .removeAttr( "disabled" )
+ .removeAttr( "autocomplete" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-valuemin" )
+ .removeAttr( "aria-valuemax" )
+ .removeAttr( "aria-valuenow" );
this._super( "destroy" );
- this.uiSpinner.replaceWith(this.element);
+ this.uiSpinner.replaceWith( this.element );
},
-
- stepUp: function(steps) {
- this._spin((steps || 1) * this.options.step);
+
+ stepUp: function( steps ) {
+ this._spin( (steps || 1) * this.options.step );
},
-
- stepDown: function(steps) {
- this._spin((steps || 1) * -this.options.step);
+
+ stepDown: function( steps ) {
+ this._spin( (steps || 1) * -this.options.step );
},
-
- pageUp: function(pages) {
- this.stepUp((pages || 1) * this.options.page);
+
+ pageUp: function( pages ) {
+ this.stepUp( (pages || 1) * this.options.page );
},
-
- pageDown: function(pages) {
- this.stepDown((pages || 1) * this.options.page);
+
+ pageDown: function( pages ) {
+ this.stepDown( (pages || 1) * this.options.page );
},
-
- value: function(newVal) {
- if (!arguments.length) {
- return this._parse(this.element.val());
+
+ value: function( newVal ) {
+ if ( !arguments.length ) {
+ return this._parse( this.element.val() );
}
- this.option('value', newVal);
+ this.option( "value", newVal );
},
-
+
widget: function() {
return this.uiSpinner;
}
@@ -359,4 +370,4 @@ $.widget('ui.spinner', {
$.ui.spinner.version = "@VERSION";
-})(jQuery);
+}( jQuery ) );
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js
index cce50d3e7..239805b14 100644
--- a/ui/jquery.ui.tabs.js
+++ b/ui/jquery.ui.tabs.js
@@ -13,17 +13,11 @@
*/
(function( $, undefined ) {
-var tabId = 0,
- listId = 0;
-
+var tabId = 0;
function getNextTabId() {
return ++tabId;
}
-function getNextListId() {
- return ++listId;
-}
-
$.widget( "ui.tabs", {
options: {
active: null,
@@ -150,7 +144,7 @@ $.widget( "ui.tabs", {
_sanitizeSelector: function( hash ) {
// we need this because an id may contain a ":"
- return hash ? hash.replace( /:/g, "\\:" ) : "";
+ return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@[\]^`{|}~]/g, "\\$&" ) : "";
},
refresh: function() {
@@ -292,61 +286,13 @@ $.widget( "ui.tabs", {
}
},
- // Reset certain styles left over from animation
- // and prevent IE's ClearType bug...
+ // TODO: remove once jQuery core properly removes filters - see #4621
_resetStyle: function ( $el, fx ) {
- $el.css( "display", "" );
if ( !$.support.opacity && fx.opacity ) {
$el[ 0 ].style.removeAttribute( "filter" );
}
},
- _showTab: function( event, eventData ) {
- var that = this;
-
- $( eventData.newTab ).closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
-
- if ( that.showFx ) {
- that.running = true;
- eventData.newPanel
- // TODO: why are we hiding? old code?
- .hide()
- .animate( that.showFx, that.showFx.duration || "normal", function() {
- that._resetStyle( $( this ), that.showFx );
- that.running = false;
- that._trigger( "activate", event, eventData );
- });
- } else {
- eventData.newPanel.show();
- that._trigger( "activate", event, eventData );
- }
- },
-
- // TODO: combine with _showTab()
- _hideTab: function( event, eventData ) {
- var that = this;
-
- if ( that.hideFx ) {
- that.running = true;
- eventData.oldPanel.animate( that.hideFx, that.hideFx.duration || "normal", function() {
- that.running = false;
- eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
- that._resetStyle( $( this ), that.hideFx );
- that.element.dequeue( "tabs" );
- if ( !eventData.newPanel.length ) {
- that._trigger( "activate", event, eventData );
- }
- });
- } else {
- eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
- eventData.oldPanel.hide();
- that.element.dequeue( "tabs" );
- if ( !eventData.newPanel.length ) {
- that._trigger( "activate", event, eventData );
- }
- }
- },
-
_setupEvents: function( event ) {
// attach tab event handler, unbind to avoid duplicates from former tabifying...
this.anchors.unbind( ".tabs" );
@@ -401,52 +347,60 @@ $.widget( "ui.tabs", {
that.xhr.abort();
}
- // if tab may be closed
- if ( options.collapsible ) {
- if ( collapsing ) {
- options.active = false;
+ if ( !toHide.length && !toShow.length ) {
+ throw "jQuery UI Tabs: Mismatching fragment identifier.";
+ }
- that.element.queue( "tabs", function() {
- that._hideTab( event, eventData );
- }).dequeue( "tabs" );
+ if ( toShow.length ) {
- clicked[ 0 ].blur();
- return;
- } else if ( !toHide.length ) {
- that.element.queue( "tabs", function() {
- that._showTab( event, eventData );
- });
+ // TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171
+ that.load( that.anchors.index( clicked ), event );
- // TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171
- that.load( that.anchors.index( clicked ), event );
+ clicked[ 0 ].blur();
+ }
+ that._toggle( event, eventData );
+ },
- clicked[ 0 ].blur();
- return;
- }
+ // handles show/hide for selecting tabs
+ _toggle: function( event, eventData ) {
+ var that = this,
+ options = that.options,
+ toShow = eventData.newPanel,
+ toHide = eventData.oldPanel;
+
+ that.running = true;
+
+ function complete() {
+ that.running = false;
+ that._trigger( "activate", event, eventData );
}
- // show new tab
- if ( toShow.length ) {
- if ( toHide.length ) {
- that.element.queue( "tabs", function() {
- that._hideTab( event, eventData );
- });
- }
- that.element.queue( "tabs", function() {
- that._showTab( event, eventData );
- });
+ function show() {
+ eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
- that.load( that.anchors.index( clicked ), event );
- } else {
- throw "jQuery UI Tabs: Mismatching fragment identifier.";
+ if ( toShow.length && that.showFx ) {
+ toShow
+ .animate( that.showFx, that.showFx.duration || "normal", function() {
+ that._resetStyle( $( this ), that.showFx );
+ complete();
+ });
+ } else {
+ toShow.show();
+ complete();
+ }
}
- // Prevent IE from keeping other link focussed when using the back button
- // and remove dotted border from clicked link. This is controlled via CSS
- // in modern browsers; blur() removes focus from address bar in Firefox
- // which can become a usability
- if ( $.browser.msie ) {
- clicked[ 0 ].blur();
+ // start out by hiding, then showing, then completing
+ if ( toHide.length && that.hideFx ) {
+ toHide.animate( that.hideFx, that.hideFx.duration || "normal", function() {
+ eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
+ that._resetStyle( $( this ), that.hideFx );
+ show();
+ });
+ } else {
+ eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
+ toHide.hide();
+ show();
}
},
@@ -569,24 +523,19 @@ $.widget( "ui.tabs", {
load: function( index, event ) {
index = this._getIndex( index );
var self = this,
- o = this.options,
- a = this.anchors.eq( index )[ 0 ],
- panel = self._getPanelForTab( a ),
+ options = this.options,
+ anchor = this.anchors.eq( index ),
+ panel = self._getPanelForTab( anchor ),
// TODO until #3808 is fixed strip fragment identifier from url
// (IE fails to load from such url)
- url = $( a ).attr( "href" ).replace( /#.*$/, "" ),
+ url = anchor.attr( "href" ).replace( /#.*$/, "" ),
eventData = {
- tab: $( a ),
+ tab: anchor,
panel: panel
};
- if ( this.xhr ) {
- this.xhr.abort();
- }
-
// not remote
if ( !url ) {
- this.element.dequeue( "tabs" );
return;
}
@@ -599,7 +548,6 @@ $.widget( "ui.tabs", {
});
if ( this.xhr ) {
- // load remote from here on
this.lis.eq( index ).addClass( "ui-tabs-loading" );
this.xhr
@@ -609,24 +557,17 @@ $.widget( "ui.tabs", {
})
.complete(function( jqXHR, status ) {
if ( status === "abort" ) {
- // stop possibly running animations
- self.element.queue( [] );
self.panels.stop( false, true );
-
- // "tabs" queue must not contain more than two elements,
- // which are the callbacks for the latest clicked tab...
- self.element.queue( "tabs", self.element.queue( "tabs" ).splice( -2, 2 ) );
}
self.lis.eq( index ).removeClass( "ui-tabs-loading" );
- delete self.xhr;
+ if ( jqXHR === self.xhr ) {
+ delete self.xhr;
+ }
});
}
- // last, so that load event is fired before show...
- self.element.dequeue( "tabs" );
-
return this;
},
@@ -677,7 +618,7 @@ if ( $.uiBackCompat !== false ) {
var self = this;
- this.element.bind( "tabsbeforeload", function( event, ui ) {
+ this.element.bind( "tabsbeforeload.tabs", function( event, ui ) {
// tab is already cached
if ( $.data( ui.tab[ 0 ], "cache.tabs" ) ) {
event.preventDefault();
@@ -825,20 +766,30 @@ if ( $.uiBackCompat !== false ) {
li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true );
li.find( "a" ).attr( "aria-controls", id );
+ var doInsertAfter = index >= this.lis.length;
+
// try to find an existing element before creating a new one
var panel = this.element.find( "#" + id );
if ( !panel.length ) {
panel = this._createPanel( id );
+ if ( doInsertAfter ) {
+ if ( index > 0 ) {
+ panel.insertAfter( this.panels.eq( -1 ) );
+ } else {
+ panel.appendTo( this.element );
+ }
+ } else {
+ panel.insertBefore( this.panels[ index ] );
+ }
}
panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ).hide();
- if ( index >= this.lis.length ) {
+ if ( doInsertAfter ) {
li.appendTo( this.list );
- panel.appendTo( this.list[ 0 ].parentNode );
} else {
li.insertBefore( this.lis[ index ] );
- panel.insertBefore( this.panels[ index ] );
}
+
options.disabled = $.map( options.disabled, function( n ) {
return n >= index ? ++n : n;
});
@@ -970,7 +921,7 @@ if ( $.uiBackCompat !== false ) {
this._trigger( "show", null, this._ui(
this.active[ 0 ], this._getPanelForTab( this.active )[ 0 ] ) );
}
- }
+ };
prototype._trigger = function( type, event, data ) {
var ret = _trigger.apply( this, arguments );
if ( !ret ) {
@@ -1008,6 +959,10 @@ if ( $.uiBackCompat !== false ) {
}( jQuery, jQuery.ui.tabs.prototype ) );
// cookie option
+ var listId = 0;
+ function getNextListId() {
+ return ++listId;
+ }
$.widget( "ui.tabs", $.ui.tabs, {
options: {
cookie: null // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
@@ -1052,6 +1007,18 @@ if ( $.uiBackCompat !== false ) {
}
}
});
+
+ // load event
+ $.widget( "ui.tabs", $.ui.tabs, {
+ _trigger: function( type, event, data ) {
+ var _data = $.extend( {}, data );
+ if ( type === "load" ) {
+ _data.panel = _data.panel[ 0 ];
+ _data.tab = _data.tab[ 0 ];
+ }
+ return this._super( "_trigger", type, event, _data );
+ }
+ });
}
})( jQuery );
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index a74e6b77b..4167fd4e5 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -55,7 +55,7 @@ $.widget = function( name, base, prototype ) {
// we need to make the options hash a property directly on the new instance
// otherwise we'll modify the options hash on the prototype that we're
// inheriting from
- basePrototype.options = $.extend( true, {}, basePrototype.options );
+ basePrototype.options = $.widget.extend( {}, basePrototype.options );
$.each( prototype, function( prop, value ) {
if ( $.isFunction( value ) ) {
prototype[ prop ] = (function() {
@@ -83,7 +83,7 @@ $.widget = function( name, base, prototype ) {
}());
}
});
- $[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
+ $[ namespace ][ name ].prototype = $.widget.extend( basePrototype, {
namespace: namespace,
widgetName: name,
widgetEventPrefix: name,
@@ -93,6 +93,23 @@ $.widget = function( name, base, prototype ) {
$.widget.bridge( name, $[ namespace ][ name ] );
};
+$.widget.extend = function( target ) {
+ var input = slice.call( arguments, 1 ),
+ inputIndex = 0,
+ inputLength = input.length,
+ key,
+ value;
+ for ( ; inputIndex < inputLength; inputIndex++ ) {
+ for ( key in input[ inputIndex ] ) {
+ value = input[ inputIndex ][ key ];
+ if (input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
+ target[ key ] = $.isPlainObject( value ) ? $.widget.extend( {}, target[ key ], value ) : value;
+ }
+ }
+ }
+ return target;
+};
+
$.widget.bridge = function( name, object ) {
$.fn[ name ] = function( options ) {
var isMethodCall = typeof options === "string",
@@ -101,7 +118,7 @@ $.widget.bridge = function( name, object ) {
// allow multiple hashes to be passed on init
options = !isMethodCall && args.length ?
- $.extend.apply( null, [ true, options ].concat(args) ) :
+ $.widget.extend.apply( null, [ options ].concat(args) ) :
options;
if ( isMethodCall ) {
@@ -163,7 +180,7 @@ $.Widget.prototype = {
_createWidget: function( options, element ) {
element = $( element || this.defaultElement || this )[ 0 ];
this.element = $( element );
- this.options = $.extend( true, {},
+ this.options = $.widget.extend( {},
this.options,
this._getCreateOptions(),
options );
@@ -218,7 +235,7 @@ $.Widget.prototype = {
if ( arguments.length === 0 ) {
// don't return a reference to the internal hash
- return $.extend( {}, this.options );
+ return $.widget.extend( {}, this.options );
}
if ( typeof key === "string" ) {
@@ -230,7 +247,7 @@ $.Widget.prototype = {
parts = key.split( "." );
key = parts.shift();
if ( parts.length ) {
- curOption = options[ key ] = $.extend( true, {}, this.options[ key ] );
+ curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
for ( i = 0; i < parts.length - 1; i++ ) {
curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
curOption = curOption[ parts[ i ] ];