bootstrap-datepicker-rails 1.4.0 → 1.5.0.RC1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bootstrap-datepicker-rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/bootstrap-datepicker/core.js +194 -56
  4. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.az.js +3 -3
  5. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.bg.js +3 -3
  6. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.bs.js +3 -3
  7. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ca.js +3 -3
  8. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.cs.js +4 -4
  9. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.cy.js +3 -3
  10. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.da.js +6 -5
  11. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.de.js +3 -3
  12. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.el.js +3 -3
  13. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.en-GB.js +3 -3
  14. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.eo.js +17 -0
  15. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.es.js +3 -3
  16. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.et.js +3 -3
  17. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.eu.js +5 -5
  18. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.fi.js +4 -3
  19. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.fo.js +3 -3
  20. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.fr-CH.js +3 -3
  21. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.fr.js +3 -3
  22. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.gl.js +3 -3
  23. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.hr.js +3 -3
  24. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.hu.js +8 -6
  25. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.hy.js +3 -3
  26. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.id.js +3 -3
  27. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.is.js +3 -3
  28. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.it-CH.js +3 -3
  29. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.it.js +3 -3
  30. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ja.js +4 -3
  31. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ka.js +3 -3
  32. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.kk.js +3 -3
  33. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ko.js +18 -0
  34. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.kr.js +7 -3
  35. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.lt.js +3 -3
  36. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.lv.js +3 -3
  37. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.me.js +3 -3
  38. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.mk.js +3 -3
  39. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.mn.js +17 -0
  40. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ms.js +5 -4
  41. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.nb.js +3 -3
  42. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.nl-BE.js +3 -3
  43. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.nl.js +3 -3
  44. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.no.js +5 -5
  45. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.pl.js +11 -10
  46. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.pt-BR.js +5 -4
  47. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.pt.js +5 -4
  48. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ro.js +3 -3
  49. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.rs-latin.js +3 -3
  50. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.rs.js +3 -3
  51. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ru.js +3 -3
  52. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.sk.js +5 -4
  53. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.sl.js +3 -3
  54. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.sq.js +3 -3
  55. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.sr-latin.js +3 -3
  56. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.sr.js +3 -3
  57. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.sv.js +3 -3
  58. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.sw.js +3 -3
  59. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.tr.js +3 -3
  60. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.uk.js +3 -3
  61. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.vi.js +3 -3
  62. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.js +7 -6
  63. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.zh-TW.js +6 -5
  64. data/vendor/assets/stylesheets/bootstrap-datepicker.css +42 -43
  65. data/vendor/assets/stylesheets/bootstrap-datepicker3.css +465 -426
  66. metadata +8 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12275b3675337b334e802880958e6feed1c83d69
4
- data.tar.gz: 2e857161bcceda4eadcff09b70d4bafc5310bba6
3
+ metadata.gz: 15ecea8a3e9f7cda2da55c618e307c679641baab
4
+ data.tar.gz: 04f89a02d7cba87dde841c93be2af82925a8cf5e
5
5
  SHA512:
6
- metadata.gz: 84753fc92289d03b14ed3cfaf1f525a634eb6d5a46590493cabdd4ac5a93756e47a1df0478a158ea35d342d6d162a170ac4e3f0af89a93c9a847ece3a2e96088
7
- data.tar.gz: 32f8bca100026f3e6f283be25e3ec2de9a5583a7ad65ce5d703e5540d4460606e24d749d6c4193c22bcf32553ec80cefeb0283f9fd2777d3f7d02b1ae4c7e57d
6
+ metadata.gz: 64d855e92ac2a8aa8b96c70c2cc6022a00646d45696d7b16a5c98706d537a8c89fdb14730e56818c24d7133bc5bb08b986965ab56521c06bf0ea25e5ecb04b5c
7
+ data.tar.gz: 7a2cfaa2f6a21652f66628623c6d1340b203d82233f524f8727abf3643c9f96438b9a5c91ed2dc5c8ed031a6f935232af2415ec2521a65007e0437926c3e713f
@@ -1,5 +1,5 @@
1
1
  module BootstrapDatepickerRails
