mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Merge branch 'master' into selectmenu
This commit is contained in:
commit
91dde04dad
@ -66,7 +66,7 @@
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.data( "autocomplete" )._renderItem = function( ul, item ) {
|
||||
.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
|
||||
return $( "<li>" )
|
||||
.append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
|
||||
.appendTo( ul );
|
||||
|
@ -29,7 +29,7 @@
|
||||
// don't navigate away from the field on tab when selecting an item
|
||||
.bind( "keydown", function( event ) {
|
||||
if ( event.keyCode === $.ui.keyCode.TAB &&
|
||||
$( this ).data( "autocomplete" ).menu.active ) {
|
||||
$( this ).data( "ui-autocomplete" ).menu.active ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
})
|
||||
|
@ -48,7 +48,7 @@
|
||||
// don't navigate away from the field on tab when selecting an item
|
||||
.bind( "keydown", function( event ) {
|
||||
if ( event.keyCode === $.ui.keyCode.TAB &&
|
||||
$( this ).data( "autocomplete" ).menu.active ) {
|
||||
$( this ).data( "ui-autocomplete" ).menu.active ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ var setupTeardown = TestHelpers.accordion.setupTeardown,
|
||||
module( "accordion: events", setupTeardown() );
|
||||
|
||||
test( "create", function() {
|
||||
expect( 10 );
|
||||
expect( 15 );
|
||||
|
||||
var element = $( "#list1" ),
|
||||
headers = element.children( "h3" ),
|
||||
@ -16,6 +16,8 @@ test( "create", function() {
|
||||
create: function( event, ui ) {
|
||||
equal( ui.header.length, 1, "header length" );
|
||||
strictEqual( ui.header[ 0 ], headers[ 0 ], "header" );
|
||||
equal( ui.panel.length, 1, "panel length" );
|
||||
strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" );
|
||||
equal( ui.content.length, 1, "content length" );
|
||||
strictEqual( ui.content[ 0 ], contents[ 0 ], "content" );
|
||||
}
|
||||
@ -27,6 +29,8 @@ test( "create", function() {
|
||||
create: function( event, ui ) {
|
||||
equal( ui.header.length, 1, "header length" );
|
||||
strictEqual( ui.header[ 0 ], headers[ 2 ], "header" );
|
||||
equal( ui.panel.length, 1, "panel length" );
|
||||
strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" );
|
||||
equal( ui.content.length, 1, "content length" );
|
||||
strictEqual( ui.content[ 0 ], contents[ 2 ], "content" );
|
||||
}
|
||||
@ -38,6 +42,7 @@ test( "create", function() {
|
||||
collapsible: true,
|
||||
create: function( event, ui ) {
|
||||
equal( ui.header.length, 0, "header length" );
|
||||
equal( ui.panel.length, 0, "panel length" );
|
||||
equal( ui.content.length, 0, "content length" );
|
||||
}
|
||||
});
|
||||
|
@ -384,7 +384,7 @@ test("miscellaneous", function() {
|
||||
});
|
||||
|
||||
test("minMax", function() {
|
||||
expect( 19 );
|
||||
expect( 23 );
|
||||
var date,
|
||||
inp = TestHelpers.datepicker.init("#inp"),
|
||||
dp = $("#ui-datepicker-div"),
|
||||
@ -472,6 +472,22 @@ test("minMax", function() {
|
||||
ok(dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - previous button disabled at 1/1/minYear");
|
||||
inp.datepicker("setDate", "12/30/" + new Date().getFullYear());
|
||||
ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - next button disabled at 12/30/maxYear");
|
||||
|
||||
inp.datepicker("option", {
|
||||
minDate: new Date(1900, 0, 1),
|
||||
maxDate: "-6Y",
|
||||
yearRange: "1900:-6"
|
||||
}).val( "" );
|
||||
ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - next button disabled");
|
||||
ok(!dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - prev button enabled");
|
||||
|
||||
inp.datepicker("option", {
|
||||
minDate: new Date(1900, 0, 1),
|
||||
maxDate: "1/25/2007",
|
||||
yearRange: "1900:2007"
|
||||
}).val( "" );
|
||||
ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - next button disabled");
|
||||
ok(!dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - prev button enabled");
|
||||
});
|
||||
|
||||
test("setDate", function() {
|
||||
|
@ -34,7 +34,9 @@ test("init", function() {
|
||||
});
|
||||
|
||||
test("destroy", function() {
|
||||
expect( 7 );
|
||||
expect( 17 );
|
||||
|
||||
var el, el2;
|
||||
|
||||
$( "#dialog1, #form-dialog" ).hide();
|
||||
domEqual( "#dialog1", function() {
|
||||
@ -57,6 +59,35 @@ test("destroy", function() {
|
||||
domEqual( "#dialog1", function() {
|
||||
$( "#dialog1" ).dialog().dialog( "destroy" );
|
||||
});
|
||||
|
||||
// Don't throw errors when destroying a never opened modal dialog (#9004)
|
||||
$( "#dialog1" ).dialog({ autoOpen: false, modal: true }).dialog( "destroy" );
|
||||
equal( $( ".ui-widget-overlay" ).length, 0, "overlay does not exist" );
|
||||
equal( $.ui.dialog.overlayInstances, 0, "overlayInstances equals the number of open overlays");
|
||||
|
||||
el = $( "#dialog1" ).dialog({ modal: true }),
|
||||
el2 = $( "#dialog2" ).dialog({ modal: true });
|
||||
equal( $( ".ui-widget-overlay" ).length, 2, "overlays created when dialogs are open" );
|
||||
equal( $.ui.dialog.overlayInstances, 2, "overlayInstances equals the number of open overlays" );
|
||||
el.dialog( "close" );
|
||||
equal( $( ".ui-widget-overlay" ).length, 1, "overlay remains after closing one dialog" );
|
||||
equal( $.ui.dialog.overlayInstances, 1, "overlayInstances equals the number of open overlays" );
|
||||
el.dialog( "destroy" );
|
||||
equal( $( ".ui-widget-overlay" ).length, 1, "overlay remains after destroying one dialog" );
|
||||
equal( $.ui.dialog.overlayInstances, 1, "overlayInstances equals the number of open overlays" );
|
||||
el2.dialog( "destroy" );
|
||||
equal( $( ".ui-widget-overlay" ).length, 0, "overlays removed when all dialogs are destoryed" );
|
||||
equal( $.ui.dialog.overlayInstances, 0, "overlayInstances equals the number of open overlays" );
|
||||
});
|
||||
|
||||
asyncTest("#9000: Dialog leaves broken event handler after close/destroy in certain cases", function() {
|
||||
expect( 1 );
|
||||
$( "#dialog1" ).dialog({ modal:true }).dialog( "close" ).dialog( "destroy" );
|
||||
setTimeout(function() {
|
||||
$( "#favorite-animal" ).focus();
|
||||
ok( true, "close and destroy modal dialog before its really opened" );
|
||||
start();
|
||||
}, 2 );
|
||||
});
|
||||
|
||||
test("#4980: Destroy should place element back in original DOM position", function(){
|
||||
|
@ -6,43 +6,63 @@
|
||||
module("dialog: options");
|
||||
|
||||
test( "appendTo", function() {
|
||||
expect( 8 );
|
||||
expect( 16 );
|
||||
var detached = $( "<div>" ),
|
||||
element = $( "#dialog1" ).dialog();
|
||||
element = $( "#dialog1" ).dialog({
|
||||
modal: true
|
||||
});
|
||||
equal( element.dialog( "widget" ).parent()[0], document.body, "defaults to body" );
|
||||
equal( $( ".ui-widget-overlay" ).parent()[0], document.body, "overlay defaults to body" );
|
||||
element.dialog( "destroy" );
|
||||
|
||||
element.dialog({
|
||||
appendTo: ".wrap"
|
||||
appendTo: ".wrap",
|
||||
modal: true
|
||||
});
|
||||
equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "first found element" );
|
||||
equal( $( ".ui-widget-overlay" ).parent()[0], $( "#wrap1" )[0], "overlay first found element" );
|
||||
equal( $( "#wrap2 .ui-dialog" ).length, 0, "only appends to one element" );
|
||||
equal( $( "#wrap2 .ui-widget-overlay" ).length, 0, "overlay only appends to one element" );
|
||||
element.dialog( "destroy" );
|
||||
|
||||
element.dialog({
|
||||
appendTo: null
|
||||
appendTo: null,
|
||||
modal: true
|
||||
});
|
||||
equal( element.dialog( "widget" ).parent()[0], document.body, "null" );
|
||||
element.dialog( "destroy" );
|
||||
|
||||
element.dialog({ autoOpen: false }).dialog( "option", "appendTo", "#wrap1" ).dialog( "open" );
|
||||
equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "modified after init" );
|
||||
equal( $( ".ui-widget-overlay" ).parent()[0], document.body, "overlay null" );
|
||||
element.dialog( "destroy" );
|
||||
|
||||
element.dialog({
|
||||
appendTo: detached
|
||||
autoOpen: false,
|
||||
modal: true
|
||||
}).dialog( "option", "appendTo", "#wrap1" ).dialog( "open" );
|
||||
equal( element.dialog( "widget" ).parent()[0], $( "#wrap1" )[0], "modified after init" );
|
||||
equal( $( ".ui-widget-overlay" ).parent()[0], $( "#wrap1" )[0], "overlay modified after init" );
|
||||
element.dialog( "destroy" );
|
||||
|
||||
element.dialog({
|
||||
appendTo: detached,
|
||||
modal: true
|
||||
});
|
||||
equal( element.dialog( "widget" ).parent()[0], detached[0], "detached jQuery object" );
|
||||
equal( detached.find( ".ui-widget-overlay" ).parent()[0], detached[0], "overlay detached jQuery object" );
|
||||
element.dialog( "destroy" );
|
||||
|
||||
element.dialog({
|
||||
appendTo: detached[0]
|
||||
appendTo: detached[0],
|
||||
modal: true
|
||||
});
|
||||
equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element" );
|
||||
equal( detached.find( ".ui-widget-overlay" ).parent()[0], detached[0], "overlay detached DOM element" );
|
||||
element.dialog( "destroy" );
|
||||
|
||||
element.dialog({ autoOpen: false }).dialog( "option", "appendTo", detached );
|
||||
element.dialog({
|
||||
autoOpen: false,
|
||||
modal: true
|
||||
}).dialog( "option", "appendTo", detached );
|
||||
equal( element.dialog( "widget" ).parent()[0], detached[0], "detached DOM element via option()" );
|
||||
equal( detached.find( ".ui-widget-overlay" ).length, 0, "overlay detached DOM element via option()" );
|
||||
element.dialog( "destroy" );
|
||||
});
|
||||
|
||||
|
@ -38,6 +38,17 @@ asyncTest( "Parse of null for options", function() {
|
||||
});
|
||||
});
|
||||
|
||||
test( "removeClass", function() {
|
||||
expect( 3 );
|
||||
|
||||
var element = $( "<div>" );
|
||||
equal( "", element[ 0 ].className );
|
||||
element.addClass( "destroyed" );
|
||||
equal( "destroyed", element[ 0 ].className );
|
||||
element.removeClass();
|
||||
equal( "", element[ 0 ].className );
|
||||
});
|
||||
|
||||
|
||||
/* TODO: Disabled - Can't figure out why this is failing in IE 6/7
|
||||
test( "createWrapper and removeWrapper retain focused elements (#7595)", function() {
|
||||
|
5
ui/jquery.ui.accordion.js
vendored
5
ui/jquery.ui.accordion.js
vendored
@ -65,6 +65,7 @@ $.widget( "ui.accordion", {
|
||||
_getCreateEventData: function() {
|
||||
return {
|
||||
header: this.active,
|
||||
panel: !this.active.length ? $() : this.active.next(),
|
||||
content: !this.active.length ? $() : this.active.next()
|
||||
};
|
||||
},
|
||||
@ -262,8 +263,8 @@ $.widget( "ui.accordion", {
|
||||
(this.element.attr( "id" ) || ++uid);
|
||||
|
||||
this.active = this._findActive( options.active )
|
||||
.addClass( "ui-accordion-header-active ui-state-active" )
|
||||
.toggleClass( "ui-corner-all ui-corner-top" );
|
||||
.addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
|
||||
.removeClass( "ui-corner-all" );
|
||||
this.active.next()
|
||||
.addClass( "ui-accordion-content-active" )
|
||||
.show();
|
||||
|
10
ui/jquery.ui.datepicker.js
vendored
10
ui/jquery.ui.datepicker.js
vendored
@ -1918,8 +1918,14 @@ $.extend(Datepicker.prototype, {
|
||||
if (years){
|
||||
yearSplit = years.split(":");
|
||||
currentYear = new Date().getFullYear();
|
||||
minYear = parseInt(yearSplit[0], 10) + currentYear;
|
||||
maxYear = parseInt(yearSplit[1], 10) + currentYear;
|
||||
minYear = parseInt(yearSplit[0], 10);
|
||||
maxYear = parseInt(yearSplit[1], 10);
|
||||
if ( yearSplit[0].match(/[+\-].*/) ) {
|
||||
minYear += currentYear;
|
||||
}
|
||||
if ( yearSplit[1].match(/[+\-].*/) ) {
|
||||
maxYear += currentYear;
|
||||
}
|
||||
}
|
||||
|
||||
return ((!minDate || date.getTime() >= minDate.getTime()) &&
|
||||
|
19
ui/jquery.ui.dialog.js
vendored
19
ui/jquery.ui.dialog.js
vendored
@ -679,7 +679,10 @@ $.widget( "ui.dialog", {
|
||||
if ( $.ui.dialog.overlayInstances ) {
|
||||
this._on( this.document, {
|
||||
focusin: function( event ) {
|
||||
if ( !$( event.target ).closest(".ui-dialog").length ) {
|
||||
if ( !$( event.target ).closest(".ui-dialog").length &&
|
||||
// TODO: Remove hack when datepicker implements
|
||||
// the .ui-front logic (#8989)
|
||||
!$( event.target ).closest(".ui-datepicker").length ) {
|
||||
event.preventDefault();
|
||||
$(".ui-dialog:visible:last .ui-dialog-content")
|
||||
.data("ui-dialog")._focusTabbable();
|
||||
@ -692,7 +695,7 @@ $.widget( "ui.dialog", {
|
||||
|
||||
this.overlay = $("<div>")
|
||||
.addClass("ui-widget-overlay ui-front")
|
||||
.appendTo( this.document[0].body );
|
||||
.appendTo( this._appendTo() );
|
||||
this._on( this.overlay, {
|
||||
mousedown: "_keepFocus"
|
||||
});
|
||||
@ -704,11 +707,15 @@ $.widget( "ui.dialog", {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ui.dialog.overlayInstances--;
|
||||
if ( !$.ui.dialog.overlayInstances ) {
|
||||
this._off( this.document, "focusin" );
|
||||
if ( this.overlay ) {
|
||||
$.ui.dialog.overlayInstances--;
|
||||
|
||||
if ( !$.ui.dialog.overlayInstances ) {
|
||||
this._off( this.document, "focusin" );
|
||||
}
|
||||
this.overlay.remove();
|
||||
this.overlay = null;
|
||||
}
|
||||
this.overlay.remove();
|
||||
}
|
||||
});
|
||||
|
||||
|
4
ui/jquery.ui.effect.js
vendored
4
ui/jquery.ui.effect.js
vendored
@ -849,10 +849,10 @@ $.fn.extend({
|
||||
|
||||
_removeClass: $.fn.removeClass,
|
||||
removeClass: function( classNames, speed, easing, callback ) {
|
||||
return speed ?
|
||||
return arguments.length > 1 ?
|
||||
$.effects.animateClass.call( this,
|
||||
{ remove: classNames }, speed, easing, callback ) :
|
||||
this._removeClass( classNames );
|
||||
this._removeClass.apply( this, arguments );
|
||||
},
|
||||
|
||||
_toggleClass: $.fn.toggleClass,
|
||||
|
2
ui/jquery.ui.slider.js
vendored
2
ui/jquery.ui.slider.js
vendored
@ -80,7 +80,7 @@ $.widget( "ui.slider", $.ui.mouse, {
|
||||
.addClass( "ui-slider-range" +
|
||||
// note: this isn't the most fittingly semantic framework class for this element,
|
||||
// but worked best visually with a variety of themes
|
||||
" ui-widget-header" +
|
||||
" ui-widget-header ui-corner-all" +
|
||||
( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user