Merge branch 'master' of github.com:jquery/jquery-ui into selectmenu

This commit is contained in:
Felix Nagel 2012-01-22 14:47:21 +01:00
commit 21d96f12f8
14 changed files with 139 additions and 42 deletions

View File

@ -45,7 +45,7 @@ $.extend( $.simulate.prototype, {
} }
}, },
mouseEvent: function( type, options ) { mouseEvent: function( type, options ) {
var evt; var evt, eventDoc, doc, body;
var e = $.extend({ var e = $.extend({
bubbles: true, bubbles: true,
cancelable: (type !== "mousemove"), cancelable: (type !== "mousemove"),
@ -71,6 +71,30 @@ $.extend( $.simulate.prototype, {
e.screenX, e.screenY, e.clientX, e.clientY, e.screenX, e.screenY, e.clientX, e.clientY,
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
e.button, e.relatedTarget || document.body.parentNode ); 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 ) { } else if ( document.createEventObject ) {
evt = document.createEventObject(); evt = document.createEventObject();
$.extend( evt, e ); $.extend( evt, e );

View File

@ -1,12 +1,11 @@
commonWidgetTests( "menu", { commonWidgetTests( "menu", {
defaults: { defaults: {
disabled: false, disabled: false,
menus: "ul",
position: { position: {
my: "left top", my: "left top",
at: "right top" at: "right top"
}, },
menus: "ul",
trigger: null,
// callbacks // callbacks
create: null create: null

View File

@ -2,6 +2,45 @@
module( "tabs: events" ); 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() { test( "beforeActivate", function() {
expect( 38 ); expect( 38 );

View File

@ -261,6 +261,21 @@ test( "._getCreateOptions()", function() {
$( "<div>" ).testWidget({ option2: "value2" }); $( "<div>" ).testWidget({ option2: "value2" });
}); });
test( "._getCreateEventData()", function() {
expect( 1 );
var data = { foo: "bar" };
$.widget( "ui.testWidget", {
_getCreateEventData: function() {
return data;
}
});
$( "<div>" ).testWidget({
create: function( event, ui ) {
strictEqual( ui, data, "event data" );
}
});
});
test( "re-init", function() { test( "re-init", function() {
var div = $( "<div>" ), var div = $( "<div>" ),
actions = []; actions = [];

View File

@ -1,23 +1,23 @@
/* Korean initialisation for the jQuery calendar extension. */ /* 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($){ jQuery(function($){
$.datepicker.regional['ko'] = { $.datepicker.regional['ko'] = {
closeText: '닫기', closeText: '닫기',
prevText: '이전달', prevText: '이전달',
nextText: '다음달', nextText: '다음달',
currentText: '오늘', currentText: '오늘',
monthNames: ['1월(JAN)','2월(FEB)','3월(MAR)','4월(APR)','5월(MAY)','6월(JUN)', monthNames: ['1월','2월','3월','4월','5월','6월',
'7월(JUL)','8월(AUG)','9월(SEP)','10월(OCT)','11월(NOV)','12월(DEC)'], '7월','8월','9월','10월','11월','12월'],
monthNamesShort: ['1월(JAN)','2월(FEB)','3월(MAR)','4월(APR)','5월(MAY)','6월(JUN)', monthNamesShort: ['1월','2월','3월','4월','5월','6월',
'7월(JUL)','8월(AUG)','9월(SEP)','10월(OCT)','11월(NOV)','12월(DEC)'], '7월','8월','9월','10월','11월','12월'],
dayNames: ['일','월','화','수','목','금','토'], dayNames: ['일요일','월요일','화요일','수요일','목요일','금요일','토요일'],
dayNamesShort: ['일','월','화','수','목','금','토'], dayNamesShort: ['일','월','화','수','목','금','토'],
dayNamesMin: ['일','월','화','수','목','금','토'], dayNamesMin: ['일','월','화','수','목','금','토'],
weekHeader: 'Wk', weekHeader: 'Wk',
dateFormat: 'yy-mm-dd', dateFormat: 'yy-mm-dd',
firstDay: 0, firstDay: 0,
isRTL: false, isRTL: false,
showMonthAfterYear: false, showMonthAfterYear: true,
yearSuffix: '년'}; yearSuffix: '년'};
$.datepicker.setDefaults($.datepicker.regional['ko']); $.datepicker.setDefaults($.datepicker.regional['ko']);
}); });

View File

@ -14,7 +14,7 @@ jQuery(function($){
dayNamesShort: ['Нед','Пон','Вто','Сре','Чет','Пет','Саб'], dayNamesShort: ['Нед','Пон','Вто','Сре','Чет','Пет','Саб'],
dayNamesMin: ['Не','По','Вт','Ср','Че','Пе','Са'], dayNamesMin: ['Не','По','Вт','Ср','Че','Пе','Са'],
weekHeader: 'Сед', weekHeader: 'Сед',
dateFormat: 'dd/mm/yy', dateFormat: 'dd.mm.yy',
firstDay: 1, firstDay: 1,
isRTL: false, isRTL: false,
showMonthAfterYear: false, showMonthAfterYear: false,

View File

@ -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 */ /* David De Sloovere @DavidDeSloovere */
jQuery(function($){ jQuery(function($){
$.datepicker.regional['nl-BE'] = { $.datepicker.regional['nl-BE'] = {

View File

@ -58,7 +58,9 @@ $.widget( "ui.button", {
.bind( "reset.button", formResetHandler ); .bind( "reset.button", formResetHandler );
if ( typeof this.options.disabled !== "boolean" ) { 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(); this._determineButtonType();
@ -74,10 +76,6 @@ $.widget( "ui.button", {
options.label = this.buttonElement.html(); options.label = this.buttonElement.html();
} }
if ( this.element.is( ":disabled" ) ) {
options.disabled = true;
}
this.buttonElement this.buttonElement
.addClass( baseClasses ) .addClass( baseClasses )
.attr( "role", "button" ) .attr( "role", "button" )

View File

@ -223,6 +223,11 @@ $(function() {
var body = document.body, var body = document.body,
div = body.appendChild( div = document.createElement( "div" ) ); 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, { $.extend( div.style, {
minHeight: "100px", minHeight: "100px",
height: "auto", height: "auto",

View File

@ -233,7 +233,10 @@ $.extend(Datepicker.prototype, {
inst.trigger.click(function() { inst.trigger.click(function() {
if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0]) if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
$.datepicker._hideDatepicker(); $.datepicker._hideDatepicker();
else else if ($.datepicker._datepickerShowing && $.datepicker._lastInput != input[0]) {
$.datepicker._hideDatepicker();
$.datepicker._showDatepicker(input[0]);
} else
$.datepicker._showDatepicker(input[0]); $.datepicker._showDatepicker(input[0]);
return false; return false;
}); });

View File

@ -429,7 +429,7 @@ $.ui.position = {
background: "none" background: "none"
}; };
if ( body ) { if ( body ) {
jQuery.extend( testElementStyle, { $.extend( testElementStyle, {
position: "absolute", position: "absolute",
left: "-1000px", left: "-1000px",
top: "-1000px" top: "-1000px"

View File

@ -17,6 +17,7 @@
$.widget("ui.sortable", $.ui.mouse, { $.widget("ui.sortable", $.ui.mouse, {
version: "@VERSION", version: "@VERSION",
widgetEventPrefix: "sort", widgetEventPrefix: "sort",
ready: false,
options: { options: {
appendTo: "parent", appendTo: "parent",
axis: false, axis: false,
@ -59,6 +60,9 @@ $.widget("ui.sortable", $.ui.mouse, {
//Initialize mouse events for interaction //Initialize mouse events for interaction
this._mouseInit(); this._mouseInit();
//We're ready to go
this.ready = true
}, },
destroy: function() { destroy: function() {
@ -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 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(); 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--){ for (var i = connectWith.length - 1; i >= 0; i--){
var cur = $(connectWith[i]); var cur = $(connectWith[i]);
for (var j = cur.length - 1; j >= 0; j--){ for (var j = cur.length - 1; j >= 0; j--){

37
ui/jquery.ui.tabs.js vendored
View File

@ -13,23 +13,20 @@
*/ */
(function( $, undefined ) { (function( $, undefined ) {
var tabId = 0; var tabId = 0,
rhash = /#.*$/;
function getNextTabId() { function getNextTabId() {
return ++tabId; return ++tabId;
} }
var isLocal = (function() { var isLocal = function( anchor ) {
var rhash = /#.*$/, // clone the node to work around IE 6 not normalizing the href property
currentPage = location.href.replace( rhash, "" ); // if it's manually set, i.e., a.href = "#foo" kills the normalization
anchor = anchor.cloneNode( false );
return function( anchor ) { return anchor.hash.length > 1 &&
// clone the node to work around IE 6 not normalizing the href property anchor.href.replace( rhash, "" ) === location.href.replace( rhash, "" );
// 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;
};
})();
$.widget( "ui.tabs", { $.widget( "ui.tabs", {
version: "@VERSION", 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 ) { _setOption: function( key, value ) {
if ( key == "active" ) { if ( key == "active" ) {
// _activate() will handle invalid values and update this.options // _activate() will handle invalid values and update this.options
@ -212,7 +216,7 @@ $.widget( "ui.tabs", {
_processTabs: function() { _processTabs: function() {
var self = this; 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.lis = $( " > li:has(a[href])", this.list );
this.anchors = this.lis.map(function() { this.anchors = this.lis.map(function() {
return $( "a", this )[ 0 ]; 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 ) { _createPanel: function( id ) {
return $( "<div></div>" ) return $( "<div></div>" )
.attr( "id", id ) .attr( "id", id )

View File

@ -204,10 +204,11 @@ $.Widget.prototype = {
} }
this._create(); this._create();
this._trigger( "create" ); this._trigger( "create", null, this._getCreateEventData() );
this._init(); this._init();
}, },
_getCreateOptions: $.noop, _getCreateOptions: $.noop,
_getCreateEventData: $.noop,
_create: $.noop, _create: $.noop,
_init: $.noop, _init: $.noop,