2
2
  module Rails
3
- VERSION = "1.4.0"
3
+ VERSION = "1.5.0.RC1"
4
4
  end
5
5
  end
@@ -1,10 +1,18 @@
1
1
  /*!
2
- * Datepicker for Bootstrap v1.4.0 (https://github.com/eternicode/bootstrap-datepicker)
2
+ * Datepicker for Bootstrap v1.5.0-RC1 (https://github.com/eternicode/bootstrap-datepicker)
3
3
  *
4
4
  * Copyright 2012 Stefan Petre
5
5
  * Improvements by Andrew Rowls
6
6
  * Licensed under the Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0)
7
- */(function($, undefined){
7
+ */(function(factory){
8
+ if (typeof define === "function" && define.amd) {
9
+ define(["jquery"], factory);
10
+ } else if (typeof exports === 'object') {
11
+ factory(require('jquery'));
12
+ } else {
13
+ factory(jQuery);
14
+ }
15
+ }(function($, undefined){
8
16
 
9
17
  function UTCDate(){
10
18
  return new Date(Date.UTC.apply(Date, arguments));
@@ -25,6 +33,9 @@
25
33
  return this[method].apply(this, arguments);
26
34
  };
27
35
  }
36
+ function isValidDate(d) {
37
+ return d && !isNaN(d.getTime());
38
+ }
28
39
 
29
40
  var DateArray = (function(){
30
41
  var extras = {
@@ -115,6 +126,7 @@
115
126
  this.setStartDate(this._o.startDate);
116
127
  this.setEndDate(this._o.endDate);
117
128
  this.setDaysOfWeekDisabled(this.o.daysOfWeekDisabled);
129
+ this.setDaysOfWeekHighlighted(this.o.daysOfWeekHighlighted);
118
130
  this.setDatesDisabled(this.o.datesDisabled);
119
131
 
120
132
  this.fillDow();
@@ -175,6 +187,20 @@
175
187
  o.minViewMode = 0;
176
188
  }
177
189
 
190
+ switch (o.maxViewMode) {
191
+ case 0:
192
+ case 'days':
193
+ o.maxViewMode = 0;
194
+ break;
195
+ case 1:
196
+ case 'months':
197
+ o.maxViewMode = 1;
198
+ break;
199
+ default:
200
+ o.maxViewMode = 2;
201
+ }
202
+
203
+ o.startView = Math.min(o.startView, o.maxViewMode);
178
204
  o.startView = Math.max(o.startView, o.minViewMode);
179
205
 
180
206
  // true, false, or Number > 0
@@ -219,6 +245,13 @@
219
245
  return parseInt(d, 10);
220
246
  });
221
247
 
248
+ o.daysOfWeekHighlighted = o.daysOfWeekHighlighted||[];
249
+ if (!$.isArray(o.daysOfWeekHighlighted))
250
+ o.daysOfWeekHighlighted = o.daysOfWeekHighlighted.split(/[,\s]*/);
251
+ o.daysOfWeekHighlighted = $.map(o.daysOfWeekHighlighted, function(d){
252
+ return parseInt(d, 10);
253
+ });
254
+
222
255
  o.datesDisabled = o.datesDisabled||[];
223
256
  if (!$.isArray(o.datesDisabled)) {
224
257
  var datesDisabled = [];
@@ -269,6 +302,7 @@
269
302
  o.defaultViewDate = UTCToday();
270
303
  }
271
304
  o.showOnFocus = o.showOnFocus !== undefined ? o.showOnFocus : true;
305
+ o.zIndexOffset = o.zIndexOffset !== undefined ? o.zIndexOffset : 10;
272
306
  },
273
307
  _events: [],
274
308
  _secondaryEvents: [],
@@ -306,7 +340,8 @@
306
340
  if ($.inArray(e.keyCode, [27, 37, 39, 38, 40, 32, 13, 9]) === -1)
307
341
  this.update();
308
342
  }, this),
309
- keydown: $.proxy(this.keydown, this)
343
+ keydown: $.proxy(this.keydown, this),
344
+ paste: $.proxy(this.paste, this)
310
345
  };
