aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/i18n/jquery.ui.datepicker-ca.js26
-rw-r--r--ui/i18n/jquery.ui.datepicker-cy-GB.js23
-rw-r--r--ui/i18n/jquery.ui.datepicker-kk.js (renamed from ui/i18n/jquery.ui.datepicker-kz.js)4
-rw-r--r--ui/i18n/jquery.ui.datepicker-lb.js23
-rw-r--r--ui/i18n/jquery.ui.datepicker-mk.js23
-rw-r--r--ui/i18n/jquery.ui.datepicker-nl-BE.js23
-rw-r--r--ui/i18n/jquery.ui.datepicker-uk.js3
-rw-r--r--ui/jquery.effects.core.js42
-rw-r--r--ui/jquery.effects.scale.js21
-rw-r--r--ui/jquery.ui.accordion.js34
-rw-r--r--ui/jquery.ui.autocomplete.js58
-rw-r--r--ui/jquery.ui.button.js16
-rw-r--r--ui/jquery.ui.core.js2
-rw-r--r--ui/jquery.ui.datepicker.js29
-rw-r--r--ui/jquery.ui.dialog.js34
-rw-r--r--ui/jquery.ui.draggable.js2
-rw-r--r--ui/jquery.ui.droppable.js2
-rw-r--r--ui/jquery.ui.menu.js116
-rw-r--r--ui/jquery.ui.menubar.js30
-rw-r--r--ui/jquery.ui.popup.js164
-rw-r--r--ui/jquery.ui.position.js49
-rw-r--r--ui/jquery.ui.progressbar.js2
-rw-r--r--ui/jquery.ui.resizable.js2
-rw-r--r--ui/jquery.ui.selectable.js1
-rw-r--r--ui/jquery.ui.sortable.js19
-rw-r--r--ui/jquery.ui.spinner.js35
-rw-r--r--ui/jquery.ui.tabs.js44
-rw-r--r--ui/jquery.ui.tooltip.js6
-rw-r--r--ui/jquery.ui.widget.js51
29 files changed, 582 insertions, 302 deletions
diff --git a/ui/i18n/jquery.ui.datepicker-ca.js b/ui/i18n/jquery.ui.datepicker-ca.js
index 23c5c8c81..a10b549c2 100644
--- a/ui/i18n/jquery.ui.datepicker-ca.js
+++ b/ui/i18n/jquery.ui.datepicker-ca.js
@@ -1,23 +1,23 @@
-/* Inicialització en català per a l'extenció 'calendar' per jQuery. */
+/* Inicialització en català per a l'extensió 'UI date picker' per jQuery. */
/* Writers: (joan.leon@gmail.com). */
jQuery(function($){
$.datepicker.regional['ca'] = {
- closeText: 'Tancar',
- prevText: '<Ant',
- nextText: 'Seg>',
+ closeText: 'Tanca',
+ prevText: 'Anterior',
+ nextText: 'Següent',
currentText: 'Avui',
- monthNames: ['Gener','Febrer','Març','Abril','Maig','Juny',
- 'Juliol','Agost','Setembre','Octubre','Novembre','Desembre'],
- monthNamesShort: ['Gen','Feb','Mar','Abr','Mai','Jun',
- 'Jul','Ago','Set','Oct','Nov','Des'],
- dayNames: ['Diumenge','Dilluns','Dimarts','Dimecres','Dijous','Divendres','Dissabte'],
- dayNamesShort: ['Dug','Dln','Dmt','Dmc','Djs','Dvn','Dsb'],
- dayNamesMin: ['Dg','Dl','Dt','Dc','Dj','Dv','Ds'],
- weekHeader: 'Sm',
+ monthNames: ['gener','febrer','març','abril','maig','juny',
+ 'juliol','agost','setembre','octubre','novembre','desembre'],
+ monthNamesShort: ['gen','feb','març','abr','maig','juny',
+ 'jul','ag','set','oct','nov','des'],
+ dayNames: ['diumenge','dilluns','dimarts','dimecres','dijous','divendres','dissabte'],
+ dayNamesShort: ['dg','dl','dt','dc','dj','dv','ds'],
+ dayNamesMin: ['dg','dl','dt','dc','dj','dv','ds'],
+ weekHeader: 'Set',
dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['ca']);
-}); \ No newline at end of file
+});
diff --git a/ui/i18n/jquery.ui.datepicker-cy-GB.js b/ui/i18n/jquery.ui.datepicker-cy-GB.js
new file mode 100644
index 000000000..dfee2f9d4
--- /dev/null
+++ b/ui/i18n/jquery.ui.datepicker-cy-GB.js
@@ -0,0 +1,23 @@
+/* Welsh/UK initialisation for the jQuery UI date picker plugin. */
+/* Written by William Griffiths. */
+jQuery(function($){
+ $.datepicker.regional['cy-GB'] = {
+ closeText: 'Done',
+ prevText: 'Prev',
+ nextText: 'Next',
+ currentText: 'Today',
+ monthNames: ['Ionawr','Chwefror','Mawrth','Ebrill','Mai','Mehefin',
+ 'Gorffennaf','Awst','Medi','Hydref','Tachwedd','Rhagfyr'],
+ monthNamesShort: ['Ion', 'Chw', 'Maw', 'Ebr', 'Mai', 'Meh',
+ 'Gor', 'Aws', 'Med', 'Hyd', 'Tac', 'Rha'],
+ dayNames: ['Dydd Sul', 'Dydd Llun', 'Dydd Mawrth', 'Dydd Mercher', 'Dydd Iau', 'Dydd Gwener', 'Dydd Sadwrn'],
+ dayNamesShort: ['Sul', 'Llu', 'Maw', 'Mer', 'Iau', 'Gwe', 'Sad'],
+ dayNamesMin: ['Su','Ll','Ma','Me','Ia','Gw','Sa'],
+ weekHeader: 'Wy',
+ dateFormat: 'dd/mm/yy',
+ firstDay: 1,
+ isRTL: false,
+ showMonthAfterYear: false,
+ yearSuffix: ''};
+ $.datepicker.setDefaults($.datepicker.regional['cy-GB']);
+}); \ No newline at end of file
diff --git a/ui/i18n/jquery.ui.datepicker-kz.js b/ui/i18n/jquery.ui.datepicker-kk.js
index 658c21275..dcd6a65df 100644
--- a/ui/i18n/jquery.ui.datepicker-kz.js
+++ b/ui/i18n/jquery.ui.datepicker-kk.js
@@ -1,7 +1,7 @@
/* Kazakh (UTF-8) initialisation for the jQuery UI date picker plugin. */
/* Written by Dmitriy Karasyov (dmitriy.karasyov@gmail.com). */
jQuery(function($){
- $.datepicker.regional['kz'] = {
+ $.datepicker.regional['kk'] = {
closeText: 'Жабу',
prevText: '<Алдыңғы',
nextText: 'Келесі>',
@@ -19,5 +19,5 @@ jQuery(function($){
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
- $.datepicker.setDefaults($.datepicker.regional['kz']);
+ $.datepicker.setDefaults($.datepicker.regional['kk']);
});
diff --git a/ui/i18n/jquery.ui.datepicker-lb.js b/ui/i18n/jquery.ui.datepicker-lb.js
new file mode 100644
index 000000000..87c79d594
--- /dev/null
+++ b/ui/i18n/jquery.ui.datepicker-lb.js
@@ -0,0 +1,23 @@
+/* Luxembourgish initialisation for the jQuery UI date picker plugin. */
+/* Written by Michel Weimerskirch <michel@weimerskirch.net> */
+jQuery(function($){
+ $.datepicker.regional['lb'] = {
+ closeText: 'Fäerdeg',
+ prevText: 'Zréck',
+ nextText: 'Weider',
+ currentText: 'Haut',
+ monthNames: ['Januar','Februar','Mäerz','Abrëll','Mee','Juni',
+ 'Juli','August','September','Oktober','November','Dezember'],
+ monthNamesShort: ['Jan', 'Feb', 'Mäe', 'Abr', 'Mee', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
+ dayNames: ['Sonndeg', 'Méindeg', 'Dënschdeg', 'Mëttwoch', 'Donneschdeg', 'Freideg', 'Samschdeg'],
+ dayNamesShort: ['Son', 'Méi', 'Dën', 'Mët', 'Don', 'Fre', 'Sam'],
+ dayNamesMin: ['So','Mé','Dë','Më','Do','Fr','Sa'],
+ weekHeader: 'W',
+ dateFormat: 'dd.mm.yy',
+ firstDay: 1,
+ isRTL: false,
+ showMonthAfterYear: false,
+ yearSuffix: ''};
+ $.datepicker.setDefaults($.datepicker.regional['lb']);
+});
diff --git a/ui/i18n/jquery.ui.datepicker-mk.js b/ui/i18n/jquery.ui.datepicker-mk.js
new file mode 100644
index 000000000..554ad20ba
--- /dev/null
+++ b/ui/i18n/jquery.ui.datepicker-mk.js
@@ -0,0 +1,23 @@
+/* Macedonian i18n for the jQuery UI date picker plugin. */
+/* Written by Stojce Slavkovski. */
+jQuery(function($){
+ $.datepicker.regional['mk'] = {
+ closeText: 'Затвори',
+ prevText: '&#x3C;',
+ nextText: '&#x3E;',
+ currentText: 'Денес',
+ monthNames: ['Јануари','Фебруари','Март','Април','Мај','Јуни',
+ 'Јули','Август','Септември','Октомври','Ноември','Декември'],
+ monthNamesShort: ['Јан','Феб','Мар','Апр','Мај','Јун',
+ 'Јул','Авг','Сеп','Окт','Ное','Дек'],
+ dayNames: ['Недела','Понеделник','Вторник','Среда','Четврток','Петок','Сабота'],
+ dayNamesShort: ['Нед','Пон','Вто','Сре','Чет','Пет','Саб'],
+ dayNamesMin: ['Не','По','Вт','Ср','Че','Пе','Са'],
+ weekHeader: 'Сед',
+ dateFormat: 'dd/mm/yy',
+ firstDay: 1,
+ isRTL: false,
+ showMonthAfterYear: false,
+ yearSuffix: ''};
+ $.datepicker.setDefaults($.datepicker.regional['mk']);
+});
diff --git a/ui/i18n/jquery.ui.datepicker-nl-BE.js b/ui/i18n/jquery.ui.datepicker-nl-BE.js
new file mode 100644
index 000000000..56207cb04
--- /dev/null
+++ b/ui/i18n/jquery.ui.datepicker-nl-BE.js
@@ -0,0 +1,23 @@
+/* Dutch (Belgium) initialisation for the jQuery UI date picker plugin. */
+/* David De Sloovere @DavidDeSloovere */
+jQuery(function($){
+ $.datepicker.regional['nl-BE'] = {
+ closeText: 'Sluiten',
+ prevText: '←',
+ nextText: '→',
+ currentText: 'Vandaag',
+ monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
+ 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
+ monthNamesShort: ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun',
+ 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
+ dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
+ dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
+ dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
+ weekHeader: 'Wk',
+ dateFormat: 'dd/mm/yy',
+ firstDay: 1,
+ isRTL: false,
+ showMonthAfterYear: false,
+ yearSuffix: ''};
+ $.datepicker.setDefaults($.datepicker.regional['nl-BE']);
+}); \ No newline at end of file
diff --git a/ui/i18n/jquery.ui.datepicker-uk.js b/ui/i18n/jquery.ui.datepicker-uk.js
index 07ce206b9..31964af44 100644
--- a/ui/i18n/jquery.ui.datepicker-uk.js
+++ b/ui/i18n/jquery.ui.datepicker-uk.js
@@ -1,5 +1,6 @@
/* Ukrainian (UTF-8) initialisation for the jQuery UI date picker plugin. */
/* Written by Maxim Drogobitskiy (maxdao@gmail.com). */
+/* Corrected by Igor Milla (igor.fsp.milla@gmail.com). */
jQuery(function($){
$.datepicker.regional['uk'] = {
closeText: 'Закрити',
@@ -13,7 +14,7 @@ jQuery(function($){
dayNames: ['неділя','понеділок','вівторок','середа','четвер','п’ятниця','субота'],
dayNamesShort: ['нед','пнд','вів','срд','чтв','птн','сбт'],
dayNamesMin: ['Нд','Пн','Вт','Ср','Чт','Пт','Сб'],
- weekHeader: 'Не',
+ weekHeader: 'Тиж',
dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js
index 15d81b4b0..233b4f96d 100644
--- a/ui/jquery.effects.core.js
+++ b/ui/jquery.effects.core.js
@@ -161,7 +161,7 @@ var classAnimationActions = [ "add", "remove", "toggle" ],
// prefix used for storing data on .data()
dataSpace = "ec.storage.";
-$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function(_, prop) {
+$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
$.fx.step[ prop ] = function( fx ) {
if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
jQuery.style( fx.elem, prop, fx.end );
@@ -171,8 +171,8 @@ $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopS
});
function getElementStyles() {
- var style = document.defaultView
- ? document.defaultView.getComputedStyle(this, null)
+ var style = this.ownerDocument.defaultView
+ ? this.ownerDocument.defaultView.getComputedStyle( this, null )
: this.currentStyle,
newStyle = {},
key,
@@ -223,8 +223,8 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
return this.queue( function() {
var animated = $( this ),
- baseClass = animated.attr( "class" ),
- finalClass,
+ baseClass = animated.attr( "class" ) || "",
+ applyClassChange,
allAnimations = o.children ? animated.find( "*" ).andSelf() : animated;
// map the animated objects to store the original styles.
@@ -232,18 +232,19 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
var el = $( this );
return {
el: el,
- originalStyleAttr: el.attr( "style" ) || " ",
start: getElementStyles.call( this )
};
});
// apply class change
- $.each( classAnimationActions, function(i, action) {
- if ( value[ action ] ) {
- animated[ action + "Class" ]( value[ action ] );
- }
- });
- finalClass = animated.attr( "class" );
+ applyClassChange = function() {
+ $.each( classAnimationActions, function(i, action) {
+ if ( value[ action ] ) {
+ animated[ action + "Class" ]( value[ action ] );
+ }
+ });
+ };
+ applyClassChange();
// map all animated objects again - calculate new styles and diff
allAnimations = allAnimations.map(function() {
@@ -275,16 +276,15 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
$.when.apply( $, allAnimations.get() ).done(function() {
// set the final class
- animated.attr( "class", finalClass );
+ applyClassChange();
- // for each animated element
+ // for each animated element,
+ // clear all css properties that were animated
$.each( arguments, function() {
- if ( typeof this.el.attr( "style" ) === "object" ) {
- this.el.attr( "style" ).cssText = "";
- this.el.attr( "style" ).cssText = this.originalStyleAttr;
- } else {
- this.el.attr( "style", this.originalStyleAttr );
- }
+ var el = this.el;
+ $.each( this.diff, function(key) {
+ el.css( key, '' );
+ });
});
// this is guarnteed to be there if you use jQuery.speed()
@@ -425,7 +425,7 @@ $.extend( $.effects, {
$( active ).focus();
}
- wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element
+ wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
// transfer positioning properties to the wrapper
if ( element.css( "position" ) === "static" ) {
diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js
index 000fdee28..96a9269ec 100644
--- a/ui/jquery.effects.scale.js
+++ b/ui/jquery.effects.scale.js
@@ -117,9 +117,7 @@ $.effects.effect.size = function( o, done ) {
scale = o.scale || "both",
origin = o.origin || [ "middle", "center" ],
original, baseline, factor,
- position = el.css( "position" ),
- originalVerticalPositioning = el.css( "bottom" ) !== "auto" ? "bottom" : "top";
- originalHorizontalPositioning = el.css( "right" ) !== "auto" ? "right" : "left";
+ position = el.css( "position" );
if ( mode === "show" ) {
el.show();
@@ -260,32 +258,19 @@ $.effects.effect.size = function( o, done ) {
left: el.to.left
});
} else {
- $.each([ originalVerticalPositioning, originalHorizontalPositioning ], function( idx, pos ) {
+ $.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",
- direction = pos == "left" || pos == "top";
+ mid = origin[ idx ] === "middle" || origin[ idx ] === "center";
// if original was "auto", recalculate the new value from wrapper
if ( str === "auto" ) {
return toRef + "px";
}
- // if not setting left or top
- if ( !direction ) {
-
- // if the position is relative, bottom/right are reversed meaning
- if ( position === "relative" ) {
- toRef *= -1;
-
- // otherwise, if its NOT a midpoint origin, compensate for the outerWidth difference
- } else if ( !mid ) {
- toRef -= delta * ( same ? -1 : 1 );
- }
- }
return val + toRef + "px";
});
});
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index c976e3e69..127099d59 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -12,8 +12,6 @@
* jquery.ui.widget.js
*/
(function( $, undefined ) {
-
-var lastToggle = {};
// TODO: use ui-accordion-header-active class and fix styling
$.widget( "ui.accordion", {
@@ -39,6 +37,7 @@ $.widget( "ui.accordion", {
var self = this,
options = self.options;
+ self.lastToggle = {};
self.element.addClass( "ui-accordion ui-widget ui-helper-reset" );
self.headers = self.element.find( options.header )
@@ -168,7 +167,7 @@ $.widget( "ui.accordion", {
this._setupEvents( value );
}
- this._super( "_setOption", key, value );
+ this._super( key, value );
// setting collapsible: false while collapsed; open first panel
if ( key === "collapsible" && !value && this.options.active === false ) {
@@ -245,7 +244,7 @@ $.widget( "ui.accordion", {
if ( position === "absolute" || position === "fixed" ) {
return;
}
- maxHeight -= elem.outerHeight( true );
+ maxHeight -= elem.outerHeight( true );
});
if ( overflow ) {
parent.css( "overflow", overflow );
@@ -378,10 +377,11 @@ $.widget( "ui.accordion", {
}
animations[ animation ]({
+ widget: self,
toShow: toShow,
toHide: toHide,
- prevShow: lastToggle.toShow,
- prevHide: lastToggle.toHide,
+ prevShow: self.lastToggle.toShow,
+ prevHide: self.lastToggle.toHide,
complete: complete,
down: toShow.length && ( !toHide.length || ( toShow.index() < toHide.index() ) )
}, additional );
@@ -437,7 +437,7 @@ $.extend( $.ui.accordion, {
options.prevHide.stop( true, true );
options.toHide = options.prevShow;
}
-
+
var showOverflow = options.toShow.css( "overflow" ),
hideOverflow = options.toHide.css( "overflow" ),
percentDone = 0,
@@ -449,8 +449,8 @@ $.extend( $.ui.accordion, {
easing: "swing",
duration: 300
}, options, additions );
-
- lastToggle = options;
+
+ options.widget.lastToggle = options;
if ( !options.toHide.size() ) {
originalWidth = options.toShow[0].style.width;
@@ -483,11 +483,11 @@ $.extend( $.ui.accordion, {
// fix width before calculating height of hidden element
var s = options.toShow;
originalWidth = s[0].style.width;
- s.width( parseInt( s.parent().width(), 10 )
- - parseInt( s.css( "paddingLeft" ), 10 )
- - parseInt( s.css( "paddingRight" ), 10 )
- - ( parseInt( s.css( "borderLeftWidth" ), 10 ) || 0 )
- - ( parseInt( s.css( "borderRightWidth" ), 10) || 0 ) );
+ s.width( s.parent().width()
+ - parseFloat( s.css( "paddingLeft" ) )
+ - parseFloat( s.css( "paddingRight" ) )
+ - ( parseFloat( s.css( "borderLeftWidth" ) ) || 0 )
+ - ( parseFloat( s.css( "borderRightWidth" ) ) || 0 ) );
$.each( fxAttrs, function( i, prop ) {
hideProps[ prop ] = "hide";
@@ -628,8 +628,10 @@ if ( $.uiBackCompat !== false ) {
var _createIcons = prototype._createIcons;
prototype._createIcons = function() {
- this.options.icons.activeHeader = this.options.icons.activeHeader ||
- this.options.icons.headerSelected;
+ if ( this.options.icons ) {
+ this.options.icons.activeHeader = this.options.icons.activeHeader ||
+ this.options.icons.headerSelected;
+ }
_createIcons.call( this );
};
}( jQuery, jQuery.ui.accordion.prototype ) );
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index b871715ba..9871b52d7 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -47,8 +47,15 @@ $.widget( "ui.autocomplete", {
_create: function() {
var self = this,
- doc = this.element[ 0 ].ownerDocument,
+ // 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;
this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
@@ -66,11 +73,13 @@ $.widget( "ui.autocomplete", {
if ( self.options.disabled || self.element.prop( "readOnly" ) ) {
suppressKeyPress = true;
suppressInput = true;
+ suppressKeyPressRepeat = true;
return;
}
suppressKeyPress = false;
suppressInput = false;
+ suppressKeyPressRepeat = false;
var keyCode = $.ui.keyCode;
switch( event.keyCode ) {
case keyCode.PAGE_UP:
@@ -110,10 +119,13 @@ $.widget( "ui.autocomplete", {
self.menu.select( event );
break;
case keyCode.ESCAPE:
- self._value( self.term );
- self.close( event );
+ if ( self.menu.element.is(":visible") ) {
+ self._value( self.term );
+ self.close( event );
+ }
break;
default:
+ suppressKeyPressRepeat = true;
// search timeout should be triggered before the input value is changed
self._searchTimeout( event );
break;
@@ -125,6 +137,9 @@ $.widget( "ui.autocomplete", {
event.preventDefault();
return;
}
+ if ( suppressKeyPressRepeat ) {
+ return;
+ }
// replicate some key handlers to allow them to repeat in Firefox and Opera
var keyCode = $.ui.keyCode;
@@ -181,7 +196,7 @@ $.widget( "ui.autocomplete", {
};
this.menu = $( "<ul></ul>" )
.addClass( "ui-autocomplete" )
- .appendTo( $( this.options.appendTo || "body", doc )[0] )
+ .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 ) {
// clicking on the scrollbar causes focus to shift to the body
@@ -191,7 +206,7 @@ $.widget( "ui.autocomplete", {
var menuElement = self.menu.element[ 0 ];
if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
setTimeout(function() {
- $( document ).one( 'mousedown', function( event ) {
+ self.document.one( 'mousedown', function( event ) {
if ( event.target !== self.element[ 0 ] &&
event.target !== menuElement &&
!$.contains( menuElement, event.target ) ) {
@@ -223,7 +238,7 @@ $.widget( "ui.autocomplete", {
previous = self.previous;
// only trigger when focus was lost (click on menu)
- if ( self.element[0] !== doc.activeElement ) {
+ if ( self.element[0] !== self.document[0].activeElement ) {
self.element.focus();
self.previous = previous;
// #6109 - IE triggers two focus events and the second
@@ -244,22 +259,24 @@ $.widget( "ui.autocomplete", {
self.close( event );
self.selectedItem = item;
- },
- blur: function( event, ui ) {
- // don't set the value of the text field if it's already correct
- // this prevents moving the cursor unnecessarily
- if ( self.menu.element.is(":visible") &&
- ( self._value() !== self.term ) ) {
- self._value( self.term );
- }
}
})
.zIndex( this.element.zIndex() + 1 )
.hide()
.data( "menu" );
+
if ( $.fn.bgiframe ) {
this.menu.element.bgiframe();
}
+
+ // turning off autocomplete prevents the browser from remembering the
+ // value when navigating through history, so we re-enable autocomplete
+ // if the page is unloaded before the widget is destroyed. #7790
+ this._bind( this.window, {
+ beforeunload: function() {
+ this.element.removeAttr( "autocomplete" );
+ }
+ });
},
_destroy: function() {
@@ -274,12 +291,12 @@ $.widget( "ui.autocomplete", {
},
_setOption: function( key, value ) {
- this._super( "_setOption", key, value );
+ this._super( key, value );
if ( key === "source" ) {
this._initSource();
}
if ( key === "appendTo" ) {
- this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
+ this.menu.element.appendTo( this.document.find( value || "body" )[0] );
}
if ( key === "disabled" && value && this.xhr ) {
this.xhr.abort();
@@ -325,9 +342,10 @@ $.widget( "ui.autocomplete", {
_searchTimeout: function( event ) {
var self = this;
+ clearTimeout( self.searching );
self.searching = setTimeout(function() {
// only search if the value has changed
- if ( self.term != self.element.val() ) {
+ if ( self.term !== self._value() ) {
self.selectedItem = null;
self.search( null, event );
}
@@ -384,7 +402,7 @@ $.widget( "ui.autocomplete", {
this._trigger( "close", event );
}
},
-
+
_change: function( event ) {
if ( this.previous !== this._value() ) {
this._trigger( "change", event, { item: this.selectedItem } );
@@ -434,7 +452,9 @@ $.widget( "ui.autocomplete", {
_resizeMenu: function() {
var ul = this.menu.element;
ul.outerWidth( Math.max(
- ul.width( "" ).outerWidth(),
+ // Firefox wraps long text (possibly a rounding bug)
+ // so we add 1px to avoid the wrapping (#7513)
+ ul.width( "" ).outerWidth() + 1,
this.element.outerWidth()
) );
},
diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js
index 1d9393d37..18a950563 100644
--- a/ui/jquery.ui.button.js
+++ b/ui/jquery.ui.button.js
@@ -174,7 +174,7 @@ $.widget( "ui.button", {
}
$( this ).addClass( "ui-state-active" );
lastActive = this;
- $( document ).one( "mouseup", function() {
+ self.document.one( "mouseup", function() {
lastActive = null;
});
})
@@ -269,7 +269,7 @@ $.widget( "ui.button", {
},
_setOption: function( key, value ) {
- this._super( "_setOption", key, value );
+ this._super( key, value );
if ( key === "disabled" ) {
if ( value ) {
this.element.prop( "disabled", true );
@@ -319,14 +319,14 @@ $.widget( "ui.button", {
return;
}
var buttonElement = this.buttonElement.removeClass( typeClasses ),
- buttonText = $( "<span></span>" )
+ buttonText = $( "<span></span>", this.document[0] )
.addClass( "ui-button-text" )
.html( this.options.label )
.appendTo( buttonElement.empty() )
.text(),
icons = this.options.icons,
multipleIcons = icons.primary && icons.secondary,
- buttonClasses = [];
+ buttonClasses = [];
if ( icons.primary || icons.secondary ) {
if ( this.options.text ) {
@@ -365,7 +365,7 @@ $.widget( "ui.buttonset", {
_create: function() {
this.element.addClass( "ui-buttonset" );
},
-
+
_init: function() {
this.refresh();
},
@@ -375,12 +375,12 @@ $.widget( "ui.buttonset", {
this.buttons.button( "option", key, value );
}
- this._super( "_setOption", key, value );
+ this._super( key, value );
},
-
+
refresh: function() {
var rtl = this.element.css( "direction" ) === "rtl";
-
+
this.buttons = this.element.find( this.options.items )
.filter( ":ui-button" )
.button( "refresh" )
diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js
index 8bcc4c441..f0cf89ba7 100644
--- a/ui/jquery.ui.core.js
+++ b/ui/jquery.ui.core.js
@@ -255,7 +255,7 @@ $.extend( $.ui, {
},
call: function( instance, name, args ) {
var set = instance.plugins[ name ];
- if ( !set || !instance.element[ 0 ].parentNode ) {
+ if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
return;
}
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index a5ff08c63..45ddf8678 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -636,10 +636,10 @@ $.extend(Datepicker.prototype, {
return;
var inst = $.datepicker._getInst(input);
if ($.datepicker._curInst && $.datepicker._curInst != inst) {
- if ( $.datepicker._datepickerShowing ) {
- $.datepicker._triggerOnClose($.datepicker._curInst);
- }
$.datepicker._curInst.dpDiv.stop(true, true);
+ if ( inst && $.datepicker._datepickerShowing ) {
+ $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
+ }
}
var beforeShow = $.datepicker._get(inst, 'beforeShow');
var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
@@ -790,14 +790,6 @@ $.extend(Datepicker.prototype, {
return [position.left, position.top];
},
- /* Trigger custom callback of onClose. */
- _triggerOnClose: function(inst) {
- var onClose = this._get(inst, 'onClose');
- if (onClose)
- onClose.apply((inst.input ? inst.input[0] : null),
- [(inst.input ? inst.input.val() : ''), inst]);
- },
-
/* Hide the date picker from view.
@param input element - the input field attached to the date picker */
_hideDatepicker: function(input) {
@@ -821,8 +813,11 @@ $.extend(Datepicker.prototype, {
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
if (!showAnim)
postProcess();
- $.datepicker._triggerOnClose(inst);
this._datepickerShowing = false;
+ var onClose = this._get(inst, 'onClose');
+ if (onClose)
+ onClose.apply((inst.input ? inst.input[0] : null),
+ [(inst.input ? inst.input.val() : ''), inst]);
this._lastInput = null;
if (this._inDialog) {
this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
@@ -844,12 +839,16 @@ $.extend(Datepicker.prototype, {
_checkExternalClick: function(event) {
if (!$.datepicker._curInst)
return;
- var $target = $(event.target);
- if ($target[0].id != $.datepicker._mainDivId &&
+
+ var $target = $(event.target),
+ inst = $.datepicker._getInst($target[0]);
+
+ if ( ( ( $target[0].id != $.datepicker._mainDivId &&
$target.parents('#' + $.datepicker._mainDivId).length == 0 &&
!$target.hasClass($.datepicker.markerClassName) &&
!$target.hasClass($.datepicker._triggerClass) &&
- $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
+ $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
+ ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) )
$.datepicker._hideDatepicker();
},
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index 065d640fb..49ef8f64b 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -169,7 +169,7 @@ $.widget("ui.dialog", {
_destroy: function() {
var self = this;
-
+
if ( self.overlay ) {
self.overlay.destroy();
}
@@ -196,7 +196,7 @@ $.widget("ui.dialog", {
var self = this,
maxZ, thisZ;
-
+
if ( false === self._trigger( "beforeClose", event ) ) {
return;
}
@@ -372,8 +372,7 @@ $.widget("ui.dialog", {
_makeDraggable: function() {
var self = this,
- options = self.options,
- doc = $( document );
+ options = self.options;
function filteredUi( ui ) {
return {
@@ -396,8 +395,8 @@ $.widget("ui.dialog", {
},
stop: function( event, ui ) {
options.position = [
- ui.position.left - doc.scrollLeft(),
- ui.position.top - doc.scrollTop()
+ ui.position.left - self.document.scrollLeft(),
+ ui.position.top - self.document.scrollTop()
];
$( this )
.removeClass( "ui-dialog-dragging" );
@@ -494,7 +493,7 @@ $.widget("ui.dialog", {
at: myAt.join( " " ),
offset: offset.join( " " )
};
- }
+ }
position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
} else {
@@ -519,7 +518,7 @@ $.widget("ui.dialog", {
$.each( options, function( key, value ) {
self._setOption( key, value );
-
+
if ( key in sizeRelatedOptions ) {
resize = true;
}
@@ -565,7 +564,7 @@ $.widget("ui.dialog", {
if ( isDraggable && !value ) {
uiDialog.draggable( "destroy" );
}
-
+
if ( !isDraggable && value ) {
self._makeDraggable();
}
@@ -597,7 +596,7 @@ $.widget("ui.dialog", {
break;
}
- this._super( "_setOption", key, value );
+ this._super( key, value );
},
_size: function() {
@@ -628,7 +627,7 @@ $.widget("ui.dialog", {
})
.height();
minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
-
+
if ( options.height === "auto" ) {
// only needed for IE6 support
if ( $.support.minHeight ) {
@@ -705,7 +704,7 @@ $.extend( $.ui.dialog.overlay, {
$( 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();
}
@@ -715,12 +714,11 @@ $.extend( $.ui.dialog.overlay, {
$( window ).bind( "resize.dialog-overlay", $.ui.dialog.overlay.resize );
}
- var $el = ( this.oldInstances.pop() || $( "<div>" ).addClass( "ui-widget-overlay" ) )
- .appendTo( document.body )
- .css({
- width: this.width(),
- height: this.height()
- });
+ var $el = ( this.oldInstances.pop() || $( "<div>" ).addClass( "ui-widget-overlay" ) );
+ $el.appendTo( document.body ).css({
+ width: this.width(),
+ height: this.height()
+ });
if ( $.fn.bgiframe ) {
$el.bgiframe();
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js
index 6475ebd61..92dd13c0d 100644
--- a/ui/jquery.ui.draggable.js
+++ b/ui/jquery.ui.draggable.js
@@ -208,7 +208,7 @@ $.widget("ui.draggable", $.ui.mouse, {
}
//if the original element is removed, don't bother to continue
- if(!this.element[0] || !this.element[0].parentNode)
+ if((!this.element[0] || !this.element[0].parentNode) && 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.droppable.js b/ui/jquery.ui.droppable.js
index 3942c6b8f..62bba2aba 100644
--- a/ui/jquery.ui.droppable.js
+++ b/ui/jquery.ui.droppable.js
@@ -224,7 +224,7 @@ $.ui.ddmanager = {
if(!this.options) return;
if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
- dropped = dropped || this._drop.call(this, event);
+ dropped = this._drop.call(this, event) || dropped;
if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
this.isout = 1; this.isover = 0;
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index 9cb6afe32..bf36a77fe 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -20,13 +20,16 @@ $.widget( "ui.menu", {
defaultElement: "<ul>",
delay: 150,
options: {
+ items: "ul",
position: {
my: "left top",
at: "right top"
- }
+ },
+ trigger: null
},
_create: function() {
this.activeMenu = this.element;
+ this.isScrolling = false;
this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++;
if ( this.element.find( ".ui-icon" ).length ) {
this.element.addClass( "ui-menu-icons" );
@@ -37,6 +40,16 @@ $.widget( "ui.menu", {
id: this.menuId,
role: "menu"
})
+ // Prevent focus from sticking to links inside menu after clicking
+ // them (focus should always stay on UL during navigation).
+ // If the link is clicked, redirect focus to the menu.
+ // TODO move to _bind below
+ .bind( "mousedown.menu", function( event ) {
+ if ( $( event.target).is( "a" ) ) {
+ event.preventDefault();
+ $( this ).focus( 1 );
+ }
+ })
// need to catch all clicks on disabled menu
// not possible through _bind
.bind( "click.menu", $.proxy( function( event ) {
@@ -56,18 +69,31 @@ $.widget( "ui.menu", {
},
"mouseover .ui-menu-item": function( event ) {
event.stopImmediatePropagation();
- 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
- target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
- this.focus( event, target );
+ if ( !this.isScrolling ) {
+ 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
+ target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
+ this.focus( event, target );
+ }
+ this.isScrolling = false;
},
- "mouseleave": "_mouseleave",
- "mouseleave .ui-menu": "_mouseleave",
+ "mouseleave": "collapseAll",
+ "mouseleave .ui-menu": "collapseAll",
"mouseout .ui-menu-item": "blur",
"focus": function( event ) {
this.focus( event, $( event.target ).children( ".ui-menu-item:first" ) );
},
- "blur": "collapseAll"
+ blur: function( event ) {
+ this._delay( function() {
+ if ( ! $.contains( this.element[0], this.document[0].activeElement ) ) {
+ this.collapseAll( event );
+ }
+ }, 0);
+ },
+ scroll: function( event ) {
+ // Keep track of scrolling to prevent mouseover from firing inadvertently when scrolling the menu
+ this.isScrolling = true;
+ }
});
this.refresh();
@@ -181,20 +207,34 @@ $.widget( "ui.menu", {
}
});
- this._bind( document, {
+ this._bind( this.document, {
click: function( event ) {
if ( !$( event.target ).closest( ".ui-menu" ).length ) {
this.collapseAll( event );
}
}
});
+
+ if ( this.options.trigger ) {
+ this.element.popup({
+ trigger: this.options.trigger,
+ managed: true,
+ focusPopup: $.proxy( function( event, ui ) {
+ this.focus( event, this.element.children( ".ui-menu-item" ).first() );
+ this.element.focus( 1 );
+ }, this)
+ });
+ }
},
_destroy: function() {
//destroy (sub)menus
+ if ( this.options.trigger ) {
+ this.element.popup( "destroy" );
+ }
this.element
.removeAttr( "aria-activedescendant" )
- .find( "ul" )
+ .find( ".ui-menu" )
.andSelf()
.removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.removeAttr( "role" )
@@ -221,7 +261,7 @@ $.widget( "ui.menu", {
refresh: function() {
// initialize nested menus
- var submenus = this.element.find( "ul:not(.ui-menu)" )
+ var submenus = this.element.find( this.options.items + ":not( .ui-menu )" )
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.attr( "role", "menu" )
.hide()
@@ -230,7 +270,7 @@ $.widget( "ui.menu", {
// don't refresh list items that are already adapted
var menuId = this.menuId;
- submenus.add( this.element ).children( "li:not(.ui-menu-item):has(a)" )
+ submenus.add( this.element ).children( ":not( .ui-menu-item ):has( a )" )
.addClass( "ui-menu-item" )
.attr( "role", "presentation" )
.children( "a" )
@@ -273,16 +313,16 @@ $.widget( "ui.menu", {
.children( "a" )
.addClass( "ui-state-focus" )
.end();
- this.element.attr( "aria-activedescendant", this.active.children("a").attr("id") );
+ this.element.attr( "aria-activedescendant", this.active.children( "a" ).attr( "id" ) );
// highlight active parent menu item, if any
- this.active.parent().closest(".ui-menu-item").children("a:first").addClass("ui-state-active");
+ this.active.parent().closest( ".ui-menu-item" ).children( "a:first" ).addClass( "ui-state-active" );
this.timer = this._delay( function() {
this._close();
}, this.delay );
- var nested = $( ">ul", item );
+ var nested = $( "> .ui-menu", item );
if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
this._startOpening(nested);
}
@@ -340,32 +380,32 @@ $.widget( "ui.menu", {
.position( position );
},
- collapseAll: function( event ) {
- var currentMenu = false;
- if ( event ) {
- var target = $( event.target );
- if ( target.is( "ui.menu" ) ) {
- currentMenu = target;
- } else if ( target.closest( ".ui-menu" ).length ) {
- currentMenu = target.closest( ".ui-menu" );
- }
+ collapseAll: function( event, all ) {
+
+ // 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" ) );
+
+ // if we found no valid submenu ancestor, use the main menu to close all sub menus anyway
+ if ( !currentMenu.length ) {
+ currentMenu = this.element;
}
this._close( currentMenu );
- if( !currentMenu ) {
- this.blur( event );
- this.activeMenu = this.element;
- }
+ this.blur( event );
+ this.activeMenu = currentMenu;
},
+ // With no arguments, closes the currently active menu - if nothing is active
+ // it closes all menus. If passed an argument, it will search for menus BELOW
_close: function( startMenu ) {
- if( !startMenu ) {
+ if ( !startMenu ) {
startMenu = this.active ? this.active.parent() : this.element;
}
startMenu
- .find( "ul" )
+ .find( ".ui-menu" )
.hide()
.attr( "aria-hidden", "true" )
.attr( "aria-expanded", "false" )
@@ -375,7 +415,7 @@ $.widget( "ui.menu", {
},
collapse: function( event ) {
- var newItem = this.active && this.active.parents("li:not(.ui-menubar-item)").first();
+ var newItem = this.active && this.active.parent().closest( ".ui-menu-item", this.element );
if ( newItem && newItem.length ) {
this._close();
this.focus( event, newItem );
@@ -384,7 +424,7 @@ $.widget( "ui.menu", {
},
expand: function( event ) {
- var newItem = this.active && this.active.children("ul").children("li").first();
+ var newItem = this.active && this.active.children( ".ui-menu " ).children( ".ui-menu-item" ).first();
if ( newItem && newItem.length ) {
this._open( newItem.parent() );
@@ -486,17 +526,17 @@ $.widget( "ui.menu", {
return this.element.height() < this.element.prop( "scrollHeight" );
},
- _mouseleave: function( event ) {
- this.collapseAll( event );
- this.blur();
- },
-
select: function( event ) {
+
// save active reference before collapseAll triggers blur
var ui = {
item: this.active
};
- this.collapseAll( event );
+ this.collapseAll( event, true );
+ if ( this.options.trigger ) {
+ $( this.options.trigger ).focus( 1 );
+ this.element.popup( "close" );
+ }
this._trigger( "select", event, ui );
}
});
diff --git a/ui/jquery.ui.menubar.js b/ui/jquery.ui.menubar.js
index 9af3aa080..673493366 100644
--- a/ui/jquery.ui.menubar.js
+++ b/ui/jquery.ui.menubar.js
@@ -94,7 +94,7 @@ $.widget( "ui.menubar", {
}
if ( ( that.open && event.type == "mouseenter" ) || event.type == "click" || that.options.autoExpand ) {
if( that.options.autoExpand ) {
- clearTimeout( that.timer );
+ clearTimeout( that.closeTimer );
}
that._open( event, menu );
@@ -123,22 +123,6 @@ $.widget( "ui.menubar", {
.attr( "aria-haspopup", "true" )
.wrapInner( "<span class='ui-button-text'></span>" );
- if ( that.options.autoExpand ) {
- input.bind( "mouseleave.menubar", function( event ) {
- that.timer = setTimeout( function() {
- that._close();
- }, 150 );
- });
- menu.bind( "mouseleave.menubar", function( event ) {
- that.timer = setTimeout( function() {
- that._close();
- }, 150 );
- })
- .bind( "mouseenter.menubar", function( event ) {
- clearTimeout( that.timer );
- });
- }
-
// TODO review if these options are a good choice, maybe they can be merged
if ( that.options.menuIcon ) {
input.addClass( "ui-state-default" ).append( "<span class='ui-button-icon-secondary ui-icon ui-icon-triangle-1-s'></span>" );
@@ -166,7 +150,17 @@ $.widget( "ui.menubar", {
focusout: function( event ) {
that.closeTimer = setTimeout( function() {
that._close( event );
- }, 100);
+ }, 150);
+ },
+ "mouseleave .ui-menubar-item": function( event ) {
+ if ( that.options.autoExpand ) {
+ that.closeTimer = setTimeout( function() {
+ that._close( event );
+ }, 150);
+ }
+ },
+ "mouseenter .ui-menubar-item": function( event ) {
+ clearTimeout( that.closeTimer );
}
});
},
diff --git a/ui/jquery.ui.popup.js b/ui/jquery.ui.popup.js
index 15349bc23..128464cc2 100644
--- a/ui/jquery.ui.popup.js
+++ b/ui/jquery.ui.popup.js
@@ -14,7 +14,8 @@
*/
(function($) {
-var idIncrement = 0;
+var idIncrement = 0,
+ suppressExpandOnFocus = false;
$.widget( "ui.popup", {
version: "@VERSION",
@@ -22,6 +23,16 @@ $.widget( "ui.popup", {
position: {
my: "left top",
at: "left bottom"
+ },
+ managed: false,
+ expandOnFocus: false,
+ show: {
+ effect: "slideDown",
+ duration: "fast"
+ },
+ hide: {
+ effect: "fadeOut",
+ duration: "fast"
}
},
_create: function() {
@@ -35,9 +46,10 @@ $.widget( "ui.popup", {
}
if ( !this.element.attr( "role" ) ) {
- // TODO alternatives to tooltip are dialog and menu, all three aren't generic popups
- this.element.attr( "role", "dialog" );
- this.generatedRole = true;
+ if ( !this.options.managed ) {
+ this.element.attr( "role", "dialog" );
+ this.generatedRole = true;
+ }
}
this.options.trigger
@@ -46,40 +58,91 @@ $.widget( "ui.popup", {
this.element
.addClass( "ui-popup" );
- this.close();
+ this._beforeClose();
+ this.element.hide();
this._bind(this.options.trigger, {
keydown: function( event ) {
- // prevent space-to-open to scroll the page, only happens for anchor ui.button
- if ( $.ui.button && this.options.trigger.is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE ) {
- event.preventDefault();
- }
- // TODO handle SPACE to open popup? only when not handled by ui.button
- if ( event.keyCode == $.ui.keyCode.SPACE && this.options.trigger.is( "a:not(:ui-button)" ) ) {
- this.options.trigger.trigger( "click", event );
- }
- // translate keydown to click
- // opens popup and let's tooltip hide itself
- if ( event.keyCode == $.ui.keyCode.DOWN ) {
- // prevent scrolling
- event.preventDefault();
- this.options.trigger.trigger( "click", event );
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.TAB:
+ // Waiting for close() will make popup hide too late, which breaks tab key behavior
+ this.element.hide();
+ this.close( event );
+ break;
+ case $.ui.keyCode.ESCAPE:
+ if ( this.isOpen ) {
+ this.close( event );
+ }
+ break;
+ case $.ui.keyCode.SPACE:
+ // prevent space-to-open to scroll the page, only happens for anchor ui.button
+ // TODO check for $.ui.button before using custom selector, once more below
+ if ( this.options.trigger.is( "a:ui-button" ) ) {
+ event.preventDefault();
+ }
+
+ else if (this.options.trigger.is( "a:not(:ui-button)" ) ) {
+ this.options.trigger.trigger( "click", event );
+ }
+ break;
+ case $.ui.keyCode.DOWN:
+ case $.ui.keyCode.UP:
+ // prevent scrolling
+ event.preventDefault();
+ clearTimeout( this.closeTimer );
+ this._delay(function() {
+ this.open( event );
+ this.focusPopup( event );
+ }, 1);
+ break;
}
},
click: function( event ) {
+ event.stopPropagation();
event.preventDefault();
+ },
+ mousedown: function( event ) {
+ var noFocus = false;
+ /* TODO: Determine in which cases focus should stay on the trigger after the popup opens
+ (should apply for any trigger that has other interaction besides opening the popup, e.g. a text field) */
+ if ( $( event.target ).is( "input" ) ) {
+ noFocus = true;
+ }
if (this.isOpen) {
- // let it propagate to close
+ suppressExpandOnFocus = true;
+ this.close();
return;
}
+ this.open( event );
clearTimeout( this.closeTimer );
- this._delay(function() {
- this.open( event );
- }, 1);
+ this._delay( function() {
+ if ( !noFocus ) {
+ this.focusPopup();
+ }
+ }, 1 );
}
});
- if ( !this.element.is( ":ui-menu" ) ) {
+ if ( this.options.expandOnFocus ) {
+ this._bind( this.options.trigger, {
+ focus : function( event ) {
+ if ( !suppressExpandOnFocus ) {
+ this._delay( function() {
+ if ( !this.isOpen ) {
+ this.open( event );
+ }
+ }, 1);
+ }
+ this._delay( function() {
+ suppressExpandOnFocus = false;
+ }, 100);
+ },
+ blur: function( event ) {
+ suppressExpandOnFocus = false;
+ }
+ });
+ }
+ if ( !this.options.managed ) {
//default use case, wrap tab order in popup
this._bind({ keydown : function( event ) {
if ( event.keyCode !== $.ui.keyCode.TAB ) {
@@ -105,33 +168,32 @@ $.widget( "ui.popup", {
// handle the closing instead of opening again
this.closeTimer = this._delay( function() {
this.close( event );
- }, 100);
+ }, 150);
},
focusin: function( event ) {
clearTimeout( this.closeTimer );
+ },
+ mouseup: function( event ) {
+ clearTimeout( this.closeTimer );
}
});
this._bind({
- // TODO only triggered on element if it can receive focus
- // bind to document instead?
- // either element itself or a child should be focusable
keyup: function( event ) {
if ( event.keyCode == $.ui.keyCode.ESCAPE && this.element.is( ":visible" ) ) {
this.close( event );
- // TODO move this to close()? would allow menu.select to call popup.close, and get focus back to trigger
- this.options.trigger.focus();
+ this.focusTrigger();
}
}
});
- this._bind(document, {
+ this._bind( this.document, {
click: function( event ) {
- if ( this.isOpen && !$(event.target).closest(".ui-popup").length ) {
+ if ( this.isOpen && !$( event.target ).closest( this.element.add( this.options.trigger ) ).length ) {
this.close( event );
}
}
- })
+ });
},
_destroy: function() {
@@ -159,16 +221,20 @@ $.widget( "ui.popup", {
of: this.options.trigger
}, this.options.position );
+ this._show( this.element, this.options.show );
this.element
- .show()
.attr( "aria-hidden", "false" )
.attr( "aria-expanded", "true" )
.position( position );
- if (this.element.is( ":ui-menu" )) { //popup is a menu
- this.element.menu( "focus", event, this.element.children( "li" ).first() );
- this.element.focus();
- } else {
+ // take trigger out of tab order to allow shift-tab to skip trigger
+ this.options.trigger.attr( "tabindex", -1 );
+ this.isOpen = true;
+ this._trigger( "open", event );
+ },
+
+ focusPopup: function( event ) {
+ if ( !this.options.managed ) {
// set focus to the first tabbable element in the popup container
// if there are no tabbable elements, set focus on the popup itself
var tabbables = this.element.find( ":tabbable" );
@@ -182,18 +248,18 @@ $.widget( "ui.popup", {
}
tabbables.first().focus( 1 );
}
+ this._trigger( "focusPopup", event );
+ },
- // take trigger out of tab order to allow shift-tab to skip trigger
- this.options.trigger.attr( "tabindex", -1 );
- this.isOpen = true;
- this._trigger( "open", event );
+ focusTrigger: function( event ) {
+ suppressExpandOnFocus = true;
+ this.options.trigger.focus();
+ this._trigger( "focusTrigger", event );
},
close: function( event ) {
- this.element
- .hide()
- .attr( "aria-hidden", "true" )
- .attr( "aria-expanded", "false" );
+ this._beforeClose();
+ this._hide( this.element, this.options.hide );
this.options.trigger.attr( "tabindex" , 0 );
if ( this.removeTabIndex ) {
@@ -201,6 +267,12 @@ $.widget( "ui.popup", {
}
this.isOpen = false;
this._trigger( "close", event );
+ },
+
+ _beforeClose: function() {
+ this.element
+ .attr( "aria-hidden", "true" )
+ .attr( "aria-expanded", "false" );
}
});
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js
index 24a033fc2..9a520f845 100644
--- a/ui/jquery.ui.position.js
+++ b/ui/jquery.ui.position.js
@@ -183,6 +183,12 @@ $.fn.position = function( options ) {
position.left += myOffset[ 0 ];
position.top += myOffset[ 1 ];
+ // 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 );
+ }
+
collisionPosition = {
marginLeft: marginLeft,
marginTop: marginTop
@@ -376,7 +382,7 @@ $.ui.position = {
newOverBottom;
if ( overTop < 0 ) {
newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
- if ( newOverBottom < 0 || newOverBottom < Math.abs( overTop ) ) {
+ if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < Math.abs( overTop ) ) ) {
data.elem
.addClass( "ui-flipped-bottom" );
@@ -385,7 +391,7 @@ $.ui.position = {
}
else if ( overBottom > 0 ) {
newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - withinOffset;
- if ( newOverTop > 0 || Math.abs( newOverTop ) < overBottom ) {
+ if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || Math.abs( newOverTop ) < overBottom ) ) {
data.elem
.addClass( "ui-flipped-top" );
@@ -406,6 +412,45 @@ $.ui.position = {
}
};
+// fraction support test
+(function () {
+ var testElement, testElementParent, testElementStyle, offsetLeft, i
+ body = document.getElementsByTagName( "body" )[ 0 ],
+ div = document.createElement( "div" );
+
+ //Create a "fake body" for testing based on method used in jQuery.support
+ testElement = document.createElement( body ? "div" : "body" );
+ testElementStyle = {
+ visibility: "hidden",
+ width: 0,
+ height: 0,
+ border: 0,
+ margin: 0,
+ background: "none"
+ };
+ if ( body ) {
+ jQuery.extend( testElementStyle, {
+ position: "absolute",
+ left: "-1000px",
+ top: "-1000px"
+ });
+ }
+ for ( i in testElementStyle ) {
+ testElement.style[ i ] = testElementStyle[ i ];
+ }
+ testElement.appendChild( div );
+ testElementParent = body || document.documentElement;
+ testElementParent.insertBefore( testElement, testElementParent.firstChild );
+
+ div.style.cssText = "position: absolute; left: 10.7432222px;";
+
+ offsetLeft = $( div ).offset().left;
+ $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
+
+ testElement.innerHTML = "";
+ testElementParent.removeChild( testElement );
+})();
+
// DEPRECATED
if ( $.uiBackCompat !== false ) {
// offset option
diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js
index 187470681..f754f61a4 100644
--- a/ui/jquery.ui.progressbar.js
+++ b/ui/jquery.ui.progressbar.js
@@ -68,7 +68,7 @@ $.widget( "ui.progressbar", {
}
}
- this._super( "_setOption", key, value );
+ this._super( key, value );
},
_value: function() {
diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js
index 673a8fd75..baca11f83 100644
--- a/ui/jquery.ui.resizable.js
+++ b/ui/jquery.ui.resizable.js
@@ -292,7 +292,7 @@ $.widget("ui.resizable", $.ui.mouse, {
if (!trigger) return false;
// Calculate the attrs that will be change
- var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
+ var data = trigger.apply(this, [event, dx, dy]);
// Put this in the mouseDrag handler since the user can start pressing shift while resizing
this._updateVirtualBoundaries(event.shiftKey);
diff --git a/ui/jquery.ui.selectable.js b/ui/jquery.ui.selectable.js
index 75f1cee66..d7b24d4e3 100644
--- a/ui/jquery.ui.selectable.js
+++ b/ui/jquery.ui.selectable.js
@@ -34,6 +34,7 @@ $.widget("ui.selectable", $.ui.mouse, {
var selectees;
this.refresh = function() {
selectees = $(self.options.filter, self.element[0]);
+ selectees.addClass("ui-selectee");
selectees.each(function() {
var $this = $(this);
var pos = $this.offset();
diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js
index 99798a915..62d227a3d 100644
--- a/ui/jquery.ui.sortable.js
+++ b/ui/jquery.ui.sortable.js
@@ -63,13 +63,11 @@ $.widget("ui.sortable", $.ui.mouse, {
destroy: function() {
this.element
- .removeClass("ui-sortable ui-sortable-disabled")
- .removeData("sortable")
- .unbind(".sortable");
+ .removeClass("ui-sortable ui-sortable-disabled");
this._mouseDestroy();
for ( var i = this.items.length - 1; i >= 0; i-- )
- this.items[i].item.removeData("sortable-item");
+ this.items[i].item.removeData(this.widgetName + "-item");
return this;
},
@@ -86,6 +84,7 @@ $.widget("ui.sortable", $.ui.mouse, {
},
_mouseCapture: function(event, overrideHandle) {
+ var that = this;
if (this.reverting) {
return false;
@@ -98,12 +97,12 @@ $.widget("ui.sortable", $.ui.mouse, {
//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, 'sortable-item') == self) {
+ if($.data(this, that.widgetName + '-item') == self) {
currentItem = $(this);
return false;
}
});
- if($.data(event.target, 'sortable-item') == self) currentItem = $(event.target);
+ if($.data(event.target, that.widgetName + '-item') == self) currentItem = $(event.target);
if(!currentItem) return false;
if(this.options.handle && !overrideHandle) {
@@ -528,7 +527,7 @@ $.widget("ui.sortable", $.ui.mouse, {
for (var i = connectWith.length - 1; i >= 0; i--){
var cur = $(connectWith[i]);
for (var j = cur.length - 1; j >= 0; j--){
- var inst = $.data(cur[j], 'sortable');
+ var inst = $.data(cur[j], this.widgetName);
if(inst && inst != this && !inst.options.disabled) {
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'), inst]);
}
@@ -550,7 +549,7 @@ $.widget("ui.sortable", $.ui.mouse, {
_removeCurrentsFromItems: function() {
- var list = this.currentItem.find(":data(sortable-item)");
+ var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
for (var i=0; i < this.items.length; i++) {
@@ -576,7 +575,7 @@ $.widget("ui.sortable", $.ui.mouse, {
for (var i = connectWith.length - 1; i >= 0; i--){
var cur = $(connectWith[i]);
for (var j = cur.length - 1; j >= 0; j--){
- var inst = $.data(cur[j], 'sortable');
+ var inst = $.data(cur[j], this.widgetName);
if(inst && inst != this && !inst.options.disabled) {
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
this.containers.push(inst);
@@ -592,7 +591,7 @@ $.widget("ui.sortable", $.ui.mouse, {
for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
var item = $(_queries[j]);
- item.data('sortable-item', targetData); // Data for target checking (mouse manager)
+ item.data(this.widgetName + '-item', targetData); // Data for target checking (mouse manager)
items.push({
item: item,
diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js
index 4b7239850..b78b4dbea 100644
--- a/ui/jquery.ui.spinner.js
+++ b/ui/jquery.ui.spinner.js
@@ -30,6 +30,7 @@ $.widget( "ui.spinner", {
defaultElement: "<input>",
widgetEventPrefix: "spin",
options: {
+ culture: null,
incremental: true,
max: null,
min: null,
@@ -48,6 +49,15 @@ $.widget( "ui.spinner", {
this._draw();
this._bind( this._events );
this._refresh();
+
+ // turning off autocomplete prevents the browser from remembering the
+ // value when navigating through history, so we re-enable autocomplete
+ // if the page is unloaded before the widget is destroyed. #7790
+ this._bind( this.window, {
+ beforeunload: function() {
+ this.element.removeAttr( "autocomplete" );
+ }
+ });
},
_getCreateOptions: function() {
@@ -92,7 +102,7 @@ $.widget( "ui.spinner", {
this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
clearTimeout( this.mousewheelTimer );
- this.mousewheelTimer = setTimeout(function() {
+ this.mousewheelTimer = this._delay(function() {
if ( this.spinning ) {
this._stop( event );
}
@@ -102,7 +112,7 @@ $.widget( "ui.spinner", {
"mousedown .ui-spinner-button": function( event ) {
// ensure focus is on (or stays on) the text field
event.preventDefault();
- if ( document.activeElement !== this.element[ 0 ] ) {
+ if ( this.document[0].activeElement !== this.element[ 0 ] ) {
this.element.focus();
}
@@ -150,7 +160,8 @@ $.widget( "ui.spinner", {
// IE 6 doesn't understand height: 50% for the buttons
// unless the wrapper has an explicit height
- if ( this.buttons.height() === uiSpinner.height() ) {
+ if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
+ uiSpinner.height() > 0 ) {
uiSpinner.height( uiSpinner.height() );
}
@@ -300,7 +311,14 @@ $.widget( "ui.spinner", {
},
_setOption: function( key, value ) {
- this._super( "_setOption", key, value );
+ if ( key === "culture" || key === "numberFormat" ) {
+ var prevValue = this._parse( this.element.val() );
+ this.options[ key ] = value;
+ this.element.val( this._format( prevValue ) );
+ return;
+ }
+
+ this._super( key, value );
if ( key === "disabled" ) {
if ( value ) {
@@ -314,13 +332,14 @@ $.widget( "ui.spinner", {
},
_setOptions: modifier(function( options ) {
- this._super( "_setOptions", options );
+ this._super( options );
this._value( this.element.val() );
}),
_parse: function( val ) {
if ( typeof val === "string" && val !== "" ) {
- val = window.Globalize && this.options.numberFormat ? Globalize.parseFloat( val ) : +val;
+ val = window.Globalize && this.options.numberFormat ?
+ Globalize.parseFloat( val, 10, this.options.culture ) : +val;
}
return val === "" || isNaN( val ) ? null : val;
},
@@ -330,7 +349,7 @@ $.widget( "ui.spinner", {
return "";
}
return window.Globalize && this.options.numberFormat ?
- Globalize.format( value, this.options.numberFormat ) :
+ Globalize.format( value, this.options.numberFormat, this.options.culture ) :
value;
},
@@ -368,7 +387,7 @@ $.widget( "ui.spinner", {
.removeAttr( "aria-valuemin" )
.removeAttr( "aria-valuemax" )
.removeAttr( "aria-valuenow" );
- this._super( "destroy" );
+ this._super();
this.uiSpinner.replaceWith( this.element );
},
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js
index a1bf72cb1..5c9fc1326 100644
--- a/ui/jquery.ui.tabs.js
+++ b/ui/jquery.ui.tabs.js
@@ -136,7 +136,7 @@ $.widget( "ui.tabs", {
return;
}
- this._super( "_setOption", key, value);
+ this._super( key, value);
// setting collapsible: false while collapsed; open first panel
if ( key === "collapsible" && !value && this.options.active === false ) {
@@ -323,7 +323,7 @@ $.widget( "ui.tabs", {
if ( tab.hasClass( "ui-state-disabled" ) ||
// tab is already loading
- tab.hasClass( "ui-tabs-loading" ) ||
+ tab.hasClass( "ui-tabs-loading" ) ||
// can't switch durning an animation
that.running ||
// click on active header, but not collapsible
@@ -541,19 +541,27 @@ $.widget( "ui.tabs", {
this.xhr
.success(function( response ) {
- panel.html( response );
- self._trigger( "load", event, eventData );
+ // TODO: IE resolves cached XHRs immediately
+ // remove when core #10467 is fixed
+ setTimeout(function() {
+ panel.html( response );
+ self._trigger( "load", event, eventData );
+ }, 1 );
})
.complete(function( jqXHR, status ) {
- if ( status === "abort" ) {
- self.panels.stop( false, true );
- }
+ // TODO: IE resolves cached XHRs immediately
+ // remove when core #10467 is fixed
+ setTimeout(function() {
+ if ( status === "abort" ) {
+ self.panels.stop( false, true );
+ }
- self.lis.eq( index ).removeClass( "ui-tabs-loading" );
+ self.lis.eq( index ).removeClass( "ui-tabs-loading" );
- if ( jqXHR === self.xhr ) {
- delete self.xhr;
- }
+ if ( jqXHR === self.xhr ) {
+ delete self.xhr;
+ }
+ }, 1 );
});
}
@@ -666,13 +674,13 @@ if ( $.uiBackCompat !== false ) {
spinner: "<em>Loading&#8230;</em>"
},
_create: function() {
- this._super( "_create" );
+ this._super();
this._bind({
tabsbeforeload: function( event, ui ) {
if ( !this.options.spinner ) {
return;
}
-
+
var span = ui.tab.find( "span" ),
html = span.html();
span.html( this.options.spinner );
@@ -965,7 +973,7 @@ if ( $.uiBackCompat !== false ) {
}
options.active = active;
}
- this._super( "_create" );
+ this._super();
},
_cookie: function( active ) {
var cookie = [ this.cookie ||
@@ -977,19 +985,19 @@ if ( $.uiBackCompat !== false ) {
return $.cookie.apply( null, cookie );
},
_refresh: function() {
- this._super( "_refresh" );
+ this._super();
if ( this.options.cookie ) {
this._cookie( this.options.active, this.options.cookie );
}
},
_eventHandler: function( event ) {
- this._superApply( "_eventHandler", arguments );
+ this._superApply( arguments );
if ( this.options.cookie ) {
this._cookie( this.options.active, this.options.cookie );
}
},
_destroy: function() {
- this._super( "_destroy" );
+ this._super();
if ( this.options.cookie ) {
this._cookie( null, this.options.cookie );
}
@@ -1004,7 +1012,7 @@ if ( $.uiBackCompat !== false ) {
_data.panel = _data.panel[ 0 ];
_data.tab = _data.tab[ 0 ];
}
- return this._super( "_trigger", type, event, _data );
+ return this._super( type, event, _data );
}
});
}
diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js
index 2f8d92969..a006f3bf7 100644
--- a/ui/jquery.ui.tooltip.js
+++ b/ui/jquery.ui.tooltip.js
@@ -54,7 +54,7 @@ $.widget( "ui.tooltip", {
// disable element style changes
return;
}
- this._super( "_setOption", key, value );
+ this._super( key, value );
},
_disable: function() {
@@ -166,7 +166,7 @@ $.widget( "ui.tooltip", {
// don't close if the element has focus
// this prevents the tooltip from closing if you hover while focused
- if ( !force && document.activeElement === target[0] ) {
+ if ( !force && this.document[0].activeElement === target[0] ) {
return;
}
@@ -200,7 +200,7 @@ $.widget( "ui.tooltip", {
$( "<div>" )
.addClass( "ui-tooltip-content" )
.appendTo( tooltip );
- tooltip.appendTo( document.body );
+ tooltip.appendTo( this.document[0].body );
if ( $.fn.bgiframe ) {
tooltip.bgiframe();
}
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index 31328a455..4f47a008b 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -62,11 +62,11 @@ $.widget = function( name, base, prototype ) {
$.each( prototype, function( prop, value ) {
if ( $.isFunction( value ) ) {
prototype[ prop ] = (function() {
- var _super = function( method ) {
- return base.prototype[ method ].apply( this, slice.call( arguments, 1 ) );
+ var _super = function() {
+ return base.prototype[ prop ].apply( this, arguments );
};
- var _superApply = function( method, args ) {
- return base.prototype[ method ].apply( this, args );
+ var _superApply = function( args ) {
+ return base.prototype[ prop ].apply( this, args );
};
return function() {
var __super = this._super,
@@ -195,6 +195,12 @@ $.Widget.prototype = {
if ( element !== this ) {
$.data( element, this.widgetName, this );
this._bind({ remove: "destroy" });
+ this.document = $( element.style ?
+ // element within the document
+ element.ownerDocument :
+ // element is window or document
+ element.document || element );
+ this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
}
this._create();
@@ -270,10 +276,11 @@ $.Widget.prototype = {
return this;
},
_setOptions: function( options ) {
- var that = this;
- $.each( options, function( key, value ) {
- that._setOption( key, value );
- });
+ var key;
+
+ for ( key in options ) {
+ this._setOption( key, options[ key ] );
+ }
return this;
},
@@ -367,33 +374,31 @@ $.Widget.prototype = {
},
_trigger: function( type, event, data ) {
- var callback = this.options[ type ],
- args;
+ var prop, orig,
+ callback = this.options[ type ];
+ data = data || {};
event = $.Event( event );
event.type = ( type === this.widgetEventPrefix ?
type :
this.widgetEventPrefix + type ).toLowerCase();
- data = data || {};
+ // the original event may come from any element
+ // so we need to reset the target on the new event
+ event.target = this.element[ 0 ];
// copy original event properties over to the new event
- // this would happen if we could call $.event.fix instead of $.Event
- // but we don't have a way to force an event to be fixed multiple times
- if ( event.originalEvent ) {
- for ( var i = $.event.props.length, prop; i; ) {
- prop = $.event.props[ --i ];
- event[ prop ] = event.originalEvent[ prop ];
+ orig = event.originalEvent;
+ if ( orig ) {
+ for ( prop in orig ) {
+ if ( !( prop in event ) ) {
+ event[ prop ] = orig[ prop ];
+ }
}
}
this.element.trigger( event, data );
-
- args = $.isArray( data ) ?
- [ event ].concat( data ) :
- [ event, data ];
-
return !( $.isFunction( callback ) &&
- callback.apply( this.element[0], args ) === false ||
+ callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
event.isDefaultPrevented() );
}
};