bootstrap-datepicker-rails 0.6.15 → 0.6.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module BootstrapDatepickerRails
2
2
  module Rails
3
- VERSION = "0.6.15"
3
+ VERSION = "0.6.16"
4
4
  end
5
5
  end
@@ -71,8 +71,15 @@
71
71
  } else if ('dateAutoclose' in this.element.data()) {
72
72
  this.autoclose = this.element.data('date-autoclose');
73
73
  }
74
-
75
- switch(options.startView){
74
+
75
+ this.keyboardNavigation = true;
76
+ if ('keyboardNavigation' in options) {
77
+ this.keyboardNavigation = options.keyboardNavigation;
78
+ } else if ('dateKeyboardNavigation' in this.element.data()) {
79
+ this.keyboardNavigation = this.element.data('date-keyboard-navigation');
80
+ }
81
+
82
+ switch(options.startView || this.element.data('date-start-view')){
76
83
  case 2:
77
84
  case 'decade':
78
85
  this.viewMode = this.startViewMode = 2;
@@ -106,6 +113,7 @@
106
113
  show: function(e) {
107
114
  this.picker.show();
108
115
  this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
116
+ this.update();
109
117
  this.place();
110
118
  $(window).on('resize', $.proxy(this.place, this));
111
119
  if (e ) {
@@ -163,14 +171,14 @@
163
171
  },
164
172
 
165
173
  setValue: function() {
166
- var formated = DPGlobal.formatDate(this.date, this.format, this.language);
174
+ var formatted = DPGlobal.formatDate(this.date, this.format, this.language);
167
175
  if (!this.isInput) {
168
176
  if (this.component){
169
- this.element.find('input').prop('value', formated);
177
+ this.element.find('input').prop('value', formatted);
170
178
  }
171
- this.element.data('date', formated);
179
+ this.element.data('date', formatted);
172
180
  } else {
173
- this.element.prop('value', formated);
181
+ this.element.prop('value', formatted);
174
182
  }
175
183
  },
176
184
 
@@ -193,10 +201,14 @@
193
201
  },
194
202
 
195
203
  place: function(){
204
+ var zIndex = parseInt(this.element.parents().filter(function() {
205
+ return $(this).css('z-index') != 'auto';
206
+ }).first().css('z-index'))+10;
196
207
  var offset = this.component ? this.component.offset() : this.element.offset();
197
208
  this.picker.css({
198
209
  top: offset.top + this.height,
199
- left: offset.left
210
+ left: offset.left,
211
+ zIndex: zIndex
200
212
  });
201
213
  },
202
214
 
@@ -248,13 +260,14 @@
248
260
  this.updateNavArrows();
249
261
  this.fillMonths();
250
262
  var prevMonth = new Date(year, month-1, 28,0,0,0,0),
251
- day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());
263
+ day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth()),
264
+ prevDate, dstDay = 0, date;
252
265
  prevMonth.setDate(day);
253
266
  prevMonth.setDate(day - (prevMonth.getDay() - this.weekStart + 7)%7);
254
267
  var nextMonth = new Date(prevMonth);
255
268
  nextMonth.setDate(nextMonth.getDate() + 42);
256
269
  nextMonth = nextMonth.valueOf();
257
- html = [];
270
+ var html = [];
258
271
  var clsName;