311
346
 
312
347
  if (this.o.showOnFocus === true) {
@@ -352,6 +387,15 @@
352
387
  }]
353
388
  );
354
389
 
390
+ if (this.o.immediateUpdates) {
391
+ // Trigger input updates immediately on changed year/month
392
+ this._events.push([this.element, {
393
+ 'changeYear changeMonth': $.proxy(function(e){
394
+ this.update(e.date);
395
+ }, this)
396
+ }]);
397
+ }
398
+
355
399
  this._secondaryEvents = [
356
400
  [this.picker, {
357
401
  click: $.proxy(this.click, this)
@@ -360,13 +404,14 @@
360
404
  resize: $.proxy(this.place, this)
361
405
  }],
362
406
  [$(document), {
363
- 'mousedown touchstart': $.proxy(function(e){
407
+ mousedown: $.proxy(function(e){
364
408
  // Clicked outside the datepicker, hide it
365
409
  if (!(
366
410
  this.element.is(e.target) ||
367
411
  this.element.find(e.target).length ||
368
412
  this.picker.is(e.target) ||
369
- this.picker.find(e.target).length
413
+ this.picker.find(e.target).length ||
414
+ this.picker.hasClass('datepicker-inline')
370
415
  )){
371
416
  this.hide();
372
417
  }
@@ -462,6 +507,23 @@
462
507
  return this;
463
508
  },
464
509
 
510
+ paste: function(evt){
511
+ var dateString;
512
+ if (evt.originalEvent.clipboardData && evt.originalEvent.clipboardData.types
513
+ && $.inArray('text/plain', evt.originalEvent.clipboardData.types) !== -1) {
514
+ dateString = evt.originalEvent.clipboardData.getData('text/plain');
515
+ }
516
+ else if (window.clipboardData) {
517
+ dateString = window.clipboardData.getData('Text');
518
+ }
519
+ else {
520
+ return;
521
+ }
522
+ this.setDate(dateString);
523
+ this.update();
524
+ evt.preventDefault();
525
+ },
526
+
465
527
  _utc_to_local: function(utc){
466
528
  return utc && new Date(utc.getTime() + (utc.getTimezoneOffset()*60000));
467
529
  },
@@ -507,7 +569,7 @@
507
569
  }
508
570
 
509
571
  if (element) {
510
- element.val('').change();
572
+ element.val('');
511
573
  }
512
574
 
513
575
  this.update();
@@ -540,11 +602,11 @@
540
602
  var formatted = this.getFormattedDate();
541
603
  if (!this.isInput){
542
604
  if (this.component){
543
- this.element.find('input').val(formatted).change();
605
+ this.element.find('input').val(formatted);
544
606
  }
545
607
  }
546
608
  else {
547
- this.element.val(formatted).change();
609
+ this.element.val(formatted);
548
610
  }
549
611
  return this;
550
612
  },
@@ -580,6 +642,12 @@
580
642
  return this;
581
643
  },
582
644
 
645
+ setDaysOfWeekHighlighted: function(daysOfWeekHighlighted){
646
+ this._process_options({daysOfWeekHighlighted: daysOfWeekHighlighted});
647
+ this.update();
648
+ return this;
649
+ },
650
+
583
651
  setDatesDisabled: function(datesDisabled){
584
652
  this._process_options({datesDisabled: datesDisabled});
585
653
  this.update();
@@ -592,17 +660,17 @@
592
660
  var calendarWidth = this.picker.outerWidth(),
593
661
  calendarHeight = this.picker.outerHeight(),
594
662
  visualPadding = 10,
595
- windowWidth = $(this.o.container).width(),
596
- windowHeight = $(this.o.container).height(),
597
- scrollTop = $(this.o.container).scrollTop(),
598
- appendOffset = $(this.o.container).offset();
663
+ container = $(this.o.container),
664
+ windowWidth = container.width(),
665
+ scrollTop = container.scrollTop(),
666
+ appendOffset = container.offset();
599
667
 
600
668
  var parentsZindex = [];
601
669
  this.element.parents().each(function(){
602
670
  var itemZIndex = $(this).css('z-index');
603
671
  if (itemZIndex !== 'auto' && itemZIndex !== 0) parentsZindex.push(parseInt(itemZIndex));
604
672
  });
605
- var zIndex = Math.max.apply(Math, parentsZindex) + 10;
673
+ var zIndex = Math.max.apply(Math, parentsZindex) + this.o.zIndexOffset;
606
674
  var offset = this.component ? this.component.parent().offset() : this.element.offset();
607
675
  var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(false);
608
676
  var width = this.component ? this.component.outerWidth(true) : this.element.outerWidth(false);
@@ -639,20 +707,17 @@
639
707
  // auto y orientation is best-situation: top or bottom, no fudging,
640
708
  // decision based on which shows more of the calendar
641
709
  var yorient = this.o.orientation.y,
642
- top_overflow, bottom_overflow;
710
+ top_overflow;
643
711
  if (yorient === 'auto'){
644
712
  top_overflow = -scrollTop + top - calendarHeight;
645
- bottom_overflow = scrollTop + windowHeight - (top + height + calendarHeight);
646
- if (Math.max(top_overflow, bottom_overflow) === bottom_overflow)
647
- yorient = 'top';
648
- else
649
- yorient = 'bottom';
713
+ yorient = top_overflow < 0 ? 'bottom' : 'top';
650
714
  }
715
+
651
716
  this.picker.addClass('datepicker-orient-' + yorient);
652
717
  if (yorient === 'top')
653
- top += height;
654
- else
655
718
  top -= calendarHeight + parseInt(this.picker.css('padding-top'));
719
+ else
720
+ top += height;
656
721
 
657
722
  if (this.o.rtl) {
658
723
  var right = windowWidth - (left + width);
@@ -716,6 +781,8 @@
716
781
  this.viewDate = new Date(this.o.startDate);
717
782
  else if (this.viewDate > this.o.endDate)
718
783
  this.viewDate = new Date(this.o.endDate);
784
+ else
785
+ this.viewDate = this.o.defaultViewDate;
719
786
 
720
787
  if (fromArgs){
721
788
  // setting date by clicking
@@ -730,6 +797,7 @@
730
797
  this._trigger('clearDate');
731
798
 
732
799
  this.fill();
800
+ this.element.change();
733
801
  return this;
734
802
  },
735
803
 
@@ -737,12 +805,11 @@
737
805
  var dowCnt = this.o.weekStart,
738
806
  html = '<tr>';
739
807
  if (this.o.calendarWeeks){
740
- this.picker.find('.datepicker-days thead tr:first-child .datepicker-switch')
808
+ this.picker.find('.datepicker-days .datepicker-switch')
741
809
  .attr('colspan', function(i, val){
742
810
  return parseInt(val) + 1;
743
811
  });
744
- var cell = '<th class="cw">&#160;</th>';
745
- html += cell;
812
+ html += '<th class="cw">&#160;</th>';
746
813
  }
747
814
  while (dowCnt < this.o.weekStart + 7){
748
815
  html += '<th class="dow">'+dates[this.o.language].daysMin[(dowCnt++)%7]+'</th>';
@@ -796,6 +863,9 @@
796
863
  $.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1){
797
864
  cls.push('disabled');
798
865
  }
866
+ if ($.inArray(date.getUTCDay(), this.o.daysOfWeekHighlighted) !== -1){
867
+ cls.push('highlighted');
868
+ }
799
869
  if (this.o.datesDisabled.length > 0 &&
800
870
  $.grep(this.o.datesDisabled, function(d){
801
871
  return isUTCEquals(date, d); }).length > 0) {
@@ -809,6 +879,12 @@
809
879
  if ($.inArray(date.valueOf(), this.range) !== -1){
810
880
  cls.push('selected');
811
881
  }
882
+ if (date.valueOf() === this.range[0]){
883
+ cls.push('range-start');
884
+ }
885
+ if (date.valueOf() === this.range[this.range.length-1]){
886
+ cls.push('range-end');
887
+ }
812
888
  }
813
889
  return cls;
814
890
  },
@@ -823,17 +899,21 @@
823
899
  endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
824
900
  todaytxt = dates[this.o.language].today || dates['en'].today || '',
825
901
  cleartxt = dates[this.o.language].clear || dates['en'].clear || '',
902
+ titleFormat = dates[this.o.language].titleFormat || dates['en'].titleFormat,
826
903
  tooltip;
827
904
  if (isNaN(year) || isNaN(month))
828
905
  return;
829
906
  this.picker.find('.datepicker-days thead .datepicker-switch')
830
- .text(dates[this.o.language].months[month]+' '+year);
907
+ .text(DPGlobal.formatDate(new UTCDate(year, month), titleFormat, this.o.language));
831
908
  this.picker.find('tfoot .today')
832
909
  .text(todaytxt)
833
910
  .toggle(this.o.todayBtn !== false);
834
911
  this.picker.find('tfoot .clear')
835
912
  .text(cleartxt)
836
913
  .toggle(this.o.clearBtn !== false);
914
+ this.picker.find('thead .datepicker-title')
915
+ .text(this.o.title)
916
+ .toggle(this.o.title !== '');
837
917
  this.updateNavArrows();
838
918
  this.fillMonths();
839
919
  var prevMonth = UTCDate(year, month-1, 28),
@@ -841,6 +921,9 @@
841
921
  prevMonth.setUTCDate(day);
842
922
  prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.o.weekStart + 7)%7);
843
923
  var nextMonth = new Date(prevMonth);
924
+ if (prevMonth.getUTCFullYear() < 100){
925
+ nextMonth.setUTCFullYear(prevMonth.getUTCFullYear());
926
+ }
844
927
  nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
845
928
  nextMonth = nextMonth.valueOf();
846
929
  var html = [];
@@ -894,8 +977,8 @@
894
977
  this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
895
978
 
896
979
  var months = this.picker.find('.datepicker-months')
897
- .find('th:eq(1)')
898
- .text(year)
980
+ .find('.datepicker-switch')
981
+ .text(this.o.maxViewMode < 2 ? 'Months' : year)
899
982
  .end()
900
983
  .find('span').removeClass('active');
901
984
 
@@ -929,7 +1012,7 @@
929
1012
  html = '';
930
1013
  year = parseInt(year/10, 10) * 10;
931
1014
  var yearCont = this.picker.find('.datepicker-years')
932
- .find('th:eq(1)')
1015
+ .find('.datepicker-switch')
933
1016
  .text(year + '-' + (year + 9))
934
1017
  .end()
935
1018
  .find('td');
@@ -940,6 +1023,8 @@
940
1023
  classes;
941
1024
  for (var i = -1; i < 11; i++){
942
1025
  classes = ['year'];
1026
+ tooltip = null;
1027
+
943
1028
  if (i === -1)
944
1029
  classes.push('old');
945
1030
  else if (i === 10)
@@ -948,7 +1033,24 @@
948
1033
  classes.push('active');
949
1034
  if (year < startYear || year > endYear)
950
1035
  classes.push('disabled');
951
- html += '<span class="' + classes.join(' ') + '">' + year + '</span>';
1036
+
1037
+ if (this.o.beforeShowYear !== $.noop) {
1038
+ var yrBefore = this.o.beforeShowYear(new Date(year, 0, 1));
1039
+ if (yrBefore === undefined)
1040
+ yrBefore = {};
1041
+ else if (typeof(yrBefore) === 'boolean')
1042
+ yrBefore = {enabled: yrBefore};
1043
+ else if (typeof(yrBefore) === 'string')
1044
+ yrBefore = {classes: yrBefore};
1045
+ if (yrBefore.enabled === false)
1046
+ classes.push('disabled');
1047
+ if (yrBefore.classes)
1048
+ classes = classes.concat(yrBefore.classes.split(/\s+/));
1049
+ if (yrBefore.tooltip)
1050
+ tooltip = yrBefore.tooltip;
1051
+ }
1052
+
1053
+ html += '<span class="' + classes.join(' ') + '"' + (tooltip ? ' title="'+tooltip+'"' : '') + '>' + year + '</span>';
952
1054
  year += 1;
953
1055
  }
954
1056
  yearCont.html(html);
@@ -978,13 +1080,13 @@
978
1080
  break;
979
1081
  case 1:
980
1082
  case 2:
981
- if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear()){
1083
+ if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear() || this.o.maxViewMode < 2){
982
1084
  this.picker.find('.prev').css({visibility: 'hidden'});
983
1085
  }
984
1086
  else {
985
1087
  this.picker.find('.prev').css({visibility: 'visible'});
986
1088
  }
987
- if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear()){
1089
+ if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear() || this.o.maxViewMode < 2){
988
1090
  this.picker.find('.next').css({visibility: 'hidden'});
989
1091
  }
