diff options
author | Felix Nagel <info@felixnagel.com> | 2015-10-08 15:06:55 +0200 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2015-10-08 15:06:55 +0200 |
commit | 2fe43bbbe20ba59dbbbef1effd9f59ac64cb15a7 (patch) | |
tree | 223ec5d743a1c0fbfc18127b7a6bc75c435c72be | |
parent | 7e8b7234b214f9ee363f4f85ad4a24c4a269baba (diff) | |
download | jquery-ui-2fe43bbbe20ba59dbbbef1effd9f59ac64cb15a7.tar.gz jquery-ui-2fe43bbbe20ba59dbbbef1effd9f59ac64cb15a7.zip |
Calendar: Fix jscs errors after merging master
-rw-r--r-- | tests/unit/calendar/common.js | 2 | ||||
-rw-r--r-- | tests/unit/calendar/core.js | 67 | ||||
-rw-r--r-- | tests/unit/calendar/methods.js | 14 | ||||
-rw-r--r-- | tests/unit/calendar/options.js | 44 | ||||
-rw-r--r-- | tests/unit/date/core.js | 32 | ||||
-rw-r--r-- | tests/unit/date/helper.js | 10 | ||||
-rw-r--r-- | tests/unit/datepicker/common.js | 2 | ||||
-rw-r--r-- | tests/unit/datepicker/core.js | 18 | ||||
-rw-r--r-- | tests/unit/datepicker/events.js | 24 | ||||
-rw-r--r-- | tests/unit/datepicker/methods.js | 18 | ||||
-rw-r--r-- | tests/unit/datepicker/options.js | 36 | ||||
-rw-r--r-- | ui/date.js | 1 | ||||
-rw-r--r-- | ui/widgets/calendar.js | 12 | ||||
-rw-r--r-- | ui/widgets/datepicker.js | 31 |
14 files changed, 159 insertions, 152 deletions
diff --git a/tests/unit/calendar/common.js b/tests/unit/calendar/common.js index 5dae54464..8b8f40f73 100644 --- a/tests/unit/calendar/common.js +++ b/tests/unit/calendar/common.js @@ -28,6 +28,6 @@ common.testWidget( "calendar", { create: null, select: null } -}); +} ); } ); diff --git a/tests/unit/calendar/core.js b/tests/unit/calendar/core.js index 23e5da43a..b9c5836a1 100644 --- a/tests/unit/calendar/core.js +++ b/tests/unit/calendar/core.js @@ -51,7 +51,7 @@ test( "base structure", function() { element.calendar( "option", "buttons", { "test": function() {}, "test button": function() {} - }); + } ); equal( dp.children().length, 3, "Structure buttons - child count (header, calendar, buttonpane)" ); @@ -65,6 +65,7 @@ test( "base structure", function() { } function step3() { + // Multi-month 2 element = $( "#calendar" ).calendar( { numberOfMonths: 2 } ); dp = element.calendar( "widget" ); @@ -79,7 +80,7 @@ test( "base structure", function() { } step1(); -}); +} ); test( "Localization", function() { expect( 10 ); @@ -130,7 +131,7 @@ test( "Localization", function() { .calendar( "option", optionsDe ) .calendar( "refresh" ); testLocalization( "After init: " ); -}); +} ); asyncTest( "keyboard handling", function() { expect( 10 ); @@ -138,12 +139,12 @@ asyncTest( "keyboard handling", function() { var element = $( "#calendar" ); function step1() { - element.calendar({ value: new Date( 2014, 1 - 1, 1 ) }); + element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } ); testHelper .focusGrid( element ) .simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); - setTimeout(function() { + setTimeout( function() { $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); testHelper.equalsDate( element.calendar( "valueAsDate" ), @@ -156,7 +157,7 @@ asyncTest( "keyboard handling", function() { } function step2() { - element.calendar({ value: new Date( 2014, 1 - 1, 1 ) }); + element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } ); testHelper.focusGrid( element ) .simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ) @@ -171,10 +172,10 @@ asyncTest( "keyboard handling", function() { } function step3() { - element.calendar({ value: new Date( 2014, 1 - 1, 1 ) }); + element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } ); testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); - setTimeout(function() { + setTimeout( function() { $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); testHelper.equalsDate( element.calendar( "valueAsDate" ), @@ -187,10 +188,10 @@ asyncTest( "keyboard handling", function() { } function step4() { - element.calendar({ value: new Date( 2014, 1 - 1, 1 ) }); + element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } ); testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - setTimeout(function() { + setTimeout( function() { $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); testHelper.equalsDate( element.calendar( "valueAsDate" ), @@ -203,10 +204,10 @@ asyncTest( "keyboard handling", function() { } function step5() { - element.calendar({ value: new Date( 2014, 1 - 1, 1 ) }); + element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } ); testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); - setTimeout(function() { + setTimeout( function() { $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); testHelper.equalsDate( element.calendar( "valueAsDate" ), @@ -219,11 +220,11 @@ asyncTest( "keyboard handling", function() { } function step6() { - element.calendar({ value: new Date( 2014, 1 - 1, 1 ) }); + element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } ); testHelper.focusGrid( element ) .simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP, altKey: true } ); - setTimeout(function() { + setTimeout( function() { $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); testHelper.equalsDate( element.calendar( "valueAsDate" ), @@ -236,10 +237,10 @@ asyncTest( "keyboard handling", function() { } function step7() { - element.calendar({ value: new Date( 2014, 1 - 1, 1 ) }); + element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } ); testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); - setTimeout(function() { + setTimeout( function() { $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); testHelper.equalsDate( element.calendar( "valueAsDate" ), @@ -252,11 +253,11 @@ asyncTest( "keyboard handling", function() { } function step8() { - element.calendar({ value: new Date( 2014, 1 - 1, 1 ) }); + element.calendar( { value: new Date( 2014, 1 - 1, 1 ) } ); testHelper.focusGrid( element ) .simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN, altKey: true } ); - setTimeout(function() { + setTimeout( function() { $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); testHelper.equalsDate( element.calendar( "valueAsDate" ), @@ -270,10 +271,10 @@ asyncTest( "keyboard handling", function() { // Check for moving to short months function step9() { - element.calendar({ value: new Date( 2014, 3 - 1, 31 ) }); + element.calendar( { value: new Date( 2014, 3 - 1, 31 ) } ); testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); - setTimeout(function() { + setTimeout( function() { $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); testHelper.equalsDate( element.calendar( "valueAsDate" ), @@ -286,10 +287,10 @@ asyncTest( "keyboard handling", function() { } function step10() { - element.calendar({ value: new Date( 2016, 1 - 1, 30 ) }); + element.calendar( { value: new Date( 2016, 1 - 1, 30 ) } ); testHelper.focusGrid( element ).simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); - setTimeout(function() { + setTimeout( function() { $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); testHelper.equalsDate( element.calendar( "valueAsDate" ), @@ -302,7 +303,7 @@ asyncTest( "keyboard handling", function() { } step1(); -}); +} ); asyncTest( "mouse", function() { expect( 6 ); @@ -319,7 +320,7 @@ asyncTest( "mouse", function() { "Mouse click" ); - element.calendar( "option", "value", new Date( 2008, 2 - 1, 4) ); + element.calendar( "option", "value", new Date( 2008, 2 - 1, 4 ) ); $( ".ui-calendar-calendar tbody button:contains(12)", element ).simulate( "mousedown" ); testHelper.equalsDate( element.calendar( "valueAsDate" ), @@ -328,7 +329,7 @@ asyncTest( "mouse", function() { ); // Previous/next - element.calendar( "option", "value", new Date( 2008, 2 - 1, 4) ); + element.calendar( "option", "value", new Date( 2008, 2 - 1, 4 ) ); $( ".ui-calendar-prev", element ).simulate( "click" ); $( ".ui-calendar-calendar tbody button:contains(16)", element ).simulate( "mousedown" ); testHelper.equalsDate( @@ -337,7 +338,7 @@ asyncTest( "mouse", function() { "Mouse click - previous" ); - element.calendar( "option", "value", new Date( 2008, 2 - 1, 4) ); + element.calendar( "option", "value", new Date( 2008, 2 - 1, 4 ) ); $( ".ui-calendar-next", element ).simulate( "click" ); $( ".ui-calendar-calendar tbody button:contains(18)", element ).simulate( "mousedown" ); testHelper.equalsDate( @@ -352,11 +353,11 @@ asyncTest( "mouse", function() { // Previous/next with minimum/maximum function step2() { element.calendar( "destroy" ); - element.calendar({ - value: new Date( 2008, 3 - 1, 4), + element.calendar( { + value: new Date( 2008, 3 - 1, 4 ), min: new Date( 2008, 2 - 1, 2 ), max: new Date( 2008, 2 - 1, 26 ) - }); + } ); $( ".ui-calendar-prev", element ).simulate( "click" ); $( "tbody button:contains(16)", element ).simulate( "mousedown" ); @@ -370,11 +371,11 @@ asyncTest( "mouse", function() { function step3() { element.calendar( "destroy" ); - element.calendar({ - value: new Date( 2008, 1 - 1, 4), + element.calendar( { + value: new Date( 2008, 1 - 1, 4 ), min: new Date( 2008, 2 - 1, 2 ), max: new Date( 2008, 2 - 1, 26 ) - }); + } ); $( ".ui-calendar-next", element ).simulate( "click" ); $( "tbody button:contains(18)", element ).simulate( "mousedown" ); @@ -387,6 +388,6 @@ asyncTest( "mouse", function() { } step1(); -}); +} ); } ); diff --git a/tests/unit/calendar/methods.js b/tests/unit/calendar/methods.js index 23989860c..84e265710 100644 --- a/tests/unit/calendar/methods.js +++ b/tests/unit/calendar/methods.js @@ -11,8 +11,8 @@ test( "destroy", function( assert ) { assert.domEqual( "#calendar", function() { $( "#calendar" ).calendar().calendar( "destroy" ); - }); -}); + } ); +} ); test( "enable / disable", function() { expect( 8 ); @@ -30,7 +30,7 @@ test( "enable / disable", function() { ok( !element.hasClass( "ui-calendar-disabled" ), "no longer has disabled widget class name" ); ok( !element.hasClass( "ui-state-disabled" ), "no longer has disabled state class name" ); equal( element.attr( "aria-disabled" ), "false", "no longer has ARIA disabled" ); -}); +} ); test( "widget", function() { expect( 1 ); @@ -39,7 +39,7 @@ test( "widget", function() { widget = element.calendar( "widget" ); strictEqual( widget[ 0 ], element[ 0 ] ); -}); +} ); test( "value", function() { expect( 3 ); @@ -54,7 +54,7 @@ test( "value", function() { element.calendar( "value", "abc" ); equal( element.calendar( "value" ), "1/1/14", "Setting invalid values should be ignored." ); -}); +} ); test( "valueAsDate", function() { expect( 11 ); @@ -77,7 +77,7 @@ test( "valueAsDate", function() { equal( element.calendar( "valueAsDate" ), null, "Set date - default" ); element.calendar( "valueAsDate", date1 ); - testHelper.equalsDate(element.calendar( "valueAsDate" ), date1, "Set date - 2008-06-04" ); + testHelper.equalsDate( element.calendar( "valueAsDate" ), date1, "Set date - 2008-06-04" ); // With minimum/maximum element = $( "#calendar" ).calendar(); @@ -140,6 +140,6 @@ test( "valueAsDate", function() { dateAndTimeClone.getTime(), "Date object passed should not be changed by valueAsDate" ); -}); +} ); } ); diff --git a/tests/unit/calendar/options.js b/tests/unit/calendar/options.js index bcb86c55f..4c9c1f15d 100644 --- a/tests/unit/calendar/options.js +++ b/tests/unit/calendar/options.js @@ -6,13 +6,13 @@ define( [ module( "calendar: options" ); -test("buttons", function() { +test( "buttons", function() { expect( 21 ); var button, i, newButtons, buttons = { "Ok": function( event ) { - ok(true, "button click fires callback" ); + ok( true, "button click fires callback" ); equal( this, element[ 0 ], "context of callback" ); equal( event.target, button[ 0 ], "event target" ); }, @@ -22,7 +22,7 @@ test("buttons", function() { equal( event.target, button[ 1 ], "event target" ); } }, - element = $( "#calendar" ).calendar({ buttons: buttons }); + element = $( "#calendar" ).calendar( { buttons: buttons } ); button = element.calendar( "widget" ).find( ".ui-calendar-buttonpane button" ); equal( button.length, 2, "number of buttons" ); @@ -31,7 +31,7 @@ test("buttons", function() { $.each( buttons, function( key ) { equal( button.eq( i ).text(), key, "text of button " + ( i + 1 ) ); i++; - }); + } ); ok( button.parent().hasClass( "ui-calendar-buttonset" ), "buttons in container" ); ok( @@ -69,7 +69,7 @@ test("buttons", function() { $.each( newButtons, function( key ) { equal( button.eq( i ).text(), key, "text of button " + ( i + 1 ) ); i += 1; - }); + } ); element.calendar( "option", "buttons", null ); button = element.calendar( "widget" ).find( ".ui-calendar-buttonpane button" ); @@ -78,14 +78,14 @@ test("buttons", function() { equal( element.hasClass( "ui-calendar-buttons" ), false, "calendar element removes class about having buttons" ); element.remove(); -}); +} ); test( "buttons - advanced", function() { expect( 7 ); var buttons, - element = $( "#calendar" ).calendar({ - buttons: [{ + element = $( "#calendar" ).calendar( { + buttons: [ { text: "a button", "class": "additional-class", id: "my-button-id", @@ -96,8 +96,8 @@ test( "buttons - advanced", function() { primary: "ui-icon-cancel" }, showText: false - }] - }); + } ] + } ); buttons = element.calendar( "widget" ).find( ".ui-calendar-buttonpane button" ); equal( buttons.length, 1, "correct number of buttons" ); @@ -109,7 +109,7 @@ test( "buttons - advanced", function() { buttons.click(); element.remove(); -}); +} ); test( "dateFormat", function() { expect( 2 ); @@ -122,7 +122,7 @@ test( "dateFormat", function() { element.calendar( "option", "dateFormat", { date: "full" } ); equal( element.calendar( "value" ), "Wednesday, January 1, 2014", "updated formatting" ); -}); +} ); test( "eachDay", function() { expect( 5 ); @@ -140,7 +140,7 @@ test( "eachDay", function() { if ( day.date === 1 ) { day.render = false; } - }); + } ); firstCell = picker.find( "td[id]:first" ); timestamp = parseInt( firstCell.find( "button" ).attr( "data-timestamp" ), 10 ); equal( new Date( timestamp ).getDate(), 2, "first available day is the 2nd" ); @@ -150,7 +150,7 @@ test( "eachDay", function() { if ( day.date === 1 ) { day.selectable = false; } - }); + } ); firstCell = picker.find( "td[id]:first" ); ok( firstCell.find( "button" ).prop( "disabled" ), "the 1st is not selectable" ); @@ -158,11 +158,11 @@ test( "eachDay", function() { if ( day.date === 1 ) { day.extraClasses = "ui-custom"; } - }); + } ); ok( picker.find( "td[id]:first button" ).hasClass( "ui-custom" ), "extraClasses applied" ); input.calendar( "destroy" ); -}); +} ); test( "showWeek", function() { expect( 7 ); @@ -174,7 +174,7 @@ test( "showWeek", function() { "no week column cells present" ); input.calendar( "destroy" ); - input = $( "#calendar" ).calendar({ showWeek: true }); + input = $( "#calendar" ).calendar( { showWeek: true } ); container = input.calendar( "widget" ); equal( container.find( "thead th" ).length, 8, "7 days + a column cell" ); ok( container.find( "thead th:first" ).is( ".ui-calendar-week-col" ), @@ -188,7 +188,7 @@ test( "showWeek", function() { equal( container.find( "thead th" ).length, 7, "no week column" ); input.calendar( "option", "showWeek", true ); equal( container.find( "thead th" ).length, 8, "supports changing option after init" ); -}); +} ); test( "min / max", function() { expect( 17 ); @@ -268,15 +268,15 @@ test( "min / max", function() { ok( prevButton.hasClass( "ui-state-disabled" ), "Other year below min: Prev button disabled after click" ); nextButton.simulate( "click" ); ok( !prevButton.hasClass( "ui-state-disabled" ), "Other year below min: Prev button enabled after click" ); -}); +} ); test( "numberOfMonths", function() { expect( 6 ); var date = new Date( 2015, 8 - 1, 1 ), - input = $( "#calendar" ).calendar({ + input = $( "#calendar" ).calendar( { numberOfMonths: 3, value: date - }), + } ), container = input.calendar( "widget" ); equal( container.find( ".ui-calendar-group" ).length, 3, "3 calendar grids" ); @@ -310,7 +310,7 @@ test( "numberOfMonths", function() { equal( container.find( ".ui-calendar-month:last" ).text(), "October", "After move to next month: Last month is October" ); -}); +} ); /* // TODO: Move this to $.date, Globalize or calendar widget diff --git a/tests/unit/date/core.js b/tests/unit/date/core.js index c12303516..b04531593 100644 --- a/tests/unit/date/core.js +++ b/tests/unit/date/core.js @@ -12,7 +12,7 @@ test( "Instantiation", function() { expect( 2 ); ok( new $.ui.date( null, attributes ) instanceof $.ui.date, "constructor function" ); ok( $.ui.date( null, attributes ) instanceof $.ui.date, "instantiation without new" ); -}); +} ); test( "Check Sets and Gets", 4, function() { var date = $.ui.date( null, attributes ); @@ -20,8 +20,9 @@ test( "Check Sets and Gets", 4, function() { equal( date.setFullDate( 2012, 9, 15 ).year(), 2012, "Set full date and retrieve year" ); equal( date.month(), 9, "Set full date and retrieve month" ); equal( date.day(), 15, "Set full date and retrieve day" ); + // TODO Add setTime test -}); +} ); test( "Date Adjustments - Normal Use Cases", 10, function() { var date = $.ui.date( null, attributes ); @@ -46,7 +47,7 @@ test( "Date Adjustments - Normal Use Cases", 10, function() { equal( date.adjust( "D", 1 ).year(), 2013, "Add 1 day to change year from 2012 to 2013" ); equal( date.adjust( "D", -1 ).year(), 2012, "Subtract 1 day to change month from 2013 to 2012" ); -}); +} ); test( "Date Adjustments - Month Overflow Edge Cases", 2, function() { var date = $.ui.date( null, attributes ); @@ -57,7 +58,7 @@ test( "Date Adjustments - Month Overflow Edge Cases", 2, function() { "Add 1 month from May to June sets days to 30, last day in June (prevent Overflow)" ); equal( date.adjust( "M", -1 ).day(), 30, "Subtract 1 month from June to May sets days to 30 in May" ); -}); +} ); test( "Date Adjustments - Leap Year Edge Cases", 1, function() { var date = $.ui.date( null, attributes ); @@ -66,7 +67,7 @@ test( "Date Adjustments - Leap Year Edge Cases", 1, function() { date.setFullDate( 2012, 1, 29 ); equal( date.adjust( "Y", 1 ).day(), 28, "Feb 29 2012, add a year to convert to Feb 28, 2013" ); -}); +} ); test( "List days of Week", 2, function() { var date = $.ui.date( null, attributes ), @@ -92,7 +93,7 @@ test( "List days of Week", 2, function() { deepEqual( date.weekdays(), offset0, "Get weekdays with start of day on 0 (English)" ); date = $.ui.date( null, testHelper.getAttributes( "de" ) ); deepEqual( date.weekdays(), offset1, "Get weekdays with start of day on 1 (Germany)" ); -}); +} ); test( "Days in Month", 3, function() { var date = $.ui.date( null, attributes ); @@ -100,23 +101,24 @@ test( "Days in Month", 3, function() { equal( date.daysInMonth(), 29, "Leap Year implicit check for 29 days" ); equal( date.daysInMonth( 2012, 1 ), 29, "Leap Year explicit check for 29 days" ); equal( date.daysInMonth( 2011, 3 ), 30, "April has 30 days" ); -}); +} ); test( "Month Name", 2, function() { var date = $.ui.date( null, attributes ); equal( date.setFullDate( 2012, 3, 1 ).monthName(), "April", "Month name return April (English)" ); date = $.ui.date( null, testHelper.getAttributes( "de" ) ); equal( date.setFullDate( 2012, 2, 1 ).monthName(), "März", "Month name return March (German)" ); -}); +} ); test( "Clone", 2, function() { var date = $.ui.date( null, attributes ), date2 = date.clone(); ok( date2, "Created cloned object" ); notEqual( date.adjust( "Y", 1 ).year(), date2.year(), "Object manipulated independently" ); -}); +} ); test( "Days", 1, function() { + // TODO Needs work var date = $.ui.date( null, attributes ); date.eachDay = function( day ) { @@ -139,10 +141,10 @@ test( "Days", 1, function() { day.title = "A good day!"; } }; - ok( date.days(), "Date days() returns"); -}); + ok( date.days(), "Date days() returns" ); +} ); -test( "Months", 5, function(){ +test( "Months", 5, function() { var date = $.ui.date( null, attributes ), firstMonth = date.months( 1 )[ 0 ], lastMonth = date.months( 1 )[ 1 ]; @@ -153,7 +155,7 @@ test( "Months", 5, function(){ ok( !lastMonth.first ); ok( firstMonth.month() === lastMonth.month() - 1 ); -}); +} ); test( "Equal", 4, function() { var date = $.ui.date( null, attributes ); @@ -162,11 +164,11 @@ test( "Equal", 4, function() { ok( !date.equal( new Date( 2011, 9, 16 ) ), "Does date year not equal provide date" ); ok( !date.equal( new Date( 2012, 8, 16 ) ), "Does date month not equal provide date" ); ok( !date.equal( new Date( 2012, 9, 15 ) ), "Does date day not equal provide date" ); -}); +} ); test( "Date", 1, function() { var date = $.ui.date( null, attributes ); ok( date.date() instanceof Date, "Date returned" ); -}); +} ); } ); diff --git a/tests/unit/date/helper.js b/tests/unit/date/helper.js index 01755c53a..fa9c9cf66 100644 --- a/tests/unit/date/helper.js +++ b/tests/unit/date/helper.js @@ -8,8 +8,8 @@ define( [ return $.extend( helper, { getAttributes: function( locale ) { var globalize = new Globalize( locale ), - weekdayShortFormatter = globalize.dateFormatter({ raw: "EEEEEE" }), - weekdayNarrowFormatter = globalize.dateFormatter({ raw: "EEEEE" } ); + weekdayShortFormatter = globalize.dateFormatter( { raw: "EEEEEE" } ), + weekdayNarrowFormatter = globalize.dateFormatter( { raw: "EEEEE" } ); return { firstDay: globalize.cldr.supplemental.weekData.firstDay(), @@ -20,9 +20,9 @@ return $.extend( helper, { return shortWeekday.length > 3 ? weekdayNarrowFormatter( date ) : shortWeekday; }, - formatWeekdayFull: globalize.dateFormatter({ raw: "EEEE" }), - formatMonth: globalize.dateFormatter({ raw: "MMMM" }), - formatWeekOfYear: globalize.dateFormatter({ raw: "w" }) + formatWeekdayFull: globalize.dateFormatter( { raw: "EEEE" } ), + formatMonth: globalize.dateFormatter( { raw: "MMMM" } ), + formatWeekOfYear: globalize.dateFormatter( { raw: "w" } ) }; } } ); diff --git a/tests/unit/datepicker/common.js b/tests/unit/datepicker/common.js index 61c7ace43..bc06a8992 100644 --- a/tests/unit/datepicker/common.js +++ b/tests/unit/datepicker/common.js @@ -37,6 +37,6 @@ common.testWidget( "datepicker", { open: null, select: null } -}); +} ); } ); diff --git a/tests/unit/datepicker/core.js b/tests/unit/datepicker/core.js index 2a8910875..83882ef7a 100644 --- a/tests/unit/datepicker/core.js +++ b/tests/unit/datepicker/core.js @@ -19,7 +19,7 @@ test( "input's value determines starting date", function() { equal( picker.find( ".ui-state-active" ).html(), "1", "correct day highlighted" ); input.val( "" ).datepicker( "destroy" ); -}); +} ); asyncTest( "base structure", function() { expect( 5 ); @@ -29,7 +29,7 @@ asyncTest( "base structure", function() { input.focus(); - setTimeout(function() { + setTimeout( function() { ok( widget.is( ":visible" ), "Datepicker visible" ); equal( widget.children().length, 2, "Child count" ); ok( widget.is( ".ui-calendar" ), "Class ui-calendar" ); @@ -39,7 +39,7 @@ asyncTest( "base structure", function() { input.datepicker( "close" ); start(); }, 50 ); -}); +} ); asyncTest( "Keyboard handling: input", function() { expect( 10 ); @@ -53,7 +53,7 @@ asyncTest( "Keyboard handling: input", function() { ok( !picker.is( ":visible" ), "datepicker closed" ); input.val( "" ).simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - setTimeout(function() { + setTimeout( function() { ok( picker.is( ":visible" ), "Keystroke down opens datepicker" ); input.datepicker( "destroy" ); step2(); @@ -67,7 +67,7 @@ asyncTest( "Keyboard handling: input", function() { ok( !picker.is( ":visible" ), "datepicker closed" ); input.val( "" ).simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); - setTimeout(function() { + setTimeout( function() { ok( picker.is( ":visible" ), "Keystroke up opens datepicker" ); input.datepicker( "destroy" ); step3(); @@ -121,12 +121,12 @@ asyncTest( "Keyboard handling: input", function() { } step1(); -}); +} ); // TODO: implement test( "ARIA", function() { expect( 0 ); -}); +} ); asyncTest( "mouse", function() { expect( 4 ); @@ -136,7 +136,7 @@ asyncTest( "mouse", function() { input.datepicker( "open" ); - setTimeout(function() { + setTimeout( function() { input.val( "4/4/08" ).datepicker( "refresh" ).datepicker( "open" ); $( ".ui-calendar-calendar tbody button:contains(12)", picker ).simulate( "mousedown", {} ); testHelper.equalsDate( @@ -168,6 +168,6 @@ asyncTest( "mouse", function() { start(); }, 100 ); -}); +} ); } ); diff --git a/tests/unit/datepicker/events.js b/tests/unit/datepicker/events.js index 833316ce4..902896f2a 100644 --- a/tests/unit/datepicker/events.js +++ b/tests/unit/datepicker/events.js @@ -17,7 +17,7 @@ test( "beforeOpen", function() { open: function() { ok( input.datepicker( "widget" ).is( ":visible" ), "calendar open on open" ); } - }); + } ); input .datepicker( "open" ) @@ -29,9 +29,9 @@ test( "beforeOpen", function() { open: function() { ok( false, "calendar should not open when openBefore is canceled" ); } - }) + } ) .datepicker( "open" ); -}); +} ); test( "close", function() { expect( 4 ); @@ -41,7 +41,7 @@ test( "close", function() { close: function() { ok( shouldFire, "close event fired" ); } - }); + } ); shouldFire = false; input.datepicker( "open" ); @@ -62,7 +62,7 @@ test( "close", function() { input.datepicker( "open" ); shouldFire = true; input.datepicker( "widget" ).find( "tbody tr:first button:first" ).simulate( "mousedown" ); -}); +} ); test( "open", function() { expect( 2 ); @@ -72,11 +72,11 @@ test( "open", function() { ok( true, "open event fired on open" ); ok( widget.is( ":visible" ), "calendar open on open" ); } - }), + } ), widget = input.datepicker( "widget" ); input.datepicker( "open" ); -}); +} ); asyncTest( "select", function() { expect( 4 ); @@ -90,7 +90,7 @@ asyncTest( "select", function() { "select originalEvent " + message ); } - }), + } ), widget = input.datepicker( "widget" ), message = ""; @@ -99,7 +99,7 @@ asyncTest( "select", function() { input .simulate( "focus" ) .simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - setTimeout(function() { + setTimeout( function() { widget.find( "tbody tr:first button:first" ).simulate( "mousedown" ); input.datepicker( "close" ); step2(); @@ -111,7 +111,7 @@ asyncTest( "select", function() { input .simulate( "focus" ) .simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - setTimeout(function() { + setTimeout( function() { $( document.activeElement ) .simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ) .simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); @@ -125,7 +125,7 @@ asyncTest( "select", function() { input .simulate( "focus" ) .simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - setTimeout(function() { + setTimeout( function() { $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); input.datepicker( "close" ); start(); @@ -133,6 +133,6 @@ asyncTest( "select", function() { } step1(); -}); +} ); } ); diff --git a/tests/unit/datepicker/methods.js b/tests/unit/datepicker/methods.js index f05958af0..2cf835698 100644 --- a/tests/unit/datepicker/methods.js +++ b/tests/unit/datepicker/methods.js @@ -15,8 +15,8 @@ test( "destroy", function( assert ) { ok( input.attr( "aria-owns" ), "aria-owns attribute added" ); ok( input.attr( "aria-haspopup" ), "aria-haspopup attribute added" ); input.datepicker( "destroy" ); - }); -}); + } ); +} ); test( "enable / disable", function() { expect( 10 ); @@ -37,7 +37,7 @@ test( "enable / disable", function() { ok( !input.hasClass( "ui-state-disabled" ), "no longer has disabled state class name" ); equal( input.attr( "aria-disabled" ), "false", "no longer has ARIA disabled" ); equal( input.attr( "disabled" ), undefined, "input no longer disabled" ); -}); +} ); test( "widget", function() { expect( 1 ); @@ -45,12 +45,12 @@ test( "widget", function() { var actual = $( "#datepicker" ).datepicker().datepicker( "widget" ); deepEqual( $( "body > .ui-front" )[ 0 ], actual[ 0 ] ); actual.remove(); -}); +} ); test( "open / close", function() { expect( 7 ); - var input = testHelper.initNewInput({ show: false, hide: false }), + var input = testHelper.initNewInput( { show: false, hide: false } ), calendar = input.datepicker( "widget" ); ok( calendar.is( ":hidden" ), "calendar hidden on init" ); @@ -64,7 +64,7 @@ test( "open / close", function() { ok( !calendar.is( ":visible" ), "close: calendar hidden" ); equal( calendar.attr( "aria-hidden" ), "true", "close: calendar aria-hidden" ); equal( calendar.attr( "aria-expanded" ), "false", "close: calendar aria-expanded" ); -}); +} ); test( "value", function() { expect( 4 ); @@ -84,7 +84,7 @@ test( "value", function() { input.val( "abc" ); strictEqual( input.datepicker( "value" ), null, "Invalid values should return null." ); -}); +} ); test( "valueAsDate", function() { expect( 6 ); @@ -110,7 +110,7 @@ test( "valueAsDate", function() { strictEqual( input.datepicker( "valueAsDate" ), null, "Set date - default" ); input.datepicker( "valueAsDate", date1 ); testHelper.equalsDate( input.datepicker( "valueAsDate" ), date1, "Set date - 2008-06-04" ); -}); +} ); test( "isValid", function() { expect( 2 ); @@ -123,6 +123,6 @@ test( "isValid", function() { ok( !input.datepicker( "isValid" ) ); input.datepicker( "destroy" ); -}); +} ); } ); diff --git a/tests/unit/datepicker/options.js b/tests/unit/datepicker/options.js index 75d745460..6021f1b7e 100644 --- a/tests/unit/datepicker/options.js +++ b/tests/unit/datepicker/options.js @@ -17,12 +17,12 @@ test( "appendTo", function() { equal( container, document.body, "defaults to body" ); input.datepicker( "destroy" ); - input.datepicker({ appendTo: "#qunit-fixture" }); + input.datepicker( { appendTo: "#qunit-fixture" } ); container = input.datepicker( "widget" ).parent()[ 0 ]; equal( container, $( "#qunit-fixture" )[ 0 ], "child of specified element" ); input.datepicker( "destroy" ); - input.datepicker({ appendTo: "#does-not-exist" }); + input.datepicker( { appendTo: "#does-not-exist" } ); container = input.datepicker( "widget" ).parent()[ 0 ]; equal( container, document.body, "set to body if element does not exist" ); input.datepicker( "destroy" ); @@ -33,16 +33,16 @@ test( "appendTo", function() { equal( container, $( "#qunit-fixture" )[ 0 ], "modified after init" ); input.datepicker( "destroy" ); - input.datepicker({ appendTo: detached }); + input.datepicker( { appendTo: detached } ); container = input.datepicker( "widget" ).parent()[ 0 ]; equal( container, detached[ 0 ], "detached jQuery object" ); input.datepicker( "destroy" ); - input.datepicker({ appendTo: detached[ 0 ] }); + input.datepicker( { appendTo: detached[ 0 ] } ); container = input.datepicker( "widget" ).parent()[ 0 ]; equal( container, detached[ 0 ], "detached DOM element" ); input.datepicker( "destroy" ); -}); +} ); test( "Pass-through options", function() { expect( 11 ); @@ -77,20 +77,20 @@ test( "Pass-through options", function() { if ( key === "locale" ) { equal( input.val(), "Mittwoch, 1. Januar 2014", "option " + key + ": updated locale" ); } - }); -}); + } ); +} ); -asyncTest( "position", function(assert) { +asyncTest( "position", function( assert ) { expect( 3 ); - var input = $( "<input>" ).datepicker().appendTo( "body" ).css({ + var input = $( "<input>" ).datepicker().appendTo( "body" ).css( { position: "absolute", top: 0, left: 0 - }), + } ), container = input.datepicker( "widget" ); input.datepicker( "open" ); - setTimeout(function() { + setTimeout( function() { assert.close( input.offset().left, container.offset().left, 1, "left sides line up by default" ); assert.close( container.offset().top, input.offset().top + input.outerHeight(), 1, "datepicker directly under input by default" ); @@ -99,21 +99,21 @@ asyncTest( "position", function(assert) { input.datepicker( "option", "position", { my: "left top", at: "right bottom" - }); + } ); assert.close( container.offset().left, input.offset().left + input.outerWidth(), 1, "datepicker on right hand side of input after position change" ); input.remove(); start(); - }); -}); + } ); +} ); test( "Stop datepicker from appearing with beforeOpen event handler", function() { expect( 3 ); var input = testHelper.init( "#datepicker", { beforeOpen: function() {} - }); + } ); input.datepicker( "open" ); ok( input.datepicker( "widget" ).is( ":visible" ), "beforeOpen returns nothing" ); @@ -123,7 +123,7 @@ test( "Stop datepicker from appearing with beforeOpen event handler", function() beforeOpen: function() { return true; } - }); + } ); input.datepicker( "open" ); ok( input.datepicker( "widget" ).is( ":visible" ), "beforeOpen returns true" ); input.datepicker( "close" ).datepicker( "destroy" ); @@ -132,10 +132,10 @@ test( "Stop datepicker from appearing with beforeOpen event handler", function() beforeOpen: function() { return false; } - }); + } ); input.datepicker( "open" ); ok( !input.datepicker( "widget" ).is( ":visible" ), "beforeOpen returns false" ); input.datepicker( "destroy" ); -}); +} ); } ); diff --git a/ui/date.js b/ui/date.js index ba9203873..2d94f1083 100644 --- a/ui/date.js +++ b/ui/date.js @@ -59,6 +59,7 @@ $.extend( $.ui.date.prototype, { setDay: function( day ) { var date = this.dateObject; + // FIXME: Why not to use .setDate? this.dateObject = new Date( date.getFullYear(), date.getMonth(), day, date.getHours(), date.getMinutes(), date.getSeconds() ); diff --git a/ui/widgets/calendar.js b/ui/widgets/calendar.js index 1cdb07fdb..cb777ef01 100644 --- a/ui/widgets/calendar.js +++ b/ui/widgets/calendar.js @@ -195,8 +195,8 @@ return $.widget( "ui.calendar", { _setLocale: function( locale, dateFormat ) { var globalize = new Globalize( locale ), - weekdayShortFormatter = globalize.dateFormatter({ raw: "EEEEEE" }), - weekdayNarrowFormatter = globalize.dateFormatter({ raw: "EEEEE" }); + weekdayShortFormatter = globalize.dateFormatter( { raw: "EEEEEE" } ), + weekdayNarrowFormatter = globalize.dateFormatter( { raw: "EEEEE" } ); this._format = globalize.dateFormatter( dateFormat ); this._parse = globalize.dateParser( dateFormat ); @@ -209,9 +209,9 @@ return $.widget( "ui.calendar", { return shortWeekday.length > 3 ? weekdayNarrowFormatter( date ) : shortWeekday; }, - formatWeekdayFull: globalize.dateFormatter({ raw: "EEEE" }), - formatMonth: globalize.dateFormatter({ raw: "MMMM" }), - formatWeekOfYear: globalize.dateFormatter({ raw: "w" }), + formatWeekdayFull: globalize.dateFormatter( { raw: "EEEE" } ), + formatMonth: globalize.dateFormatter( { raw: "MMMM" } ), + formatWeekOfYear: globalize.dateFormatter( { raw: "w" } ), parse: this._parse }; }, @@ -539,7 +539,7 @@ return $.widget( "ui.calendar", { } if ( this.options.max !== null && months[ i ].last ) { this._disableElement( this.nextButton, - ( this.options.max.getMonth() <= months[ i].month() && + ( this.options.max.getMonth() <= months[ i ].month() && this.options.max.getFullYear() === months[ i ].year() ) || this.options.max.getFullYear() < months[ i ].year() ); diff --git a/ui/widgets/datepicker.js b/ui/widgets/datepicker.js index 5e0e47eb5..3534b3144 100644 --- a/ui/widgets/datepicker.js +++ b/ui/widgets/datepicker.js @@ -13,11 +13,11 @@ //>>docs: http://api.jqueryui.com/datepicker/ //>>demos: http://jqueryui.com/datepicker/ -(function( factory ) { +( function( factory ) { if ( typeof define === "function" && define.amd ) { // AMD. Register as an anonymous module. - define([ + define( [ "jquery", "globalize", "globalize/date", @@ -32,7 +32,7 @@ // Browser globals factory( jQuery, Globalize ); } -}(function( $, Globalize ) { +}( function( $, Globalize ) { var widget = $.widget( "ui.datepicker", { version: "@VERSION", @@ -106,23 +106,24 @@ var widget = $.widget( "ui.datepicker", { that._focusTrigger(); that._trigger( "select", event ); } - }) ) + } ) ) .calendar( "instance" ); this.calendarInstance.buttonClickContext = that.element[ 0 ]; this._setHiddenPicker(); - this.element.attr({ + this.element.attr( { "aria-haspopup": true, "aria-owns": this.calendar.attr( "id" ) - }); + } ); }, _inputEvents: { keydown: function( event ) { switch ( event.keyCode ) { case $.ui.keyCode.TAB: + // Waiting for close() will make popup hide too late, which breaks tab key behavior this.calendar.hide(); this.close( event ); @@ -160,7 +161,7 @@ var widget = $.widget( "ui.datepicker", { if ( !this.suppressExpandOnFocus && !this.isOpen ) { this._delay( function() { this.open( event ); - }); + } ); } this._delay( function() { this.suppressExpandOnFocus = false; @@ -173,6 +174,7 @@ var widget = $.widget( "ui.datepicker", { _calendarEvents: { focusout: function( event ) { + // use a timer to allow click to clear it and letting that // handle the closing instead of opening again // also allows tabbing inside the calendar without it closing @@ -186,6 +188,7 @@ var widget = $.widget( "ui.datepicker", { mouseup: function() { clearTimeout( this.closeTimer ); }, + // TODO on TAB (or shift TAB), make sure it ends up on something useful in DOM order keyup: function( event ) { if ( event.keyCode === $.ui.keyCode.ESCAPE && this.calendar.is( ":visible" ) ) { @@ -246,10 +249,10 @@ var widget = $.widget( "ui.datepicker", { this.calendarInstance.refresh(); this.calendar - .attr({ + .attr( { "aria-hidden": false, "aria-expanded": true - }) + } ) .show() .position( this._buildPosition() ) .hide(); @@ -274,10 +277,10 @@ var widget = $.widget( "ui.datepicker", { }, _setHiddenPicker: function() { - this.calendar.attr({ + this.calendar.attr( { "aria-hidden": true, "aria-expanded": false - }); + } ); }, _buildPosition: function() { @@ -351,12 +354,12 @@ var widget = $.widget( "ui.datepicker", { this.calendar.position( this._buildPosition() ); } } -}); +} ); $.each( $.ui.datepicker.prototype.calendarOptions, function( index, option ) { $.ui.datepicker.prototype.options[ option ] = $.ui.calendar.prototype.options[ option ]; -}); +} ); return widget; -})); +} ) ); |