259
272
  while(prevMonth.valueOf() < nextMonth) {
260
273
  if (prevMonth.getDay() == this.weekStart) {
@@ -272,11 +285,42 @@
272
285
  if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate) {
273
286
  clsName += ' disabled';
274
287
  }
275
- html.push('<td class="day'+clsName+'">'+prevMonth.getDate() + '</td>');
288
+ date = prevMonth.getDate();
289
+ if (dstDay == -1) date++;
290
+ html.push('<td class="day'+clsName+'">'+date+ '</td>');
276
291
  if (prevMonth.getDay() == this.weekEnd) {
277
292
  html.push('</tr>');
278
293
  }
294
+ prevDate = prevMonth.getDate();
279
295
  prevMonth.setDate(prevMonth.getDate()+1);
296
+ if (prevMonth.getHours() != 0) {
297
+ // Fix for DST bug: if we are no longer at start of day, a DST jump probably happened
298
+ // We either fell back (eg, Jan 1 00:00 -> Jan 1 23:00)
299
+ // or jumped forward (eg, Jan 1 00:00 -> Jan 2 01:00)
300
+ // Unfortunately, I can think of no way to test this in the unit tests, as it depends
301
+ // on the TZ of the client system.
302
+ if (!dstDay) {
303
+ // We are not currently handling a dst day (next round will deal with it)
304
+ if (prevMonth.getDate() == prevDate)
305
+ // We must compensate for fall-back
306
+ dstDay = -1;
307
+ else
308
+ // We must compensate for a jump-ahead
309
+ dstDay = +1;
310
+ }
311
+ else {
312
+ // The last round was our dst day (hours are still non-zero)
313
+ if (dstDay == -1)
314
+ // For a fall-back, fast-forward to next midnight
315
+ prevMonth.setHours(24);
316
+ else
317
+ // For a jump-ahead, just reset to 0
318
+ prevMonth.setHours(0);
319
+ // Reset minutes, as some TZs may be off by portions of an hour
320
+ prevMonth.setMinutes(0);
321
+ dstDay = 0;
322
+ }
323
+ }
280
324
  }
281
325
  this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
282
326
  var currentYear = this.date.getFullYear();
@@ -380,9 +424,17 @@
380
424
  if (target.is('.month')) {
381
425
  var month = target.parent().find('span').index(target);
382
426
  this.viewDate.setMonth(month);
427
+ this.element.trigger({
428
+ type: 'changeMonth',
429
+ date: this.viewDate
430
+ });
383
431
  } else {
384
432
  var year = parseInt(target.text(), 10)||0;
385
433
  this.viewDate.setFullYear(year);
434
+ this.element.trigger({
435
+ type: 'changeYear',
436
+ date: this.viewDate
437
+ });
386
438
  }
387
439
  this.showMode(-1);
388
440
  this.fill();
@@ -483,6 +535,10 @@
483
535
  return this.moveMonth(date, dir*12);
484
536
  },
485
537
 
538
+ dateWithinRange: function(date){
539
+ return date >= this.startDate && date <= this.endDate;
540
+ },
541
+
486
542
  keydown: function(e){
487
543
  if (this.picker.is(':not(:visible)')){
488
544
  if (e.keyCode == 27) // allow escape to hide and re-show picker
@@ -490,7 +546,8 @@
490
546
  return;
491
547
  }
492
548
  var dateChanged = false,
493
- dir, day, month;
549
+ dir, day, month,
550
+ newDate, newViewDate;
494
551
  switch(e.keyCode){
495
552
  case 27: // escape
496
553
  this.hide();
@@ -498,39 +555,53 @@
498
555
  break;
499
556
  case 37: // left
500
557
  case 39: // right
558
+ if (!this.keyboardNavigation) break;
501
559
  dir = e.keyCode == 37 ? -1 : 1;
502
560
  if (e.ctrlKey){
503
- this.date = this.moveYear(this.date, dir);
504
- this.viewDate = this.moveYear(this.viewDate, dir);
561
+ newDate = this.moveYear(this.date, dir);
562
+ newViewDate = this.moveYear(this.viewDate, dir);
505
563
  } else if (e.shiftKey){
506
- this.date = this.moveMonth(this.date, dir);
507
- this.viewDate = this.moveMonth(this.viewDate, dir);
564
+ newDate = this.moveMonth(this.date, dir);
565
+ newViewDate = this.moveMonth(this.viewDate, dir);
508
566
  } else {
509
- this.date.setDate(this.date.getDate() + dir);
510
- this.viewDate.setDate(this.viewDate.getDate() + dir);
567
+ newDate = new Date(this.date);
568
+ newDate.setDate(this.date.getDate() + dir);
569
+ newViewDate = new Date(this.viewDate);
570
+ newViewDate.setDate(this.viewDate.getDate() + dir);
571
+ }
572
+ if (this.dateWithinRange(newDate)){
573
+ this.date = newDate;
574
+ this.viewDate = newViewDate;
575
+ this.setValue();
576
+ this.update();
577
+ e.preventDefault();
578
+ dateChanged = true;
511
579
  }
512
- this.setValue();
513
- this.update();
514
- e.preventDefault();
515
- dateChanged = true;
516
580
  break;
517
581
  case 38: // up
518
582
  case 40: // down
583
+ if (!this.keyboardNavigation) break;
519
584
  dir = e.keyCode == 38 ? -1 : 1;
520
585
  if (e.ctrlKey){
521
- this.date = this.moveYear(this.date, dir);
522
- this.viewDate = this.moveYear(this.viewDate, dir);
586
+ newDate = this.moveYear(this.date, dir);
587
+ newViewDate = this.moveYear(this.viewDate, dir);
523
588
  } else if (e.shiftKey){
524
- this.date = this.moveMonth(this.date, dir);
525
- this.viewDate = this.moveMonth(this.viewDate, dir);
589
+ newDate = this.moveMonth(this.date, dir);
590
+ newViewDate = this.moveMonth(this.viewDate, dir);
526
591
  } else {
527
- this.date.setDate(this.date.getDate() + dir * 7);
528
- this.viewDate.setDate(this.viewDate.getDate() + dir * 7);
592
+ newDate = new Date(this.date);
593
+ newDate.setDate(this.date.getDate() + dir * 7);
594
+ newViewDate = new Date(this.viewDate);
595
+ newViewDate.setDate(this.viewDate.getDate() + dir * 7);
596
+ }
597
+ if (this.dateWithinRange(newDate)){
598
+ this.date = newDate;
599
+ this.viewDate = newViewDate;
600
+ this.setValue();
601
+ this.update();
602
+ e.preventDefault();
603
+ dateChanged = true;
529
604
  }
530
- this.setValue();
531
- this.update();
532
- e.preventDefault();
533
- dateChanged = true;
534
605
  break;
535
606
  case 13: // enter
536
607
  this.hide();
@@ -573,7 +644,9 @@
573
644
  if (!data) {
574
645
  $this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options))));