990
1092
  else {
@@ -996,6 +1098,7 @@
996
1098
 
997
1099
  click: function(e){
998
1100
  e.preventDefault();
1101
+ e.stopPropagation();
999
1102
  var target = $(e.target).closest('span, td, th'),
1000
1103
  year, month, day;
1001
1104
  if (target.length === 1){
@@ -1046,6 +1149,9 @@
1046
1149
  this._trigger('changeMonth', this.viewDate);
1047
1150
  if (this.o.minViewMode === 1){
1048
1151
  this._setDate(UTCDate(year, month, day));
1152
+ this.showMode();
1153
+ } else {
1154
+ this.showMode(-1);
1049
1155
  }
1050
1156
  }
1051
1157
  else {
@@ -1057,8 +1163,8 @@
1057
1163
  if (this.o.minViewMode === 2){
1058
1164
  this._setDate(UTCDate(year, month, day));
1059
1165
  }
1166
+ this.showMode(-1);
1060
1167
  }
1061
- this.showMode(-1);
1062
1168
  this.fill();
1063
1169
  }
1064
1170
  break;
@@ -1146,8 +1252,8 @@
1146
1252
  },
1147
1253
 
1148
1254
  moveMonth: function(date, dir){
1149
- if (!date)
1150
- return undefined;
1255
+ if (!isValidDate(date))
1256
+ return this.o.defaultViewDate;
1151
1257
  if (!dir)
1152
1258
  return date;
1153
1259
  var new_date = new Date(date.valueOf()),
@@ -1205,8 +1311,10 @@
1205
1311
 
1206
1312
  keydown: function(e){
1207
1313
  if (!this.picker.is(':visible')){
1208
- if (e.keyCode === 27) // allow escape to hide and re-show picker
1314
+ if (e.keyCode === 40 || e.keyCode === 27) { // allow down to re-show picker
1209
1315
  this.show();
1316
+ e.stopPropagation();
1317
+ }
1210
1318
  return;
1211
1319
  }
1212
1320
  var dateChanged = false,
@@ -1222,6 +1330,7 @@
1222
1330
  else
1223
1331
  this.hide();
1224
1332
  e.preventDefault();
1333
+ e.stopPropagation();
1225
1334
  break;
1226
1335
  case 37: // left
1227
1336
  case 39: // right
@@ -1284,6 +1393,9 @@
1284
1393
  // As such, its behavior should not be hijacked.
1285
1394
  break;
1286
1395
  case 13: // enter
1396
+ if (!this.o.forceParse) {
1397
+ break;
1398
+ }
1287
1399
  focusDate = this.focusDate || this.dates.get(-1) || this.viewDate;
1288
1400
  if (this.o.keyboardNavigation) {
1289
1401
  this._toggle_multidate(focusDate);
@@ -1331,13 +1443,13 @@
1331
1443
 
1332
1444
  showMode: function(dir){
1333
1445
  if (dir){
1334
- this.viewMode = Math.max(this.o.minViewMode, Math.min(2, this.viewMode + dir));
1446
+ this.viewMode = Math.max(this.o.minViewMode, Math.min(this.o.maxViewMode, this.viewMode + dir));
1335
1447
  }
1336
1448
  this.picker
1337
1449
  .children('div')
1338
1450
  .hide()
1339
1451
  .filter('.datepicker-' + DPGlobal.modes[this.viewMode].clsName)
1340
- .css('display', 'block');
1452
+ .show();
1341
1453
  this.updateNavArrows();
1342
1454
  }
1343
1455
  };
@@ -1350,7 +1462,7 @@
1350
1462
  delete options.inputs;
1351
1463
 
1352
1464
  datepickerPlugin.call($(this.inputs), options)
1353
- .bind('changeDate', $.proxy(this.dateUpdated, this));
1465
+ .on('changeDate', $.proxy(this.dateUpdated, this));
1354
1466
 
1355
1467
  this.pickers = $.map(this.inputs, function(i){
1356
1468
  return $(i).data('datepicker');
@@ -1380,8 +1492,13 @@
1380
1492
  return;
1381
1493
  this.updating = true;
1382
1494
 
1383
- var dp = $(e.target).data('datepicker'),
1384
- new_date = dp.getUTCDate(),
1495
+ var dp = $(e.target).data('datepicker');
1496
+
1497
+ if (typeof(dp) === "undefined") {
1498
+ return;
1499
+ }
1500
+
1501
+ var new_date = dp.getUTCDate(),
1385
1502
  i = $.inArray(e.target, this.inputs),
1386
1503
  j = i - 1,
1387
1504
  k = i + 1,
@@ -1479,14 +1596,20 @@
1479
1596
  }
1480
1597
  if (typeof option === 'string' && typeof data[option] === 'function'){
1481
1598
  internal_return = data[option].apply(data, args);
1482
- if (internal_return !== undefined)
1483
- return false;
1484
1599
  }
1485
1600
  });
1486
- if (internal_return !== undefined)
1487
- return internal_return;
1488
- else
1601
+
1602
+ if (
1603
+ internal_return === undefined ||
1604
+ internal_return instanceof Datepicker ||
1605
+ internal_return instanceof DateRangePicker
1606
+ )
1489
1607
  return this;
1608
+
1609
+ if (this.length > 1)
1610
+ throw new Error('Using only allowed for the collection of a single element (' + option + ' function)');
1611
+ else
1612
+ return internal_return;
1490
1613
  };
