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