bootstrap-datepicker-rails 0.5 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -24,6 +24,7 @@
|
|
24
24
|
|
25
25
|
var Datepicker = function(element, options){
|
26
26
|
this.element = $(element);
|
27
|
+
this.language = options.language in dates ? options.language : "en";
|
27
28
|
this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');
|
28
29
|
this.picker = $(DPGlobal.template)
|
29
30
|
.appendTo('body')
|
@@ -132,7 +133,7 @@
|
|
132
133
|
},
|
133
134
|
|
134
135
|
setValue: function() {
|
135
|
-
var formated = DPGlobal.formatDate(this.date, this.format);
|
136
|
+
var formated = DPGlobal.formatDate(this.date, this.format, this.language);
|
136
137
|
if (!this.isInput) {
|
137
138
|
if (this.component){
|
138
139
|
this.element.find('input').prop('value', formated);
|
@@ -146,7 +147,7 @@
|
|
146
147
|
setStartDate: function(startDate){
|
147
148
|
this.startDate = startDate||-Infinity;
|
148
149
|
if (this.startDate !== -Infinity) {
|
149
|
-
this.startDate = DPGlobal.parseDate(this.startDate, this.format);
|
150
|
+
this.startDate = DPGlobal.parseDate(this.startDate, this.format, this.language);
|
150
151
|
}
|
151
152
|
this.update();
|
152
153
|
this.updateNavArrows();
|
@@ -155,7 +156,7 @@
|
|
155
156
|
setEndDate: function(endDate){
|
156
157
|
this.endDate = endDate||Infinity;
|
157
158
|
if (this.endDate !== Infinity) {
|
158
|
-
this.endDate = DPGlobal.parseDate(this.endDate, this.format);
|
159
|
+
this.endDate = DPGlobal.parseDate(this.endDate, this.format, this.language);
|
159
160
|
}
|
160
161
|
this.update();
|
161
162
|
this.updateNavArrows();
|
@@ -172,7 +173,7 @@
|
|
172
173
|
update: function(){
|
173
174
|
this.date = DPGlobal.parseDate(
|
174
175
|
this.isInput ? this.element.prop('value') : this.element.data('date'),
|
175
|
-
this.format
|
176
|
+
this.format, this.language
|
176
177
|
);
|
177
178
|
if (this.date < this.startDate) {
|
178
179
|
this.viewDate = new Date(this.startDate);
|
@@ -188,7 +189,7 @@
|
|
188
189
|
var dowCnt = this.weekStart;
|
189
190
|
var html = '<tr>';
|
190
191
|
while (dowCnt < this.weekStart + 7) {
|
191
|
-
html += '<th class="dow">'+
|
192
|
+
html += '<th class="dow">'+dates[this.language].daysMin[(dowCnt++)%7]+'</th>';
|
192
193
|
}
|
193
194
|
html += '</tr>';
|
194
195
|
this.picker.find('.datepicker-days thead').append(html);
|
@@ -198,7 +199,7 @@
|
|
198
199
|
var html = '';
|
199
200
|
var i = 0
|
200
201
|
while (i < 12) {
|
201
|
-
html += '<span class="month">'+
|
202
|
+
html += '<span class="month">'+dates[this.language].monthsShort[i++]+'</span>';
|
202
203
|
}
|
203
204
|
this.picker.find('.datepicker-months td').html(html);
|
204
205
|
},
|
@@ -213,7 +214,7 @@
|
|
213
214
|
endMonth = this.endDate !== Infinity ? this.endDate.getMonth() : Infinity,
|
214
215
|
currentDate = this.date.valueOf();
|
215
216
|
this.picker.find('.datepicker-days th:eq(1)')
|
216
|
-
.text(
|
217
|
+
.text(dates[this.language].months[month]+' '+year);
|
217
218
|
this.updateNavArrows();
|
218
219
|
this.fillMonths();
|
219
220
|
var prevMonth = new Date(year, month-1, 28,0,0,0,0),
|
@@ -525,7 +526,23 @@
|
|
525
526
|
$.fn.datepicker.defaults = {
|
526
527
|
};
|
527
528
|
$.fn.datepicker.Constructor = Datepicker;
|
528
|
-
|
529
|
+
var dates = $.fn.datepicker.dates = {
|
530
|
+
en: {
|
531
|
+
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
532
|
+
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
533
|
+
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
534
|
+
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
535
|
+
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
536
|
+
},
|
537
|
+
de: {
|
538
|
+
days: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"],
|
539
|
+
daysShort: ["Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam", "Son"],
|
540
|
+
daysMin: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"],
|
541
|
+
months: ["Januar", "Februar", "M\xe4rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"],
|
542
|
+
monthsShort: ["Jan", "Feb", "M\xe4r", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"]
|
543
|
+
}
|
544
|
+
}
|
545
|
+
|
529
546
|
var DPGlobal = {
|
530
547
|
modes: [
|
531
548
|
{
|
@@ -543,13 +560,6 @@
|
|
543
560
|
navFnc: 'FullYear',
|
544
561
|
navStep: 10
|
545
562
|
}],
|
546
|
-
dates:{
|
547
|
-
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
548
|
-
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
549
|
-
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
550
|
-
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
551
|
-
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
552
|
-
},
|
553
563
|
isLeapYear: function (year) {
|
554
564
|
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
|
555
565
|
},
|
@@ -564,7 +574,7 @@
|
|
564
574
|
}
|
565
575
|
return {separator: separator, parts: parts};
|
566
576
|
},
|
567
|
-
parseDate: function(date, format) {
|
577
|
+
parseDate: function(date, format, language) {
|
568
578
|
if (date instanceof Date) return date;
|
569
579
|
var parts = date ? date.split(format.separator) : [],
|
570
580
|
date = new Date(),
|
@@ -575,20 +585,20 @@
|
|
575
585
|
val = parseInt(parts[i], 10)||1;
|
576
586
|
switch(format.parts[i]) {
|
577
587
|
case 'MM':
|
578
|
-
filtered = $(
|
588
|
+
filtered = $(dates[language].months).filter(function(){
|
579
589
|
var m = this.slice(0, parts[i].length),
|
580
590
|
p = parts[i].slice(0, m.length);
|
581
591
|
return m == p;
|
582
592
|
});
|
583
|
-
val = $.inArray(filtered[0],
|
593
|
+
val = $.inArray(filtered[0], dates[language].months) + 1;
|
584
594
|
break;
|
585
595
|
case 'M':
|
586
|
-
filtered = $(
|
596
|
+
filtered = $(dates[language].monthsShort).filter(function(){
|
587
597
|
var m = this.slice(0, parts[i].length),
|
588
598
|
p = parts[i].slice(0, m.length);
|
589
599
|
return m == p;
|
590
600
|
});
|
591
|
-
val = $.inArray(filtered[0],
|
601
|
+
val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
|
592
602
|
break;
|
593
603
|
}
|
594
604
|
switch(format.parts[i]) {
|
@@ -613,12 +623,12 @@
|
|
613
623
|
}
|
614
624
|
return date;
|
615
625
|
},
|
616
|
-
formatDate: function(date, format){
|
626
|
+
formatDate: function(date, format, language){
|
617
627
|
var val = {
|
618
628
|
d: date.getDate(),
|
619
629
|
m: date.getMonth() + 1,
|
620
|
-
M:
|
621
|
-
MM:
|
630
|
+
M: dates[language].monthsShort[date.getMonth()],
|
631
|
+
MM: dates[language].months[date.getMonth()],
|
622
632
|
yy: date.getFullYear().toString().substring(2),
|
623
633
|
yyyy: date.getFullYear()
|
624
634
|
};
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap-datepicker-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -92,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
segments:
|
94
94
|
- 0
|
95
|
-
hash:
|
95
|
+
hash: 3212205110107691319
|
96
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: '0'
|
102
102
|
segments:
|
103
103
|
- 0
|
104
|
-
hash:
|
104
|
+
hash: 3212205110107691319
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project:
|
107
107
|
rubygems_version: 1.8.19
|