aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/.jshintrc17
-rw-r--r--ui/i18n/jquery.ui.datepicker-hi.js18
-rw-r--r--ui/jquery.effects.bounce.js16
-rw-r--r--ui/jquery.effects.core.js30
-rw-r--r--ui/jquery.effects.drop.js24
-rw-r--r--ui/jquery.effects.fade.js2
-rw-r--r--ui/jquery.effects.scale.js73
-rw-r--r--ui/jquery.effects.slide.js23
-rw-r--r--ui/jquery.ui.accordion.js32
-rw-r--r--ui/jquery.ui.autocomplete.js294
-rw-r--r--ui/jquery.ui.datepicker.js2
-rw-r--r--ui/jquery.ui.dialog.js221
-rw-r--r--ui/jquery.ui.draggable.js10
-rw-r--r--ui/jquery.ui.menu.js395
-rw-r--r--ui/jquery.ui.position.js260
-rw-r--r--ui/jquery.ui.resizable.js191
-rw-r--r--ui/jquery.ui.selectable.js28
-rw-r--r--ui/jquery.ui.slider.js130
-rw-r--r--ui/jquery.ui.sortable.js178
-rw-r--r--ui/jquery.ui.spinner.js42
-rw-r--r--ui/jquery.ui.tabs.js86
-rw-r--r--ui/jquery.ui.tooltip.js19
22 files changed, 1080 insertions, 1011 deletions
diff --git a/ui/.jshintrc b/ui/.jshintrc
new file mode 100644
index 000000000..415d69e90
--- /dev/null
+++ b/ui/.jshintrc
@@ -0,0 +1,17 @@
+{
+ "browser": true,
+ "curly": true,
+ "eqnull": true,
+ "eqeqeq": true,
+ "expr": true,
+ "jquery": true,
+ "latedef": true,
+ "noarg": true,
+ "onevar": true,
+ "smarttabs": true,
+ "trailing": true,
+ "undef": true,
+ "predef": [
+ "Globalize"
+ ]
+}
diff --git a/ui/i18n/jquery.ui.datepicker-hi.js b/ui/i18n/jquery.ui.datepicker-hi.js
index d75e98ead..6c563b997 100644
--- a/ui/i18n/jquery.ui.datepicker-hi.js
+++ b/ui/i18n/jquery.ui.datepicker-hi.js
@@ -2,19 +2,19 @@
/* Written by Michael Dawart. */
jQuery(function($){
$.datepicker.regional['hi'] = {
- closeText: 'होकर',
- prevText: 'अगला',
- nextText: 'नेक्स्ट',
+ closeText: 'बंद',
+ prevText: 'पिछला',
+ nextText: 'अगला',
currentText: 'आज',
- monthNames: ['जनवरी ','फरवरी','मार्च','अप्रेल','मै','जून',
- 'जूलाई','अगस्त ','सितम्बर','आक्टोबर','नवम्बर','दिसम्बर'],
- monthNamesShort: ['जन', 'फर', 'मार्च', 'अप्रेल', 'मै', 'जून',
- 'जूलाई', 'अग', 'सित', 'आक्ट', 'नव', 'िद'],
- dayNames: ['रविवासर', 'सोमवासर', 'मंगलवासर', 'बुधवासर', 'गुरुवासर', 'शुक्रवासर', 'शनिवासर'],
+ monthNames: ['जनवरी ','फरवरी','मार्च','अप्रेल','मई','जून',
+ 'जूलाई','अगस्त ','सितम्बर','अक्टूबर','नवम्बर','दिसम्बर'],
+ monthNamesShort: ['जन', 'फर', 'मार्च', 'अप्रेल', 'मई', 'जून',
+ 'जूलाई', 'अग', 'सित', 'अक्ट', 'नव', 'दि'],
+ dayNames: ['रविवार', 'सोमवार', 'मंगलवार', 'बुधवार', 'गुरुवार', 'शुक्रवार', 'शनिवार'],
dayNamesShort: ['रवि', 'सोम', 'मंगल', 'बुध', 'गुरु', 'शुक्र', 'शनि'],
dayNamesMin: ['रवि', 'सोम', 'मंगल', 'बुध', 'गुरु', 'शुक्र', 'शनि'],
weekHeader: 'हफ्ता',
- dateFormat: 'mm/dd/yy',
+ dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js
index 94d73644e..934fb16ef 100644
--- a/ui/jquery.effects.bounce.js
+++ b/ui/jquery.effects.bounce.js
@@ -13,14 +13,14 @@
(function( $, undefined ) {
$.effects.effect.bounce = function( o, done ) {
- var el = $( this ),
+ var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
// defaults:
mode = $.effects.setMode( el, o.mode || "effect" ),
hide = mode === "hide",
show = mode === "show",
- direction = o.direction || "up",
+ direction = o.direction || "up",
distance = o.distance,
times = o.times || 5,
@@ -31,7 +31,7 @@ $.effects.effect.bounce = function( o, done ) {
// utility:
ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
- motion = ( direction === "up" || direction === "left" ),
+ motion = ( direction === "up" || direction === "left" ),
i,
upAnim,
downAnim,
@@ -40,13 +40,13 @@ $.effects.effect.bounce = function( o, done ) {
queue = el.queue(),
queuelen = queue.length;
- // Avoid touching opacity to prevent clearType and PNG issues in IE
+ // Avoid touching opacity to prevent clearType and PNG issues in IE
if ( show || hide ) {
props.push( "opacity" );
- }
+ }
- $.effects.save( el, props );
- el.show();
+ $.effects.save( el, props );
+ el.show();
$.effects.createWrapper( el ); // Create Wrapper
// default distance for the BIGGEST bounce is the outer Distance / 3
@@ -90,7 +90,7 @@ $.effects.effect.bounce = function( o, done ) {
el.animate( upAnim, speed, easing );
}
-
+
el.queue(function() {
if ( hide ) {
el.hide();
diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js
index 626ab1a89..fe2bf298d 100644
--- a/ui/jquery.effects.core.js
+++ b/ui/jquery.effects.core.js
@@ -268,16 +268,15 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
// 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 );
- }
- });
+ dfd = $.Deferred(),
+ opts = jQuery.extend({}, o, {
+ queue: false,
+ complete: function() {
+ dfd.resolve( styleInfo );
+ }
+ });
+
+ this.el.animate( this.diff, opts );
return dfd.promise();
});
@@ -429,6 +428,15 @@ $.extend( $.effects, {
},
active = document.activeElement;
+ // support: Firefox
+ // Firefox incorrectly exposes anonymous content
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
+ try {
+ active.id;
+ } catch( e ) {
+ active = document.body;
+ }
+
element.wrap( wrapper );
// Fixes #7595 - Elements lose focus when wrapped.
@@ -722,7 +730,7 @@ $.each( baseEasings, function( name, easeIn ) {
$.easing[ "easeInOut" + name ] = function( p ) {
return p < 0.5 ?
easeIn( p * 2 ) / 2 :
- easeIn( p * -2 + 2 ) / -2 + 1;
+ 1 - easeIn( p * -2 + 2 ) / 2;
};
});
diff --git a/ui/jquery.effects.drop.js b/ui/jquery.effects.drop.js
index 6c72be9e5..ea8d242d5 100644
--- a/ui/jquery.effects.drop.js
+++ b/ui/jquery.effects.drop.js
@@ -14,7 +14,7 @@
$.effects.effect.drop = function( o, done ) {
- var el = $( this ),
+ var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
mode = $.effects.setMode( el, o.mode || "hide" ),
show = mode === "show",
@@ -27,9 +27,9 @@ $.effects.effect.drop = function( o, done ) {
distance;
// Adjust
- $.effects.save( el, props );
- el.show();
- $.effects.createWrapper( el );
+ $.effects.save( el, props );
+ el.show();
+ $.effects.createWrapper( el );
distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]({ margin: true }) / 2;
@@ -40,22 +40,22 @@ $.effects.effect.drop = function( o, done ) {
}
// Animation
- animation[ ref ] = ( show ?
- ( motion === "pos" ? "+=" : "-=" ) :
+ animation[ ref ] = ( show ?
+ ( motion === "pos" ? "+=" : "-=" ) :
( motion === "pos" ? "-=" : "+=" ) ) +
distance;
// Animate
- el.animate( animation, {
- queue: false,
- duration: o.duration,
- easing: o.easing,
+ el.animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
complete: function() {
if ( mode === "hide" ) {
el.hide();
}
- $.effects.restore( el, props );
- $.effects.removeWrapper( el );
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
done();
}
});
diff --git a/ui/jquery.effects.fade.js b/ui/jquery.effects.fade.js
index 89784bd08..66029b51c 100644
--- a/ui/jquery.effects.fade.js
+++ b/ui/jquery.effects.fade.js
@@ -18,7 +18,7 @@ $.effects.effect.fade = function( o, done ) {
hide = mode === "hide";
el.show();
- el.animate({
+ el.animate({
opacity: hide ? 0 : 1
}, {
queue: false,
diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js
index 83b41d3c2..5352bde77 100644
--- a/ui/jquery.effects.scale.js
+++ b/ui/jquery.effects.scale.js
@@ -18,9 +18,9 @@ $.effects.effect.puff = function( o, done ) {
hide = mode === "hide",
percent = parseInt( o.percent, 10 ) || 150,
factor = percent / 100,
- original = {
- height: elem.height(),
- width: elem.width()
+ original = {
+ height: elem.height(),
+ width: elem.width()
};
$.extend( o, {
@@ -51,8 +51,8 @@ $.effects.effect.scale = function( o, done ) {
( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
direction = o.direction || "both",
origin = o.origin,
- original = {
- height: el.height(),
+ original = {
+ height: el.height(),
width: el.width(),
outerHeight: el.outerHeight(),
outerWidth: el.outerWidth()
@@ -60,7 +60,7 @@ $.effects.effect.scale = function( o, done ) {
factor = {
y: direction !== "horizontal" ? (percent / 100) : 1,
x: direction !== "vertical" ? (percent / 100) : 1
- };
+ };
// We are going to pass this effect to the size effect:
options.effect = "size";
@@ -68,27 +68,27 @@ $.effects.effect.scale = function( o, done ) {
options.complete = done;
// Set default origin and restore for show/hide
- if ( mode !== "effect" ) {
+ if ( mode !== "effect" ) {
options.origin = origin || ["middle","center"];
options.restore = true;
}
- options.from = o.from || ( mode === "show" ? { height: 0, width: 0 } : original );
+ options.from = o.from || ( mode === "show" ? { height: 0, width: 0 } : original );
options.to = {
- height: original.height * factor.y,
+ height: original.height * factor.y,
width: original.width * factor.x,
- outerHeight: original.outerHeight * factor.y,
+ outerHeight: original.outerHeight * factor.y,
outerWidth: original.outerWidth * factor.x
- };
+ };
// Fade option to support puff
if ( options.fade ) {
if ( mode === "show" ) {
- options.from.opacity = 0;
+ options.from.opacity = 0;
options.to.opacity = 1;
}
if ( mode === "hide" ) {
- options.from.opacity = 1;
+ options.from.opacity = 1;
options.to.opacity = 0;
}
}
@@ -101,7 +101,7 @@ $.effects.effect.scale = function( o, done ) {
$.effects.effect.size = function( o, done ) {
// Create element
- var el = $( this ),
+ var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
// Always restore
@@ -125,7 +125,7 @@ $.effects.effect.size = function( o, done ) {
el.show();
}
original = {
- height: el.height(),
+ height: el.height(),
width: el.width(),
outerHeight: el.outerHeight(),
outerWidth: el.outerWidth()
@@ -137,11 +137,11 @@ $.effects.effect.size = function( o, done ) {
// Set scaling factor
factor = {
from: {
- y: el.from.height / original.height,
+ y: el.from.height / original.height,
x: el.from.width / original.width
},
to: {
- y: el.to.height / original.height,
+ y: el.to.height / original.height,
x: el.to.width / original.width
}
};
@@ -150,14 +150,14 @@ $.effects.effect.size = function( o, done ) {
if ( scale === "box" || scale === "both" ) {
// Vertical props scaling
- if ( factor.from.y !== factor.to.y ) {
+ if ( factor.from.y !== factor.to.y ) {
props = props.concat( vProps );
el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
}
// Horizontal props scaling
- if ( factor.from.x !== factor.to.x ) {
+ if ( factor.from.x !== factor.to.x ) {
props = props.concat( hProps );
el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
@@ -165,20 +165,20 @@ $.effects.effect.size = function( o, done ) {
}
// Scale the content
- if ( scale === "content" || scale === "both" ) {
+ if ( scale === "content" || scale === "both" ) {
// Vertical props scaling
- if ( factor.from.y !== factor.to.y ) {
+ if ( factor.from.y !== factor.to.y ) {
props = props.concat( cProps );
el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
}
}
- $.effects.save( el, restore ? props : props1 );
- el.show();
+ $.effects.save( el, restore ? props : props1 );
+ el.show();
$.effects.createWrapper( el );
- el.css( "overflow", "hidden" ).css( el.from );
+ el.css( "overflow", "hidden" ).css( el.from );
// Adjust
if (origin) { // Calculate baseline shifts
@@ -200,8 +200,8 @@ $.effects.effect.size = function( o, done ) {
el.find( "*[width]" ).each( function(){
var child = $( this ),
- c_original = {
- height: child.height(),
+ c_original = {
+ height: child.height(),
width: child.width()
};
if (restore) {
@@ -209,16 +209,16 @@ $.effects.effect.size = function( o, done ) {
}
child.from = {
- height: c_original.height * factor.from.y,
+ height: c_original.height * factor.from.y,
width: c_original.width * factor.from.x
};
child.to = {
- height: c_original.height * factor.to.y,
+ height: c_original.height * factor.to.y,
width: c_original.width * factor.to.x
};
// Vertical props scaling
- if ( factor.from.y !== factor.to.y ) {
+ if ( factor.from.y !== factor.to.y ) {
child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
}
@@ -242,10 +242,10 @@ $.effects.effect.size = function( o, done ) {
}
// Animate
- el.animate( el.to, {
- queue: false,
- duration: o.duration,
- easing: o.easing,
+ el.animate( el.to, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
complete: function() {
if ( el.to.opacity === 0 ) {
el.css( "opacity", el.from.opacity );
@@ -267,17 +267,14 @@ $.effects.effect.size = function( o, done ) {
$.each([ "top", "left" ], function( idx, pos ) {
el.css( pos, function( _, str ) {
var val = parseInt( str, 10 ),
- toRef = idx ? el.to.left : el.to.top,
- delta = idx ? el.to.outerWidth - el.from.outerWidth: el.to.outerHeight - el.from.outerHeight,
- same = origin[ idx ] === pos,
- mid = origin[ idx ] === "middle" || origin[ idx ] === "center";
+ toRef = idx ? el.to.left : el.to.top;
// if original was "auto", recalculate the new value from wrapper
if ( str === "auto" ) {
return toRef + "px";
}
- return val + toRef + "px";
+ return val + toRef + "px";
});
});
}
diff --git a/ui/jquery.effects.slide.js b/ui/jquery.effects.slide.js
index 77d540a9c..ae25a187e 100644
--- a/ui/jquery.effects.slide.js
+++ b/ui/jquery.effects.slide.js
@@ -23,38 +23,37 @@ $.effects.effect.slide = function( o, done ) {
ref = (direction === "up" || direction === "down") ? "top" : "left",
positiveMotion = (direction === "up" || direction === "left"),
distance,
- animation = {},
- size;
+ animation = {};
// Adjust
$.effects.save( el, props );
el.show();
- distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]({
+ distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]({
margin: true
});
-
+
$.effects.createWrapper( el ).css({
overflow: "hidden"
});
-
+
if ( show ) {
el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
}
// Animation
- animation[ ref ] = ( show ?
- ( positiveMotion ? "+=" : "-=") :
+ animation[ ref ] = ( show ?
+ ( positiveMotion ? "+=" : "-=") :
( positiveMotion ? "-=" : "+=")) +
distance;
// Animate
- el.animate( animation, {
- queue: false,
- duration: o.duration,
- easing: o.easing,
+ el.animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
complete: function() {
if ( mode === "hide" ) {
- el.hide();
+ el.hide();
}
$.effects.restore( el, props );
$.effects.removeWrapper( el );
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index 00ecd1b64..fe1771bc8 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -12,10 +12,11 @@
* jquery.ui.widget.js
*/
(function( $, undefined ) {
- var uid = 0,
- hideProps = {},
- showProps = {},
- showPropsAdjust = {};
+
+var uid = 0,
+ hideProps = {},
+ showProps = {},
+ showPropsAdjust = {};
hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
@@ -166,8 +167,7 @@ $.widget( "ui.accordion", {
},
_destroy: function() {
- var contents,
- accordionId = this.accordionId;
+ var contents;
// clean up main element
this.element
@@ -410,9 +410,8 @@ $.widget( "ui.accordion", {
this._toggle( eventData );
// switch classes
- active
- .removeClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
- .addClass( "ui-corner-all" );
+ // corner classes on the previously active header stay after the animation
+ active.removeClass( "ui-accordion-header-active ui-state-active" );
if ( options.icons ) {
active.children( ".ui-accordion-header-icon" )
.removeClass( options.icons.activeHeader )
@@ -496,10 +495,10 @@ $.widget( "ui.accordion", {
easing = easing || options.easing || animate.easing;
duration = duration || options.duration || animate.duration;
- if ( !toHide.size() ) {
+ if ( !toHide.length ) {
return toShow.animate( showProps, duration, easing, complete );
}
- if ( !toShow.size() ) {
+ if ( !toShow.length ) {
return toHide.animate( hideProps, duration, easing, complete );
}
@@ -516,11 +515,14 @@ $.widget( "ui.accordion", {
},
_toggleComplete: function( data ) {
- var toShow = data.newContent,
- toHide = data.oldContent;
+ var toHide = data.oldContent;
+
+ toHide
+ .removeClass( "ui-accordion-content-active" )
+ .prev()
+ .removeClass( "ui-corner-top" )
+ .addClass( "ui-corner-all" );
- // other classes are removed before the animation; this one needs to stay until completed
- toHide.removeClass( "ui-accordion-content-active" );
// Work around for rendering bug in IE (#5421)
if ( toHide.length ) {
toHide.parent()[0].className = toHide.parent()[0].className;
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 5ec5790ed..fab9691a3 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -1,4 +1,4 @@
-/*
+/*!
* jQuery UI Autocomplete @VERSION
*
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
@@ -46,17 +46,14 @@ $.widget( "ui.autocomplete", {
pending: 0,
_create: function() {
- var self = this,
- // Some browsers only repeat keydown events, not keypress events,
- // so we use the suppressKeyPress flag to determine if we've already
- // handled the keydown event. #7269
- // Unfortunately the code for & in keypress is the same as the up arrow,
- // so we use the suppressKeyPressRepeat flag to avoid handling keypress
- // events when we know the keydown event was used to modify the
- // search term. #7799
- suppressKeyPress,
- suppressKeyPressRepeat,
- suppressInput;
+ // Some browsers only repeat keydown events, not keypress events,
+ // so we use the suppressKeyPress flag to determine if we've already
+ // handled the keydown event. #7269
+ // Unfortunately the code for & in keypress is the same as the up arrow,
+ // so we use the suppressKeyPressRepeat flag to avoid handling keypress
+ // events when we know the keydown event was used to modify the
+ // search term. #7799
+ var suppressKeyPress, suppressKeyPressRepeat, suppressInput;
this.isMultiLine = this.element.is( "textarea,[contenteditable]" );
this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
@@ -69,9 +66,11 @@ $.widget( "ui.autocomplete", {
role: "textbox",
"aria-autocomplete": "list",
"aria-haspopup": "true"
- })
- .bind( "keydown.autocomplete", function( event ) {
- if ( self.options.disabled || self.element.prop( "readOnly" ) ) {
+ });
+
+ this._bind({
+ keydown: function( event ) {
+ if ( this.element.prop( "readOnly" ) ) {
suppressKeyPress = true;
suppressInput = true;
suppressKeyPressRepeat = true;
@@ -85,50 +84,54 @@ $.widget( "ui.autocomplete", {
switch( event.keyCode ) {
case keyCode.PAGE_UP:
suppressKeyPress = true;
- self._move( "previousPage", event );
+ this._move( "previousPage", event );
break;
case keyCode.PAGE_DOWN:
suppressKeyPress = true;
- self._move( "nextPage", event );
+ this._move( "nextPage", event );
break;
case keyCode.UP:
suppressKeyPress = true;
- self._keyEvent( "previous", event );
+ this._keyEvent( "previous", event );
break;
case keyCode.DOWN:
suppressKeyPress = true;
- self._keyEvent( "next", event );
+ this._keyEvent( "next", event );
break;
case keyCode.ENTER:
case keyCode.NUMPAD_ENTER:
// when menu is open and has focus
- if ( self.menu.active ) {
+ if ( this.menu.active ) {
// #6055 - Opera still allows the keypress to occur
// which causes forms to submit
suppressKeyPress = true;
event.preventDefault();
+ this.menu.select( event );
}
- //passthrough - ENTER and TAB both select the current element
+ break;
case keyCode.TAB:
- if ( !self.menu.active ) {
- return;
+ if ( this.menu.active ) {
+ this.menu.select( event );
}
- self.menu.select( event );
break;
case keyCode.ESCAPE:
- if ( self.menu.element.is(":visible") ) {
- self._value( self.term );
- self.close( event );
+ if ( this.menu.element.is(":visible") ) {
+ this._value( this.term );
+ this.close( event );
+ // Different browsers have different default behavior for escape
+ // Single press can mean undo or clear
+ // Double press in IE means clear the whole form
+ event.preventDefault();
}
break;
default:
suppressKeyPressRepeat = true;
// search timeout should be triggered before the input value is changed
- self._searchTimeout( event );
+ this._searchTimeout( event );
break;
}
- })
- .bind( "keypress.autocomplete", function( event ) {
+ },
+ keypress: function( event ) {
if ( suppressKeyPress ) {
suppressKeyPress = false;
event.preventDefault();
@@ -142,132 +145,125 @@ $.widget( "ui.autocomplete", {
var keyCode = $.ui.keyCode;
switch( event.keyCode ) {
case keyCode.PAGE_UP:
- self._move( "previousPage", event );
+ this._move( "previousPage", event );
break;
case keyCode.PAGE_DOWN:
- self._move( "nextPage", event );
+ this._move( "nextPage", event );
break;
case keyCode.UP:
- self._keyEvent( "previous", event );
+ this._keyEvent( "previous", event );
break;
case keyCode.DOWN:
- self._keyEvent( "next", event );
+ this._keyEvent( "next", event );
break;
}
- })
- .bind( "input.autocomplete", function(event) {
+ },
+ input: function( event ) {
if ( suppressInput ) {
suppressInput = false;
event.preventDefault();
return;
}
- self._searchTimeout( event );
- })
- .bind( "focus.autocomplete", function() {
- if ( self.options.disabled ) {
- return;
- }
-
- self.selectedItem = null;
- self.previous = self._value();
- })
- .bind( "blur.autocomplete", function( event ) {
- if ( self.options.disabled ) {
+ this._searchTimeout( event );
+ },
+ focus: function() {
+ this.selectedItem = null;
+ this.previous = this._value();
+ },
+ blur: function( event ) {
+ if ( this.cancelBlur ) {
+ delete this.cancelBlur;
return;
}
- if ( self.cancelBlur ) {
- delete self.cancelBlur;
- return;
- }
+ clearTimeout( this.searching );
+ this.close( event );
+ this._change( event );
+ }
+ });
- clearTimeout( self.searching );
- self.close( event );
- self._change( event );
- });
this._initSource();
- this.response = function() {
- return self._response.apply( self, arguments );
- };
this.menu = $( "<ul></ul>" )
.addClass( "ui-autocomplete" )
.appendTo( this.document.find( this.options.appendTo || "body" )[0] )
- // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
- .mousedown(function( event ) {
+ .menu({
+ // custom key handling for now
+ input: $()
+ })
+ .zIndex( this.element.zIndex() + 1 )
+ .hide()
+ .data( "menu" );
+ this._bind( this.menu.element, {
+ mousedown: function( event ) {
// prevent moving focus out of the text field
event.preventDefault();
// IE doesn't prevent moving focus even with event.preventDefault()
// so we set a flag to know when we should ignore the blur event
- self.cancelBlur = true;
- setTimeout(function() {
- delete self.cancelBlur;
- }, 1 );
+ this.cancelBlur = true;
+ this._delay(function() {
+ delete this.cancelBlur;
+ });
// clicking on the scrollbar causes focus to shift to the body
// but we can't detect a mouseup or a click immediately afterward
// so we have to track the next mousedown and close the menu if
// the user clicks somewhere outside of the autocomplete
- var menuElement = self.menu.element[ 0 ];
+ var menuElement = this.menu.element[ 0 ];
if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
- setTimeout(function() {
- self.document.one( 'mousedown', function( event ) {
- if ( event.target !== self.element[ 0 ] &&
- event.target !== menuElement &&
- !$.contains( menuElement, event.target ) ) {
- self.close();
+ this._delay(function() {
+ var that = this;
+ this.document.one( 'mousedown', function( event ) {
+ if ( event.target !== that.element[ 0 ] &&
+ event.target !== menuElement &&
+ !$.contains( menuElement, event.target ) ) {
+ that.close();
}
});
- }, 1 );
+ });
}
- })
- .menu({
- // custom key handling for now
- input: $(),
- focus: function( event, ui ) {
- // back compat for _renderItem using item.autocomplete, via #7810
- // TODO remove the fallback, see #8156
- var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" );
- if ( false !== self._trigger( "focus", event, { item: item } ) ) {
- // use value to match what will end up in the input, if it was a key event
- if ( /^key/.test(event.originalEvent.type) ) {
- self._value( item.value );
- }
- }
- },
- select: function( event, ui ) {
- // back compat for _renderItem using item.autocomplete, via #7810
- // TODO remove the fallback, see #8156
- var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ),
- previous = self.previous;
-
- // only trigger when focus was lost (click on menu)
- if ( self.element[0] !== self.document[0].activeElement ) {
- self.element.focus();
- self.previous = previous;
- // #6109 - IE triggers two focus events and the second
- // is asynchronous, so we need to reset the previous
- // term synchronously and asynchronously :-(
- setTimeout(function() {
- self.previous = previous;
- self.selectedItem = item;
- }, 1);
+ },
+ menufocus: function( event, ui ) {
+ // back compat for _renderItem using item.autocomplete, via #7810
+ // TODO remove the fallback, see #8156
+ var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" );
+ if ( false !== this._trigger( "focus", event, { item: item } ) ) {
+ // use value to match what will end up in the input, if it was a key event
+ if ( /^key/.test(event.originalEvent.type) ) {
+ this._value( item.value );
}
+ }
+ },
+ menuselect: function( event, ui ) {
+ // back compat for _renderItem using item.autocomplete, via #7810
+ // TODO remove the fallback, see #8156
+ var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ),
+ previous = this.previous;
+
+ // only trigger when focus was lost (click on menu)
+ if ( this.element[0] !== this.document[0].activeElement ) {
+ this.element.focus();
+ this.previous = previous;
+ // #6109 - IE triggers two focus events and the second
+ // is asynchronous, so we need to reset the previous
+ // term synchronously and asynchronously :-(
+ this._delay(function() {
+ this.previous = previous;
+ this.selectedItem = item;
+ });
+ }
- if ( false !== self._trigger( "select", event, { item: item } ) ) {
- self._value( item.value );
- }
- // reset the term after the select event
- // this allows custom select handling to work properly
- self.term = self._value();
-
- self.close( event );
- self.selectedItem = item;
+ if ( false !== this._trigger( "select", event, { item: item } ) ) {
+ this._value( item.value );
}
- })
- .zIndex( this.element.zIndex() + 1 )
- .hide()
- .data( "menu" );
+ // reset the term after the select event
+ // this allows custom select handling to work properly
+ this.term = this._value();
+
+ this.close( event );
+ this.selectedItem = item;
+ }
+ });
if ( $.fn.bgiframe ) {
this.menu.element.bgiframe();
@@ -308,7 +304,7 @@ $.widget( "ui.autocomplete", {
},
_initSource: function() {
- var self = this,
+ var that = this,
array,
url;
if ( $.isArray(this.options.source) ) {
@@ -319,25 +315,18 @@ $.widget( "ui.autocomplete", {
} else if ( typeof this.options.source === "string" ) {
url = this.options.source;
this.source = function( request, response ) {
- if ( self.xhr ) {
- self.xhr.abort();
+ if ( that.xhr ) {
+ that.xhr.abort();
}
- self.xhr = $.ajax({
+ that.xhr = $.ajax({
url: url,
data: request,
dataType: "json",
- context: {
- autocompleteRequest: ++requestIndex
- },
success: function( data, status ) {
- if ( this.autocompleteRequest === requestIndex ) {
- response( data );
- }
+ response( data );
},
error: function() {
- if ( this.autocompleteRequest === requestIndex ) {
- response( [] );
- }
+ response( [] );
}
});
};
@@ -347,15 +336,14 @@ $.widget( "ui.autocomplete", {
},
_searchTimeout: function( event ) {
- var self = this;
- clearTimeout( self.searching );
- self.searching = setTimeout(function() {
+ clearTimeout( this.searching );
+ this.searching = this._delay(function() {
// only search if the value has changed
- if ( self.term !== self._value() ) {
- self.selectedItem = null;
- self.search( null, event );
+ if ( this.term !== this._value() ) {
+ this.selectedItem = null;
+ this.search( null, event );
}
- }, self.options.delay );
+ }, this.options.delay );
},
search: function( value, event ) {
@@ -380,10 +368,26 @@ $.widget( "ui.autocomplete", {
this.element.addClass( "ui-autocomplete-loading" );
this.cancelSearch = false;
- this.source( { term: value }, this.response );
+ this.source( { term: value }, this._response() );
+ },
+
+ _response: function() {
+ var that = this,
+ index = ++requestIndex;
+
+ return function( content ) {
+ if ( index === requestIndex ) {
+ that.__response( content );
+ }
+
+ that.pending--;
+ if ( !that.pending ) {
+ that.element.removeClass( "ui-autocomplete-loading" );
+ }
+ };
},
- _response: function( content ) {
+ __response: function( content ) {
if ( content ) {
content = this._normalize( content );
}
@@ -395,10 +399,6 @@ $.widget( "ui.autocomplete", {
// use ._close() instead of .close() so we don't cancel future searches
this._close();
}
- this.pending--;
- if ( !this.pending ) {
- this.element.removeClass( "ui-autocomplete-loading" );
- }
},
close: function( event ) {
@@ -472,9 +472,9 @@ $.widget( "ui.autocomplete", {
},
_renderMenu: function( ul, items ) {
- var self = this;
+ var that = this;
$.each( items, function( index, item ) {
- self._renderItemData( ul, item );
+ that._renderItemData( ul, item );
});
},
@@ -522,7 +522,7 @@ $.widget( "ui.autocomplete", {
$.extend( $.ui.autocomplete, {
escapeRegex: function( value ) {
- return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
+ return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
},
filter: function(array, term) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index c0de503f5..a92c9fafa 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -801,10 +801,8 @@ $.extend(Datepicker.prototype, {
if (this._datepickerShowing) {
var showAnim = this._get(inst, 'showAnim');
var duration = this._get(inst, 'duration');
- var that = this;
var postProcess = function() {
$.datepicker._tidyDialog(inst);
- that._curInst = null;
};
// DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index 3a9bd5dc6..f60a1f78d 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -77,19 +77,19 @@ $.widget("ui.dialog", {
// #5742 - .attr() might return a DOMElement
if ( typeof this.originalTitle !== "string" ) {
this.originalTitle = "";
- }
- this.oldPosition = {
- parent: this.element.parent(),
- index: this.element.parent().children().index( this.element )
+ }
+ this.oldPosition = {
+ parent: this.element.parent(),
+ index: this.element.parent().children().index( this.element )
};
this.options.title = this.options.title || this.originalTitle;
- var self = this,
- options = self.options,
+ var that = this,
+ options = this.options,
title = options.title || "&#160;",
- titleId = $.ui.dialog.getTitleId( self.element ),
+ titleId = $.ui.dialog.getTitleId( this.element ),
- uiDialog = ( self.uiDialog = $( "<div>" ) )
+ uiDialog = ( this.uiDialog = $( "<div>" ) )
.addClass( uiDialogClasses + options.dialogClass )
.css({
display: "none",
@@ -101,7 +101,7 @@ $.widget("ui.dialog", {
.keydown(function( event ) {
if ( options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
event.keyCode === $.ui.keyCode.ESCAPE ) {
- self.close( event );
+ that.close( event );
event.preventDefault();
}
})
@@ -110,17 +110,17 @@ $.widget("ui.dialog", {
"aria-labelledby": titleId
})
.mousedown(function( event ) {
- self.moveToTop( false, event );
+ that.moveToTop( false, event );
})
.appendTo( "body" ),
- uiDialogContent = self.element
+ uiDialogContent = this.element
.show()
.removeAttr( "title" )
.addClass( "ui-dialog-content ui-widget-content" )
.appendTo( uiDialog ),
- uiDialogTitlebar = ( self.uiDialogTitlebar = $( "<div>" ) )
+ uiDialogTitlebar = ( this.uiDialogTitlebar = $( "<div>" ) )
.addClass( "ui-dialog-titlebar ui-widget-header " +
"ui-corner-all ui-helper-clearfix" )
.prependTo( uiDialog ),
@@ -130,11 +130,11 @@ $.widget("ui.dialog", {
.attr( "role", "button" )
.click(function( event ) {
event.preventDefault();
- self.close( event );
+ that.close( event );
})
.appendTo( uiDialogTitlebar ),
- uiDialogTitlebarCloseText = ( self.uiDialogTitlebarCloseText = $( "<span>" ) )
+ uiDialogTitlebarCloseText = ( this.uiDialogTitlebarCloseText = $( "<span>" ) )
.addClass( "ui-icon ui-icon-closethick" )
.text( options.closeText )
.appendTo( uiDialogTitlebarClose ),
@@ -150,14 +150,14 @@ $.widget("ui.dialog", {
this._focusable( uiDialogTitlebarClose );
if ( options.draggable && $.fn.draggable ) {
- self._makeDraggable();
+ this._makeDraggable();
}
if ( options.resizable && $.fn.resizable ) {
- self._makeResizable();
+ this._makeResizable();
}
- self._createButtons( options.buttons );
- self._isOpen = false;
+ this._createButtons( options.buttons );
+ this._isOpen = false;
if ( $.fn.bgiframe ) {
uiDialog.bgiframe();
@@ -171,29 +171,29 @@ $.widget("ui.dialog", {
},
_destroy: function() {
- var self = this, next,
+ var next,
oldPosition = this.oldPosition;
- if ( self.overlay ) {
- self.overlay.destroy();
+ if ( this.overlay ) {
+ this.overlay.destroy();
}
- self.uiDialog.hide();
- self.element
+ this.uiDialog.hide();
+ this.element
.removeClass( "ui-dialog-content ui-widget-content" )
.hide()
.appendTo( "body" );
- self.uiDialog.remove();
+ this.uiDialog.remove();
- if ( self.originalTitle ) {
- self.element.attr( "title", self.originalTitle );
+ if ( this.originalTitle ) {
+ this.element.attr( "title", this.originalTitle );
}
-
+
next = oldPosition.parent.children().eq( oldPosition.index );
if ( next.length ) {
- next.before( self.element );
+ next.before( this.element );
} else {
- oldPosition.parent.append( self.element );
- }
+ oldPosition.parent.append( this.element );
+ }
},
widget: function() {
@@ -201,40 +201,40 @@ $.widget("ui.dialog", {
},
close: function( event ) {
- var self = this,
+ var that = this,
maxZ, thisZ;
if ( !this._isOpen ) {
return;
}
- if ( false === self._trigger( "beforeClose", event ) ) {
+ if ( false === this._trigger( "beforeClose", event ) ) {
return;
}
- self._isOpen = false;
+ this._isOpen = false;
- if ( self.overlay ) {
- self.overlay.destroy();
+ if ( this.overlay ) {
+ this.overlay.destroy();
}
- self.uiDialog.unbind( "keypress.ui-dialog" );
+ this.uiDialog.unbind( "keypress.ui-dialog" );
- if ( self.options.hide ) {
- self.uiDialog.hide( self.options.hide, function() {
- self._trigger( "close", event );
+ if ( this.options.hide ) {
+ this.uiDialog.hide( this.options.hide, function() {
+ that._trigger( "close", event );
});
} else {
- self.uiDialog.hide();
- self._trigger( "close", event );
+ this.uiDialog.hide();
+ this._trigger( "close", event );
}
$.ui.dialog.overlay.resize();
// adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
- if ( self.options.modal ) {
+ if ( this.options.modal ) {
maxZ = 0;
$( ".ui-dialog" ).each(function() {
- if ( this !== self.uiDialog[0] ) {
+ if ( this !== that.uiDialog[0] ) {
thisZ = $( this ).css( "z-index" );
if ( !isNaN( thisZ ) ) {
maxZ = Math.max( maxZ, thisZ );
@@ -244,7 +244,7 @@ $.widget("ui.dialog", {
$.ui.dialog.maxZ = maxZ;
}
- return self;
+ return this;
},
isOpen: function() {
@@ -254,37 +254,36 @@ $.widget("ui.dialog", {
// the force parameter allows us to move modal dialogs to their correct
// position on open
moveToTop: function( force, event ) {
- var self = this,
- options = self.options,
+ var options = this.options,
saveScroll;
if ( ( options.modal && !force ) ||
( !options.stack && !options.modal ) ) {
- return self._trigger( "focus", event );
+ return this._trigger( "focus", event );
}
if ( options.zIndex > $.ui.dialog.maxZ ) {
$.ui.dialog.maxZ = options.zIndex;
}
- if ( self.overlay ) {
+ if ( this.overlay ) {
$.ui.dialog.maxZ += 1;
$.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ;
- self.overlay.$el.css( "z-index", $.ui.dialog.overlay.maxZ );
+ this.overlay.$el.css( "z-index", $.ui.dialog.overlay.maxZ );
}
// Save and then restore scroll
// Opera 9.5+ resets when parent z-index is changed.
// http://bugs.jqueryui.com/ticket/3193
saveScroll = {
- scrollTop: self.element.scrollTop(),
- scrollLeft: self.element.scrollLeft()
+ scrollTop: this.element.scrollTop(),
+ scrollLeft: this.element.scrollLeft()
};
$.ui.dialog.maxZ += 1;
- self.uiDialog.css( "z-index", $.ui.dialog.maxZ );
- self.element.attr( saveScroll );
- self._trigger( "focus", event );
+ this.uiDialog.css( "z-index", $.ui.dialog.maxZ );
+ this.element.attr( saveScroll );
+ this._trigger( "focus", event );
- return self;
+ return this;
},
open: function() {
@@ -293,15 +292,14 @@ $.widget("ui.dialog", {
}
var hasFocus,
- self = this,
- options = self.options,
- uiDialog = self.uiDialog;
+ options = this.options,
+ uiDialog = this.uiDialog;
- self._size();
- self._position( options.position );
+ this._size();
+ this._position( options.position );
uiDialog.show( options.show );
- self.overlay = options.modal ? new $.ui.dialog.overlay( self ) : null;
- self.moveToTop( true );
+ this.overlay = options.modal ? new $.ui.dialog.overlay( this ) : null;
+ this.moveToTop( true );
// prevent tabbing out of modal dialogs
if ( options.modal ) {
@@ -326,7 +324,7 @@ $.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
- hasFocus = self.element.find( ":tabbable" );
+ hasFocus = this.element.find( ":tabbable" );
if ( !hasFocus.length ) {
hasFocus = uiDialog.find( ".ui-dialog-buttonpane :tabbable" );
if ( !hasFocus.length ) {
@@ -335,19 +333,19 @@ $.widget("ui.dialog", {
}
hasFocus.eq( 0 ).focus();
- self._isOpen = true;
- self._trigger( "open" );
+ this._isOpen = true;
+ this._trigger( "open" );
- return self;
+ return this;
},
_createButtons: function( buttons ) {
var uiDialogButtonPane, uiButtonSet,
- self = this,
+ that = this,
hasButtons = false;
// if we already have a button pane, remove it
- self.uiDialog.find( ".ui-dialog-buttonpane" ).remove();
+ this.uiDialog.find( ".ui-dialog-buttonpane" ).remove();
if ( typeof buttons === "object" && buttons !== null ) {
$.each( buttons, function() {
@@ -369,23 +367,23 @@ $.widget("ui.dialog", {
.attr( props, true )
.unbind( "click" )
.click(function() {
- props.click.apply( self.element[0], arguments );
+ props.click.apply( that.element[0], arguments );
})
.appendTo( uiButtonSet );
if ( $.fn.button ) {
button.button();
}
});
- self.uiDialog.addClass( "ui-dialog-buttons" );
- uiDialogButtonPane.appendTo( self.uiDialog );
+ this.uiDialog.addClass( "ui-dialog-buttons" );
+ uiDialogButtonPane.appendTo( this.uiDialog );
} else {
- self.uiDialog.removeClass( "ui-dialog-buttons" );
+ this.uiDialog.removeClass( "ui-dialog-buttons" );
}
},
_makeDraggable: function() {
- var self = this,
- options = self.options;
+ var that = this,
+ options = this.options;
function filteredUi( ui ) {
return {
@@ -394,26 +392,26 @@ $.widget("ui.dialog", {
};
}
- self.uiDialog.draggable({
+ this.uiDialog.draggable({
cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
handle: ".ui-dialog-titlebar",
containment: "document",
start: function( event, ui ) {
$( this )
.addClass( "ui-dialog-dragging" );
- self._trigger( "dragStart", event, filteredUi( ui ) );
+ that._trigger( "dragStart", event, filteredUi( ui ) );
},
drag: function( event, ui ) {
- self._trigger( "drag", event, filteredUi( ui ) );
+ that._trigger( "drag", event, filteredUi( ui ) );
},
stop: function( event, ui ) {
options.position = [
- ui.position.left - self.document.scrollLeft(),
- ui.position.top - self.document.scrollTop()
+ ui.position.left - that.document.scrollLeft(),
+ ui.position.top - that.document.scrollTop()
];
$( this )
.removeClass( "ui-dialog-dragging" );
- self._trigger( "dragStop", event, filteredUi( ui ) );
+ that._trigger( "dragStop", event, filteredUi( ui ) );
$.ui.dialog.overlay.resize();
}
});
@@ -421,11 +419,11 @@ $.widget("ui.dialog", {
_makeResizable: function( handles ) {
handles = (handles === undefined ? this.options.resizable : handles);
- var self = this,
- options = self.options,
+ var that = this,
+ options = this.options,
// .ui-resizable has position: relative defined in the stylesheet
// but dialogs have to use absolute or fixed positioning
- position = self.uiDialog.css( "position" ),
+ position = this.uiDialog.css( "position" ),
resizeHandles = typeof handles === 'string' ?
handles :
"n,e,s,w,se,sw,ne,nw";
@@ -439,27 +437,27 @@ $.widget("ui.dialog", {
};
}
- self.uiDialog.resizable({
+ this.uiDialog.resizable({
cancel: ".ui-dialog-content",
containment: "document",
- alsoResize: self.element,
+ alsoResize: this.element,
maxWidth: options.maxWidth,
maxHeight: options.maxHeight,
minWidth: options.minWidth,
- minHeight: self._minHeight(),
+ minHeight: this._minHeight(),
handles: resizeHandles,
start: function( event, ui ) {
$( this ).addClass( "ui-dialog-resizing" );
- self._trigger( "resizeStart", event, filteredUi( ui ) );
+ that._trigger( "resizeStart", event, filteredUi( ui ) );
},
resize: function( event, ui ) {
- self._trigger( "resize", event, filteredUi( ui ) );
+ that._trigger( "resize", event, filteredUi( ui ) );
},
stop: function( event, ui ) {
$( this ).removeClass( "ui-dialog-resizing" );
options.height = $( this ).height();
options.width = $( this ).width();
- self._trigger( "resizeStop", event, filteredUi( ui ) );
+ that._trigger( "resizeStop", event, filteredUi( ui ) );
$.ui.dialog.overlay.resize();
}
})
@@ -525,12 +523,12 @@ $.widget("ui.dialog", {
},
_setOptions: function( options ) {
- var self = this,
+ var that = this,
resizableOptions = {},
resize = false;
$.each( options, function( key, value ) {
- self._setOption( key, value );
+ that._setOption( key, value );
if ( key in sizeRelatedOptions ) {
resize = true;
@@ -550,20 +548,19 @@ $.widget("ui.dialog", {
_setOption: function( key, value ) {
var isDraggable, isResizable,
- self = this,
- uiDialog = self.uiDialog;
+ uiDialog = this.uiDialog;
switch ( key ) {
case "buttons":
- self._createButtons( value );
+ this._createButtons( value );
break;
case "closeText":
// ensure that we always pass a string
- self.uiDialogTitlebarCloseText.text( "" + value );
+ this.uiDialogTitlebarCloseText.text( "" + value );
break;
case "dialogClass":
uiDialog
- .removeClass( self.options.dialogClass )
+ .removeClass( this.options.dialogClass )
.addClass( uiDialogClasses + value );
break;
case "disabled":
@@ -580,11 +577,11 @@ $.widget("ui.dialog", {
}
if ( !isDraggable && value ) {
- self._makeDraggable();
+ this._makeDraggable();
}
break;
case "position":
- self._position( value );
+ this._position( value );
break;
case "resizable":
// currently resizable, becoming non-resizable
@@ -600,12 +597,12 @@ $.widget("ui.dialog", {
// currently non-resizable, becoming resizable
if ( !isResizable && value !== false ) {
- self._makeResizable( value );
+ this._makeResizable( value );
}
break;
case "title":
// convert whatever was passed in o a string, for html() to not throw up
- $( ".ui-dialog-title", self.uiDialogTitlebar )
+ $( ".ui-dialog-title", this.uiDialogTitlebar )
.html( "" + ( value || "&#160;" ) );
break;
}
@@ -713,21 +710,25 @@ $.extend( $.ui.dialog.overlay, {
}
}, 1 );
- // allow closing by pressing the escape key
- $( document ).bind( "keydown.dialog-overlay", function( event ) {
- if ( dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
- event.keyCode === $.ui.keyCode.ESCAPE ) {
-
- dialog.close( event );
- event.preventDefault();
- }
- });
-
// handle window resize
$( window ).bind( "resize.dialog-overlay", $.ui.dialog.overlay.resize );
}
var $el = ( this.oldInstances.pop() || $( "<div>" ).addClass( "ui-widget-overlay" ) );
+
+ // allow closing by pressing the escape key
+ $( document ).bind( "keydown.dialog-overlay", function( event ) {
+ var instances = $.ui.dialog.overlay.instances;
+ // only react to the event if we're the top overlay
+ if ( instances.length !== 0 && instances[ instances.length - 1 ] === $el &&
+ dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
+ event.keyCode === $.ui.keyCode.ESCAPE ) {
+
+ dialog.close( event );
+ event.preventDefault();
+ }
+ });
+
$el.appendTo( document.body ).css({
width: this.width(),
height: this.height()
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js
index 25b256710..84077ed29 100644
--- a/ui/jquery.ui.draggable.js
+++ b/ui/jquery.ui.draggable.js
@@ -207,8 +207,14 @@ $.widget("ui.draggable", $.ui.mouse, {
this.dropped = false;
}
- //if the original element is removed, don't bother to continue
- if((!this.element[0] || !this.element[0].parentNode) && this.options.helper === "original")
+ //if the original element is no longer in the DOM don't bother to continue (see #8269)
+ var element = this.element[0], elementInDom = false;
+ while ( element && (element = element.parentNode) ) {
+ if (element == document ) {
+ elementInDom = true;
+ }
+ }
+ if ( !elementInDom && this.options.helper === "original" )
return false;
if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index af22c19b0..7704521fb 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -13,7 +13,8 @@
*/
(function($) {
-var idIncrement = 0;
+var idIncrement = 0,
+ currentEventTarget = null;
$.widget( "ui.menu", {
version: "@VERSION",
@@ -41,18 +42,23 @@ $.widget( "ui.menu", {
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.attr({
id: this.menuId,
- role: "menu"
+ role: "menu",
+ tabIndex: 0
})
// need to catch all clicks on disabled menu
// not possible through _bind
- .bind( "click.menu", $.proxy( function( event ) {
+ .bind( "click.menu", $.proxy(function( event ) {
if ( this.options.disabled ) {
event.preventDefault();
}
- }, this));
+ }, this ));
+
if ( this.options.disabled ) {
- this.element.addClass( "ui-state-disabled" );
+ this.element
+ .addClass( "ui-state-disabled" )
+ .attr( "aria-disabled", "true" );
}
+
this._bind({
// Prevent focus from sticking to links inside menu after clicking
// them (focus should always stay on UL during navigation).
@@ -63,22 +69,28 @@ $.widget( "ui.menu", {
event.preventDefault();
},
"click .ui-menu-item:has(a)": function( event ) {
- event.stopImmediatePropagation();
- //Don't select disabled menu items
- if ( !$( event.target ).closest( ".ui-menu-item" ).is( ".ui-state-disabled" ) ) {
- this.select( event );
- // Redirect focus to the menu with a delay for firefox
- this._delay( function() {
- if ( !this.element.is(":focus") ) {
- this.element.focus();
- }
- }, 20);
+ var target = $( event.target );
+ if ( target[0] !== currentEventTarget ) {
+ currentEventTarget = target[0];
+ target.one( "click.menu", function( event ) {
+ currentEventTarget = null;
+ });
+ // Don't select disabled menu items
+ if ( !target.closest( ".ui-menu-item" ).is( ".ui-state-disabled" ) ) {
+ this.select( event );
+ // Redirect focus to the menu with a delay for firefox
+ this._delay(function() {
+ if ( !this.element.is(":focus") ) {
+ this.element.focus();
+ }
+ }, 20 );
+ }
}
},
- "mouseover .ui-menu-item": function( event ) {
- event.stopImmediatePropagation();
+ "mouseenter .ui-menu-item": function( event ) {
var target = $( event.currentTarget );
- // Remove ui-state-active class from siblings of the newly focused menu item to avoid a jump caused by adjacent elements both having a class with a border
+ // Remove ui-state-active class from siblings of the newly focused menu item
+ // to avoid a jump caused by adjacent elements both having a class with a border
target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
this.focus( event, target );
},
@@ -86,9 +98,9 @@ $.widget( "ui.menu", {
"mouseleave .ui-menu": "collapseAll",
"focus": function( event ) {
var menu = this.element,
- firstItem = menu.children( ".ui-menu-item" ).not( ".ui-state-disabled" ).eq( 0 );
+ firstItem = menu.children( ".ui-menu-item" ).eq( 0 );
if ( this._hasScroll() && !this.active ) {
- menu.children().each( function() {
+ menu.children().each(function() {
var currentItem = $( this );
if ( currentItem.offset().top - menu.offset().top >= 0 ) {
firstItem = currentItem;
@@ -101,125 +113,17 @@ $.widget( "ui.menu", {
this.focus( event, firstItem );
},
blur: function( event ) {
- this._delay( function() {
- if ( ! $.contains( this.element[0], this.document[0].activeElement ) ) {
+ this._delay(function() {
+ if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
this.collapseAll( event );
}
- }, 0);
- }
+ });
+ },
+ "keydown": "_keydown"
});
this.refresh();
- this.element.attr( "tabIndex", 0 );
- this._bind({
- "keydown": function( event ) {
- switch ( event.keyCode ) {
- case $.ui.keyCode.PAGE_UP:
- this.previousPage( event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.PAGE_DOWN:
- this.nextPage( event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.HOME:
- this._move( "first", "first", event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.END:
- this._move( "last", "last", event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.UP:
- this.previous( event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.DOWN:
- this.next( event );
- event.preventDefault();
- event.stopImmediatePropagation();
- break;
- case $.ui.keyCode.LEFT:
- if (this.collapse( event )) {
- event.stopImmediatePropagation();
- }
- event.preventDefault();
- break;
- case $.ui.keyCode.RIGHT:
- if (this.expand( event )) {
- event.stopImmediatePropagation();
- }
- event.preventDefault();
- break;
- case $.ui.keyCode.ENTER:
- if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
- if ( this.expand( event ) ) {
- event.stopImmediatePropagation();
- }
- }
- else {
- this.select( event );
- event.stopImmediatePropagation();
- }
- event.preventDefault();
- break;
- case $.ui.keyCode.ESCAPE:
- if ( this.collapse( event ) ) {
- event.stopImmediatePropagation();
- }
- event.preventDefault();
- break;
- default:
- event.stopPropagation();
- clearTimeout( this.filterTimer );
- var match,
- prev = this.previousFilter || "",
- character = String.fromCharCode( event.keyCode ),
- skip = false;
-
- if (character === prev) {
- skip = true;
- } else {
- character = prev + character;
- }
- function escape( value ) {
- return value.replace( /[-[\]{}()*+?.,\\^$|#\s]/g , "\\$&" );
- }
- match = this.activeMenu.children( ".ui-menu-item" ).filter( function() {
- return new RegExp("^" + escape(character), "i")
- .test( $( this ).children( "a" ).text() );
- });
- match = skip && match.index(this.active.next()) !== -1 ? this.active.nextAll(".ui-menu-item") : match;
- if ( !match.length ) {
- character = String.fromCharCode(event.keyCode);
- match = this.activeMenu.children(".ui-menu-item").filter( function() {
- return new RegExp("^" + escape(character), "i")
- .test( $( this ).children( "a" ).text() );
- });
- }
- if ( match.length ) {
- this.focus( event, match );
- if (match.length > 1) {
- this.previousFilter = character;
- this.filterTimer = this._delay( function() {
- delete this.previousFilter;
- }, 1000 );
- } else {
- delete this.previousFilter;
- }
- } else {
- delete this.previousFilter;
- }
- }
- }
- });
-
this._bind( this.document, {
click: function( event ) {
if ( !$( event.target ).closest( ".ui-menu" ).length ) {
@@ -230,38 +134,136 @@ $.widget( "ui.menu", {
},
_destroy: function() {
- //destroy (sub)menus
+ // destroy (sub)menus
this.element
.removeAttr( "aria-activedescendant" )
- .find( ".ui-menu" )
- .andSelf()
- .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
- .removeAttr( "role" )
- .removeAttr( "tabIndex" )
- .removeAttr( "aria-labelledby" )
- .removeAttr( "aria-expanded" )
- .removeAttr( "aria-hidden" )
- .show();
-
- //destroy menu items
+ .find( ".ui-menu" ).andSelf()
+ .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
+ .removeAttr( "role" )
+ .removeAttr( "tabIndex" )
+ .removeAttr( "aria-labelledby" )
+ .removeAttr( "aria-expanded" )
+ .removeAttr( "aria-hidden" )
+ .show();
+
+ // destroy menu items
this.element.find( ".ui-menu-item" )
.unbind( ".menu" )
.removeClass( "ui-menu-item" )
.removeAttr( "role" )
.children( "a" )
- .removeClass( "ui-corner-all ui-state-hover" )
- .removeAttr( "tabIndex" )
- .removeAttr( "role" )
- .removeAttr( "aria-haspopup" )
- .removeAttr( "id" )
- .children( ".ui-icon" )
- .remove();
+ .removeClass( "ui-corner-all ui-state-hover" )
+ .removeAttr( "tabIndex" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-haspopup" )
+ .removeAttr( "id" )
+ .children( ".ui-icon" )
+ .remove();
+
+ // unbind currentEventTarget click event handler
+ $( currentEventTarget ).unbind( "click.menu" );
+ },
+
+ _keydown: function( event ) {
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.PAGE_UP:
+ this.previousPage( event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.PAGE_DOWN:
+ this.nextPage( event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.HOME:
+ this._move( "first", "first", event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.END:
+ this._move( "last", "last", event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.UP:
+ this.previous( event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.DOWN:
+ this.next( event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.LEFT:
+ this.collapse( event );
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.RIGHT:
+ if ( !this.active.is( ".ui-state-disabled" ) ) {
+ this.expand( event );
+ }
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.ENTER:
+ if ( !this.active.is( ".ui-state-disabled" ) ) {
+ if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
+ this.expand( event );
+ } else {
+ this.select( event );
+ }
+ }
+ event.preventDefault();
+ break;
+ case $.ui.keyCode.ESCAPE:
+ this.collapse( event );
+ event.preventDefault();
+ break;
+ default:
+ clearTimeout( this.filterTimer );
+ var match,
+ prev = this.previousFilter || "",
+ character = String.fromCharCode( event.keyCode ),
+ skip = false;
+
+ if ( character === prev ) {
+ skip = true;
+ } else {
+ character = prev + character;
+ }
+ function escape( value ) {
+ return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
+ }
+ match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
+ return new RegExp( "^" + escape( character ), "i" )
+ .test( $( this ).children( "a" ).text() );
+ });
+ match = skip && match.index(this.active.next()) !== -1 ?
+ this.active.nextAll(".ui-menu-item") :
+ match;
+ if ( !match.length ) {
+ character = String.fromCharCode(event.keyCode);
+ match = this.activeMenu.children(".ui-menu-item").filter(function() {
+ return new RegExp( "^" + escape(character), "i" )
+ .test( $( this ).children( "a" ).text() );
+ });
+ }
+ if ( match.length ) {
+ this.focus( event, match );
+ if ( match.length > 1 ) {
+ this.previousFilter = character;
+ this.filterTimer = this._delay(function() {
+ delete this.previousFilter;
+ }, 1000 );
+ } else {
+ delete this.previousFilter;
+ }
+ } else {
+ delete this.previousFilter;
+ }
+ }
},
refresh: function() {
// initialize nested menus
- var menuId,
- submenus = this.element.find( this.options.menus + ":not( .ui-menu )" )
+ var menus,
+ menuId = this.menuId,
+ submenus = this.element.find( this.options.menus + ":not(.ui-menu)" )
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.hide()
.attr({
@@ -271,8 +273,9 @@ $.widget( "ui.menu", {
});
// don't refresh list items that are already adapted
- menuId = this.menuId;
- submenus.add( this.element ).children( ":not( .ui-menu-item ):has( a )" )
+ menus = submenus.add( this.element );
+
+ menus.children( ":not( .ui-menu-item ):has( a )" )
.addClass( "ui-menu-item" )
.attr( "role", "presentation" )
.children( "a" )
@@ -283,7 +286,13 @@ $.widget( "ui.menu", {
return menuId + "-" + i;
});
- submenus.each( function() {
+ // initialize unlinked menu-items as dividers
+ menus.children( ":not(.ui-menu-item)" ).addClass( "ui-widget-content ui-menu-divider" );
+
+ // add aria-disabled attribute to any disabled menu item
+ menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
+
+ submenus.each(function() {
var menu = $( this ),
item = menu.prev( "a" );
@@ -295,7 +304,7 @@ $.widget( "ui.menu", {
focus: function( event, item ) {
var nested, borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
- this.blur( event );
+ this.blur( event, event && event.type === "focus" );
if ( this._hasScroll() ) {
borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
@@ -312,18 +321,22 @@ $.widget( "ui.menu", {
}
}
- this.active = item.first()
- .children( "a" )
+ this.active = item.first();
+ this.element.attr( "aria-activedescendant",
+ this.active.children( "a" )
.addClass( "ui-state-focus" )
- .end();
- this.element.attr( "aria-activedescendant", this.active.children( "a" ).attr( "id" ) );
+ .attr( "id" ) );
// highlight active parent menu item, if any
this.active.parent().closest( ".ui-menu-item" ).children( "a:first" ).addClass( "ui-state-active" );
- this.timer = this._delay( function() {
+ if ( event.type === "keydown" ) {
this._close();
- }, this.delay );
+ } else {
+ this.timer = this._delay(function() {
+ this._close();
+ }, this.delay );
+ }
nested = $( "> .ui-menu", item );
if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
@@ -334,8 +347,10 @@ $.widget( "ui.menu", {
this._trigger( "focus", event, { item: item } );
},
- blur: function( event ) {
- clearTimeout( this.timer );
+ blur: function( event, fromFocus ) {
+ if ( !fromFocus ) {
+ clearTimeout( this.timer );
+ }
if ( !this.active ) {
return;
@@ -356,7 +371,7 @@ $.widget( "ui.menu", {
return;
}
- this.timer = this._delay( function() {
+ this.timer = this._delay(function() {
this._close();
this._open( submenu );
}, this.delay );
@@ -364,20 +379,19 @@ $.widget( "ui.menu", {
_open: function( submenu ) {
clearTimeout( this.timer );
- this.element
- .find( ".ui-menu" )
- .not( submenu.parents() )
+ this.element.find( ".ui-menu" ).not( submenu.parents() )
.hide()
.attr( "aria-hidden", "true" );
- var position = $.extend({}, {
+ var position = $.extend( {}, {
of: this.active
}, $.type(this.options.position) === "function" ?
this.options.position(this.active) :
this.options.position
);
- submenu.show()
+ submenu
+ .show()
.removeAttr( "aria-hidden" )
.attr( "aria-expanded", "true" )
.position( position );
@@ -385,7 +399,7 @@ $.widget( "ui.menu", {
collapseAll: function( event, all ) {
clearTimeout( this.timer );
- this.timer = this._delay( function() {
+ this.timer = this._delay(function() {
// if we were passed an event, look for the submenu that contains the event
var currentMenu = all ? this.element :
$( event && event.target ).closest( this.element.find( ".ui-menu" ) );
@@ -399,7 +413,7 @@ $.widget( "ui.menu", {
this.blur( event );
this.activeMenu = currentMenu;
- }, this.delay);
+ }, this.delay );
},
// With no arguments, closes the currently active menu - if nothing is active
@@ -416,11 +430,12 @@ $.widget( "ui.menu", {
.attr( "aria-expanded", "false" )
.end()
.find( "a.ui-state-active" )
- .removeClass( "ui-state-active" );
+ .removeClass( "ui-state-active" );
},
collapse: function( event ) {
- var newItem = this.active && this.active.parent().closest( ".ui-menu-item", this.element );
+ var newItem = this.active &&
+ this.active.parent().closest( ".ui-menu-item", this.element );
if ( newItem && newItem.length ) {
this._close();
this.focus( event, newItem );
@@ -429,13 +444,17 @@ $.widget( "ui.menu", {
},
expand: function( event ) {
- var newItem = this.active && this.active.children( ".ui-menu " ).children( ".ui-menu-item" ).not( ".ui-state-disabled" ).first();
+ var newItem = this.active &&
+ this.active
+ .children( ".ui-menu " )
+ .children( ".ui-menu-item" )
+ .first();
if ( newItem && newItem.length ) {
this._open( newItem.parent() );
//timeout so Firefox will not hide activedescendant change in expanding submenu from AT
- this._delay( function() {
+ this._delay(function() {
this.focus( event, newItem );
}, 20 );
return true;
@@ -462,9 +481,13 @@ $.widget( "ui.menu", {
var next;
if ( this.active ) {
if ( direction === "first" || direction === "last" ) {
- next = this.active[ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" ).not( ".ui-state-disabled" ).eq( -1 );
+ next = this.active
+ [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
+ .eq( -1 );
} else {
- next = this.active[ direction + "All" ]( ".ui-menu-item" ).not( ".ui-state-disabled" ).eq( 0 );
+ next = this.active
+ [ direction + "All" ]( ".ui-menu-item" )
+ .eq( 0 );
}
}
if ( !next || !next.length || !this.active ) {
@@ -472,9 +495,6 @@ $.widget( "ui.menu", {
}
this.focus( event, next );
- if ( next.is( ".ui-state-disabled" ) ) {
- this._move( direction, filter, event );
- }
},
nextPage: function( event ) {
@@ -489,14 +509,14 @@ $.widget( "ui.menu", {
var base = this.active.offset().top,
height = this.element.height(),
result;
- this.active.nextAll( ".ui-menu-item" ).not( ".ui-state-disabled" ).each( function() {
+ this.active.nextAll( ".ui-menu-item" ).each(function() {
result = $( this );
return $( this ).offset().top - base - height < 0;
});
this.focus( event, result );
} else {
- this.focus( event, this.activeMenu.children( ".ui-menu-item" ).not( ".ui-state-disabled" )
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" )
[ !this.active ? "first" : "last" ]() );
}
},
@@ -513,14 +533,14 @@ $.widget( "ui.menu", {
var base = this.active.offset().top,
height = this.element.height(),
result;
- this.active.prevAll( ".ui-menu-item" ).not( ".ui-state-disabled" ).each( function() {
+ this.active.prevAll( ".ui-menu-item" ).each(function() {
result = $( this );
return $(this).offset().top - base + height > 0;
});
this.focus( event, result );
} else {
- this.focus( event, this.activeMenu.children( ".ui-menu-item" ).not( ".ui-state-disabled" ).first() );
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
}
},
@@ -529,7 +549,6 @@ $.widget( "ui.menu", {
},
select: function( event ) {
-
// save active reference before collapseAll triggers blur
var ui = {
item: this.active
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js
index 7fe31626d..bd7bfb015 100644
--- a/ui/jquery.ui.position.js
+++ b/ui/jquery.ui.position.js
@@ -11,16 +11,32 @@
$.ui = $.ui || {};
-var rhorizontal = /left|center|right/,
+var cachedScrollbarWidth,
+ max = Math.max,
+ abs = Math.abs,
+ round = Math.round,
+ rhorizontal = /left|center|right/,
rvertical = /top|center|bottom/,
- roffset = /[+-]\d+%?/,
+ roffset = /[\+\-]\d+%?/,
rposition = /^\w+/,
rpercent = /%$/,
- center = "center",
_position = $.fn.position;
+function getOffsets( offsets, width, height ) {
+ return [
+ parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
+ parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
+ ];
+}
+function parseCss( element, property ) {
+ return parseInt( $.css( element, property ), 10 ) || 0;
+}
+
$.position = {
scrollbarWidth: function() {
+ if ( cachedScrollbarWidth !== undefined ) {
+ return cachedScrollbarWidth;
+ }
var w1, w2,
div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
innerDiv = div.children()[0];
@@ -37,18 +53,31 @@ $.position = {
div.remove();
- return w1 - w2;
+ return (cachedScrollbarWidth = w1 - w2);
},
- getScrollInfo: function(within) {
- var notWindow = within[0] !== window,
- overflowX = notWindow ? within.css( "overflow-x" ) : "",
- overflowY = notWindow ? within.css( "overflow-y" ) : "",
- scrollbarWidth = overflowX === "auto" || overflowX === "scroll" ? $.position.scrollbarWidth() : 0,
- scrollbarHeight = overflowY === "auto" || overflowY === "scroll" ? $.position.scrollbarWidth() : 0;
-
+ getScrollInfo: function( within ) {
+ var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
+ overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
+ hasOverflowX = overflowX === "scroll" ||
+ ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
+ hasOverflowY = overflowY === "scroll" ||
+ ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
+ return {
+ width: hasOverflowX ? $.position.scrollbarWidth() : 0,
+ height: hasOverflowY ? $.position.scrollbarWidth() : 0
+ };
+ },
+ getWithinInfo: function( element ) {
+ var withinElement = $( element || window ),
+ isWindow = $.isWindow( withinElement[0] );
return {
- height: within.height() < within[0].scrollHeight ? scrollbarHeight : 0,
- width: within.width() < within[0].scrollWidth ? scrollbarWidth : 0
+ element: withinElement,
+ isWindow: isWindow,
+ offset: withinElement.offset() || { left: 0, top: 0 },
+ scrollLeft: withinElement.scrollLeft(),
+ scrollTop: withinElement.scrollTop(),
+ width: isWindow ? withinElement.width() : withinElement.outerWidth(),
+ height: isWindow ? withinElement.height() : withinElement.outerHeight()
};
}
};
@@ -61,34 +90,34 @@ $.fn.position = function( options ) {
// make a copy, we don't want to modify arguments
options = $.extend( {}, options );
- var target = $( options.of ),
- within = $( options.within || window ),
+ var atOffset, targetWidth, targetHeight, targetOffset, basePosition,
+ target = $( options.of ),
+ within = $.position.getWithinInfo( options.within ),
+ scrollInfo = $.position.getScrollInfo( within ),
targetElem = target[0],
collision = ( options.collision || "flip" ).split( " " ),
- offsets = {},
- atOffset,
- targetWidth,
- targetHeight,
- basePosition;
+ offsets = {};
if ( targetElem.nodeType === 9 ) {
targetWidth = target.width();
targetHeight = target.height();
- basePosition = { top: 0, left: 0 };
+ targetOffset = { top: 0, left: 0 };
} else if ( $.isWindow( targetElem ) ) {
targetWidth = target.width();
targetHeight = target.height();
- basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
+ targetOffset = { top: target.scrollTop(), left: target.scrollLeft() };
} else if ( targetElem.preventDefault ) {
// force left top to allow flipping
options.at = "left top";
targetWidth = targetHeight = 0;
- basePosition = { top: options.of.pageY, left: options.of.pageX };
+ targetOffset = { top: targetElem.pageY, left: targetElem.pageX };
} else {
targetWidth = target.outerWidth();
targetHeight = target.outerHeight();
- basePosition = target.offset();
+ targetOffset = target.offset();
}
+ // clone to reuse original targetOffset later
+ basePosition = $.extend( {}, targetOffset );
// force my and at to have valid horizontal and vertical positions
// if a value is missing or invalid, it will be converted to center
@@ -99,13 +128,13 @@ $.fn.position = function( options ) {
if ( pos.length === 1) {
pos = rhorizontal.test( pos[ 0 ] ) ?
- pos.concat( [ center ] ) :
+ pos.concat( [ "center" ] ) :
rvertical.test( pos[ 0 ] ) ?
- [ center ].concat( pos ) :
- [ center, center ];
+ [ "center" ].concat( pos ) :
+ [ "center", "center" ];
}
- pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : center;
- pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : center;
+ pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
+ pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
// calculate offsets
horizontalOffset = roffset.exec( pos[ 0 ] );
@@ -129,54 +158,41 @@ $.fn.position = function( options ) {
if ( options.at[ 0 ] === "right" ) {
basePosition.left += targetWidth;
- } else if ( options.at[ 0 ] === center ) {
+ } else if ( options.at[ 0 ] === "center" ) {
basePosition.left += targetWidth / 2;
}
if ( options.at[ 1 ] === "bottom" ) {
basePosition.top += targetHeight;
- } else if ( options.at[ 1 ] === center ) {
+ } else if ( options.at[ 1 ] === "center" ) {
basePosition.top += targetHeight / 2;
}
- atOffset = [
- parseInt( offsets.at[ 0 ], 10 ) *
- ( rpercent.test( offsets.at[ 0 ] ) ? targetWidth / 100 : 1 ),
- parseInt( offsets.at[ 1 ], 10 ) *
- ( rpercent.test( offsets.at[ 1 ] ) ? targetHeight / 100 : 1 )
- ];
+ atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
basePosition.left += atOffset[ 0 ];
basePosition.top += atOffset[ 1 ];
return this.each(function() {
- var elem = $( this ),
+ var collisionPosition, using,
+ elem = $( this ),
elemWidth = elem.outerWidth(),
elemHeight = elem.outerHeight(),
- marginLeft = parseInt( $.css( this, "marginLeft" ), 10 ) || 0,
- marginTop = parseInt( $.css( this, "marginTop" ), 10 ) || 0,
- scrollInfo = $.position.getScrollInfo( within ),
- collisionWidth = elemWidth + marginLeft +
- ( parseInt( $.css( this, "marginRight" ), 10 ) || 0 ) + scrollInfo.width,
- collisionHeight = elemHeight + marginTop +
- ( parseInt( $.css( this, "marginBottom" ), 10 ) || 0 ) + scrollInfo.height,
+ marginLeft = parseCss( this, "marginLeft" ),
+ marginTop = parseCss( this, "marginTop" ),
+ collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
+ collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
position = $.extend( {}, basePosition ),
- myOffset = [
- parseInt( offsets.my[ 0 ], 10 ) *
- ( rpercent.test( offsets.my[ 0 ] ) ? elem.outerWidth() / 100 : 1 ),
- parseInt( offsets.my[ 1 ], 10 ) *
- ( rpercent.test( offsets.my[ 1 ] ) ? elem.outerHeight() / 100 : 1 )
- ],
- collisionPosition;
+ myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
if ( options.my[ 0 ] === "right" ) {
position.left -= elemWidth;
- } else if ( options.my[ 0 ] === center ) {
+ } else if ( options.my[ 0 ] === "center" ) {
position.left -= elemWidth / 2;
}
if ( options.my[ 1 ] === "bottom" ) {
position.top -= elemHeight;
- } else if ( options.my[ 1 ] === center ) {
+ } else if ( options.my[ 1 ] === "center" ) {
position.top -= elemHeight / 2;
}
@@ -185,8 +201,8 @@ $.fn.position = function( options ) {
// if the browser doesn't support fractions, then round for consistent results
if ( !$.support.offsetFractions ) {
- position.left = Math.round( position.left );
- position.top = Math.round( position.top );
+ position.left = round( position.left );
+ position.top = round( position.top );
}
collisionPosition = {
@@ -216,7 +232,48 @@ $.fn.position = function( options ) {
if ( $.fn.bgiframe ) {
elem.bgiframe();
}
- elem.offset( $.extend( position, { using: options.using } ) );
+
+ if ( options.using ) {
+ // adds feedback as second argument to using callback, if present
+ using = function( props ) {
+ var left = targetOffset.left - position.left,
+ right = left + targetWidth - elemWidth,
+ top = targetOffset.top - position.top,
+ bottom = top + targetHeight - elemHeight,
+ feedback = {
+ target: {
+ element: target,
+ left: targetOffset.left,
+ top: targetOffset.top,
+ width: targetWidth,
+ height: targetHeight
+ },
+ element: {
+ element: elem,
+ left: position.left,
+ top: position.top,
+ width: elemWidth,
+ height: elemHeight
+ },
+ horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
+ vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
+ };
+ if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
+ feedback.horizontal = "center";
+ }
+ if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
+ feedback.vertical = "middle";
+ }
+ if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
+ feedback.important = "horizontal";
+ } else {
+ feedback.important = "vertical";
+ }
+ options.using.call( this, props, feedback );
+ };
+ }
+
+ elem.offset( $.extend( position, { using: using } ) );
});
};
@@ -224,15 +281,12 @@ $.ui.position = {
fit: {
left: function( position, data ) {
var within = data.within,
- win = $( window ),
- isWindow = $.isWindow( data.within[0] ),
- withinOffset = isWindow ? win.scrollLeft() : within.offset().left,
- outerWidth = isWindow ? win.width() : within.outerWidth(),
+ withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
+ outerWidth = within.width,
collisionPosLeft = position.left - data.collisionPosition.marginLeft,
overLeft = withinOffset - collisionPosLeft,
overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
- newOverRight,
- newOverLeft;
+ newOverRight;
// element is wider than within
if ( data.collisionWidth > outerWidth ) {
@@ -259,19 +313,16 @@ $.ui.position = {
position.left -= overRight;
// adjust based on position and margin
} else {
- position.left = Math.max( position.left - collisionPosLeft, position.left );
+ position.left = max( position.left - collisionPosLeft, position.left );
}
},
top: function( position, data ) {
var within = data.within,
- win = $( window ),
- isWindow = $.isWindow( data.within[0] ),
- withinOffset = isWindow ? win.scrollTop() : within.offset().top,
- outerHeight = isWindow ? win.height() : within.outerHeight(),
+ withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
+ outerHeight = data.within.height,
collisionPosTop = position.top - data.collisionPosition.marginTop,
overTop = withinOffset - collisionPosTop,
overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
- newOverTop,
newOverBottom;
// element is taller than within
@@ -299,28 +350,19 @@ $.ui.position = {
position.top -= overBottom;
// adjust based on position and margin
} else {
- position.top = Math.max( position.top - collisionPosTop, position.top );
+ position.top = max( position.top - collisionPosTop, position.top );
}
}
},
flip: {
left: function( position, data ) {
- if ( data.at[ 0 ] === center ) {
- return;
- }
-
- data.elem
- .removeClass( "ui-flipped-left ui-flipped-right" );
-
var within = data.within,
- win = $( window ),
- isWindow = $.isWindow( data.within[0] ),
- withinOffset = ( isWindow ? 0 : within.offset().left ) + within.scrollLeft(),
- outerWidth = isWindow ? within.width() : within.outerWidth(),
+ withinOffset = within.offset.left + within.scrollLeft,
+ outerWidth = within.width,
+ offsetLeft = within.isWindow ? 0 : within.offset.left,
collisionPosLeft = position.left - data.collisionPosition.marginLeft,
- overLeft = collisionPosLeft - withinOffset,
- overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
- left = data.my[ 0 ] === "left",
+ overLeft = collisionPosLeft - offsetLeft,
+ overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
myOffset = data.my[ 0 ] === "left" ?
-data.elemWidth :
data.my[ 0 ] === "right" ?
@@ -328,46 +370,34 @@ $.ui.position = {
0,
atOffset = data.at[ 0 ] === "left" ?
data.targetWidth :
- -data.targetWidth,
+ data.at[ 0 ] === "right" ?
+ -data.targetWidth :
+ 0,
offset = -2 * data.offset[ 0 ],
newOverRight,
newOverLeft;
if ( overLeft < 0 ) {
newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
- if ( newOverRight < 0 || newOverRight < Math.abs( overLeft ) ) {
- data.elem
- .addClass( "ui-flipped-right" );
-
+ if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
position.left += myOffset + atOffset + offset;
}
}
else if ( overRight > 0 ) {
- newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - withinOffset;
- if ( newOverLeft > 0 || Math.abs( newOverLeft ) < overRight ) {
- data.elem
- .addClass( "ui-flipped-left" );
-
+ newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
+ if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
position.left += myOffset + atOffset + offset;
}
}
},
top: function( position, data ) {
- if ( data.at[ 1 ] === center ) {
- return;
- }
-
- data.elem
- .removeClass( "ui-flipped-top ui-flipped-bottom" );
-
var within = data.within,
- win = $( window ),
- isWindow = $.isWindow( data.within[0] ),
- withinOffset = ( isWindow ? 0 : within.offset().top ) + within.scrollTop(),
- outerHeight = isWindow ? within.height() : within.outerHeight(),
+ withinOffset = within.offset.top + within.scrollTop,
+ outerHeight = within.height,
+ offsetTop = within.isWindow ? 0 : within.offset.top,
collisionPosTop = position.top - data.collisionPosition.marginTop,
- overTop = collisionPosTop - withinOffset,
- overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
+ overTop = collisionPosTop - offsetTop,
+ overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
top = data.my[ 1 ] === "top",
myOffset = top ?
-data.elemHeight :
@@ -376,25 +406,21 @@ $.ui.position = {
0,
atOffset = data.at[ 1 ] === "top" ?
data.targetHeight :
- -data.targetHeight,
+ data.at[ 1 ] === "bottom" ?
+ -data.targetHeight :
+ 0,
offset = -2 * data.offset[ 1 ],
newOverTop,
newOverBottom;
if ( overTop < 0 ) {
newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
- if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < Math.abs( overTop ) ) ) {
- data.elem
- .addClass( "ui-flipped-bottom" );
-
+ if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
position.top += myOffset + atOffset + offset;
}
}
else if ( overBottom > 0 ) {
- newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - withinOffset;
- if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || Math.abs( newOverTop ) < overBottom ) ) {
- data.elem
- .addClass( "ui-flipped-top" );
-
+ newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
+ if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
position.top += myOffset + atOffset + offset;
}
}
diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js
index 9be33927e..b4433b618 100644
--- a/ui/jquery.ui.resizable.js
+++ b/ui/jquery.ui.resizable.js
@@ -37,7 +37,7 @@ $.widget("ui.resizable", $.ui.mouse, {
},
_create: function() {
- var self = this, o = this.options;
+ var that = this, o = this.options;
this.element.addClass("ui-resizable");
$.extend(this, {
@@ -99,9 +99,8 @@ $.widget("ui.resizable", $.ui.mouse, {
var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
- // increase zIndex of sw, se, ne, nw axis
- //TODO : this modifies original option
- if(/sw|se|ne|nw/.test(handle)) axis.css({ zIndex: ++o.zIndex });
+ // Apply zIndex to all handles - see #7960
+ axis.css({ zIndex: o.zIndex });
//TODO : What's going on here?
if ('se' == handle) {
@@ -159,11 +158,11 @@ $.widget("ui.resizable", $.ui.mouse, {
//Matching axis name
this._handles.mouseover(function() {
- if (!self.resizing) {
+ if (!that.resizing) {
if (this.className)
var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
//Axis, default = se
- self.axis = axis && axis[1] ? axis[1] : 'se';
+ that.axis = axis && axis[1] ? axis[1] : 'se';
}
});
@@ -175,13 +174,13 @@ $.widget("ui.resizable", $.ui.mouse, {
.hover(function() {
if (o.disabled) return;
$(this).removeClass("ui-resizable-autohide");
- self._handles.show();
+ that._handles.show();
},
function(){
if (o.disabled) return;
- if (!self.resizing) {
+ if (!that.resizing) {
$(this).addClass("ui-resizable-autohide");
- self._handles.hide();
+ that._handles.hide();
}
});
}
@@ -277,7 +276,7 @@ $.widget("ui.resizable", $.ui.mouse, {
//Increase performance, avoid regex
var el = this.helper, o = this.options, props = {},
- self = this, smp = this.originalMousePosition, a = this.axis;
+ that = this, smp = this.originalMousePosition, a = this.axis;
var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
var trigger = this._change[a];
@@ -315,22 +314,22 @@ $.widget("ui.resizable", $.ui.mouse, {
_mouseStop: function(event) {
this.resizing = false;
- var o = this.options, self = this;
+ var o = this.options, that = this;
if(this._helper) {
var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
- soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
- soffsetw = ista ? 0 : self.sizeDiff.width;
+ soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
+ soffsetw = ista ? 0 : that.sizeDiff.width;
- var s = { width: (self.helper.width() - soffsetw), height: (self.helper.height() - soffseth) },
- left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
- top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
+ var s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) },
+ left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
+ top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
if (!o.animate)
this.element.css($.extend(s, { top: top, left: left }));
- self.helper.height(self.size.height);
- self.helper.width(self.size.width);
+ that.helper.height(that.size.height);
+ that.helper.width(that.size.width);
if (this._helper && !o.animate) this._proportionallyResize();
}
@@ -548,7 +547,7 @@ $.widget("ui.resizable", $.ui.mouse, {
$.ui.plugin.add("resizable", "alsoResize", {
start: function (event, ui) {
- var self = $(this).data("resizable"), o = self.options;
+ var that = $(this).data("resizable"), o = that.options;
var _store = function (exp) {
$(exp).each(function() {
@@ -569,11 +568,11 @@ $.ui.plugin.add("resizable", "alsoResize", {
},
resize: function (event, ui) {
- var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition;
+ var that = $(this).data("resizable"), o = that.options, os = that.originalSize, op = that.originalPosition;
var delta = {
- height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
- top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
+ height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
+ top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
},
_alsoResize = function (exp, c) {
@@ -606,34 +605,34 @@ $.ui.plugin.add("resizable", "alsoResize", {
$.ui.plugin.add("resizable", "animate", {
stop: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options;
+ var that = $(this).data("resizable"), o = that.options;
- var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
- soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
- soffsetw = ista ? 0 : self.sizeDiff.width;
+ var pr = that._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
+ soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
+ soffsetw = ista ? 0 : that.sizeDiff.width;
- var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
- left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
- top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
+ var style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
+ left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
+ top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
- self.element.animate(
+ that.element.animate(
$.extend(style, top && left ? { top: top, left: left } : {}), {
duration: o.animateDuration,
easing: o.animateEasing,
step: function() {
var data = {
- width: parseInt(self.element.css('width'), 10),
- height: parseInt(self.element.css('height'), 10),
- top: parseInt(self.element.css('top'), 10),
- left: parseInt(self.element.css('left'), 10)
+ width: parseInt(that.element.css('width'), 10),
+ height: parseInt(that.element.css('height'), 10),
+ top: parseInt(that.element.css('top'), 10),
+ left: parseInt(that.element.css('left'), 10)
};
if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
// propagating resize, and updating values for each animation step
- self._updateCache(data);
- self._propagate("resize", event);
+ that._updateCache(data);
+ that._propagate("resize", event);
}
}
@@ -645,17 +644,17 @@ $.ui.plugin.add("resizable", "animate", {
$.ui.plugin.add("resizable", "containment", {
start: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options, el = self.element;
+ var that = $(this).data("resizable"), o = that.options, el = that.element;
var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
if (!ce) return;
- self.containerElement = $(ce);
+ that.containerElement = $(ce);
if (/document/.test(oc) || oc == document) {
- self.containerOffset = { left: 0, top: 0 };
- self.containerPosition = { left: 0, top: 0 };
+ that.containerOffset = { left: 0, top: 0 };
+ that.containerPosition = { left: 0, top: 0 };
- self.parentData = {
+ that.parentData = {
element: $(document), left: 0, top: 0,
width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
};
@@ -666,70 +665,70 @@ $.ui.plugin.add("resizable", "containment", {
var element = $(ce), p = [];
$([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
- self.containerOffset = element.offset();
- self.containerPosition = element.position();
- self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
+ that.containerOffset = element.offset();
+ that.containerPosition = element.position();
+ that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
- var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width,
+ var co = that.containerOffset, ch = that.containerSize.height, cw = that.containerSize.width,
width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
- self.parentData = {
+ that.parentData = {
element: ce, left: co.left, top: co.top, width: width, height: height
};
}
},
resize: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options,
- ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
- pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
+ var that = $(this).data("resizable"), o = that.options,
+ ps = that.containerSize, co = that.containerOffset, cs = that.size, cp = that.position,
+ pRatio = that._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = that.containerElement;
if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
- if (cp.left < (self._helper ? co.left : 0)) {
- self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left));
- if (pRatio) self.size.height = self.size.width / self.aspectRatio;
- self.position.left = o.helper ? co.left : 0;
+ if (cp.left < (that._helper ? co.left : 0)) {
+ that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
+ if (pRatio) that.size.height = that.size.width / that.aspectRatio;
+ that.position.left = o.helper ? co.left : 0;
}
- if (cp.top < (self._helper ? co.top : 0)) {
- self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top);
- if (pRatio) self.size.width = self.size.height * self.aspectRatio;
- self.position.top = self._helper ? co.top : 0;
+ if (cp.top < (that._helper ? co.top : 0)) {
+ that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
+ if (pRatio) that.size.width = that.size.height * that.aspectRatio;
+ that.position.top = that._helper ? co.top : 0;
}
- self.offset.left = self.parentData.left+self.position.left;
- self.offset.top = self.parentData.top+self.position.top;
+ that.offset.left = that.parentData.left+that.position.left;
+ that.offset.top = that.parentData.top+that.position.top;
- var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),
- hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
+ var woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width ),
+ hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
- var isParent = self.containerElement.get(0) == self.element.parent().get(0),
- isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position'));
+ var isParent = that.containerElement.get(0) == that.element.parent().get(0),
+ isOffsetRelative = /relative|absolute/.test(that.containerElement.css('position'));
- if(isParent && isOffsetRelative) woset -= self.parentData.left;
+ if(isParent && isOffsetRelative) woset -= that.parentData.left;
- if (woset + self.size.width >= self.parentData.width) {
- self.size.width = self.parentData.width - woset;
- if (pRatio) self.size.height = self.size.width / self.aspectRatio;
+ if (woset + that.size.width >= that.parentData.width) {
+ that.size.width = that.parentData.width - woset;
+ if (pRatio) that.size.height = that.size.width / that.aspectRatio;
}
- if (hoset + self.size.height >= self.parentData.height) {
- self.size.height = self.parentData.height - hoset;
- if (pRatio) self.size.width = self.size.height * self.aspectRatio;
+ if (hoset + that.size.height >= that.parentData.height) {
+ that.size.height = that.parentData.height - hoset;
+ if (pRatio) that.size.width = that.size.height * that.aspectRatio;
}
},
stop: function(event, ui){
- var self = $(this).data("resizable"), o = self.options, cp = self.position,
- co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
+ var that = $(this).data("resizable"), o = that.options, cp = that.position,
+ co = that.containerOffset, cop = that.containerPosition, ce = that.containerElement;
- var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height;
+ var helper = $(that.helper), ho = helper.offset(), w = helper.outerWidth() - that.sizeDiff.width, h = helper.outerHeight() - that.sizeDiff.height;
- if (self._helper && !o.animate && (/relative/).test(ce.css('position')))
+ if (that._helper && !o.animate && (/relative/).test(ce.css('position')))
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
- if (self._helper && !o.animate && (/static/).test(ce.css('position')))
+ if (that._helper && !o.animate && (/static/).test(ce.css('position')))
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
}
@@ -739,26 +738,26 @@ $.ui.plugin.add("resizable", "ghost", {
start: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options, cs = self.size;
+ var that = $(this).data("resizable"), o = that.options, cs = that.size;
- self.ghost = self.originalElement.clone();
- self.ghost
+ that.ghost = that.originalElement.clone();
+ that.ghost
.css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
.addClass('ui-resizable-ghost')
.addClass(typeof o.ghost == 'string' ? o.ghost : '');
- self.ghost.appendTo(self.helper);
+ that.ghost.appendTo(that.helper);
},
resize: function(event, ui){
- var self = $(this).data("resizable"), o = self.options;
- if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
+ var that = $(this).data("resizable"), o = that.options;
+ if (that.ghost) that.ghost.css({ position: 'relative', height: that.size.height, width: that.size.width });
},
stop: function(event, ui){
- var self = $(this).data("resizable"), o = self.options;
- if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
+ var that = $(this).data("resizable"), o = that.options;
+ if (that.ghost && that.helper) that.helper.get(0).removeChild(that.ghost.get(0));
}
});
@@ -766,29 +765,29 @@ $.ui.plugin.add("resizable", "ghost", {
$.ui.plugin.add("resizable", "grid", {
resize: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options, cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey;
+ var that = $(this).data("resizable"), o = that.options, cs = that.size, os = that.originalSize, op = that.originalPosition, a = that.axis, ratio = o._aspectRatio || event.shiftKey;
o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1);
if (/^(se|s|e)$/.test(a)) {
- self.size.width = os.width + ox;
- self.size.height = os.height + oy;
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
}
else if (/^(ne)$/.test(a)) {
- self.size.width = os.width + ox;
- self.size.height = os.height + oy;
- self.position.top = op.top - oy;
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
+ that.position.top = op.top - oy;
}
else if (/^(sw)$/.test(a)) {
- self.size.width = os.width + ox;
- self.size.height = os.height + oy;
- self.position.left = op.left - ox;
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
+ that.position.left = op.left - ox;
}
else {
- self.size.width = os.width + ox;
- self.size.height = os.height + oy;
- self.position.top = op.top - oy;
- self.position.left = op.left - ox;
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
+ that.position.top = op.top - oy;
+ that.position.left = op.left - ox;
}
}
diff --git a/ui/jquery.ui.selectable.js b/ui/jquery.ui.selectable.js
index 3244e654e..f8a0134f8 100644
--- a/ui/jquery.ui.selectable.js
+++ b/ui/jquery.ui.selectable.js
@@ -24,7 +24,7 @@ $.widget("ui.selectable", $.ui.mouse, {
tolerance: 'touch'
},
_create: function() {
- var self = this;
+ var that = this;
this.element.addClass("ui-selectable");
@@ -33,7 +33,7 @@ $.widget("ui.selectable", $.ui.mouse, {
// cache selectee children based on filter
var selectees;
this.refresh = function() {
- selectees = $(self.options.filter, self.element[0]);
+ selectees = $(that.options.filter, that.element[0]);
selectees.addClass("ui-selectee");
selectees.each(function() {
var $this = $(this);
@@ -75,7 +75,7 @@ $.widget("ui.selectable", $.ui.mouse, {
},
_mouseStart: function(event) {
- var self = this;
+ var that = this;
this.opos = [event.pageX, event.pageY];
@@ -110,7 +110,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.$element.addClass('ui-unselecting');
selectee.unselecting = true;
// selectable UNSELECTING callback
- self._trigger("unselecting", event, {
+ that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
@@ -128,11 +128,11 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.selected = doSelect;
// selectable (UN)SELECTING callback
if (doSelect) {
- self._trigger("selecting", event, {
+ that._trigger("selecting", event, {
selecting: selectee.element
});
} else {
- self._trigger("unselecting", event, {
+ that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
@@ -143,7 +143,7 @@ $.widget("ui.selectable", $.ui.mouse, {
},
_mouseDrag: function(event) {
- var self = this;
+ var that = this;
this.dragged = true;
if (this.options.disabled)
@@ -159,7 +159,7 @@ $.widget("ui.selectable", $.ui.mouse, {
this.selectees.each(function() {
var selectee = $.data(this, "selectable-item");
//prevent helper from being selected if appendTo: selectable
- if (!selectee || selectee.element == self.element[0])
+ if (!selectee || selectee.element == that.element[0])
return;
var hit = false;
if (options.tolerance == 'touch') {
@@ -182,7 +182,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.$element.addClass('ui-selecting');
selectee.selecting = true;
// selectable SELECTING callback
- self._trigger("selecting", event, {
+ that._trigger("selecting", event, {
selecting: selectee.element
});
}
@@ -202,7 +202,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.unselecting = true;
}
// selectable UNSELECTING callback
- self._trigger("unselecting", event, {
+ that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
@@ -215,7 +215,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.$element.addClass('ui-unselecting');
selectee.unselecting = true;
// selectable UNSELECTING callback
- self._trigger("unselecting", event, {
+ that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
@@ -227,7 +227,7 @@ $.widget("ui.selectable", $.ui.mouse, {
},
_mouseStop: function(event) {
- var self = this;
+ var that = this;
this.dragged = false;
@@ -238,7 +238,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.$element.removeClass('ui-unselecting');
selectee.unselecting = false;
selectee.startselected = false;
- self._trigger("unselected", event, {
+ that._trigger("unselected", event, {
unselected: selectee.element
});
});
@@ -248,7 +248,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.selecting = false;
selectee.selected = true;
selectee.startselected = true;
- self._trigger("selected", event, {
+ that._trigger("selected", event, {
selected: selectee.element
});
});
diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js
index b355f8c7e..accd3e189 100644
--- a/ui/jquery.ui.slider.js
+++ b/ui/jquery.ui.slider.js
@@ -36,7 +36,6 @@ $.widget( "ui.slider", $.ui.mouse, {
_create: function() {
var i,
- self = this,
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>",
@@ -83,7 +82,7 @@ $.widget( "ui.slider", $.ui.mouse, {
handles.push( handle );
}
- this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( self.element ) );
+ this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
this.handle = this.handles.eq( 0 );
@@ -114,17 +113,10 @@ $.widget( "ui.slider", $.ui.mouse, {
$( this ).data( "ui-slider-handle-index", i );
});
- this.handles
- .keydown(function( event ) {
- var index = $( this ).data( "ui-slider-handle-index" ),
- allowed,
- curVal,
- newVal,
- step;
-
- if ( self.options.disabled ) {
- return;
- }
+ this._bind( this.handles, {
+ keydown: function( event ) {
+ var allowed, curVal, newVal, step,
+ index = $( event.target ).data( "ui-slider-handle-index" );
switch ( event.keyCode ) {
case $.ui.keyCode.HOME:
@@ -136,10 +128,10 @@ $.widget( "ui.slider", $.ui.mouse, {
case $.ui.keyCode.DOWN:
case $.ui.keyCode.LEFT:
event.preventDefault();
- if ( !self._keySliding ) {
- self._keySliding = true;
- $( this ).addClass( "ui-state-active" );
- allowed = self._start( event, index );
+ if ( !this._keySliding ) {
+ this._keySliding = true;
+ $( event.target ).addClass( "ui-state-active" );
+ allowed = this._start( event, index );
if ( allowed === false ) {
return;
}
@@ -147,62 +139,62 @@ $.widget( "ui.slider", $.ui.mouse, {
break;
}
- step = self.options.step;
- if ( self.options.values && self.options.values.length ) {
- curVal = newVal = self.values( index );
+ step = this.options.step;
+ if ( this.options.values && this.options.values.length ) {
+ curVal = newVal = this.values( index );
} else {
- curVal = newVal = self.value();
+ curVal = newVal = this.value();
}
switch ( event.keyCode ) {
case $.ui.keyCode.HOME:
- newVal = self._valueMin();
+ newVal = this._valueMin();
break;
case $.ui.keyCode.END:
- newVal = self._valueMax();
+ newVal = this._valueMax();
break;
case $.ui.keyCode.PAGE_UP:
- newVal = self._trimAlignValue( curVal + ( (self._valueMax() - self._valueMin()) / numPages ) );
+ newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
break;
case $.ui.keyCode.PAGE_DOWN:
- newVal = self._trimAlignValue( curVal - ( (self._valueMax() - self._valueMin()) / numPages ) );
+ newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
break;
case $.ui.keyCode.UP:
case $.ui.keyCode.RIGHT:
- if ( curVal === self._valueMax() ) {
+ if ( curVal === this._valueMax() ) {
return;
}
- newVal = self._trimAlignValue( curVal + step );
+ newVal = this._trimAlignValue( curVal + step );
break;
case $.ui.keyCode.DOWN:
case $.ui.keyCode.LEFT:
- if ( curVal === self._valueMin() ) {
+ if ( curVal === this._valueMin() ) {
return;
}
- newVal = self._trimAlignValue( curVal - step );
+ newVal = this._trimAlignValue( curVal - step );
break;
}
- self._slide( event, index, newVal );
- })
- .keyup(function( event ) {
- var index = $( this ).data( "ui-slider-handle-index" );
-
- if ( self._keySliding ) {
- self._keySliding = false;
- self._stop( event, index );
- self._change( event, index );
- $( this ).removeClass( "ui-state-active" );
- }
+ this._slide( event, index, newVal );
+ },
+ keyup: function( event ) {
+ var index = $( event.target ).data( "ui-slider-handle-index" );
- });
+ if ( this._keySliding ) {
+ this._keySliding = false;
+ this._stop( event, index );
+ this._change( event, index );
+ $( event.target ).removeClass( "ui-state-active" );
+ }
+ }
+ });
this._refreshValue();
this._animateOff = false;
},
- destroy: function() {
+ _destroy: function() {
this.handles.remove();
this.range.remove();
@@ -213,26 +205,15 @@ $.widget( "ui.slider", $.ui.mouse, {
" ui-slider-disabled" +
" ui-widget" +
" ui-widget-content" +
- " ui-corner-all" )
- .removeData( "slider" )
- .unbind( ".slider" );
+ " ui-corner-all" );
this._mouseDestroy();
-
- return this;
},
_mouseCapture: function( event ) {
- var o = this.options,
- position,
- normValue,
- distance,
- closestHandle,
- self,
- index,
- allowed,
- offset,
- mouseOverHandle;
+ var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
+ that = this,
+ o = this.options;
if ( o.disabled ) {
return false;
@@ -247,9 +228,8 @@ $.widget( "ui.slider", $.ui.mouse, {
position = { x: event.pageX, y: event.pageY };
normValue = this._normValueFromMouse( position );
distance = this._valueMax() - this._valueMin() + 1;
- self = this;
this.handles.each(function( i ) {
- var thisDistance = Math.abs( normValue - self.values(i) );
+ var thisDistance = Math.abs( normValue - that.values(i) );
if ( distance > thisDistance ) {
distance = thisDistance;
closestHandle = $( this );
@@ -271,7 +251,7 @@ $.widget( "ui.slider", $.ui.mouse, {
}
this._mouseSliding = true;
- self._handleIndex = index;
+ this._handleIndex = index;
closestHandle
.addClass( "ui-state-active" )
@@ -594,36 +574,32 @@ $.widget( "ui.slider", $.ui.mouse, {
},
_refreshValue: function() {
- var oRange = this.options.range,
+ var lastValPercent, valPercent, value, valueMin, valueMax,
+ oRange = this.options.range,
o = this.options,
- self = this,
+ that = this,
animate = ( !this._animateOff ) ? o.animate : false,
- valPercent,
- _set = {},
- lastValPercent,
- value,
- valueMin,
- valueMax;
+ _set = {};
if ( this.options.values && this.options.values.length ) {
this.handles.each(function( i, j ) {
- valPercent = ( self.values(i) - self._valueMin() ) / ( self._valueMax() - self._valueMin() ) * 100;
- _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
+ valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
+ _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
$( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
- if ( self.options.range === true ) {
- if ( self.orientation === "horizontal" ) {
+ if ( that.options.range === true ) {
+ if ( that.orientation === "horizontal" ) {
if ( i === 0 ) {
- self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
+ that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
}
if ( i === 1 ) {
- self.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
+ that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
}
} else {
if ( i === 0 ) {
- self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
+ that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
}
if ( i === 1 ) {
- self.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
+ that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
}
}
}
@@ -636,7 +612,7 @@ $.widget( "ui.slider", $.ui.mouse, {
valPercent = ( valueMax !== valueMin ) ?
( value - valueMin ) / ( valueMax - valueMin ) * 100 :
0;
- _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
+ _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
if ( oRange === "min" && this.orientation === "horizontal" ) {
diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js
index 4093be245..55a64590b 100644
--- a/ui/jquery.ui.sortable.js
+++ b/ui/jquery.ui.sortable.js
@@ -59,7 +59,7 @@ $.widget("ui.sortable", $.ui.mouse, {
//Initialize mouse events for interaction
this._mouseInit();
-
+
//We're ready to go
this.ready = true
@@ -79,7 +79,7 @@ $.widget("ui.sortable", $.ui.mouse, {
_setOption: function(key, value){
if ( key === "disabled" ) {
this.options[ key ] = value;
-
+
this.widget().toggleClass( "ui-sortable-disabled", !!value );
} else {
// Don't call widget base _setOption for disable as it adds ui-state-disabled class
@@ -100,13 +100,13 @@ $.widget("ui.sortable", $.ui.mouse, {
this._refreshItems(event);
//Find out if the clicked node (or one of its parents) is a actual item in this.items
- var currentItem = null, self = this, nodes = $(event.target).parents().each(function() {
- if($.data(this, that.widgetName + '-item') == self) {
+ var currentItem = null, nodes = $(event.target).parents().each(function() {
+ if($.data(this, that.widgetName + '-item') == that) {
currentItem = $(this);
return false;
}
});
- if($.data(event.target, that.widgetName + '-item') == self) currentItem = $(event.target);
+ if($.data(event.target, that.widgetName + '-item') == that) currentItem = $(event.target);
if(!currentItem) return false;
if(this.options.handle && !overrideHandle) {
@@ -124,7 +124,7 @@ $.widget("ui.sortable", $.ui.mouse, {
_mouseStart: function(event, overrideHandle, noActivation) {
- var o = this.options, self = this;
+ var o = this.options;
this.currentContainer = this;
//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
@@ -154,11 +154,6 @@ $.widget("ui.sortable", $.ui.mouse, {
left: this.offset.left - this.margins.left
};
- // Only after we got the offset, we can change the helper's position to absolute
- // TODO: Still need to figure out a way to make relative sorting possible
- this.helper.css("position", "absolute");
- this.cssPosition = this.helper.css("position");
-
$.extend(this.offset, {
click: { //Where the click happened, relative to the element
left: event.pageX - this.offset.left,
@@ -168,6 +163,11 @@ $.widget("ui.sortable", $.ui.mouse, {
relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
});
+ // Only after we got the offset, we can change the helper's position to absolute
+ // TODO: Still need to figure out a way to make relative sorting possible
+ this.helper.css("position", "absolute");
+ this.cssPosition = this.helper.css("position");
+
//Generate the original position
this.originalPosition = this._generatePosition(event);
this.originalPageX = event.pageX;
@@ -220,7 +220,7 @@ $.widget("ui.sortable", $.ui.mouse, {
//Post 'activate' events to possible containers
if(!noActivation) {
- for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); }
+ for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, this._uiHash(this)); }
}
//Prepare possible droppables
@@ -338,16 +338,16 @@ $.widget("ui.sortable", $.ui.mouse, {
$.ui.ddmanager.drop(this, event);
if(this.options.revert) {
- var self = this;
- var cur = self.placeholder.offset();
+ var that = this;
+ var cur = this.placeholder.offset();
- self.reverting = true;
+ this.reverting = true;
$(this.helper).animate({
- left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
- top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
+ left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
+ top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
}, parseInt(this.options.revert, 10) || 500, function() {
- self._clear(event);
+ that._clear(event);
});
} else {
this._clear(event, noPropagation);
@@ -359,8 +359,6 @@ $.widget("ui.sortable", $.ui.mouse, {
cancel: function() {
- var self = this;
-
if(this.dragging) {
this._mouseUp({ target: null });
@@ -372,9 +370,9 @@ $.widget("ui.sortable", $.ui.mouse, {
//Post deactivating events to containers
for (var i = this.containers.length - 1; i >= 0; i--){
- this.containers[i]._trigger("deactivate", null, self._uiHash(this));
+ this.containers[i]._trigger("deactivate", null, this._uiHash(this));
if(this.containers[i].containerCache.over) {
- this.containers[i]._trigger("out", null, self._uiHash(this));
+ this.containers[i]._trigger("out", null, this._uiHash(this));
this.containers[i].containerCache.over = 0;
}
}
@@ -467,8 +465,8 @@ $.widget("ui.sortable", $.ui.mouse, {
_intersectsWithPointer: function(item) {
- var isOverElementHeight = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
- isOverElementWidth = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
+ var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
+ isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
isOverElement = isOverElementHeight && isOverElementWidth,
verticalDirection = this._getDragVerticalDirection(),
horizontalDirection = this._getDragHorizontalDirection();
@@ -519,10 +517,9 @@ $.widget("ui.sortable", $.ui.mouse, {
? [options.connectWith]
: options.connectWith;
},
-
+
_getItemsAsjQuery: function(connected) {
- var self = this;
var items = [];
var queries = [];
var connectWith = this._connectWith();
@@ -571,7 +568,6 @@ $.widget("ui.sortable", $.ui.mouse, {
this.items = [];
this.containers = [this];
var items = this.items;
- var self = this;
var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
var connectWith = this._connectWith();
@@ -650,17 +646,17 @@ $.widget("ui.sortable", $.ui.mouse, {
},
_createPlaceholder: function(that) {
-
- var self = that || this, o = self.options;
+ that = that || this;
+ var o = that.options;
if(!o.placeholder || o.placeholder.constructor == String) {
var className = o.placeholder;
o.placeholder = {
element: function() {
- var el = $(document.createElement(self.currentItem[0].nodeName))
- .addClass(className || self.currentItem[0].className+" ui-sortable-placeholder")
- .removeClass("ui-sortable-helper").html("&nbsp;")[0];
+ var el = $(document.createElement(that.currentItem[0].nodeName))
+ .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
+ .removeClass("ui-sortable-helper")[0];
if(!className)
el.style.visibility = "hidden";
@@ -674,46 +670,46 @@ $.widget("ui.sortable", $.ui.mouse, {
if(className && !o.forcePlaceholderSize) return;
//If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
- if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
- if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
+ if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css('paddingTop')||0, 10) - parseInt(that.currentItem.css('paddingBottom')||0, 10)); };
+ if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css('paddingLeft')||0, 10) - parseInt(that.currentItem.css('paddingRight')||0, 10)); };
}
};
}
//Create the placeholder
- self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem));
+ that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
//Append it after the actual current item
- self.currentItem.after(self.placeholder);
+ that.currentItem.after(that.placeholder);
//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
- o.placeholder.update(self, self.placeholder);
+ o.placeholder.update(that, that.placeholder);
},
_contactContainers: function(event) {
-
- // get innermost container that intersects with item
- var innermostContainer = null, innermostIndex = null;
-
-
+
+ // get innermost container that intersects with item
+ var innermostContainer = null, innermostIndex = null;
+
+
for (var i = this.containers.length - 1; i >= 0; i--){
- // never consider a container that's located within the item itself
+ // never consider a container that's located within the item itself
if($.contains(this.currentItem[0], this.containers[i].element[0]))
continue;
if(this._intersectsWith(this.containers[i].containerCache)) {
- // if we've already found a container and it's more "inner" than this, then continue
+ // if we've already found a container and it's more "inner" than this, then continue
if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0]))
continue;
- innermostContainer = this.containers[i];
+ innermostContainer = this.containers[i];
innermostIndex = i;
-
+
} else {
- // container doesn't intersect. trigger "out" event if necessary
+ // container doesn't intersect. trigger "out" event if necessary
if(this.containers[i].containerCache.over) {
this.containers[i]._trigger("out", event, this._uiHash(this));
this.containers[i].containerCache.over = 0;
@@ -721,42 +717,42 @@ $.widget("ui.sortable", $.ui.mouse, {
}
}
-
- // if no intersecting containers found, return
- if(!innermostContainer) return;
+
+ // if no intersecting containers found, return
+ if(!innermostContainer) return;
// move the item into the container if it's not there already
if(this.containers.length === 1) {
this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
this.containers[innermostIndex].containerCache.over = 1;
- } else if(this.currentContainer != this.containers[innermostIndex]) {
-
- //When entering a new container, we will find the item with the least distance and append our item near it
- var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
- for (var j = this.items.length - 1; j >= 0; j--) {
- if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
- var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
- if(Math.abs(cur - base) < dist) {
- dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
- }
- }
-
- if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
- return;
-
- this.currentContainer = this.containers[innermostIndex];
- itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
- this._trigger("change", event, this._uiHash());
- this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
-
- //Update the placeholder
- this.options.placeholder.update(this.currentContainer, this.placeholder);
-
- this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
+ } else if(this.currentContainer != this.containers[innermostIndex]) {
+
+ //When entering a new container, we will find the item with the least distance and append our item near it
+ var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
+ for (var j = this.items.length - 1; j >= 0; j--) {
+ if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
+ var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
+ if(Math.abs(cur - base) < dist) {
+ dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
+ }
+ }
+
+ if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
+ return;
+
+ this.currentContainer = this.containers[innermostIndex];
+ itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
+ this._trigger("change", event, this._uiHash());
+ this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
+
+ //Update the placeholder
+ this.options.placeholder.update(this.currentContainer, this.placeholder);
+
+ this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
this.containers[innermostIndex].containerCache.over = 1;
- }
-
-
+ }
+
+
},
_createHelper: function(event) {
@@ -970,11 +966,11 @@ $.widget("ui.sortable", $.ui.mouse, {
// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
// 4. this lets only the last addition to the timeout stack through
this.counter = this.counter ? ++this.counter : 1;
- var self = this, counter = this.counter;
+ var counter = this.counter;
- window.setTimeout(function() {
- if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
- },0);
+ this._delay(function() {
+ if(counter == this.counter) this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
+ });
},
@@ -983,7 +979,7 @@ $.widget("ui.sortable", $.ui.mouse, {
this.reverting = false;
// We delay all events that have to be triggered to after the point where the placeholder has been removed and
// everything else normalized again
- var delayedTriggers = [], self = this;
+ var delayedTriggers = [];
// We first have to update the dom position of the actual currentItem
// Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
@@ -1058,16 +1054,16 @@ $.widget("ui.sortable", $.ui.mouse, {
}
},
- _uiHash: function(inst) {
- var self = inst || this;
+ _uiHash: function(_inst) {
+ var inst = _inst || this;
return {
- helper: self.helper,
- placeholder: self.placeholder || $([]),
- position: self.position,
- originalPosition: self.originalPosition,
- offset: self.positionAbs,
- item: self.currentItem,
- sender: inst ? inst.element : null
+ helper: inst.helper,
+ placeholder: inst.placeholder || $([]),
+ position: inst.position,
+ originalPosition: inst.originalPosition,
+ offset: inst.positionAbs,
+ item: inst.currentItem,
+ sender: _inst ? _inst.element : null
};
}
diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js
index bd55a09ea..1e4204a0c 100644
--- a/ui/jquery.ui.spinner.js
+++ b/ui/jquery.ui.spinner.js
@@ -93,6 +93,11 @@ $.widget( "ui.spinner", {
this.previous = this.element.val();
},
blur: function( event ) {
+ if ( this.cancelBlur ) {
+ delete this.cancelBlur;
+ return;
+ }
+
this._refresh();
this.uiSpinner.removeClass( "ui-state-active" );
if ( this.previous !== this.element.val() ) {
@@ -117,11 +122,42 @@ $.widget( "ui.spinner", {
event.preventDefault();
},
"mousedown .ui-spinner-button": function( event ) {
+ var previous;
+
+ // We never want the buttons to have focus; whenever the user is
+ // interacting with the spinner, the focus should be on the input.
+ // If the input is focused then this.previous is properly set from
+ // when the input first received focus. If the input is not focused
+ // then we need to set this.previous based on the value before spinning.
+ previous = this.element[0] === this.document[0].activeElement ?
+ this.previous : this.element.val();
+ function checkFocus() {
+ var isActive = this.element[0] === this.document[0].activeElement;
+ if ( !isActive ) {
+ this.element.focus();
+ this.previous = previous;
+ // support: IE
+ // IE sets focus asynchronously, so we need to check if focus
+ // moved off of the input because the user clicked on the button.
+ this._delay(function() {
+ this.previous = previous;
+ });
+ }
+ }
+
// ensure focus is on (or stays on) the text field
event.preventDefault();
- if ( this.document[0].activeElement !== this.element[ 0 ] ) {
- this.element.focus();
- }
+ checkFocus.call( this );
+
+ // support: IE
+ // IE doesn't prevent moving focus even with event.preventDefault()
+ // so we set a flag to know when we should ignore the blur event
+ // and check (again) if focus moved off of the input.
+ this.cancelBlur = true;
+ this._delay(function() {
+ delete this.cancelBlur;
+ checkFocus.call( this );
+ });
if ( this._start( event ) === false ) {
return;
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js
index 68c182c31..026c50993 100644
--- a/ui/jquery.ui.tabs.js
+++ b/ui/jquery.ui.tabs.js
@@ -95,8 +95,8 @@ $.widget( "ui.tabs", {
// into account and update option properly.
if ( $.isArray( options.disabled ) ) {
options.disabled = $.unique( options.disabled.concat(
- $.map( this.lis.filter( ".ui-state-disabled" ), function( n, i ) {
- return that.lis.index( n );
+ $.map( this.lis.filter( ".ui-state-disabled" ), function( li ) {
+ return that.lis.index( li );
})
) ).sort();
}
@@ -162,13 +162,11 @@ $.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() {
var next,
- self = this,
options = this.options,
lis = this.list.children( ":has(a[href])" );
@@ -216,14 +214,14 @@ $.widget( "ui.tabs", {
},
_processTabs: function() {
- var self = this;
+ var that = this;
this.list = this._getList();
- this.lis = $( " > li:has(a[href])", this.list );
+ this.lis = this.list.find( "> li:has(a[href])" );
this.anchors = this.lis.map(function() {
return $( "a", this )[ 0 ];
});
- this.panels = $( [] );
+ this.panels = $();
this.anchors.each(function( i, a ) {
var selector, panel, id;
@@ -231,20 +229,20 @@ $.widget( "ui.tabs", {
// inline tab
if ( isLocal( a ) ) {
selector = a.hash;
- panel = self.element.find( self._sanitizeSelector( selector ) );
+ panel = that.element.find( that._sanitizeSelector( selector ) );
// remote tab
} else {
- id = self._tabId( a );
+ id = that._tabId( a );
selector = "#" + id;
- panel = self.element.find( selector );
+ panel = that.element.find( selector );
if ( !panel.length ) {
- panel = self._createPanel( id );
- panel.insertAfter( self.panels[ i - 1 ] || self.list );
+ panel = that._createPanel( id );
+ panel.insertAfter( that.panels[ i - 1 ] || that.list );
}
}
if ( panel.length) {
- self.panels = self.panels.add( panel );
+ that.panels = that.panels.add( panel );
}
$( a ).attr( "aria-controls", selector.substring( 1 ) );
});
@@ -256,10 +254,10 @@ $.widget( "ui.tabs", {
},
_createPanel: function( id ) {
- return $( "<div></div>" )
- .attr( "id", id )
- .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
- .data( "ui-tabs-destroy", true );
+ return $( "<div>" )
+ .attr( "id", id )
+ .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
+ .data( "ui-tabs-destroy", true );
},
_setupDisabled: function( disabled ) {
@@ -273,7 +271,8 @@ $.widget( "ui.tabs", {
// disable tabs
for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
- $( li ).toggleClass( "ui-state-disabled", ( disabled === true || $.inArray( i, disabled ) !== -1 ) );
+ $( li ).toggleClass( "ui-state-disabled",
+ ( disabled === true || $.inArray( i, disabled ) !== -1 ) );
}
this.options.disabled = disabled;
@@ -291,22 +290,17 @@ $.widget( "ui.tabs", {
}
},
- // TODO: remove once jQuery core properly removes filters - see #4621
- _resetStyle: function ( $el, fx ) {
- if ( !$.support.opacity && fx.opacity ) {
- $el[ 0 ].style.removeAttribute( "filter" );
- }
- },
-
_setupEvents: function( event ) {
// attach tab event handler, unbind to avoid duplicates from former tabifying...
this.anchors.unbind( ".tabs" );
+ // TODO: use event delegation via _bind()
if ( event ) {
this.anchors.bind( event.split( " " ).join( ".tabs " ) + ".tabs",
$.proxy( this, "_eventHandler" ) );
}
+ // TODO: use event delegation via _bind()
// disable click in any case
this.anchors.bind( "click.tabs", function( event ){
event.preventDefault();
@@ -353,14 +347,12 @@ $.widget( "ui.tabs", {
}
if ( !toHide.length && !toShow.length ) {
- throw "jQuery UI Tabs: Mismatching fragment identifier.";
+ jQuery.error( "jQuery UI Tabs: Mismatching fragment identifier." );
}
if ( toShow.length ) {
-
// TODO make passing in node possible
that.load( that.anchors.index( clicked ), event );
-
clicked[ 0 ].blur();
}
that._toggle( event, eventData );
@@ -369,7 +361,6 @@ $.widget( "ui.tabs", {
// handles show/hide for selecting tabs
_toggle: function( event, eventData ) {
var that = this,
- options = that.options,
toShow = eventData.newPanel,
toHide = eventData.oldPanel;
@@ -386,7 +377,6 @@ $.widget( "ui.tabs", {
if ( toShow.length && that.showFx ) {
toShow
.animate( that.showFx, that.showFx.duration || "normal", function() {
- that._resetStyle( $( this ), that.showFx );
complete();
});
} else {
@@ -399,7 +389,6 @@ $.widget( "ui.tabs", {
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 {
@@ -429,7 +418,7 @@ $.widget( "ui.tabs", {
_findActive: function( selector ) {
return typeof selector === "number" ? this.anchors.eq( selector ) :
- typeof selector === "string" ? this.anchors.filter( "[href$='" + selector + "']" ) : $();
+ typeof selector === "string" ? this.anchors.filter( "[href$='" + selector + "']" ) : $();
},
_getIndex: function( index ) {
@@ -443,8 +432,6 @@ $.widget( "ui.tabs", {
},
_destroy: function() {
- var o = this.options;
-
if ( this.xhr ) {
this.xhr.abort();
}
@@ -525,10 +512,9 @@ $.widget( "ui.tabs", {
load: function( index, event ) {
index = this._getIndex( index );
- var self = this,
- options = this.options,
+ var that = this,
anchor = this.anchors.eq( index ),
- panel = self._getPanelForTab( anchor ),
+ panel = that._getPanelForTab( anchor ),
eventData = {
tab: anchor,
panel: panel
@@ -542,7 +528,7 @@ $.widget( "ui.tabs", {
this.xhr = $.ajax({
url: anchor.attr( "href" ),
beforeSend: function( jqXHR, settings ) {
- return self._trigger( "beforeLoad", event,
+ return that._trigger( "beforeLoad", event,
$.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
}
});
@@ -556,7 +542,7 @@ $.widget( "ui.tabs", {
// remove when core #10467 is fixed
setTimeout(function() {
panel.html( response );
- self._trigger( "load", event, eventData );
+ that._trigger( "load", event, eventData );
}, 1 );
})
.complete(function( jqXHR, status ) {
@@ -564,19 +550,17 @@ $.widget( "ui.tabs", {
// remove when core #10467 is fixed
setTimeout(function() {
if ( status === "abort" ) {
- self.panels.stop( false, true );
+ that.panels.stop( false, true );
}
- self.lis.eq( index ).removeClass( "ui-tabs-loading" );
+ that.lis.eq( index ).removeClass( "ui-tabs-loading" );
- if ( jqXHR === self.xhr ) {
- delete self.xhr;
+ if ( jqXHR === that.xhr ) {
+ delete that.xhr;
}
}, 1 );
});
}
-
- return this;
},
_getPanelForTab: function( tab ) {
@@ -614,7 +598,7 @@ if ( $.uiBackCompat !== false ) {
_create: function() {
this._super();
- var self = this;
+ var that = this;
this.element.bind( "tabsbeforeload.tabs", function( event, ui ) {
// tab is already cached
@@ -623,21 +607,21 @@ if ( $.uiBackCompat !== false ) {
return;
}
- $.extend( ui.ajaxSettings, self.options.ajaxOptions, {
+ $.extend( ui.ajaxSettings, that.options.ajaxOptions, {
error: function( xhr, s, e ) {
try {
// Passing index avoid a race condition when this method is
// called after the user has selected another tab.
// Pass the anchor that initiated this request allows
// loadError to manipulate the tab content panel via $(a.hash)
- self.options.ajaxOptions.error( xhr, s, ui.tab.closest( "li" ).index(), ui.tab[ 0 ] );
+ that.options.ajaxOptions.error( xhr, s, ui.tab.closest( "li" ).index(), ui.tab[ 0 ] );
}
catch ( e ) {}
}
});
ui.jqXHR.success(function() {
- if ( self.options.cache ) {
+ if ( that.options.cache ) {
$.data( ui.tab[ 0 ], "cache.tabs", true );
}
});
@@ -843,7 +827,7 @@ if ( $.uiBackCompat !== false ) {
_tabId: function( a ) {
return $( a ).attr( "aria-controls" ) ||
- a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF-]/g, "" ) ||
+ a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF\-]/g, "" ) ||
this.options.idPrefix + getNextTabId();
}
});
diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js
index 97895a6a8..47a377bfd 100644
--- a/ui/jquery.ui.tooltip.js
+++ b/ui/jquery.ui.tooltip.js
@@ -5,8 +5,6 @@
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
- * http://docs.jquery.com/UI/Tooltip
- *
* Depends:
* jquery.ui.core.js
* jquery.ui.widget.js
@@ -130,11 +128,15 @@ $.widget( "ui.tooltip", {
// we have to check first to avoid defining a title if none exists
// (we don't want to cause an element to start matching [title])
- // We don't use removeAttr as that causes the native tooltip to show
- // up in IE (9 and below, didn't yet test 10). Happens only when removing
- // inside the mouseover handler.
+ // We use removeAttr only for key events, to allow IE to export the correct
+ // accessible attributes. For mouse events, set to empty string to avoid
+ // native tooltip showing up (happens only when removing inside mouseover).
if ( target.is( "[title]" ) ) {
- target.attr( "title", "" );
+ if ( event && event.type === "mouseover" ) {
+ target.attr( "title", "" );
+ } else {
+ target.removeAttr( "title" );
+ }
}
// ajaxy tooltip can update an existing one
@@ -181,7 +183,10 @@ $.widget( "ui.tooltip", {
// don't close if the element has focus
// this prevents the tooltip from closing if you hover while focused
- if ( !force && this.document[0].activeElement === target[0] ) {
+ // we have to check the event type because tabbing out of the document
+ // may leave the element as the activeElement
+ if ( !force && event && event.type !== "focusout" &&
+ this.document[0].activeElement === target[0] ) {
return;
}