575
646
  }
576
- if (typeof option == 'string') data[option].apply(data, args);
647
+ if (typeof option == 'string' && typeof data[option] == 'function') {
648
+ data[option].apply(data, args);
649
+ }
577
650
  });
578
651
  };
579
652
 
@@ -652,7 +725,7 @@
652
725
  }
653
726
  return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
654
727
  }
655
- var parts = date ? date.match(this.nonpunctuation) : [],
728
+ var parts = date && date.match(this.nonpunctuation) || [],
656
729
  date = new Date(),
657
730
  parsed = {},
658
731
  setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
@@ -758,4 +831,4 @@
758
831
  '</div>'+
759
832
  '</div>';
760
833
 
761
- }( window.jQuery )
834
+ }( window.jQuery );
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Bahasa translation for bootstrap-datepicker
3
+ * Azwar Akbar <azwar.akbar@gmail.com>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['id'] = {
7
+ days: ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu", "Minggu"],
8
+ daysShort: ["Mgu", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab", "Mgu"],
9
+ daysMin: ["Mg", "Sn", "Sl", "Ra", "Ka", "Ju", "Sa", "Mg"],
10
+ months: ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"],
11
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Ags", "Sep", "Okt", "Nov", "Des"]
12
+ };
13
+ }(jQuery));
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Japanese translation for bootstrap-datepicker
3
+ * Norio Suzuki <https://github.com/suzuki/>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['ja'] = {
7
+ days: ["日曜", "月曜", "火曜", "水曜", "木曜", "金曜", "土曜", "日曜"],
8
+ daysShort: ["日", "月", "火", "水", "木", "金", "土", "日"],
9
+ daysMin: ["日", "月", "火", "水", "木", "金", "土", "日"],
10
+ months: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
11
+ monthsShort: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]
12
+ };
13
+ }(jQuery));
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Korean translation for bootstrap-datepicker
3
+ * Gu Youn <http://github.com/guyoun>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['kr'] = {
7
+ days: ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일", "일요일"],
8
+ daysShort: ["일", "월", "화", "수", "목", "금", "토", "일"],
9
+ daysMin: ["일", "월", "화", "수", "목", "금", "토", "일"],
10
+ months: ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"],
11
+ monthsShort: ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"],
12
+ };
13
+ }(jQuery));
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Lithuanian translation for bootstrap-datepicker
3
+ * Šarūnas Gliebus <ssharunas@yahoo.co.uk>
4
+ */
5
+
6
+ ;(function($){
7
+ $.fn.datepicker.dates['lt'] = {
8
+ days: ["Sekmadienis", "Pirmadienis", "Antradienis", "Trečiadienis", "Ketvirtadienis", "Penktadienis", "Šeštadienis", "Sekmadienis"],
9
+ daysShort: ["S", "Pr", "A", "T", "K", "Pn", "Š", "S"],
10
+ daysMin: ["Sk", "Pr", "An", "Tr", "Ke", "Pn", "Št", "Sk"],
11
+ months: ["Sausis", "Vasaris", "Kovas", "Balandis", "Gegužė", "Birželis", "Liepa", "Rugpjūtis", "Rugsėjis", "Spalis", "Lapkritis", "Gruodis"],
12
+ monthsShort: ["Sau", "Vas", "Kov", "Bal", "Geg", "Bir", "Lie", "Rugp", "Rugs", "Spa", "Lap", "Gru"],
13
+ weekStart: 1
14
+ };
15
+ }(jQuery));
@@ -3,7 +3,7 @@
3
3
  * Ateman Faiz <noorulfaiz@gmail.com>
