mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Merge branch 'datepicker' into datepicker-globalize-1.x
This commit is contained in:
parent
76c74e5cfb
commit
8238c25980
@ -282,6 +282,7 @@ grunt.initConfig({
|
||||
"cldrjs/LICENSE-MIT": "cldrjs/LICENSE-MIT",
|
||||
|
||||
"globalize/globalize.js": "globalize/dist/globalize.js",
|
||||
"globalize/globalize/number.js": "globalize/dist/globalize/number.js",
|
||||
"globalize/globalize/date.js": "globalize/dist/globalize/date.js",
|
||||
"globalize/LICENSE.txt": "globalize/LICENSE.txt",
|
||||
|
||||
|
20
bower.json
20
bower.json
@ -14,8 +14,12 @@
|
||||
"jquery-mousewheel": "3.1.12",
|
||||
"jquery-simulate": "1.0.0",
|
||||
"jshint": "2.4.4",
|
||||
"qunit": "1.17.1",
|
||||
"globalize": "1.0.0-alpha.7",
|
||||
"qunit": "1.18.0",
|
||||
"qunit-assert-classes": "1.0.2",
|
||||
"qunit-assert-close": "JamesMGreene/qunit-assert-close#v1.1.1",
|
||||
"qunit-composite": "JamesMGreene/qunit-composite#v1.1.0",
|
||||
"requirejs": "2.1.14",
|
||||
"globalize": "1.0.0-alpha.7",
|
||||
|
||||
"jquery-1.7.0": "jquery#1.7.0",
|
||||
"jquery-1.7.1": "jquery#1.7.1",
|
||||
@ -29,10 +33,18 @@
|
||||
"jquery-1.10.0": "jquery#1.10.0",
|
||||
"jquery-1.10.1": "jquery#1.10.1",
|
||||
"jquery-1.10.2": "jquery#1.10.2",
|
||||
"jquery-1.x": "jquery#1.10.2",
|
||||
"jquery-1.11.0": "jquery#1.11.0",
|
||||
"jquery-1.11.1": "jquery#1.11.1",
|
||||
"jquery-1.11.2": "jquery#1.11.2",
|
||||
"jquery-1.11.3": "jquery#1.11.3",
|
||||
"jquery-1.x": "jquery#1.11.3",
|
||||
"jquery-2.0.0": "jquery#2.0.0",
|
||||
"jquery-2.0.1": "jquery#2.0.1",
|
||||
"jquery-2.0.2": "jquery#2.0.2",
|
||||
"jquery-2.0.3": "jquery#2.0.3"
|
||||
"jquery-2.0.3": "jquery#2.0.3",
|
||||
"jquery-2.1.0": "jquery#2.1.0",
|
||||
"jquery-2.1.1": "jquery#2.1.1",
|
||||
"jquery-2.1.2": "jquery#2.1.2",
|
||||
"jquery-2.1.3": "jquery#2.1.3"
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="../../external/globalize/globalize.js"></script>
|
||||
<script src="../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../external/localization.js"></script>
|
||||
<script src="../../ui/calendar/date.js"></script>
|
||||
<script src="../../external/date.js"></script>
|
||||
<script src="../../ui/core.js"></script>
|
||||
<script src="../../ui/widget.js"></script>
|
||||
<script src="../../ui/button.js"></script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="../../external/globalize/globalize.js"></script>
|
||||
<script src="../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../external/localization.js"></script>
|
||||
<script src="../../ui/calendar/date.js"></script>
|
||||
<script src="../../external/date.js"></script>
|
||||
<script src="../../ui/core.js"></script>
|
||||
<script src="../../ui/widget.js"></script>
|
||||
<script src="../../ui/button.js"></script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="../../external/globalize/globalize.js"></script>
|
||||
<script src="../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../external/localization.js"></script>
|
||||
<script src="../../ui/calendar/date.js"></script>
|
||||
<script src="../../external/date.js"></script>
|
||||
<script src="../../ui/core.js"></script>
|
||||
<script src="../../ui/widget.js"></script>
|
||||
<script src="../../ui/button.js"></script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="../../external/globalize/globalize.js"></script>
|
||||
<script src="../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../external/localization.js"></script>
|
||||
<script src="../../ui/calendar/date.js"></script>
|
||||
<script src="../../external/date.js"></script>
|
||||
<script src="../../ui/core.js"></script>
|
||||
<script src="../../ui/widget.js"></script>
|
||||
<script src="../../ui/button.js"></script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="../../external/globalize/globalize.js"></script>
|
||||
<script src="../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../external/localization.js"></script>
|
||||
<script src="../../ui/calendar/date.js"></script>
|
||||
<script src="../../external/date.js"></script>
|
||||
<script src="../../ui/core.js"></script>
|
||||
<script src="../../ui/widget.js"></script>
|
||||
<script src="../../ui/button.js"></script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="../../external/globalize/globalize.js"></script>
|
||||
<script src="../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../external/localization.js"></script>
|
||||
<script src="../../ui/calendar/date.js"></script>
|
||||
<script src="../../external/date.js"></script>
|
||||
<script src="../../ui/core.js"></script>
|
||||
<script src="../../ui/widget.js"></script>
|
||||
<script src="../../ui/button.js"></script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="../../external/globalize/globalize.js"></script>
|
||||
<script src="../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../external/localization.js"></script>
|
||||
<script src="../../ui/calendar/date.js"></script>
|
||||
<script src="../../external/date.js"></script>
|
||||
<script src="../../ui/core.js"></script>
|
||||
<script src="../../ui/widget.js"></script>
|
||||
<script src="../../ui/button.js"></script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="../../external/globalize/globalize.js"></script>
|
||||
<script src="../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../external/localization.js"></script>
|
||||
<script src="../../ui/calendar/date.js"></script>
|
||||
<script src="../../external/date.js"></script>
|
||||
<script src="../../ui/core.js"></script>
|
||||
<script src="../../ui/widget.js"></script>
|
||||
<script src="../../ui/button.js"></script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="../../external/globalize/globalize.js"></script>
|
||||
<script src="../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../external/localization.js"></script>
|
||||
<script src="../../ui/calendar/date.js"></script>
|
||||
<script src="../../external/date.js"></script>
|
||||
<script src="../../ui/core.js"></script>
|
||||
<script src="../../ui/widget.js"></script>
|
||||
<script src="../../ui/effect.js"></script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="../../external/globalize/globalize.js"></script>
|
||||
<script src="../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../external/localization.js"></script>
|
||||
<script src="../../ui/calendar/date.js"></script>
|
||||
<script src="../../external/date.js"></script>
|
||||
<script src="../../ui/core.js"></script>
|
||||
<script src="../../ui/widget.js"></script>
|
||||
<script src="../../ui/button.js"></script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="../../external/globalize/globalize.js"></script>
|
||||
<script src="../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../external/localization.js"></script>
|
||||
<script src="../../ui/calendar/date.js"></script>
|
||||
<script src="../../external/date.js"></script>
|
||||
<script src="../../ui/core.js"></script>
|
||||
<script src="../../ui/widget.js"></script>
|
||||
<script src="../../ui/button.js"></script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="../../external/globalize/globalize.js"></script>
|
||||
<script src="../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../external/localization.js"></script>
|
||||
<script src="../../ui/calendar/date.js"></script>
|
||||
<script src="../../external/date.js"></script>
|
||||
<script src="../../ui/core.js"></script>
|
||||
<script src="../../ui/widget.js"></script>
|
||||
<script src="../../ui/button.js"></script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<script src="../../external/globalize/globalize.js"></script>
|
||||
<script src="../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../external/localization.js"></script>
|
||||
<script src="../../ui/calendar/date.js"></script>
|
||||
<script src="../../external/date.js"></script>
|
||||
<script src="../../ui/core.js"></script>
|
||||
<script src="../../ui/widget.js"></script>
|
||||
<script src="../../ui/button.js"></script>
|
||||
@ -28,7 +28,7 @@
|
||||
locale: select.val()
|
||||
});
|
||||
|
||||
select.change( function() {
|
||||
select.on( "change", function() {
|
||||
datepicker.datepicker( "option", {
|
||||
locale: select.val()
|
||||
});
|
||||
|
103
external/date.js
vendored
103
external/date.js
vendored
@ -9,17 +9,18 @@
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"globalize"
|
||||
"jquery"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery, Globalize );
|
||||
factory( jQuery );
|
||||
}
|
||||
}( function( $, Globalize ) {
|
||||
}( function( $ ) {
|
||||
|
||||
var weekdays = [ "sun", "mon", "tue", "wed", "thu", "fri", "sat" ],
|
||||
$.ui = $.ui || {};
|
||||
|
||||
var _Date,
|
||||
weekdaysRev = {
|
||||
"sun": 0,
|
||||
"mon": 1,
|
||||
@ -30,43 +31,46 @@ var weekdays = [ "sun", "mon", "tue", "wed", "thu", "fri", "sat" ],
|
||||
"sat": 6
|
||||
};
|
||||
|
||||
Globalize.locale( "en" );
|
||||
_Date = function( date, attributes ) {
|
||||
if ( !( this instanceof _Date ) ) {
|
||||
return new _Date( date, attributes );
|
||||
}
|
||||
|
||||
this.setAttributes( attributes );
|
||||
|
||||
$.date = function( date, globalFormat ) {
|
||||
if ( !( this instanceof $.date ) ) {
|
||||
return new $.date( date, globalFormat );
|
||||
}
|
||||
if ( typeof date === "string" && date.length ) {
|
||||
this.dateObject = Globalize.parseDate( date, globalFormat );
|
||||
}
|
||||
if ( $.type( date ) === "date" ) {
|
||||
this.dateObject = attributes.parse( date );
|
||||
} else if ( $.type( date ) === "date" ) {
|
||||
this.dateObject = date;
|
||||
}
|
||||
|
||||
this.dateObject = this.dateObject || new Date();
|
||||
this.globalFormat = globalFormat;
|
||||
};
|
||||
|
||||
$.date.prototype = {
|
||||
setFormat: function( format ) {
|
||||
if ( format ) {
|
||||
this.globalFormat = format;
|
||||
}
|
||||
return this;
|
||||
$.extend( _Date.prototype, {
|
||||
|
||||
setAttributes: function( attributes ) {
|
||||
this.attributes = attributes;
|
||||
this.firstDay = weekdaysRev[ this.attributes.firstDay ];
|
||||
},
|
||||
|
||||
//TODO: same as the underlying Date object's terminology, but still misleading.
|
||||
//TODO: We can use .setTime() instead of new Date and rename to setTimestamp.
|
||||
setTime: function( time ) {
|
||||
this.dateObject = new Date( time );
|
||||
return this;
|
||||
},
|
||||
|
||||
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() );
|
||||
return this;
|
||||
},
|
||||
|
||||
setMonth: function( month ) {
|
||||
|
||||
// Overflow example: Month is October 31 (yeah Halloween) and month is changed to April with 30 days,
|
||||
// the new date will me May 1. We will honor the month the user wants to set and if and overflow
|
||||
// occurs, set to last day of month.
|
||||
@ -81,6 +85,7 @@ $.date.prototype = {
|
||||
date.getMinutes(), date.getSeconds() );
|
||||
return this;
|
||||
},
|
||||
|
||||
setYear: function( year ) {
|
||||
var date = this.dateObject,
|
||||
day = date.getDate(),
|
||||
@ -96,10 +101,12 @@ $.date.prototype = {
|
||||
date.getMinutes(), date.getSeconds() );
|
||||
return this;
|
||||
},
|
||||
|
||||
setFullDate: function( year, month, day ) {
|
||||
this.dateObject = new Date( year, month, day );
|
||||
return this;
|
||||
},
|
||||
|
||||
adjust: function( period, offset ) {
|
||||
var date = this.dateObject,
|
||||
day = period == "D" ? date.getDate() + offset : date.getDate(),
|
||||
@ -114,59 +121,71 @@ $.date.prototype = {
|
||||
date.getMinutes(), date.getSeconds() );
|
||||
return this;
|
||||
},
|
||||
|
||||
daysInMonth: function( year, month ) {
|
||||
var date = this.dateObject;
|
||||
year = year || date.getFullYear();
|
||||
month = month || date.getMonth();
|
||||
return 32 - new Date( year, month, 32 ).getDate();
|
||||
},
|
||||
|
||||
monthName: function() {
|
||||
return Globalize.formatDate( this.dateObject, { pattern: "MMMM" } );
|
||||
return this.attributes.formatMonth( this.dateObject );
|
||||
},
|
||||
|
||||
day: function() {
|
||||
return this.dateObject.getDate();
|
||||
},
|
||||
|
||||
month: function() {
|
||||
return this.dateObject.getMonth();
|
||||
},
|
||||
|
||||
year: function() {
|
||||
return this.dateObject.getFullYear();
|
||||
},
|
||||
|
||||
isLeapYear: function( year ) {
|
||||
year = year || this.dateObject.getFullYear();
|
||||
return new Date( year, 1, 29 ).getMonth() == 1;
|
||||
},
|
||||
|
||||
weekdays: function() {
|
||||
var cldr = Globalize.locale(),
|
||||
var date,
|
||||
firstDay = this.firstDay,
|
||||
result = [];
|
||||
|
||||
// date = firstDay
|
||||
date = new Date( this.dateObject.getTime() );
|
||||
date.setDate( date.getDate() + firstDay - 1 - date.getDay() );
|
||||
|
||||
for ( var dow = 0; dow < 7; dow++ ) {
|
||||
var day = ( dow + weekdaysRev[ cldr.supplemental.weekData.firstDay() ] ) % 7;
|
||||
date.setTime( date.getTime() + 86400000 );
|
||||
result.push({
|
||||
shortname:
|
||||
cldr.main([ "dates/calendars/gregorian/days/format/short", weekdays[ day ] ]).length > 3 ?
|
||||
cldr.main([ "dates/calendars/gregorian/days/format/narrow", weekdays[ day ] ]) :
|
||||
cldr.main([ "dates/calendars/gregorian/days/format/short", weekdays[ day ] ]),
|
||||
fullname: cldr.main([ "dates/calendars/gregorian/days/format/wide", weekdays[ day ] ])
|
||||
shortname: this.attributes.formatWeekdayShort( date ),
|
||||
fullname: this.attributes.formatWeekdayFull( date )
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
days: function() {
|
||||
var result = [],
|
||||
today = $.date(),
|
||||
today = new _Date( new Date(), this.attributes ),
|
||||
date = this.dateObject,
|
||||
firstDayOfMonth = new Date( this.year(), date.getMonth(), 1 ).getDay(),
|
||||
leadDays = ( firstDayOfMonth - weekdaysRev[ Globalize.locale().supplemental.weekData.firstDay() ] + 7 ) % 7,
|
||||
leadDays = ( firstDayOfMonth - this.firstDay + 7 ) % 7,
|
||||
rows = Math.ceil( ( leadDays + this.daysInMonth() ) / 7 ),
|
||||
printDate = new Date( this.year(), date.getMonth(), 1 - leadDays );
|
||||
for ( var row = 0; row < rows; row++ ) {
|
||||
var week = result[ result.length ] = {
|
||||
number: Globalize.formatDate( printDate, { pattern: "w" } ),
|
||||
number: this.attributes.formatWeekOfYear( printDate ),
|
||||
days: []
|
||||
};
|
||||
for ( var dayx = 0; dayx < 7; dayx++ ) {
|
||||
var day = week.days[ week.days.length ] = {
|
||||
lead: printDate.getMonth() != date.getMonth(),
|
||||
lead: printDate.getMonth() !== date.getMonth(),
|
||||
date: printDate.getDate(),
|
||||
month: printDate.getMonth(),
|
||||
year: printDate.getFullYear(),
|
||||
@ -177,12 +196,14 @@ $.date.prototype = {
|
||||
if ( this.eachDay ) {
|
||||
this.eachDay( day );
|
||||
}
|
||||
|
||||
// TODO use adjust("D", 1)?
|
||||
printDate.setDate( printDate.getDate() + 1 );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
// specialized for multi-month template, could be used in general
|
||||
months: function( add ) {
|
||||
var clone,
|
||||
@ -197,25 +218,25 @@ $.date.prototype = {
|
||||
result[ result.length - 1 ].last = true;
|
||||
return result;
|
||||
},
|
||||
|
||||
clone: function() {
|
||||
var date = this.dateObject;
|
||||
return new $.date( new Date( date.getFullYear(), date.getMonth(),
|
||||
date.getDate(), date.getHours(),
|
||||
date.getMinutes(), date.getSeconds()), this.globalFormat );
|
||||
return new _Date( new Date( date.getTime() ), this.attributes );
|
||||
},
|
||||
|
||||
// TODO compare year, month, day each for better performance
|
||||
equal: function( other ) {
|
||||
function format( date ) {
|
||||
return Globalize.formatDate( date, { pattern: "yyyyMMdd" } );
|
||||
var format = function( date ) {
|
||||
return "" + date.getFullYear() + date.getMonth() + date.getDate();
|
||||
}
|
||||
return format( this.dateObject ) === format( other );
|
||||
},
|
||||
|
||||
date: function() {
|
||||
return this.dateObject;
|
||||
},
|
||||
format: function( format ) {
|
||||
return Globalize.formatDate( this.dateObject, format || this.globalFormat );
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
return $.ui.calendarDate = _Date;
|
||||
|
||||
} ) );
|
||||
|
17
external/localization.js
vendored
17
external/localization.js
vendored
@ -1,6 +1,19 @@
|
||||
/**
|
||||
* CLDR data
|
||||
*/
|
||||
( function( factory ) {
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"globalize"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( Globalize );
|
||||
}
|
||||
}( function( Globalize ) {
|
||||
|
||||
Globalize.load({
|
||||
"main": {
|
||||
@ -4188,3 +4201,7 @@ Globalize.load({
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return Globalize;
|
||||
|
||||
} ) );
|
||||
|
1
tests/lib/bootstrap.js
vendored
1
tests/lib/bootstrap.js
vendored
@ -3,6 +3,7 @@
|
||||
requirejs.config({
|
||||
paths: {
|
||||
"date": "../../../external/date",
|
||||
"cldr": "../../../external/cldrjs/cldr",
|
||||
"globalize": "../../../external/globalize/globalize",
|
||||
"globalize-locales": "../../../external/localization",
|
||||
"globalize-old": "../../../external/globalize-old/globalize",
|
||||
|
@ -4,38 +4,9 @@
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Calendar Test Suite</title>
|
||||
|
||||
<script src="../../jquery.js"></script>
|
||||
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
|
||||
<script src="../../../external/qunit/qunit.js"></script>
|
||||
<script src="../../../external/jquery-simulate/jquery.simulate.js"></script>
|
||||
<script src="../testsuite.js"></script>
|
||||
<script src="../../../external/cldrjs/cldr.js"></script>
|
||||
<script src="../../../external/cldrjs/cldr/supplemental.js"></script>
|
||||
<script src="../../../external/cldrjs/cldr/event.js"></script>
|
||||
<script src="../../../external/globalize/globalize.js"></script>
|
||||
<script src="../../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../../external/localization.js"></script>
|
||||
<script src="../../../ui/calendar/date.js"></script>
|
||||
<script>
|
||||
TestHelpers.loadResources({
|
||||
css: [ "core", "calendar" ],
|
||||
js: [
|
||||
"ui/core.js",
|
||||
"ui/widget.js",
|
||||
"ui/button.js",
|
||||
"ui/calendar.js"
|
||||
]
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="calendar_common.js"></script>
|
||||
<script src="calendar_core.js"></script>
|
||||
<script src="calendar_events.js"></script>
|
||||
<script src="calendar_methods.js"></script>
|
||||
<script src="calendar_options.js"></script>
|
||||
<script src="calendar_test_helpers.js"></script>
|
||||
|
||||
<script src="../swarminject.js"></script>
|
||||
<script src="../../../external/requirejs/require.js"></script>
|
||||
<script src="../../lib/css.js" data-modules="core calendar"></script>
|
||||
<script src="../../lib/bootstrap.js" data-widget="datepicker"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
@ -1,6 +1,13 @@
|
||||
TestHelpers.commonWidgetTests( "calendar", {
|
||||
define( [
|
||||
"lib/common",
|
||||
"ui/calendar",
|
||||
"globalize-locales"
|
||||
], function( common ) {
|
||||
|
||||
common.testWidget( "calendar", {
|
||||
defaults: {
|
||||
buttons: [],
|
||||
classes: {},
|
||||
disabled: false,
|
||||
eachDay: $.noop,
|
||||
labels: {
|
||||
@ -21,3 +28,5 @@ TestHelpers.commonWidgetTests( "calendar", {
|
||||
select: null
|
||||
}
|
||||
});
|
||||
|
||||
} );
|
||||
|
@ -1,7 +1,14 @@
|
||||
TestHelpers.commonWidgetTests( "datepicker", {
|
||||
define( [
|
||||
"lib/common",
|
||||
"ui/datepicker",
|
||||
"globalize-locales"
|
||||
], function( common ) {
|
||||
|
||||
common.testWidget( "datepicker", {
|
||||
defaults: {
|
||||
appendTo: null,
|
||||
buttons: [],
|
||||
classes: {},
|
||||
disabled: false,
|
||||
eachDay: $.noop,
|
||||
labels: {
|
||||
@ -30,3 +37,5 @@ TestHelpers.commonWidgetTests( "datepicker", {
|
||||
select: null
|
||||
}
|
||||
});
|
||||
|
||||
} );
|
||||
|
@ -4,40 +4,9 @@
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Datepicker Test Suite</title>
|
||||
|
||||
<script src="../../jquery.js"></script>
|
||||
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
|
||||
<script src="../../../external/qunit/qunit.js"></script>
|
||||
<script src="../../../external/jquery-simulate/jquery.simulate.js"></script>
|
||||
<script src="../testsuite.js"></script>
|
||||
<script src="../../../external/cldrjs/cldr.js"></script>
|
||||
<script src="../../../external/cldrjs/cldr/supplemental.js"></script>
|
||||
<script src="../../../external/cldrjs/cldr/event.js"></script>
|
||||
<script src="../../../external/globalize/globalize.js"></script>
|
||||
<script src="../../../external/globalize/globalize/date.js"></script>
|
||||
<script src="../../../external/localization.js"></script>
|
||||
<script src="../../../ui/calendar/date.js"></script>
|
||||
<script>
|
||||
TestHelpers.loadResources({
|
||||
css: [ "core", "calendar", "datepicker" ],
|
||||
js: [
|
||||
"ui/core.js",
|
||||
"ui/widget.js",
|
||||
"ui/button.js",
|
||||
"ui/calendar.js",
|
||||
"ui/position.js",
|
||||
"ui/datepicker.js"
|
||||
]
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="datepicker_common.js"></script>
|
||||
<script src="datepicker_core.js"></script>
|
||||
<script src="datepicker_events.js"></script>
|
||||
<script src="datepicker_methods.js"></script>
|
||||
<script src="datepicker_options.js"></script>
|
||||
<script src="datepicker_test_helpers.js"></script>
|
||||
|
||||
<script src="../swarminject.js"></script>
|
||||
<script src="../../../external/requirejs/require.js"></script>
|
||||
<script src="../../lib/css.js" data-modules="core calendar datepicker"></script>
|
||||
<script src="../../lib/bootstrap.js" data-widget="datepicker"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
@ -13,26 +13,26 @@
|
||||
//>>docs: http://api.jqueryui.com/calendar/
|
||||
//>>demos: http://jqueryui.com/calendar/
|
||||
|
||||
(function( factory ) {
|
||||
( function( factory ) {
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
// TODO: Keep button even if its optional?
|
||||
define([
|
||||
define( [
|
||||
"jquery",
|
||||
"globalize",
|
||||
"globalize/date",
|
||||
"globalize-locales",
|
||||
"date",
|
||||
"./button",
|
||||
"./calendar/date",
|
||||
"./core",
|
||||
"./widget"
|
||||
], factory );
|
||||
"./button" ], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery, Globalize );
|
||||
}
|
||||
}(function( $, Globalize ) {
|
||||
}( function( $, Globalize ) {
|
||||
|
||||
return $.widget( "ui.calendar", {
|
||||
version: "@VERSION",
|
||||
@ -99,7 +99,7 @@ return $.widget( "ui.calendar", {
|
||||
"mouseenter .ui-calendar-calendar button": "_hover",
|
||||
"mouseleave .ui-calendar-calendar button": "_hover",
|
||||
"keydown .ui-calendar-calendar": "_handleKeydown"
|
||||
});
|
||||
} );
|
||||
|
||||
this._createCalendar();
|
||||
},
|
||||
@ -212,10 +212,10 @@ return $.widget( "ui.calendar", {
|
||||
|
||||
this.element
|
||||
.addClass( classes )
|
||||
.attr({
|
||||
.attr( {
|
||||
role: "region",
|
||||
"aria-labelledby": this.id + "-title"
|
||||
})
|
||||
} )
|
||||
.html( pickerHtml );
|
||||
|
||||
this._createButtonPane();
|
||||
@ -478,7 +478,7 @@ return $.widget( "ui.calendar", {
|
||||
$( "<button></button>", props )
|
||||
.button( buttonOptions )
|
||||
.appendTo( that.buttonSet );
|
||||
});
|
||||
} );
|
||||
this.element.addClass( "ui-calendar-buttons" );
|
||||
this.buttonPane.appendTo( this.element );
|
||||
},
|
||||
@ -536,10 +536,10 @@ return $.widget( "ui.calendar", {
|
||||
},
|
||||
|
||||
_setHiddenPicker: function() {
|
||||
this.element.attr({
|
||||
this.element.attr( {
|
||||
"aria-hidden": "true",
|
||||
"aria-expanded": "false"
|
||||
});
|
||||
} );
|
||||
},
|
||||
|
||||
value: function( value ) {
|
||||
@ -597,7 +597,7 @@ return $.widget( "ui.calendar", {
|
||||
if ( key in that.refreshRelatedOptions ) {
|
||||
refresh = true;
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
if ( refresh ) {
|
||||
this._refresh();
|
||||
@ -642,6 +642,6 @@ return $.widget( "ui.calendar", {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
}));
|
||||
} ) );
|
||||
|
@ -1,245 +0,0 @@
|
||||
/*
|
||||
* jQuery UI Calendar/Date @VERSION
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Based on Marc Grabanski's jQuery Date Plugin
|
||||
* http://marcgrabanski.com/articles/jquery-date-plugin
|
||||
*
|
||||
* Copyright 2014 jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
(function( factory ) {
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define([
|
||||
"jquery"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
}(function( $ ) {
|
||||
|
||||
$.ui = $.ui || {};
|
||||
|
||||
var _Date,
|
||||
weekdaysRev = {
|
||||
"sun": 0,
|
||||
"mon": 1,
|
||||
"tue": 2,
|
||||
"wed": 3,
|
||||
"thu": 4,
|
||||
"fri": 5,
|
||||
"sat": 6
|
||||
};
|
||||
|
||||
_Date = function( date, attributes ) {
|
||||
if ( !( this instanceof _Date ) ) {
|
||||
return new _Date( date, attributes );
|
||||
}
|
||||
|
||||
this.setAttributes( attributes );
|
||||
|
||||
if ( typeof date === "string" && date.length ) {
|
||||
this.dateObject = attributes.parse( date );
|
||||
} else if ( $.type( date ) === "date" ) {
|
||||
this.dateObject = date;
|
||||
}
|
||||
|
||||
this.dateObject = this.dateObject || new Date();
|
||||
};
|
||||
|
||||
$.extend( _Date.prototype, {
|
||||
|
||||
setAttributes: function( attributes ) {
|
||||
this.attributes = attributes;
|
||||
this.firstDay = weekdaysRev[ this.attributes.firstDay ];
|
||||
},
|
||||
|
||||
//TODO: same as the underlying Date object's terminology, but still misleading.
|
||||
//TODO: We can use .setTime() instead of new Date and rename to setTimestamp.
|
||||
setTime: function( time ) {
|
||||
this.dateObject = new Date( time );
|
||||
return this;
|
||||
},
|
||||
|
||||
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() );
|
||||
return this;
|
||||
},
|
||||
|
||||
setMonth: function( month ) {
|
||||
|
||||
// Overflow example: Month is October 31 (yeah Halloween) and month is changed to April with 30 days,
|
||||
// the new date will me May 1. We will honor the month the user wants to set and if and overflow
|
||||
// occurs, set to last day of month.
|
||||
var date = this.dateObject,
|
||||
days = date.getDay(), year = date.getFullYear();
|
||||
if ( days > this.daysInMonth( year, month ) ) {
|
||||
|
||||
// Overflow
|
||||
days = this.daysInMonth( year, month );
|
||||
}
|
||||
this.dateObject = new Date( year, month, days, date.getHours(),
|
||||
date.getMinutes(), date.getSeconds() );
|
||||
return this;
|
||||
},
|
||||
|
||||
setYear: function( year ) {
|
||||
var date = this.dateObject,
|
||||
day = date.getDate(),
|
||||
month = date.getMonth();
|
||||
|
||||
// Check if Leap, and February and day is 29th
|
||||
if ( this.isLeapYear( year ) && month == 1 && day == 29 ) {
|
||||
|
||||
// set day to last day of February
|
||||
day = this.daysInMonth( year, month );
|
||||
}
|
||||
this.dateObject = new Date( year, month, day, date.getHours(),
|
||||
date.getMinutes(), date.getSeconds() );
|
||||
return this;
|
||||
},
|
||||
|
||||
setFullDate: function( year, month, day ) {
|
||||
this.dateObject = new Date( year, month, day );
|
||||
return this;
|
||||
},
|
||||
|
||||
adjust: function( period, offset ) {
|
||||
var date = this.dateObject,
|
||||
day = period == "D" ? date.getDate() + offset : date.getDate(),
|
||||
month = period == "M" ? date.getMonth() + offset : date.getMonth(),
|
||||
year = period == "Y" ? date.getFullYear() + offset : date.getFullYear();
|
||||
|
||||
// If not day, update the day to the new month and year
|
||||
if ( period != "D" ) {
|
||||
day = Math.max( 1, Math.min( day, this.daysInMonth( year, month ) ) );
|
||||
}
|
||||
this.dateObject = new Date( year, month, day, date.getHours(),
|
||||
date.getMinutes(), date.getSeconds() );
|
||||
return this;
|
||||
},
|
||||
|
||||
daysInMonth: function( year, month ) {
|
||||
var date = this.dateObject;
|
||||
year = year || date.getFullYear();
|
||||
month = month || date.getMonth();
|
||||
return 32 - new Date( year, month, 32 ).getDate();
|
||||
},
|
||||
|
||||
monthName: function() {
|
||||
return this.attributes.formatMonth( this.dateObject );
|
||||
},
|
||||
|
||||
day: function() {
|
||||
return this.dateObject.getDate();
|
||||
},
|
||||
|
||||
month: function() {
|
||||
return this.dateObject.getMonth();
|
||||
},
|
||||
|
||||
year: function() {
|
||||
return this.dateObject.getFullYear();
|
||||
},
|
||||
|
||||
isLeapYear: function( year ) {
|
||||
year = year || this.dateObject.getFullYear();
|
||||
return new Date( year, 1, 29 ).getMonth() == 1;
|
||||
},
|
||||
|
||||
weekdays: function() {
|
||||
var date,
|
||||
firstDay = this.firstDay,
|
||||
result = [];
|
||||
|
||||
// date = firstDay
|
||||
date = new Date( this.dateObject.getTime() );
|
||||
date.setDate( date.getDate() + firstDay - date.getDay() );
|
||||
|
||||
for ( var dow = 0; dow < 7; dow++ && date.setDate( date.getDate() + 1 ) ) {
|
||||
result.push({
|
||||
shortname: this.attributes.formatWeekdayShort( date ),
|
||||
fullname: this.attributes.formatWeekdayFull( date )
|
||||
});
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
days: function() {
|
||||
var result = [],
|
||||
today = new _Date( new Date(), this.attributes ),
|
||||
date = this.dateObject,
|
||||
firstDayOfMonth = new Date( this.year(), date.getMonth(), 1 ).getDay(),
|
||||
leadDays = ( firstDayOfMonth - this.firstDay + 7 ) % 7,
|
||||
rows = Math.ceil( ( leadDays + this.daysInMonth() ) / 7 ),
|
||||
printDate = new Date( this.year(), date.getMonth(), 1 - leadDays );
|
||||
for ( var row = 0; row < rows; row++ ) {
|
||||
var week = result[ result.length ] = {
|
||||
number: this.attributes.formatWeekOfYear( printDate ),
|
||||
days: []
|
||||
};
|
||||
for ( var dayx = 0; dayx < 7; dayx++ ) {
|
||||
var day = week.days[ week.days.length ] = {
|
||||
lead: printDate.getMonth() !== date.getMonth(),
|
||||
date: printDate.getDate(),
|
||||
month: printDate.getMonth(),
|
||||
year: printDate.getFullYear(),
|
||||
timestamp: printDate.getTime(),
|
||||
today: today.equal( printDate )
|
||||
};
|
||||
day.render = day.selectable = !day.lead;
|
||||
if ( this.eachDay ) {
|
||||
this.eachDay( day );
|
||||
}
|
||||
|
||||
// TODO use adjust("D", 1)?
|
||||
printDate.setDate( printDate.getDate() + 1 );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
// specialized for multi-month template, could be used in general
|
||||
months: function( add ) {
|
||||
var clone,
|
||||
result = [ this ];
|
||||
|
||||
for ( var i = 0; i < add; i++ ) {
|
||||
clone = this.clone();
|
||||
clone.adjust( "M", i + 1 );
|
||||
result.push( clone );
|
||||
}
|
||||
result[ 0 ].first = true;
|
||||
result[ result.length - 1 ].last = true;
|
||||
return result;
|
||||
},
|
||||
|
||||
clone: function() {
|
||||
var date = this.dateObject;
|
||||
return new _Date( new Date( date.getTime() ), this.attributes );
|
||||
},
|
||||
|
||||
// TODO compare year, month, day each for better performance
|
||||
equal: function( other ) {
|
||||
var format = function( date ) {
|
||||
return "" + date.getFullYear() + date.getMonth() + date.getDate();
|
||||
}
|
||||
return format( this.dateObject ) === format( other );
|
||||
},
|
||||
|
||||
date: function() {
|
||||
return this.dateObject;
|
||||
}
|
||||
});
|
||||
|
||||
return $.ui.calendarDate = _Date;
|
||||
|
||||
}));
|
@ -217,7 +217,7 @@ var widget = $.widget( "ui.datepicker", {
|
||||
}
|
||||
|
||||
if ( !element || !element[ 0 ] ) {
|
||||
element = this.element.closest( ".ui-front" );
|
||||
element = this.element.closest( ".ui-front, dialog" );
|
||||
}
|
||||
|
||||
if ( !element.length ) {
|
||||
|
Loading…
Reference in New Issue
Block a user