0
if(typeof Prototype == 'undefined' || parseFloat(Prototype.Version.substring(0, 3)) < 1.6)
0
throw 'Timeframe requires Prototype version 1.6 or greater.';
0
-var Localizations = $H({
0
- // More localizations included in 'timeframe_localizations.js'
0
- months: $w('January February March April May June July August September October November December'),
0
- weekdays: $w('Sunday Monday Tuesday Wednesday Thursday Friday Saturday'),
0
+// Checks for localized Datejs before defaulting to 'en-US'
0
+ format: (typeof Date.CultureInfo == 'undefined' ? '%b %d, %Y' : Date.CultureInfo.formatPatterns.shortDate),
0
+ monthNames: (typeof Date.CultureInfo == 'undefined' ? $w('January February March April May June July August September October November December') : Date.CultureInfo.monthNames),
0
+ dayNames: (typeof Date.CultureInfo == 'undefined' ? $w('Sunday Monday Tuesday Wednesday Thursday Friday Saturday') : Date.CultureInfo.dayNames),
0
+ weekOffset: (typeof Date.CultureInfo == 'undefined' ? 0 : Date.CultureInfo.firstDayOfWeek)
0
this.element = $(element);
0
- this.options = $H({ months: 2
, locale: 'US' }).merge(options || {});;
0
+ this.options = $H({ months: 2
}).merge(options || {});;
0
this.months = this.options.get('months');
0
- this.locale = this.options.get('locale').toUpperCase();
0
- this.weekdayNames = Localizations.get(this.locale).get('weekdays');
0
- this.monthNames = Localizations.get(this.locale).get('months');
0
- this.format = this.options.get('format') || Localizations.get(this.locale).get('format');
0
- this.weekOffset = this.options.get('weekOffset') || Localizations.get(this.locale).get('weekOffset');
0
+ this.weekdayNames = Locale.get('dayNames');
0
+ this.monthNames = Locale.get('monthNames');
0
+ this.format = this.options.get('format') || Locale.get('format');
0
+ this.weekOffset = this.options.get('weekOffset') || Locale.get('weekOffset');
0
previous: $H({ label: '←', element: $(this.options.get('previousButton')) }),
0
refreshField: function(fieldName) {
0
var field = this.fields.get(fieldName);
0
var initValue = field.value;
0
- field.value = this.range.get(fieldName) ? this.range.get(fieldName).strftime(this.format, this.locale) : '';
0
+ if(this.range.get(fieldName)) {
0
+ field.value = typeof Date.CultureInfo == 'undefined' ? this.range.get(fieldName).strftime(this.format) : this.range.get(fieldName).toString(this.format);
0
field.hasFocus && field.value == '' && initValue != '' ? field.addClassName('error') : field.removeClassName('error');
0
field.hasFocus = false;
0
Object.extend(Date.prototype, {
0
// modified from http://alternateidea.com/blog/articles/2008/2/8/a-strftime-for-prototype
0
- strftime: function(format
, locale) {
0
+ strftime: function(format
) {
0
var day = this.getDay(), month = this.getMonth();
0
var hours = this.getHours(), minutes = this.getMinutes();
0
function pad(num) { return num.toPaddedString(2); };
0
return format.gsub(/\%([aAbBcdHImMpSwyY])/, function(part) {
0
- case 'a': return Localizations.get(locale).get('weekdays').invoke('substring', 0, 3)[day].escapeHTML(); break;
0
- case 'A': return Localizations.get(locale).get('weekdays')[day].escapeHTML(); break;
0
- case 'b': return Localizations.get(locale).get('months').invoke('substring', 0, 3)[month].escapeHTML(); break;
0
- case 'B': return Localizations.get(locale).get('months')[month].escapeHTML(); break;
0
+ case 'a': return Locale.get('dayNames').invoke('substring', 0, 3)[day].escapeHTML(); break;
0
+ case 'A': return Locale.get('dayNames')[day].escapeHTML(); break;
0
+ case 'b': return Locale.get('monthNames').invoke('substring', 0, 3)[month].escapeHTML(); break;
0
+ case 'B': return Locale.get('monthNames')[month].escapeHTML(); break;
0
case 'c': return this.toString(); break;
0
case 'd': return pad(this.getDate()); break;
0
case 'H': return pad(hours); break;
Comments
No one has commented yet.