4
4
  */
5
5
  ;(function($){
6
- $.fn.datepicker.dates['de'] = {
6
+ $.fn.datepicker.dates['ms'] = {
7
7
  days: ["Ahad", "Isnin", "Selasa", "Rabu", "Khamis", "Jumaat", "Sabtu", "Ahad"],
8
8
  daysShort: ["Aha", "Isn", "Sel", "Rab", "Kha", "Jum", "Sab", "Aha"],
9
9
  daysMin: ["Ah", "Is", "Se", "Ra", "Kh", "Ju", "Sa", "Ah"],
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Portuguese translation for bootstrap-datepicker
3
+ * Original code: Cauan Cabral <cauan@radig.com.br>
4
+ * Tiago Melo <tiago.blackcode@gmail.com>
5
+ */
6
+ ;(function($){
7
+ $.fn.datepicker.dates['pt'] = {
8
+ days: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo"],
9
+ daysShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb", "Dom"],
10
+ daysMin: ["Do", "Se", "Te", "Qu", "Qu", "Se", "Sa", "Do"],
11
+ months: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
12
+ monthsShort: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"]
13
+ };
14
+ }(jQuery));
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Traditional Chinese translation for bootstrap-datepicker
3
+ * Rung-Sheng Jang <daniel@i-trend.co.cc>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['zh-TW'] = {
7
+ days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
8
+ daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
9
+ daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
10
+ months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
11
+ monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]
12
+ };
13
+ }(jQuery));
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: 0.6.15
4
+ version: 0.6.16
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-06-23 00:00:00.000000000 Z
12
+ date: 2012-07-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -85,18 +85,24 @@ files:
85
85
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.es.js
86
86
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.fi.js
87
87
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.fr.js
88
+ - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.id.js
88
89
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.is.js
89
90
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.it.js
91
+ - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ja.js
92
+ - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.kr.js
93
+ - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.lt.js
90
94
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.lv.js
91
95
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ms.js
92
96
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.nb.js
93
97
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.nl.js
94
98
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.pl.js
99
+ - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.pt.js
95
100
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ru.js
96
101
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.sv.js
97
102
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.th.js
98
103
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.tr.js
99
104
  - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.js
105
+ - vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.zh-TW.js
100
106
  - vendor/assets/stylesheets/bootstrap-datepicker.css
101
107
  homepage: https://github.com/Nerian/bootstrap-datepicker-rails
102
108
  licenses: []
@@ -112,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
118
  version: '0'
113
119
  segments:
114
120
  - 0
115
- hash: -1080936430256417505
121
+ hash: 2327091248764895784
116
122
  required_rubygems_version: !ruby/object:Gem::Requirement
117
123
  none: false
118
124
  requirements:
@@ -121,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
127
  version: '0'
122
128
  segments:
123
129
  - 0
124
- hash: -1080936430256417505
130
+ hash: 2327091248764895784
125
131
  requirements: []
126
132
  rubyforge_project:
127
133
  rubygems_version: 1.8.24