{/if}
WCF.Language.addObject({
+ '__days': [ '{lang}wcf.date.day.sunday{/lang}', '{lang}wcf.date.day.monday{/lang}', '{lang}wcf.date.day.tuesday{/lang}', '{lang}wcf.date.day.wednesday{/lang}', '{lang}wcf.date.day.thursday{/lang}', '{lang}wcf.date.day.friday{/lang}', '{lang}wcf.date.day.saturday{/lang}' ],
+ '__daysShort': [ '{lang}wcf.date.day.sun{/lang}', '{lang}wcf.date.day.mon{/lang}', '{lang}wcf.date.day.tue{/lang}', '{lang}wcf.date.day.wed{/lang}', '{lang}wcf.date.day.thu{/lang}', '{lang}wcf.date.day.fri{/lang}', '{lang}wcf.date.day.sat{/lang}' ],
+ '__months': [ '{lang}wcf.date.month.january{/lang}', '{lang}wcf.date.month.february{/lang}', '{lang}wcf.date.month.march{/lang}', '{lang}wcf.date.month.april{/lang}', '{lang}wcf.date.month.may{/lang}', '{lang}wcf.date.month.june{/lang}', '{lang}wcf.date.month.july{/lang}', '{lang}wcf.date.month.august{/lang}', '{lang}wcf.date.month.september{/lang}', '{lang}wcf.date.month.october{/lang}', '{lang}wcf.date.month.november{/lang}', '{lang}wcf.date.month.december{/lang}' ],
+ '__monthsShort': [ '{lang}wcf.date.month.jan{/lang}', '{lang}wcf.date.month.feb{/lang}', '{lang}wcf.date.month.mar{/lang}', '{lang}wcf.date.month.apr{/lang}', '{lang}wcf.date.month.may{/lang}', '{lang}wcf.date.month.jun{/lang}', '{lang}wcf.date.month.jul{/lang}', '{lang}wcf.date.month.aug{/lang}', '{lang}wcf.date.month.sep{/lang}', '{lang}wcf.date.month.oct{/lang}', '{lang}wcf.date.month.nov{/lang}', '{lang}wcf.date.month.dec{/lang}' ],
'wcf.global.button.add': '{lang}wcf.global.button.add{/lang}',
'wcf.global.button.cancel': '{lang}wcf.global.button.cancel{/lang}',
'wcf.global.button.close': '{lang}wcf.global.button.close{/lang}',
'wcf.date.relative.minutes': '{capture assign=relativeMinutes}{lang}wcf.date.relative.minutes{/lang}{/capture}{@$relativeMinutes|encodeJS}',
'wcf.date.relative.hours': '{capture assign=relativeHours}{lang}wcf.date.relative.hours{/lang}{/capture}{@$relativeHours|encodeJS}',
'wcf.date.relative.pastDays': '{capture assign=relativePastDays}{lang}wcf.date.relative.pastDays{/lang}{/capture}{@$relativePastDays|encodeJS}',
+ 'wcf.date.dateFormat': '{lang}wcf.date.dateFormat{/lang}',
'wcf.date.dateTimeFormat': '{lang}wcf.date.dateTimeFormat{/lang}',
- '__days': [ '{lang}wcf.date.day.sunday{/lang}', '{lang}wcf.date.day.monday{/lang}', '{lang}wcf.date.day.tuesday{/lang}', '{lang}wcf.date.day.wednesday{/lang}', '{lang}wcf.date.day.thursday{/lang}', '{lang}wcf.date.day.friday{/lang}', '{lang}wcf.date.day.saturday{/lang}' ],
'wcf.global.thousandsSeparator': '{capture assign=thousandsSeparator}{lang}wcf.global.thousandsSeparator{/lang}{/capture}{@$thousandsSeparator|encodeJS}',
'wcf.global.decimalPoint': '{capture assign=decimalPoint}{lang}wcf.global.decimalPoint{/lang}{/capture}{$decimalPoint|encodeJS}',
'wcf.global.page.next': '{capture assign=pageNext}{lang}wcf.global.page.next{/lang}{/capture}{@$pageNext|encodeJS}',
* Convert PHPs date() format to jQuery UIs date picker format.
*/
_convertDateFormat: function() {
- var format = WCF.Language.get('wcf.date.dateFormat');
-
// replacement table
// format of PHP date() => format of jQuery UI date picker
//
// W ISO-8601 week number of year, weeks starting on Monday
// t Number of days in the given month
// L Whether it's a leap year
- var replacementTable = {
+ var $replacementTable = {
// day
'd': 'dd',
'D': 'D',
// do the actual replacement
// this is not perfect, but a basic implementation and should work in 99% of the cases
// TODO: support literals (magics are escaped in PHP date() by an \, in jQuery UI DatePicker they are enclosed in '')
- this._dateFormat = format.replace(/([^dDjlzFmMnoYyU\\]*(?:\\.[^dDjlzFmMnoYyU\\]*)*)([dDjlzFmMnoYyU])/g, function(match, part1, part2, offset, string) {
- $.each(replacementTable, function(key, item) {
- if(part2 == key) {
- part2 = item;
+ this._dateFormat = WCF.Language.get('wcf.date.dateFormat').replace(/([^dDjlzFmMnoYyU\\]*(?:\\.[^dDjlzFmMnoYyU\\]*)*)([dDjlzFmMnoYyU])/g, function(match, part1, part2, offset, string) {
+ for (var $key in $replacementTable) {
+ if (part2 == $key) {
+ part2 = $replacementTable[$key];
}
- });
+ }
+
return part1 + part2;
});
},
_initDatePicker: function() {
$('input[type=date]:not(.jsDatePicker)').each($.proxy(function(index, input) {
var $input = $(input);
- var inputName = $input.prop('name');
- var inputValue = $input.prop('value'); // should be Y-m-d, must be interpretable by Date
+ var $inputName = $input.prop('name');
+ var $inputValue = $input.prop('value'); // should be Y-m-d, must be interpretable by Date
// update $input
$input.prop('type', 'text').addClass('jsDatePicker');
// insert a hidden element representing the actual date
- $input.prop('name', inputName + 'Text')
- $input.before('<input type="hidden" id="' + $input.prop('id') + 'DatePicker" name="' + inputName + '" value="' + inputValue + '" />');
+ $input.removeAttr('name');
+ $input.before('<input type="hidden" id="' + $input.wcfIdentify() + 'DatePicker" name="' + $inputName + '" value="' + $inputValue + '" />');
// init date picker
$input.datepicker({
+ altField: '#' + $input.wcfIdentify() + 'DatePicker',
+ altFormat: 'yy-mm-dd', // PHPs strtotime() understands this best
changeMonth: true,
changeYear: true,
- showOtherMonths: true,
dateFormat: this._dateFormat,
- yearRange: '1900:2038', // TODO: make it configurable?
-
- altField: '#' + $input.prop('id') + 'DatePicker',
- altFormat: 'yy-mm-dd', // PHPs strtotime() understands this best
-
dayNames: WCF.Language.get('__days'),
dayNamesMin: WCF.Language.get('__daysShort'),
dayNamesShort: WCF.Language.get('__daysShort'),
monthNames: WCF.Language.get('__months'),
- monthNamesShort: WCF.Language.get('__monthsShort')
+ monthNamesShort: WCF.Language.get('__monthsShort'),
+ showOtherMonths: true,
+ yearRange: '1900:2038'
});
// format default date
- $input.datepicker('setDate', new Date(inputValue));
+ $input.datepicker('setDate', new Date($inputValue));
// bug workaround: setDate creates the widget but unfortunately doesn't hide it...
$input.datepicker('widget').hide();