diff options
author | kborchers <kris.borchers@gmail.com> | 2011-12-01 12:53:35 -0600 |
---|---|---|
committer | kborchers <kris.borchers@gmail.com> | 2011-12-01 12:53:35 -0600 |
commit | 490dc4d36b6a0bf1dac5d8a9ba86aef7c9c27ee9 (patch) | |
tree | e65043eb657d9232888dcc1435bdd6907f990d15 /ui | |
parent | e206e549352684a4c30ad53e38c5544599328f2d (diff) | |
parent | ce7918fc73c161ab237f052bad070e34250526be (diff) | |
download | jquery-ui-490dc4d36b6a0bf1dac5d8a9ba86aef7c9c27ee9.tar.gz jquery-ui-490dc4d36b6a0bf1dac5d8a9ba86aef7c9c27ee9.zip |
Merge branch 'master' into menubar_otherStructures
Diffstat (limited to 'ui')
26 files changed, 444 insertions, 197 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: '<', + nextText: '>', + 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 3dc0a4e67..233b4f96d 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -224,7 +224,7 @@ $.effects.animateClass = function( value, duration, easing, callback ) { return this.queue( function() { var animated = $( this ), baseClass = animated.attr( "class" ) || "", - finalClass, + 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.ui.accordion.js b/ui/jquery.ui.accordion.js index 580009d33..127099d59 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -12,7 +12,7 @@ * jquery.ui.widget.js */ (function( $, undefined ) { - + // TODO: use ui-accordion-header-active class and fix styling $.widget( "ui.accordion", { version: "@VERSION", @@ -167,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 ) { @@ -244,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 ); @@ -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,7 +449,7 @@ $.extend( $.ui.accordion, { easing: "swing", duration: 300 }, options, additions ); - + options.widget.lastToggle = options; if ( !options.toHide.size() ) { @@ -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 ab2edfdff..bd415aa2b 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -47,7 +47,6 @@ $.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 @@ -59,6 +58,7 @@ $.widget( "ui.autocomplete", { suppressKeyPressRepeat, suppressInput; + this.isMultiLine = this.element.is( "textarea,[contenteditable]" ); this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ]; this.element @@ -93,15 +93,11 @@ $.widget( "ui.autocomplete", { break; case keyCode.UP: suppressKeyPress = true; - self._move( "previous", event ); - // prevent moving cursor to beginning of text field in some browsers - event.preventDefault(); + self._keyEvent( "previous", event ); break; case keyCode.DOWN: suppressKeyPress = true; - self._move( "next", event ); - // prevent moving cursor to end of text field in some browsers - event.preventDefault(); + self._keyEvent( "next", event ); break; case keyCode.ENTER: case keyCode.NUMPAD_ENTER: @@ -152,14 +148,10 @@ $.widget( "ui.autocomplete", { self._move( "nextPage", event ); break; case keyCode.UP: - self._move( "previous", event ); - // prevent moving cursor to beginning of text field in some browsers - event.preventDefault(); + self._keyEvent( "previous", event ); break; case keyCode.DOWN: - self._move( "next", event ); - // prevent moving cursor to end of text field in some browsers - event.preventDefault(); + self._keyEvent( "next", event ); break; } }) @@ -185,6 +177,7 @@ $.widget( "ui.autocomplete", { } clearTimeout( self.searching ); + self.cancelSearch = true; // clicks on the menu (or a button to trigger a search) will cause a blur event self.closing = setTimeout(function() { self.close( event ); @@ -197,7 +190,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 @@ -207,7 +200,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 ) ) { @@ -239,7 +232,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 @@ -273,7 +266,7 @@ $.widget( "ui.autocomplete", { // 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( doc.defaultView, { + this._bind( this.window, { beforeunload: function() { this.element.removeAttr( "autocomplete" ); } @@ -292,12 +285,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(); @@ -374,6 +367,7 @@ $.widget( "ui.autocomplete", { _search: function( value ) { this.pending++; this.element.addClass( "ui-autocomplete-loading" ); + this.cancelSearch = false; this.source( { term: value }, this.response ); }, @@ -383,7 +377,7 @@ $.widget( "ui.autocomplete", { content = this._normalize( content ); } this._trigger( "response", null, { content: content } ); - if ( !this.options.disabled && content && content.length ) { + if ( !this.options.disabled && content && content.length && !this.cancelSearch ) { this._suggest( content ); this._trigger( "open" ); } else { @@ -453,7 +447,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() ) ); }, @@ -492,6 +488,15 @@ $.widget( "ui.autocomplete", { _value: function( value ) { return this.valueMethod.apply( this.element, arguments ); + }, + + _keyEvent: function( keyEvent, event ) { + if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) { + this._move( keyEvent, event ); + + // prevents moving cursor to beginning/end of the text field in some browsers + event.preventDefault(); + } } }); 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 e09dc5a50..45ddf8678 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -799,9 +799,10 @@ $.extend(Datepicker.prototype, { if (this._datepickerShowing) { var showAnim = this._get(inst, 'showAnim'); var duration = this._get(inst, 'duration'); + var self = this; var postProcess = function() { $.datepicker._tidyDialog(inst); - this._curInst = null; + self._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 46320426a..3d7638667 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() { @@ -626,9 +625,9 @@ $.widget("ui.dialog", { height: "auto", width: options.width }) - .height(); + .outerHeight(); 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(); } 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 944e47b7c..0263cff65 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -20,15 +20,15 @@ $.widget( "ui.menu", { defaultElement: "<ul>", delay: 150, options: { - items: "ul", + menus: "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" ); @@ -47,6 +47,11 @@ $.widget( "ui.menu", { } }, this)); this._bind({ + // Prevent focus from sticking to links inside menu after clicking + // them (focus should always stay on UL during navigation). + "mousedown .ui-menu-item > a": function( event ) { + event.preventDefault(); + }, "click .ui-menu-item:has(a)": function( event ) { event.stopImmediatePropagation(); var target = $( event.currentTarget ); @@ -55,16 +60,15 @@ $.widget( "ui.menu", { this.focus( event, target ); } this.select( event ); + // Redirect focus to the menu. + this.element.focus(); }, "mouseover .ui-menu-item": function( event ) { event.stopImmediatePropagation(); - 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; + 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 ); }, "mouseleave": "collapseAll", "mouseleave .ui-menu": "collapseAll", @@ -74,14 +78,10 @@ $.widget( "ui.menu", { }, blur: function( event ) { this._delay( function() { - if ( ! $.contains( this.element[0], document.activeElement ) ) { + 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; } }); @@ -196,17 +196,31 @@ $.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( ".ui-menu" ) @@ -236,7 +250,7 @@ $.widget( "ui.menu", { refresh: function() { // initialize nested menus - var submenus = this.element.find( this.options.items + ":not( .ui-menu )" ) + var submenus = this.element.find( this.options.menus + ":not( .ui-menu )" ) .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) .attr( "role", "menu" ) .hide() @@ -508,6 +522,10 @@ $.widget( "ui.menu", { item: this.active }; 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.popup.js b/ui/jquery.ui.popup.js index 4726f3a61..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", @@ -23,6 +24,8 @@ $.widget( "ui.popup", { my: "left top", at: "left bottom" }, + managed: false, + expandOnFocus: false, show: { effect: "slideDown", duration: "fast" @@ -43,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 @@ -59,37 +63,87 @@ $.widget( "ui.popup", { 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 ( !$.ui.menu || !this.element.is( ":ui-menu" ) ) { - // default use case, wrap tab order in popup + 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 ) { return; @@ -109,21 +163,33 @@ $.widget( "ui.popup", { } 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 + focusout: function( event ) { + // use a timer to allow click to clear it and letting that + // handle the closing instead of opening again + this.closeTimer = this._delay( function() { + this.close( event ); + }, 150); + }, + focusin: function( event ) { + clearTimeout( this.closeTimer ); + }, + mouseup: function( event ) { + clearTimeout( this.closeTimer ); + } + }); + + this._bind({ 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 ); } } @@ -161,11 +227,14 @@ $.widget( "ui.popup", { .attr( "aria-expanded", "true" ) .position( position ); - // can't use custom selector when menu isn't loaded - if ( $.ui.menu && this.element.is( ":ui-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" ); @@ -179,11 +248,13 @@ $.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 ) { diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 74530b948..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 @@ -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..408771eff 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(); @@ -103,7 +104,7 @@ $.widget("ui.selectable", $.ui.mouse, { this.selectees.filter('.ui-selected').each(function() { var selectee = $.data(this, "selectable-item"); selectee.startselected = true; - if (!event.metaKey) { + if (!event.metaKey && !event.ctrlKey) { selectee.$element.removeClass('ui-selected'); selectee.selected = false; selectee.$element.addClass('ui-unselecting'); @@ -118,7 +119,7 @@ $.widget("ui.selectable", $.ui.mouse, { $(event.target).parents().andSelf().each(function() { var selectee = $.data(this, "selectable-item"); if (selectee) { - var doSelect = !event.metaKey || !selectee.$element.hasClass('ui-selected'); + var doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass('ui-selected'); selectee.$element .removeClass(doSelect ? "ui-unselecting" : "ui-selected") .addClass(doSelect ? "ui-selecting" : "ui-unselecting"); @@ -188,7 +189,7 @@ $.widget("ui.selectable", $.ui.mouse, { } else { // UNSELECT if (selectee.selecting) { - if (event.metaKey && selectee.startselected) { + if ((event.metaKey || event.ctrlKey) && selectee.startselected) { selectee.$element.removeClass('ui-selecting'); selectee.selecting = false; selectee.$element.addClass('ui-selected'); @@ -207,7 +208,7 @@ $.widget("ui.selectable", $.ui.mouse, { } } if (selectee.selected) { - if (!event.metaKey && !selectee.startselected) { + if (!event.metaKey && !event.ctrlKey && !selectee.startselected) { selectee.$element.removeClass('ui-selected'); selectee.selected = false; diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 7fc291c00..b78b4dbea 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -53,7 +53,7 @@ $.widget( "ui.spinner", { // 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.element[0].ownerDocument.defaultView, { + this._bind( this.window, { beforeunload: function() { this.element.removeAttr( "autocomplete" ); } @@ -112,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(); } @@ -311,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 ) { @@ -325,7 +332,7 @@ $.widget( "ui.spinner", { }, _setOptions: modifier(function( options ) { - this._super( "_setOptions", options ); + this._super( options ); this._value( this.element.val() ); }), @@ -380,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 4127ddf84..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 @@ -555,13 +555,13 @@ $.widget( "ui.tabs", { if ( status === "abort" ) { self.panels.stop( false, true ); } - + self.lis.eq( index ).removeClass( "ui-tabs-loading" ); - + if ( jqXHR === self.xhr ) { delete self.xhr; } - }); + }, 1 ); }); } @@ -674,13 +674,13 @@ if ( $.uiBackCompat !== false ) { spinner: "<em>Loading…</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 ); @@ -973,7 +973,7 @@ if ( $.uiBackCompat !== false ) { } options.active = active; } - this._super( "_create" ); + this._super(); }, _cookie: function( active ) { var cookie = [ this.cookie || @@ -985,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 ); } @@ -1012,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() ); } }; |