aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2013-01-30 18:10:39 +0100
committerFelix Nagel <info@felixnagel.com>2013-01-30 18:10:39 +0100
commit91dde04dadcd9b314e099ced040a763aa35b7b5c (patch)
tree3572e1b71f5c8998c46e411b9d992795a1105530
parentde149c47d79bf5822baad786591eb837fe2af769 (diff)
parentceebe07e2c99190030c16b031813ae660d9283d1 (diff)
downloadjquery-ui-91dde04dadcd9b314e099ced040a763aa35b7b5c.tar.gz
jquery-ui-91dde04dadcd9b314e099ced040a763aa35b7b5c.zip
Merge branch 'master' into selectmenu
-rw-r--r--demos/autocomplete/custom-data.html2
-rw-r--r--demos/autocomplete/multiple-remote.html2
-rw-r--r--demos/autocomplete/multiple.html2
-rw-r--r--tests/unit/accordion/accordion_events.js7
-rw-r--r--tests/unit/datepicker/datepicker_options.js18
-rw-r--r--tests/unit/dialog/dialog_methods.js33
-rw-r--r--tests/unit/dialog/dialog_options.js36
-rw-r--r--tests/unit/effects/effects_core.js11
-rw-r--r--ui/jquery.ui.accordion.js5
-rw-r--r--ui/jquery.ui.datepicker.js10
-rw-r--r--ui/jquery.ui.dialog.js19
-rw-r--r--ui/jquery.ui.effect.js4
-rw-r--r--ui/jquery.ui.slider.js2
13 files changed, 124 insertions, 27 deletions
diff --git a/demos/autocomplete/custom-data.html b/demos/autocomplete/custom-data.html
index 327af4c13..aab331add 100644
--- a/demos/autocomplete/custom-data.html
+++ b/demos/autocomplete/custom-data.html
@@ -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 );
diff --git a/demos/autocomplete/multiple-remote.html b/demos/autocomplete/multiple-remote.html
index 4b7a861ac..0f17e091d 100644
--- a/demos/autocomplete/multiple-remote.html
+++ b/demos/autocomplete/multiple-remote.html
@@ -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();
}
})
diff --git a/demos/autocomplete/multiple.html b/demos/autocomplete/multiple.html
index 759ee48f7..5d6b05c9c 100644
--- a/demos/autocomplete/multiple.html
+++ b/demos/autocomplete/multiple.html
@@ -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();
}
})
diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js
index b67f2b26d..79283d11c 100644
--- a/tests/unit/accordion/accordion_events.js
+++ b/tests/unit/accordion/accordion_events.js
@@ -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" );
}
});
diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js
index e47235786..dac2262dc 100644
--- a/tests/unit/datepicker/datepicker_options.js
+++ b/tests/unit/datepicker/datepicker_options.js
@@ -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() {
diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js
index b4c58c31e..efca71fd8 100644
--- a/tests/unit/dialog/dialog_methods.js
+++ b/tests/unit/dialog/dialog_methods.js
@@ -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(){
diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js
index a20480de6..5f0434308 100644
--- a/tests/unit/dialog/dialog_options.js
+++ b/tests/unit/dialog/dialog_options.js
@@ -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" );
+ equal( $( ".ui-widget-overlay" ).parent()[0], document.body, "overlay null" );
element.dialog( "destroy" );
- element.dialog({ autoOpen: false }).dialog( "option", "appendTo", "#wrap1" ).dialog( "open" );
+ element.dialog({
+ 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
+ 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" );
});
diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js
index 26390b7d3..c9b1e1b4a 100644
--- a/tests/unit/effects/effects_core.js
+++ b/tests/unit/effects/effects_core.js
@@ -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() {
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index 8050e55ab..1afa95cb4 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -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();
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index 24f0d5405..e93f596fc 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -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()) &&
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index ef5787ef6..ec4032ff3 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -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();
}
});
diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js
index c6623a0a1..97f006ee0 100644
--- a/ui/jquery.ui.effect.js
+++ b/ui/jquery.ui.effect.js
@@ -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,
diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js
index 9640361a1..54024af49 100644
--- a/ui/jquery.ui.slider.js
+++ b/ui/jquery.ui.slider.js
@@ -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 : "" ) );
}