diff --git a/tests/jquery.simulate.js b/tests/jquery.simulate.js index a37302c46..a8740e6b8 100644 --- a/tests/jquery.simulate.js +++ b/tests/jquery.simulate.js @@ -45,7 +45,7 @@ $.extend( $.simulate.prototype, { } }, mouseEvent: function( type, options ) { - var evt; + var evt, eventDoc, doc, body; var e = $.extend({ bubbles: true, cancelable: (type !== "mousemove"), @@ -71,6 +71,30 @@ $.extend( $.simulate.prototype, { e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget || document.body.parentNode ); + + // IE 9+ creates events with pageX and pageY set to 0. + // Trying to modify the properties throws an error, + // so we define getters to return the correct values. + if ( evt.pageX === 0 && evt.pageY === 0 && Object.defineProperty ) { + eventDoc = evt.relatedTarget.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + Object.defineProperty( evt, "pageX", { + get: function() { + return e.clientX + + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - + ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + } + }); + Object.defineProperty( evt, "pageY", { + get: function() { + return e.clientY + + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - + ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + }); + } } else if ( document.createEventObject ) { evt = document.createEventObject(); $.extend( evt, e ); diff --git a/tests/unit/menu/menu_defaults.js b/tests/unit/menu/menu_defaults.js index 3d7ec297f..bf41fb999 100644 --- a/tests/unit/menu/menu_defaults.js +++ b/tests/unit/menu/menu_defaults.js @@ -1,12 +1,11 @@ commonWidgetTests( "menu", { defaults: { disabled: false, + menus: "ul", position: { my: "left top", at: "right top" }, - menus: "ul", - trigger: null, // callbacks create: null diff --git a/tests/unit/tabs/tabs_events.js b/tests/unit/tabs/tabs_events.js index f5cde180b..333578907 100644 --- a/tests/unit/tabs/tabs_events.js +++ b/tests/unit/tabs/tabs_events.js @@ -2,6 +2,45 @@ module( "tabs: events" ); +test( "create", function() { + expect( 10 ); + + var element = $( "#tabs1" ), + tabs = element.find( "ul a" ), + panels = element.children( "div" ); + + element.tabs({ + create: function( event, ui ) { + equals( ui.tab.size(), 1, "tab size" ); + strictEqual( ui.tab[ 0 ], tabs[ 0 ], "tab" ); + equals( ui.panel.size(), 1, "panel size" ); + strictEqual( ui.panel[ 0 ], panels[ 0 ], "panel" ); + } + }); + element.tabs( "destroy" ); + + element.tabs({ + active: 2, + create: function( event, ui ) { + equals( ui.tab.size(), 1, "tab size" ); + strictEqual( ui.tab[ 0 ], tabs[ 2 ], "tab" ); + equals( ui.panel.size(), 1, "panel size" ); + strictEqual( ui.panel[ 0 ], panels[ 2 ], "panel" ); + } + }); + element.tabs( "destroy" ); + + element.tabs({ + active: false, + collapsible: true, + create: function( event, ui ) { + equals( ui.tab.size(), 0, "tab size" ); + equals( ui.panel.size(), 0, "panel size" ); + } + }); + element.tabs( "destroy" ); +}); + test( "beforeActivate", function() { expect( 38 ); diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 2e55ad703..df83abe91 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -261,6 +261,21 @@ test( "._getCreateOptions()", function() { $( "
" ).testWidget({ option2: "value2" }); }); +test( "._getCreateEventData()", function() { + expect( 1 ); + var data = { foo: "bar" }; + $.widget( "ui.testWidget", { + _getCreateEventData: function() { + return data; + } + }); + $( "
" ).testWidget({ + create: function( event, ui ) { + strictEqual( ui, data, "event data" ); + } + }); +}); + test( "re-init", function() { var div = $( "
" ), actions = []; diff --git a/ui/i18n/jquery.ui.datepicker-ko.js b/ui/i18n/jquery.ui.datepicker-ko.js index 5b3531652..04112424d 100644 --- a/ui/i18n/jquery.ui.datepicker-ko.js +++ b/ui/i18n/jquery.ui.datepicker-ko.js @@ -1,23 +1,23 @@ /* Korean initialisation for the jQuery calendar extension. */ -/* Written by DaeKwon Kang (ncrash.dk@gmail.com). */ +/* Written by DaeKwon Kang (ncrash.dk@gmail.com), Edited by Genie. */ jQuery(function($){ $.datepicker.regional['ko'] = { closeText: '닫기', prevText: '이전달', nextText: '다음달', currentText: '오늘', - monthNames: ['1월(JAN)','2월(FEB)','3월(MAR)','4월(APR)','5월(MAY)','6월(JUN)', - '7월(JUL)','8월(AUG)','9월(SEP)','10월(OCT)','11월(NOV)','12월(DEC)'], - monthNamesShort: ['1월(JAN)','2월(FEB)','3월(MAR)','4월(APR)','5월(MAY)','6월(JUN)', - '7월(JUL)','8월(AUG)','9월(SEP)','10월(OCT)','11월(NOV)','12월(DEC)'], - dayNames: ['일','월','화','수','목','금','토'], + monthNames: ['1월','2월','3월','4월','5월','6월', + '7월','8월','9월','10월','11월','12월'], + monthNamesShort: ['1월','2월','3월','4월','5월','6월', + '7월','8월','9월','10월','11월','12월'], + dayNames: ['일요일','월요일','화요일','수요일','목요일','금요일','토요일'], dayNamesShort: ['일','월','화','수','목','금','토'], dayNamesMin: ['일','월','화','수','목','금','토'], weekHeader: 'Wk', dateFormat: 'yy-mm-dd', firstDay: 0, isRTL: false, - showMonthAfterYear: false, + showMonthAfterYear: true, yearSuffix: '년'}; $.datepicker.setDefaults($.datepicker.regional['ko']); }); \ No newline at end of file diff --git a/ui/i18n/jquery.ui.datepicker-mk.js b/ui/i18n/jquery.ui.datepicker-mk.js index 554ad20ba..1e602427a 100644 --- a/ui/i18n/jquery.ui.datepicker-mk.js +++ b/ui/i18n/jquery.ui.datepicker-mk.js @@ -14,7 +14,7 @@ jQuery(function($){ dayNamesShort: ['Нед','Пон','Вто','Сре','Чет','Пет','Саб'], dayNamesMin: ['Не','По','Вт','Ср','Че','Пе','Са'], weekHeader: 'Сед', - dateFormat: 'dd/mm/yy', + dateFormat: 'dd.mm.yy', firstDay: 1, isRTL: false, showMonthAfterYear: false, diff --git a/ui/i18n/jquery.ui.datepicker-nl-BE.js b/ui/i18n/jquery.ui.datepicker-nl-BE.js index 56207cb04..7b3cdf425 100644 --- a/ui/i18n/jquery.ui.datepicker-nl-BE.js +++ b/ui/i18n/jquery.ui.datepicker-nl-BE.js @@ -1,4 +1,4 @@ -/* Dutch (Belgium) initialisation for the jQuery UI date picker plugin. */ +/* Dutch (Belgium) initialisation for the jQuery UI date picker plugin. */ /* David De Sloovere @DavidDeSloovere */ jQuery(function($){ $.datepicker.regional['nl-BE'] = { @@ -20,4 +20,4 @@ jQuery(function($){ showMonthAfterYear: false, yearSuffix: ''}; $.datepicker.setDefaults($.datepicker.regional['nl-BE']); -}); \ No newline at end of file +}); diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 18a950563..1c3cf2c64 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -58,7 +58,9 @@ $.widget( "ui.button", { .bind( "reset.button", formResetHandler ); if ( typeof this.options.disabled !== "boolean" ) { - this.options.disabled = this.element.prop( "disabled" ); + this.options.disabled = !!this.element.prop( "disabled" ); + } else { + this.element.prop( "disabled", this.options.disabled ); } this._determineButtonType(); @@ -74,10 +76,6 @@ $.widget( "ui.button", { options.label = this.buttonElement.html(); } - if ( this.element.is( ":disabled" ) ) { - options.disabled = true; - } - this.buttonElement .addClass( baseClasses ) .attr( "role", "button" ) diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index f0cf89ba7..d777d6d49 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -223,6 +223,11 @@ $(function() { var body = document.body, div = body.appendChild( div = document.createElement( "div" ) ); + // access offsetHeight before setting the style to prevent a layout bug + // in IE 9 which causes the elemnt to continue to take up space even + // after it is removed from the DOM (#8026) + div.offsetHeight; + $.extend( div.style, { minHeight: "100px", height: "auto", diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 45ddf8678..5915d4027 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -233,7 +233,10 @@ $.extend(Datepicker.prototype, { inst.trigger.click(function() { if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0]) $.datepicker._hideDatepicker(); - else + else if ($.datepicker._datepickerShowing && $.datepicker._lastInput != input[0]) { + $.datepicker._hideDatepicker(); + $.datepicker._showDatepicker(input[0]); + } else $.datepicker._showDatepicker(input[0]); return false; }); diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 9a520f845..00976bf79 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -37,7 +37,7 @@ $.position = { div.remove(); - return w1 - w2; + return w1 - w2; }, getScrollInfo: function(within) { var notWindow = within[0] !== window, @@ -401,12 +401,12 @@ $.ui.position = { } }, flipfit: { - left: function() { - $.ui.position.flip.left.apply( this, arguments ); + left: function() { + $.ui.position.flip.left.apply( this, arguments ); $.ui.position.fit.left.apply( this, arguments ); }, - top: function() { - $.ui.position.flip.top.apply( this, arguments ); + top: function() { + $.ui.position.flip.top.apply( this, arguments ); $.ui.position.fit.top.apply( this, arguments ); } } @@ -415,7 +415,7 @@ $.ui.position = { // fraction support test (function () { var testElement, testElementParent, testElementStyle, offsetLeft, i - body = document.getElementsByTagName( "body" )[ 0 ], + body = document.getElementsByTagName( "body" )[ 0 ], div = document.createElement( "div" ); //Create a "fake body" for testing based on method used in jQuery.support @@ -429,7 +429,7 @@ $.ui.position = { background: "none" }; if ( body ) { - jQuery.extend( testElementStyle, { + $.extend( testElementStyle, { position: "absolute", left: "-1000px", top: "-1000px" diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 62d227a3d..600569451 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -17,6 +17,7 @@ $.widget("ui.sortable", $.ui.mouse, { version: "@VERSION", widgetEventPrefix: "sort", + ready: false, options: { appendTo: "parent", axis: false, @@ -58,6 +59,9 @@ $.widget("ui.sortable", $.ui.mouse, { //Initialize mouse events for interaction this._mouseInit(); + + //We're ready to go + this.ready = true }, @@ -571,7 +575,7 @@ $.widget("ui.sortable", $.ui.mouse, { var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]]; var connectWith = this._connectWith(); - if(connectWith) { + if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down for (var i = connectWith.length - 1; i >= 0; i--){ var cur = $(connectWith[i]); for (var j = cur.length - 1; j >= 0; j--){ diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 5c9fc1326..7a701405c 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -13,23 +13,20 @@ */ (function( $, undefined ) { -var tabId = 0; +var tabId = 0, + rhash = /#.*$/; + function getNextTabId() { return ++tabId; } -var isLocal = (function() { - var rhash = /#.*$/, - currentPage = location.href.replace( rhash, "" ); - - return function( anchor ) { - // clone the node to work around IE 6 not normalizing the href property - // if it's manually set, i.e., a.href = "#foo" kills the normalization - anchor = anchor.cloneNode( false ); - return anchor.hash.length > 1 && - anchor.href.replace( rhash, "" ) === currentPage; - }; -})(); +var isLocal = function( anchor ) { + // clone the node to work around IE 6 not normalizing the href property + // if it's manually set, i.e., a.href = "#foo" kills the normalization + anchor = anchor.cloneNode( false ); + return anchor.hash.length > 1 && + anchor.href.replace( rhash, "" ) === location.href.replace( rhash, "" ); +}; $.widget( "ui.tabs", { version: "@VERSION", @@ -123,6 +120,13 @@ $.widget( "ui.tabs", { } }, + _getCreateEventData: function() { + return { + tab: this.active, + panel: !this.active.length ? $() : this._getPanelForTab( this.active ) + }; + }, + _setOption: function( key, value ) { if ( key == "active" ) { // _activate() will handle invalid values and update this.options @@ -212,7 +216,7 @@ $.widget( "ui.tabs", { _processTabs: function() { var self = this; - this.list = this.element.find( "ol,ul" ).eq( 0 ); + this.list = this._getList(); this.lis = $( " > li:has(a[href])", this.list ); this.anchors = this.lis.map(function() { return $( "a", this )[ 0 ]; @@ -244,6 +248,11 @@ $.widget( "ui.tabs", { }); }, + // allow overriding how to find the list for rare usage scenarios (#7715) + _getList: function() { + return this.element.find( "ol,ul" ).eq( 0 ); + }, + _createPanel: function( id ) { return $( "
" ) .attr( "id", id ) diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 5c8560bfd..ad03e6f44 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -204,10 +204,11 @@ $.Widget.prototype = { } this._create(); - this._trigger( "create" ); + this._trigger( "create", null, this._getCreateEventData() ); this._init(); }, _getCreateOptions: $.noop, + _getCreateEventData: $.noop, _create: $.noop, _init: $.noop,