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",
|
"cldrjs/LICENSE-MIT": "cldrjs/LICENSE-MIT",
|
||||||
|
|
||||||
"globalize/globalize.js": "globalize/dist/globalize.js",
|
"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/globalize/date.js": "globalize/dist/globalize/date.js",
|
||||||
"globalize/LICENSE.txt": "globalize/LICENSE.txt",
|
"globalize/LICENSE.txt": "globalize/LICENSE.txt",
|
||||||
|
|
||||||
|
20
bower.json
20
bower.json
@ -14,8 +14,12 @@
|
|||||||
"jquery-mousewheel": "3.1.12",
|
"jquery-mousewheel": "3.1.12",
|
||||||
"jquery-simulate": "1.0.0",
|
"jquery-simulate": "1.0.0",
|
||||||
"jshint": "2.4.4",
|
"jshint": "2.4.4",
|
||||||
"qunit": "1.17.1",
|
"qunit": "1.18.0",
|
||||||
"globalize": "1.0.0-alpha.7",
|
"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.0": "jquery#1.7.0",
|
||||||
"jquery-1.7.1": "jquery#1.7.1",
|
"jquery-1.7.1": "jquery#1.7.1",
|
||||||
@ -29,10 +33,18 @@
|
|||||||
"jquery-1.10.0": "jquery#1.10.0",
|
"jquery-1.10.0": "jquery#1.10.0",
|
||||||
"jquery-1.10.1": "jquery#1.10.1",
|
"jquery-1.10.1": "jquery#1.10.1",
|
||||||
"jquery-1.10.2": "jquery#1.10.2",
|
"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.0": "jquery#2.0.0",
|
||||||
"jquery-2.0.1": "jquery#2.0.1",
|
"jquery-2.0.1": "jquery#2.0.1",
|
||||||
"jquery-2.0.2": "jquery#2.0.2",
|
"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.js"></script>
|
||||||
<script src="../../external/globalize/globalize/date.js"></script>
|
<script src="../../external/globalize/globalize/date.js"></script>
|
||||||
<script src="../../external/localization.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/core.js"></script>
|
||||||
<script src="../../ui/widget.js"></script>
|
<script src="../../ui/widget.js"></script>
|
||||||
<script src="../../ui/button.js"></script>
|
<script src="../../ui/button.js"></script>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<script src="../../external/globalize/globalize.js"></script>
|
<script src="../../external/globalize/globalize.js"></script>
|
||||||
<script src="../../external/globalize/globalize/date.js"></script>
|
<script src="../../external/globalize/globalize/date.js"></script>
|
||||||
<script src="../../external/localization.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/core.js"></script>
|
||||||
<script src="../../ui/widget.js"></script>
|
<script src="../../ui/widget.js"></script>
|
||||||
<script src="../../ui/button.js"></script>
|
<script src="../../ui/button.js"></script>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<script src="../../external/globalize/globalize.js"></script>
|
<script src="../../external/globalize/globalize.js"></script>
|
||||||
<script src="../../external/globalize/globalize/date.js"></script>
|
<script src="../../external/globalize/globalize/date.js"></script>
|
||||||
<script src="../../external/localization.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/core.js"></script>
|
||||||
<script src="../../ui/widget.js"></script>
|
<script src="../../ui/widget.js"></script>
|
||||||
<script src="../../ui/button.js"></script>
|
<script src="../../ui/button.js"></script>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<script src="../../external/globalize/globalize.js"></script>
|
<script src="../../external/globalize/globalize.js"></script>
|
||||||
<script src="../../external/globalize/globalize/date.js"></script>
|
<script src="../../external/globalize/globalize/date.js"></script>
|
||||||
<script src="../../external/localization.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/core.js"></script>
|
||||||
<script src="../../ui/widget.js"></script>
|
<script src="../../ui/widget.js"></script>
|
||||||
<script src="../../ui/button.js"></script>
|
<script src="../../ui/button.js"></script>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<script src="../../external/globalize/globalize.js"></script>
|
<script src="../../external/globalize/globalize.js"></script>
|
||||||
<script src="../../external/globalize/globalize/date.js"></script>
|
<script src="../../external/globalize/globalize/date.js"></script>
|
||||||
<script src="../../external/localization.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/core.js"></script>
|
||||||
<script src="../../ui/widget.js"></script>
|
<script src="../../ui/widget.js"></script>
|
||||||
<script src="../../ui/button.js"></script>
|
<script src="../../ui/button.js"></script>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<script src="../../external/globalize/globalize.js"></script>
|
<script src="../../external/globalize/globalize.js"></script>
|
||||||
<script src="../../external/globalize/globalize/date.js"></script>
|
<script src="../../external/globalize/globalize/date.js"></script>
|
||||||
<script src="../../external/localization.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/core.js"></script>
|
||||||
<script src="../../ui/widget.js"></script>
|
<script src="../../ui/widget.js"></script>
|
||||||
<script src="../../ui/button.js"></script>
|
<script src="../../ui/button.js"></script>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<script src="../../external/globalize/globalize.js"></script>
|
<script src="../../external/globalize/globalize.js"></script>
|
||||||
<script src="../../external/globalize/globalize/date.js"></script>
|
<script src="../../external/globalize/globalize/date.js"></script>
|
||||||
<script src="../../external/localization.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/core.js"></script>
|
||||||
<script src="../../ui/widget.js"></script>
|
<script src="../../ui/widget.js"></script>
|
||||||
<script src="../../ui/button.js"></script>
|
<script src="../../ui/button.js"></script>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<script src="../../external/globalize/globalize.js"></script>
|
<script src="../../external/globalize/globalize.js"></script>
|
||||||
<script src="../../external/globalize/globalize/date.js"></script>
|
<script src="../../external/globalize/globalize/date.js"></script>
|
||||||
<script src="../../external/localization.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/core.js"></script>
|
||||||
<script src="../../ui/widget.js"></script>
|
<script src="../../ui/widget.js"></script>
|
||||||
<script src="../../ui/button.js"></script>
|
<script src="../../ui/button.js"></script>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<script src="../../external/globalize/globalize.js"></script>
|
<script src="../../external/globalize/globalize.js"></script>
|
||||||
<script src="../../external/globalize/globalize/date.js"></script>
|
<script src="../../external/globalize/globalize/date.js"></script>
|
||||||
<script src="../../external/localization.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/core.js"></script>
|
||||||
<script src="../../ui/widget.js"></script>
|
<script src="../../ui/widget.js"></script>
|
||||||
<script src="../../ui/effect.js"></script>
|
<script src="../../ui/effect.js"></script>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<script src="../../external/globalize/globalize.js"></script>
|
<script src="../../external/globalize/globalize.js"></script>
|
||||||
<script src="../../external/globalize/globalize/date.js"></script>
|
<script src="../../external/globalize/globalize/date.js"></script>
|
||||||
<script src="../../external/localization.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/core.js"></script>
|
||||||
<script src="../../ui/widget.js"></script>
|
<script src="../../ui/widget.js"></script>
|
||||||
<script src="../../ui/button.js"></script>
|
<script src="../../ui/button.js"></script>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<script src="../../external/globalize/globalize.js"></script>
|
<script src="../../external/globalize/globalize.js"></script>
|
||||||
<script src="../../external/globalize/globalize/date.js"></script>
|
<script src="../../external/globalize/globalize/date.js"></script>
|
||||||
<script src="../../external/localization.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/core.js"></script>
|
||||||
<script src="../../ui/widget.js"></script>
|
<script src="../../ui/widget.js"></script>
|
||||||
<script src="../../ui/button.js"></script>
|
<script src="../../ui/button.js"></script>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<script src="../../external/globalize/globalize.js"></script>
|
<script src="../../external/globalize/globalize.js"></script>
|
||||||
<script src="../../external/globalize/globalize/date.js"></script>
|
<script src="../../external/globalize/globalize/date.js"></script>
|
||||||
<script src="../../external/localization.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/core.js"></script>
|
||||||
<script src="../../ui/widget.js"></script>
|
<script src="../../ui/widget.js"></script>
|
||||||
<script src="../../ui/button.js"></script>
|
<script src="../../ui/button.js"></script>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<script src="../../external/globalize/globalize.js"></script>
|
<script src="../../external/globalize/globalize.js"></script>
|
||||||
<script src="../../external/globalize/globalize/date.js"></script>
|
<script src="../../external/globalize/globalize/date.js"></script>
|
||||||
<script src="../../external/localization.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/core.js"></script>
|
||||||
<script src="../../ui/widget.js"></script>
|
<script src="../../ui/widget.js"></script>
|
||||||
<script src="../../ui/button.js"></script>
|
<script src="../../ui/button.js"></script>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
locale: select.val()
|
locale: select.val()
|
||||||
});
|
});
|
||||||
|
|
||||||
select.change( function() {
|
select.on( "change", function() {
|
||||||
datepicker.datepicker( "option", {
|
datepicker.datepicker( "option", {
|
||||||
locale: select.val()
|
locale: select.val()
|
||||||
});
|
});
|
||||||
|
103
external/date.js
vendored
103
external/date.js
vendored
@ -9,17 +9,18 @@
|
|||||||
|
|
||||||
// AMD. Register as an anonymous module.
|
// AMD. Register as an anonymous module.
|
||||||
define( [
|
define( [
|
||||||
"jquery",
|
"jquery"
|
||||||
"globalize"
|
|
||||||
], factory );
|
], factory );
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Browser globals
|
// Browser globals
|
||||||
factory( jQuery, Globalize );
|
factory( jQuery );
|
||||||
}
|
}
|
||||||
}( function( $, Globalize ) {
|
}( function( $ ) {
|
||||||
|
|
||||||
var weekdays = [ "sun", "mon", "tue", "wed", "thu", "fri", "sat" ],
|
$.ui = $.ui || {};
|
||||||
|
|
||||||
|
var _Date,
|
||||||
weekdaysRev = {
|
weekdaysRev = {
|
||||||
"sun": 0,
|
"sun": 0,
|
||||||
"mon": 1,
|
"mon": 1,
|
||||||
@ -30,43 +31,46 @@ var weekdays = [ "sun", "mon", "tue", "wed", "thu", "fri", "sat" ],
|
|||||||
"sat": 6
|
"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 ) {
|
if ( typeof date === "string" && date.length ) {
|
||||||
this.dateObject = Globalize.parseDate( date, globalFormat );
|
this.dateObject = attributes.parse( date );
|
||||||
}
|
} else if ( $.type( date ) === "date" ) {
|
||||||
if ( $.type( date ) === "date" ) {
|
|
||||||
this.dateObject = date;
|
this.dateObject = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dateObject = this.dateObject || new Date();
|
this.dateObject = this.dateObject || new Date();
|
||||||
this.globalFormat = globalFormat;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$.date.prototype = {
|
$.extend( _Date.prototype, {
|
||||||
setFormat: function( format ) {
|
|
||||||
if ( format ) {
|
setAttributes: function( attributes ) {
|
||||||
this.globalFormat = format;
|
this.attributes = attributes;
|
||||||
}
|
this.firstDay = weekdaysRev[ this.attributes.firstDay ];
|
||||||
return this;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
//TODO: same as the underlying Date object's terminology, but still misleading.
|
//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.
|
//TODO: We can use .setTime() instead of new Date and rename to setTimestamp.
|
||||||
setTime: function( time ) {
|
setTime: function( time ) {
|
||||||
this.dateObject = new Date( time );
|
this.dateObject = new Date( time );
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
setDay: function( day ) {
|
setDay: function( day ) {
|
||||||
var date = this.dateObject;
|
var date = this.dateObject;
|
||||||
|
// 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() );
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
setMonth: function( month ) {
|
setMonth: function( month ) {
|
||||||
|
|
||||||
// Overflow example: Month is October 31 (yeah Halloween) and month is changed to April with 30 days,
|
// 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
|
// 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.
|
// occurs, set to last day of month.
|
||||||
@ -81,6 +85,7 @@ $.date.prototype = {
|
|||||||
date.getMinutes(), date.getSeconds() );
|
date.getMinutes(), date.getSeconds() );
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
setYear: function( year ) {
|
setYear: function( year ) {
|
||||||
var date = this.dateObject,
|
var date = this.dateObject,
|
||||||
day = date.getDate(),
|
day = date.getDate(),
|
||||||
@ -96,10 +101,12 @@ $.date.prototype = {
|
|||||||
date.getMinutes(), date.getSeconds() );
|
date.getMinutes(), date.getSeconds() );
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
setFullDate: function( year, month, day ) {
|
setFullDate: function( year, month, day ) {
|
||||||
this.dateObject = new Date( year, month, day );
|
this.dateObject = new Date( year, month, day );
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
adjust: function( period, offset ) {
|
adjust: function( period, offset ) {
|
||||||
var date = this.dateObject,
|
var date = this.dateObject,
|
||||||
day = period == "D" ? date.getDate() + offset : date.getDate(),
|
day = period == "D" ? date.getDate() + offset : date.getDate(),
|
||||||
@ -114,59 +121,71 @@ $.date.prototype = {
|
|||||||
date.getMinutes(), date.getSeconds() );
|
date.getMinutes(), date.getSeconds() );
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
daysInMonth: function( year, month ) {
|
daysInMonth: function( year, month ) {
|
||||||
var date = this.dateObject;
|
var date = this.dateObject;
|
||||||
year = year || date.getFullYear();
|
year = year || date.getFullYear();
|
||||||
month = month || date.getMonth();
|
month = month || date.getMonth();
|
||||||
return 32 - new Date( year, month, 32 ).getDate();
|
return 32 - new Date( year, month, 32 ).getDate();
|
||||||
},
|
},
|
||||||
|
|
||||||
monthName: function() {
|
monthName: function() {
|
||||||
return Globalize.formatDate( this.dateObject, { pattern: "MMMM" } );
|
return this.attributes.formatMonth( this.dateObject );
|
||||||
},
|
},
|
||||||
|
|
||||||
day: function() {
|
day: function() {
|
||||||
return this.dateObject.getDate();
|
return this.dateObject.getDate();
|
||||||
},
|
},
|
||||||
|
|
||||||
month: function() {
|
month: function() {
|
||||||
return this.dateObject.getMonth();
|
return this.dateObject.getMonth();
|
||||||
},
|
},
|
||||||
|
|
||||||
year: function() {
|
year: function() {
|
||||||
return this.dateObject.getFullYear();
|
return this.dateObject.getFullYear();
|
||||||
},
|
},
|
||||||
|
|
||||||
isLeapYear: function( year ) {
|
isLeapYear: function( year ) {
|
||||||
year = year || this.dateObject.getFullYear();
|
year = year || this.dateObject.getFullYear();
|
||||||
return new Date( year, 1, 29 ).getMonth() == 1;
|
return new Date( year, 1, 29 ).getMonth() == 1;
|
||||||
},
|
},
|
||||||
|
|
||||||
weekdays: function() {
|
weekdays: function() {
|
||||||
var cldr = Globalize.locale(),
|
var date,
|
||||||
|
firstDay = this.firstDay,
|
||||||
result = [];
|
result = [];
|
||||||
|
|
||||||
|
// date = firstDay
|
||||||
|
date = new Date( this.dateObject.getTime() );
|
||||||
|
date.setDate( date.getDate() + firstDay - 1 - date.getDay() );
|
||||||
|
|
||||||
for ( var dow = 0; dow < 7; dow++ ) {
|
for ( var dow = 0; dow < 7; dow++ ) {
|
||||||
var day = ( dow + weekdaysRev[ cldr.supplemental.weekData.firstDay() ] ) % 7;
|
date.setTime( date.getTime() + 86400000 );
|
||||||
result.push({
|
result.push({
|
||||||
shortname:
|
shortname: this.attributes.formatWeekdayShort( date ),
|
||||||
cldr.main([ "dates/calendars/gregorian/days/format/short", weekdays[ day ] ]).length > 3 ?
|
fullname: this.attributes.formatWeekdayFull( date )
|
||||||
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 ] ])
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
days: function() {
|
days: function() {
|
||||||
var result = [],
|
var result = [],
|
||||||
today = $.date(),
|
today = new _Date( new Date(), this.attributes ),
|
||||||
date = this.dateObject,
|
date = this.dateObject,
|
||||||
firstDayOfMonth = new Date( this.year(), date.getMonth(), 1 ).getDay(),
|
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 ),
|
rows = Math.ceil( ( leadDays + this.daysInMonth() ) / 7 ),
|
||||||
printDate = new Date( this.year(), date.getMonth(), 1 - leadDays );
|
printDate = new Date( this.year(), date.getMonth(), 1 - leadDays );
|
||||||
for ( var row = 0; row < rows; row++ ) {
|
for ( var row = 0; row < rows; row++ ) {
|
||||||
var week = result[ result.length ] = {
|
var week = result[ result.length ] = {
|
||||||
number: Globalize.formatDate( printDate, { pattern: "w" } ),
|
number: this.attributes.formatWeekOfYear( printDate ),
|
||||||
days: []
|
days: []
|
||||||
};
|
};
|
||||||
for ( var dayx = 0; dayx < 7; dayx++ ) {
|
for ( var dayx = 0; dayx < 7; dayx++ ) {
|
||||||
var day = week.days[ week.days.length ] = {
|
var day = week.days[ week.days.length ] = {
|
||||||
lead: printDate.getMonth() != date.getMonth(),
|
lead: printDate.getMonth() !== date.getMonth(),
|
||||||
date: printDate.getDate(),
|
date: printDate.getDate(),
|
||||||
month: printDate.getMonth(),
|
month: printDate.getMonth(),
|
||||||
year: printDate.getFullYear(),
|
year: printDate.getFullYear(),
|
||||||
@ -177,12 +196,14 @@ $.date.prototype = {
|
|||||||
if ( this.eachDay ) {
|
if ( this.eachDay ) {
|
||||||
this.eachDay( day );
|
this.eachDay( day );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO use adjust("D", 1)?
|
// TODO use adjust("D", 1)?
|
||||||
printDate.setDate( printDate.getDate() + 1 );
|
printDate.setDate( printDate.getDate() + 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
// specialized for multi-month template, could be used in general
|
// specialized for multi-month template, could be used in general
|
||||||
months: function( add ) {
|
months: function( add ) {
|
||||||
var clone,
|
var clone,
|
||||||
@ -197,25 +218,25 @@ $.date.prototype = {
|
|||||||
result[ result.length - 1 ].last = true;
|
result[ result.length - 1 ].last = true;
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
clone: function() {
|
clone: function() {
|
||||||
var date = this.dateObject;
|
var date = this.dateObject;
|
||||||
return new $.date( new Date( date.getFullYear(), date.getMonth(),
|
return new _Date( new Date( date.getTime() ), this.attributes );
|
||||||
date.getDate(), date.getHours(),
|
|
||||||
date.getMinutes(), date.getSeconds()), this.globalFormat );
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO compare year, month, day each for better performance
|
// TODO compare year, month, day each for better performance
|
||||||
equal: function( other ) {
|
equal: function( other ) {
|
||||||
function format( date ) {
|
var format = function( date ) {
|
||||||
return Globalize.formatDate( date, { pattern: "yyyyMMdd" } );
|
return "" + date.getFullYear() + date.getMonth() + date.getDate();
|
||||||
}
|
}
|
||||||
return format( this.dateObject ) === format( other );
|
return format( this.dateObject ) === format( other );
|
||||||
},
|
},
|
||||||
|
|
||||||
date: function() {
|
date: function() {
|
||||||
return this.dateObject;
|
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
|
* 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({
|
Globalize.load({
|
||||||
"main": {
|
"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({
|
requirejs.config({
|
||||||
paths: {
|
paths: {
|
||||||
"date": "../../../external/date",
|
"date": "../../../external/date",
|
||||||
|
"cldr": "../../../external/cldrjs/cldr",
|
||||||
"globalize": "../../../external/globalize/globalize",
|
"globalize": "../../../external/globalize/globalize",
|
||||||
"globalize-locales": "../../../external/localization",
|
"globalize-locales": "../../../external/localization",
|
||||||
"globalize-old": "../../../external/globalize-old/globalize",
|
"globalize-old": "../../../external/globalize-old/globalize",
|
||||||
|
@ -4,38 +4,9 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>jQuery UI Calendar Test Suite</title>
|
<title>jQuery UI Calendar Test Suite</title>
|
||||||
|
|
||||||
<script src="../../jquery.js"></script>
|
<script src="../../../external/requirejs/require.js"></script>
|
||||||
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
|
<script src="../../lib/css.js" data-modules="core calendar"></script>
|
||||||
<script src="../../../external/qunit/qunit.js"></script>
|
<script src="../../lib/bootstrap.js" data-widget="datepicker"></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>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
TestHelpers.commonWidgetTests( "calendar", {
|
define( [
|
||||||
|
"lib/common",
|
||||||
|
"ui/calendar",
|
||||||
|
"globalize-locales"
|
||||||
|
], function( common ) {
|
||||||
|
|
||||||
|
common.testWidget( "calendar", {
|
||||||
defaults: {
|
defaults: {
|
||||||
buttons: [],
|
buttons: [],
|
||||||
|
classes: {},
|
||||||
disabled: false,
|
disabled: false,
|
||||||
eachDay: $.noop,
|
eachDay: $.noop,
|
||||||
labels: {
|
labels: {
|
||||||
@ -21,3 +28,5 @@ TestHelpers.commonWidgetTests( "calendar", {
|
|||||||
select: null
|
select: null
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
} );
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
TestHelpers.commonWidgetTests( "datepicker", {
|
define( [
|
||||||
|
"lib/common",
|
||||||
|
"ui/datepicker",
|
||||||
|
"globalize-locales"
|
||||||
|
], function( common ) {
|
||||||
|
|
||||||
|
common.testWidget( "datepicker", {
|
||||||
defaults: {
|
defaults: {
|
||||||
appendTo: null,
|
appendTo: null,
|
||||||
buttons: [],
|
buttons: [],
|
||||||
|
classes: {},
|
||||||
disabled: false,
|
disabled: false,
|
||||||
eachDay: $.noop,
|
eachDay: $.noop,
|
||||||
labels: {
|
labels: {
|
||||||
@ -30,3 +37,5 @@ TestHelpers.commonWidgetTests( "datepicker", {
|
|||||||
select: null
|
select: null
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
} );
|
||||||
|
@ -4,40 +4,9 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>jQuery UI Datepicker Test Suite</title>
|
<title>jQuery UI Datepicker Test Suite</title>
|
||||||
|
|
||||||
<script src="../../jquery.js"></script>
|
<script src="../../../external/requirejs/require.js"></script>
|
||||||
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
|
<script src="../../lib/css.js" data-modules="core calendar datepicker"></script>
|
||||||
<script src="../../../external/qunit/qunit.js"></script>
|
<script src="../../lib/bootstrap.js" data-widget="datepicker"></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>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
@ -13,26 +13,26 @@
|
|||||||
//>>docs: http://api.jqueryui.com/calendar/
|
//>>docs: http://api.jqueryui.com/calendar/
|
||||||
//>>demos: http://jqueryui.com/calendar/
|
//>>demos: http://jqueryui.com/calendar/
|
||||||
|
|
||||||
(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.
|
||||||
// TODO: Keep button even if its optional?
|
// TODO: Keep button even if its optional?
|
||||||
define([
|
define( [
|
||||||
"jquery",
|
"jquery",
|
||||||
"globalize",
|
"globalize",
|
||||||
"globalize/date",
|
"globalize/date",
|
||||||
|
"globalize-locales",
|
||||||
|
"date",
|
||||||
"./button",
|
"./button",
|
||||||
"./calendar/date",
|
|
||||||
"./core",
|
"./core",
|
||||||
"./widget"
|
"./button" ], factory );
|
||||||
], factory );
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Browser globals
|
// Browser globals
|
||||||
factory( jQuery, Globalize );
|
factory( jQuery, Globalize );
|
||||||
}
|
}
|
||||||
}(function( $, Globalize ) {
|
}( function( $, Globalize ) {
|
||||||
|
|
||||||
return $.widget( "ui.calendar", {
|
return $.widget( "ui.calendar", {
|
||||||
version: "@VERSION",
|
version: "@VERSION",
|
||||||
@ -99,7 +99,7 @@ return $.widget( "ui.calendar", {
|
|||||||
"mouseenter .ui-calendar-calendar button": "_hover",
|
"mouseenter .ui-calendar-calendar button": "_hover",
|
||||||
"mouseleave .ui-calendar-calendar button": "_hover",
|
"mouseleave .ui-calendar-calendar button": "_hover",
|
||||||
"keydown .ui-calendar-calendar": "_handleKeydown"
|
"keydown .ui-calendar-calendar": "_handleKeydown"
|
||||||
});
|
} );
|
||||||
|
|
||||||
this._createCalendar();
|
this._createCalendar();
|
||||||
},
|
},
|
||||||
@ -212,10 +212,10 @@ return $.widget( "ui.calendar", {
|
|||||||
|
|
||||||
this.element
|
this.element
|
||||||
.addClass( classes )
|
.addClass( classes )
|
||||||
.attr({
|
.attr( {
|
||||||
role: "region",
|
role: "region",
|
||||||
"aria-labelledby": this.id + "-title"
|
"aria-labelledby": this.id + "-title"
|
||||||
})
|
} )
|
||||||
.html( pickerHtml );
|
.html( pickerHtml );
|
||||||
|
|
||||||
this._createButtonPane();
|
this._createButtonPane();
|
||||||
@ -478,7 +478,7 @@ return $.widget( "ui.calendar", {
|
|||||||
$( "<button></button>", props )
|
$( "<button></button>", props )
|
||||||
.button( buttonOptions )
|
.button( buttonOptions )
|
||||||
.appendTo( that.buttonSet );
|
.appendTo( that.buttonSet );
|
||||||
});
|
} );
|
||||||
this.element.addClass( "ui-calendar-buttons" );
|
this.element.addClass( "ui-calendar-buttons" );
|
||||||
this.buttonPane.appendTo( this.element );
|
this.buttonPane.appendTo( this.element );
|
||||||
},
|
},
|
||||||
@ -536,10 +536,10 @@ return $.widget( "ui.calendar", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_setHiddenPicker: function() {
|
_setHiddenPicker: function() {
|
||||||
this.element.attr({
|
this.element.attr( {
|
||||||
"aria-hidden": "true",
|
"aria-hidden": "true",
|
||||||
"aria-expanded": "false"
|
"aria-expanded": "false"
|
||||||
});
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
value: function( value ) {
|
value: function( value ) {
|
||||||
@ -597,7 +597,7 @@ return $.widget( "ui.calendar", {
|
|||||||
if ( key in that.refreshRelatedOptions ) {
|
if ( key in that.refreshRelatedOptions ) {
|
||||||
refresh = true;
|
refresh = true;
|
||||||
}
|
}
|
||||||
});
|
} );
|
||||||
|
|
||||||
if ( refresh ) {
|
if ( refresh ) {
|
||||||
this._refresh();
|
this._refresh();
|
||||||
@ -642,6 +642,6 @@ return $.widget( "ui.calendar", {
|
|||||||
this.refresh();
|
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 ] ) {
|
if ( !element || !element[ 0 ] ) {
|
||||||
element = this.element.closest( ".ui-front" );
|
element = this.element.closest( ".ui-front, dialog" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !element.length ) {
|
if ( !element.length ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user