1491
1614
  $.fn.datepicker = datepickerPlugin;
1492
1615
 
@@ -1494,10 +1617,12 @@
1494
1617
  autoclose: false,
1495
1618
  beforeShowDay: $.noop,
1496
1619
  beforeShowMonth: $.noop,
1620
+ beforeShowYear: $.noop,
1497
1621
  calendarWeeks: false,
1498
1622
  clearBtn: false,
1499
1623
  toggleActive: false,
1500
1624
  daysOfWeekDisabled: [],
1625
+ daysOfWeekHighlighted: [],
1501
1626
  datesDisabled: [],
1502
1627
  endDate: Infinity,
1503
1628
  forceParse: true,
@@ -1505,6 +1630,7 @@
1505
1630
  keyboardNavigation: true,
1506
1631
  language: 'en',
1507
1632
  minViewMode: 0,
1633
+ maxViewMode: 2,
1508
1634
  multidate: false,
1509
1635
  multidateSeparator: ',',
1510
1636
  orientation: "auto",
@@ -1515,8 +1641,10 @@
1515
1641
  todayHighlight: false,
1516
1642
  weekStart: 0,
1517
1643
  disableTouchKeyboard: false,
1518
- enableOnReadonly: true,
1519
- container: 'body'
1644
+ enableOnReadonly: true,
1645
+ container: 'body',
1646
+ immediateUpdates: false,
1647
+ title: ''
1520
1648
  };
