mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Calendar: Re-introduce formatDate option
This commit is contained in:
parent
f9ba50df66
commit
6db02da67c
@ -9,6 +9,7 @@ common.testWidget( "calendar", {
|
|||||||
buttons: [],
|
buttons: [],
|
||||||
classes: {},
|
classes: {},
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
dateFormat: { date: "short" },
|
||||||
eachDay: $.noop,
|
eachDay: $.noop,
|
||||||
labels: {
|
labels: {
|
||||||
"datePickerRole": "date picker",
|
"datePickerRole": "date picker",
|
||||||
|
@ -39,6 +39,7 @@ return $.widget( "ui.calendar", {
|
|||||||
version: "@VERSION",
|
version: "@VERSION",
|
||||||
options: {
|
options: {
|
||||||
buttons: [],
|
buttons: [],
|
||||||
|
dateFormat: { date: "short" },
|
||||||
eachDay: $.noop,
|
eachDay: $.noop,
|
||||||
labels: {
|
labels: {
|
||||||
"datePickerRole": "date picker",
|
"datePickerRole": "date picker",
|
||||||
@ -58,7 +59,9 @@ return $.widget( "ui.calendar", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
refreshRelatedOptions: {
|
refreshRelatedOptions: {
|
||||||
|
dateFormat: true,
|
||||||
eachDay: true,
|
eachDay: true,
|
||||||
|
locale: true,
|
||||||
max: true,
|
max: true,
|
||||||
min: true,
|
min: true,
|
||||||
showWeek: true,
|
showWeek: true,
|
||||||
@ -70,7 +73,7 @@ return $.widget( "ui.calendar", {
|
|||||||
this.labels = this.options.labels;
|
this.labels = this.options.labels;
|
||||||
this.buttonClickContext = this.element[ 0 ];
|
this.buttonClickContext = this.element[ 0 ];
|
||||||
|
|
||||||
this._setLocale( this.options.locale );
|
this._setLocale( this.options.locale, this.options.dateFormat );
|
||||||
|
|
||||||
this.date = new $.ui.calendarDate( this.options.value, this._calendarDateOptions );
|
this.date = new $.ui.calendarDate( this.options.value, this._calendarDateOptions );
|
||||||
this.viewDate = this.date.clone();
|
this.viewDate = this.date.clone();
|
||||||
@ -177,13 +180,13 @@ return $.widget( "ui.calendar", {
|
|||||||
).addClass( "ui-state-focus" );
|
).addClass( "ui-state-focus" );
|
||||||
},
|
},
|
||||||
|
|
||||||
_setLocale: function( locale ) {
|
_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({ date: "short" });
|
this._format = globalize.dateFormatter( dateFormat );
|
||||||
this._parse = globalize.dateParser({ date: "short" });
|
this._parse = globalize.dateParser( dateFormat );
|
||||||
this._calendarDateOptions = {
|
this._calendarDateOptions = {
|
||||||
firstDay: globalize.cldr.supplemental.weekData.firstDay(),
|
firstDay: globalize.cldr.supplemental.weekData.firstDay(),
|
||||||
formatWeekdayShort: function( date ) {
|
formatWeekdayShort: function( date ) {
|
||||||
@ -590,7 +593,8 @@ return $.widget( "ui.calendar", {
|
|||||||
|
|
||||||
_setOptions: function( options ) {
|
_setOptions: function( options ) {
|
||||||
var that = this,
|
var that = this,
|
||||||
refresh = false;
|
refresh = false,
|
||||||
|
dateAttributes = false;
|
||||||
|
|
||||||
$.each( options, function( key, value ) {
|
$.each( options, function( key, value ) {
|
||||||
that._setOption( key, value );
|
that._setOption( key, value );
|
||||||
@ -598,8 +602,16 @@ return $.widget( "ui.calendar", {
|
|||||||
if ( key in that.refreshRelatedOptions ) {
|
if ( key in that.refreshRelatedOptions ) {
|
||||||
refresh = true;
|
refresh = true;
|
||||||
}
|
}
|
||||||
|
if ( key === "dateFormat" || key === "locale" ) {
|
||||||
|
dateAttributes = true;
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
if ( dateAttributes ) {
|
||||||
|
this._setLocale( this.options.locale, this.options.dateFormat );
|
||||||
|
this.date.setAttributes( this._calendarDateOptions );
|
||||||
|
this.viewDate.setAttributes( this._calendarDateOptions );
|
||||||
|
}
|
||||||
if ( refresh ) {
|
if ( refresh ) {
|
||||||
this._refresh();
|
this._refresh();
|
||||||
}
|
}
|
||||||
@ -636,12 +648,6 @@ return $.widget( "ui.calendar", {
|
|||||||
if ( key === "eachDay" ) {
|
if ( key === "eachDay" ) {
|
||||||
this.viewDate.eachDay = value;
|
this.viewDate.eachDay = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( key === "locale" ) {
|
|
||||||
this._setLocale( value );
|
|
||||||
this.date.setAttributes( this._calendarDateOptions );
|
|
||||||
this.refresh();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user