1521
1649
  var locale_opts = $.fn.datepicker.locale_opts = [
1522
1650
  'format',
@@ -1526,13 +1654,14 @@
1526
1654
  $.fn.datepicker.Constructor = Datepicker;
1527
1655
  var dates = $.fn.datepicker.dates = {
1528
1656
  en: {
1529
- days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
1530
- daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
1531
- daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
1657
+ days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
1658
+ daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
1659
+ daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
1532
1660
  months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
1533
1661
  monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
1534
1662
  today: "Today",
1535
- clear: "Clear"
1663
+ clear: "Clear",
1664
+ titleFormat: "MM yyyy"
1536
1665
  }
1537
1666
  };
1538
1667
 
@@ -1562,7 +1691,9 @@
1562
1691
  validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g,
1563
1692
  nonpunctuation: /[^ -\/:-@\[\u3400-\u9fff-`{-~\t\n\r]+/g,
1564
1693
  parseFormat: function(format){
1565
- // IE treats \0 as a string end in inputs (truncating the value),
1694
+ if (typeof format.toValue === 'function' && typeof format.toDisplay === 'function')
1695
+ return format;
1696
+ // IE treats \0 as a string end in inputs (truncating the value),
1566
1697
  // so it's a bad format delimiter, anyway
1567
1698
  var separators = format.replace(this.validParts, '\0').split('\0'),
1568
1699
  parts = format.match(this.validParts);
@@ -1578,7 +1709,9 @@
1578
1709
  return date;
1579
1710
  if (typeof format === 'string')
1580
1711
  format = DPGlobal.parseFormat(format);
1581
- var part_re = /([\-+]\d+)([dmwy])/,
1712
+ if (format.toValue)
1713
+ return format.toValue(date, format, language);
1714
+ var part_re = /([\-+]\d+)([dmwy])/,
1582
1715
  parts = date.match(/([\-+]\d+)([dmwy])/g),
1583
1716
  part, dir, i;
1584
1717
  if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)){
@@ -1683,7 +1816,9 @@
1683
1816
  return '';
1684
1817
  if (typeof format === 'string')
1685
1818
  format = DPGlobal.parseFormat(format);
1686
- var val = {
1819
+ if (format.toDisplay)
1820
+ return format.toDisplay(date, format, language);
1821
+ var val = {
1687
1822
  d: date.getUTCDate(),
1688
1823
  D: dates[language].daysShort[date.getUTCDay()],
1689
1824
  DD: dates[language].days[date.getUTCDay()],
@@ -1705,6 +1840,9 @@
1705
1840
  return date.join('');
1706
1841
  },
1707
1842
  headTemplate: '<thead>'+
1843
+ '<tr>'+
1844
+ '<th colspan="7" class="datepicker-title"></th>'+
1845
+ '</tr>'+
1708
1846
  '<tr>'+
1709
1847
  '<th class="prev">&#171;</th>'+
1710
1848
  '<th colspan="5" class="datepicker-switch"></th>'+
@@ -1758,7 +1896,7 @@
1758
1896
 
1759
1897
  /* DATEPICKER VERSION
1760
1898
  * =================== */
1761
- $.fn.datepicker.version = "1.4.0";
1899
+ $.fn.datepicker.version = '1.5.0-RC1';
1762
1900
 
1763
1901
  /* DATEPICKER DATA-API
1764
1902
  * ================== */
@@ -1779,4 +1917,4 @@
1779
1917
  datepickerPlugin.call($('[data-provide="datepicker-inline"]'));
1780
1918
  });
1781
1919
 
1782
- }(window.jQuery));
1920
+ }));