bootstrap-datepicker-rails 1.1.1.8 → 1.1.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9d536c3bdbaa776f1c8f3a42145c06d970a9fbd
4
- data.tar.gz: 83ee8ab252a0aa667e9261feb5c02fc5b6d532fd
3
+ metadata.gz: 2b67d91889fdbdfcadbc24a7982e1222b07270b1
4
+ data.tar.gz: cfadc7c156613bdb3eecb92a5f23f0e6ea8368f6
5
5
  SHA512:
6
- metadata.gz: 3beb62c5cb434b71adc8b73945c2ea4ba9b0e99137d3bf532b8c087bf286e331247b9376cdae4e37cdc6805efd831b9d68dc14ee99e6c791933a2887e2c82361
7
- data.tar.gz: e3512ad92ef00e6b8be66eb710454d5d89c2bf7b6649352a60d595e20fb3005bbeedc68b5da624cac4ce4bcdc0b6ae349daa742490f5a147d6685bea5e713be1
6
+ metadata.gz: 669c6a3f62fc9d4ce5e826c4c6639d0670cceec539e78af67567683fbc43188eb4677823cd7a30a4c84f5daf2d695c095bd04690424680d8653096c6426dc284
7
+ data.tar.gz: d85bddf9ca777cb72f87339b86675af85516f62cff9cc4853a156d70d06b4753cf150248735c081a49606e3b431b58199f69a8abc087bf4c9bb50a8326419121
@@ -1,5 +1,5 @@
1
1
  module BootstrapDatepickerRails
2
2
  module Rails
3
- VERSION = "1.1.1.8"
3
+ VERSION = "1.1.1.9"
4
4
  end
5
5
  end
@@ -20,7 +20,7 @@
20
20
  * limitations under the License.
21
21
  * ========================================================= */
22
22
 
23
- (function( $ ) {
23
+ (function($, undefined) {
24
24
 
25
25
  var $window = $(window);
26
26
 
@@ -29,14 +29,15 @@
29
29
  }
30
30
  function UTCToday(){
31
31
  var today = new Date();
32
- return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
32
+ return UTCDate(today.getFullYear(), today.getMonth(), today.getDate());
33
33
  }
34
34
 
35
35
 
36
36
  // Picker object
37
37
 
38
38
  var Datepicker = function(element, options) {
39
- var that = this;
39
+ this.date = undefined;
40
+ this.viewDate = UTCToday();
40
41
 
41
42
  this._process_options(options);
42
43
 
@@ -64,7 +65,6 @@
64
65
  .toggleClass('icon-arrow-left icon-arrow-right');
65
66
  }
66
67
 
67
-
68
68
  this.viewMode = this.o.startView;
69
69
 
70
70
  if (this.o.calendarWeeks)
@@ -224,7 +224,7 @@
224
224
  this._events = [
225
225
  [this.element, {
226
226
  focus: $.proxy(this.show, this),
227
- keyup: $.proxy(this.update, this),
227
+ keyup: $.proxy(function(){ this.update() }, this),
228
228
  keydown: $.proxy(this.keydown, this)
229
229
  }]
230
230
  ];
@@ -234,7 +234,7 @@
234
234
  // For components that are not readonly, allow keyboard nav
235
235
  [this.element.find('input'), {
236
236
  focus: $.proxy(this.show, this),
237
- keyup: $.proxy(this.update, this),
237
+ keyup: $.proxy(function(){ this.update() }, this),
238
238
  keydown: $.proxy(this.keydown, this)
239
239
  }],
240
240
  [this.component, {
@@ -316,7 +316,7 @@
316
316
  this._trigger('show');
317
317
  },
318
318
 
319
- hide: function(e){
319
+ hide: function(){
320
320
  if(this.isInline) return;
321
321
  if (!this.picker.is(':visible')) return;
322
322
  this.picker.hide().detach();
@@ -347,16 +347,16 @@
347
347
  },
348
348
 
349
349
  _utc_to_local: function(utc){
350
- return new Date(utc.getTime() + (utc.getTimezoneOffset()*60000));
350
+ return utc && new Date(utc.getTime() + (utc.getTimezoneOffset()*60000));
351
351
  },
352
352
  _local_to_utc: function(local){
353
- return new Date(local.getTime() - (local.getTimezoneOffset()*60000));
353
+ return local && new Date(local.getTime() - (local.getTimezoneOffset()*60000));
354
354
  },
355
355
  _zero_time: function(local){
356
- return new Date(local.getFullYear(), local.getMonth(), local.getDate());
356
+ return local && new Date(local.getFullYear(), local.getMonth(), local.getDate());
357
357
  },
358
358
  _zero_utc_time: function(utc){
359
- return new Date(Date.UTC(utc.getUTCFullYear(), utc.getUTCMonth(), utc.getUTCDate()));
359
+ return utc && new Date(Date.UTC(utc.getUTCFullYear(), utc.getUTCMonth(), utc.getUTCDate()));
360
360
  },
361
361
 
362
362
  getDate: function() {
@@ -479,9 +479,9 @@
479
479
  update: function(){
480
480
  if (!this._allow_update) return;
481
481
 
482
- var oldDate = new Date(this.date),
482
+ var oldDate = this.date && new Date(this.date),
483
483
  date, fromArgs = false;
484
- if(arguments && arguments.length && (typeof arguments[0] === 'string' || arguments[0] instanceof Date)) {
484
+ if(arguments.length) {
485
485
  date = arguments[0];
486
486
  if (date instanceof Date)
487
487
  date = this._local_to_utc(date);
@@ -493,28 +493,30 @@
493
493
 
494
494
  this.date = DPGlobal.parseDate(date, this.o.format, this.o.language);
495
495
 
496
- if (fromArgs) {
497
- // setting date by clicking
498
- this.setValue();
499
- } else if (date) {
500
- // setting date by typing
501
- if (oldDate.getTime() !== this.date.getTime())
502
- this._trigger('changeDate');
503
- } else {
504
- // clearing date
505
- this._trigger('clearDate');
506
- }
507
-
508
496
  if (this.date < this.o.startDate) {
509
497
  this.viewDate = new Date(this.o.startDate);
510
498
  this.date = new Date(this.o.startDate);
511
499
  } else if (this.date > this.o.endDate) {
512
500
  this.viewDate = new Date(this.o.endDate);
513
501
  this.date = new Date(this.o.endDate);
514
- } else {
502
+ } else if (this.date) {
515
503
  this.viewDate = new Date(this.date);
516
504
  this.date = new Date(this.date);
505
+ } else {
506
+ this.date = undefined;
517
507
  }
508
+
509
+ if (fromArgs) {
510
+ // setting date by clicking
511
+ this.setValue();
512
+ } else if (date) {
513
+ // setting date by typing
514
+ if (oldDate && this.date && oldDate.getTime() !== this.date.getTime())
515
+ this._trigger('changeDate');
516
+ }
517
+ if (!this.date && oldDate)
518
+ this._trigger('clearDate');
519
+
518
520
  this.fill();
519
521
  },
520
522
 
@@ -554,7 +556,7 @@
554
556
  var cls = [],
555
557
  year = this.viewDate.getUTCFullYear(),
556
558
  month = this.viewDate.getUTCMonth(),
557
- currentDate = this.date.valueOf(),
559
+ currentDate = this.date && this.date.valueOf(),
558
560
  today = new Date();
559
561
  if (date.getUTCFullYear() < year || (date.getUTCFullYear() == year && date.getUTCMonth() < month)) {
560
562
  cls.push('old');
@@ -594,7 +596,6 @@
594
596
  startMonth = this.o.startDate !== -Infinity ? this.o.startDate.getUTCMonth() : -Infinity,
595
597
  endYear = this.o.endDate !== Infinity ? this.o.endDate.getUTCFullYear() : Infinity,
596
598
  endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
597
- currentDate = this.date && this.date.valueOf(),
598
599
  tooltip;
599
600
  this.picker.find('.datepicker-days thead th.datepicker-switch')
600
601
  .text(dates[this.o.language].months[month]+' '+year);
@@ -606,7 +607,7 @@
606
607
  .toggle(this.o.clearBtn !== false);
607
608
  this.updateNavArrows();
608
609
  this.fillMonths();
609
- var prevMonth = UTCDate(year, month-1, 28,0,0,0,0),
610
+ var prevMonth = UTCDate(year, month-1, 28),
610
611
  day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
611
612
  prevMonth.setUTCDate(day);
612
613
  prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.o.weekStart + 7)%7);
@@ -669,7 +670,7 @@
669
670
  .end()
670
671
  .find('span').removeClass('active');
671
672
  if (currentYear && currentYear == year) {
672
- months.eq(this.date.getUTCMonth()).addClass('active');
673
+ months.eq(this.date && this.date.getUTCMonth()).addClass('active');
673
674
  }
674
675
  if (year < startYear || year > endYear) {
675
676
  months.addClass('disabled');
@@ -733,7 +734,8 @@
733
734
 
734
735
  click: function(e) {
735
736
  e.preventDefault();
736
- var target = $(e.target).closest('span, td, th');
737
+ var target = $(e.target).closest('span, td, th'),
738
+ year, month, day;
737
739
  if (target.length == 1) {
738
740
  switch(target[0].nodeName.toLowerCase()) {
739
741
  case 'th':
@@ -774,8 +776,8 @@
774
776
  element = this.element.find('input');
775
777
  if (element)
776
778
  element.val("").change();
777
- this._trigger('changeDate');
778
779
  this.update();
780
+ this._trigger('changeDate');
779
781
  if (this.o.autoclose)
780
782
  this.hide();
781
783
  break;
@@ -785,22 +787,22 @@
785
787
  if (!target.is('.disabled')) {
786
788
  this.viewDate.setUTCDate(1);
787
789
  if (target.is('.month')) {
788
- var day = 1;
789
- var month = target.parent().find('span').index(target);
790
- var year = this.viewDate.getUTCFullYear();
790
+ day = 1;
791
+ month = target.parent().find('span').index(target);
792
+ year = this.viewDate.getUTCFullYear();
791
793
  this.viewDate.setUTCMonth(month);
792
794
  this._trigger('changeMonth', this.viewDate);
793
795
  if (this.o.minViewMode === 1) {
794
- this._setDate(UTCDate(year, month, day,0,0,0,0));
796
+ this._setDate(UTCDate(year, month, day));
795
797
  }
796
798
  } else {
797
- var year = parseInt(target.text(), 10)||0;
798
- var day = 1;
799
- var month = 0;
799
+ day = 1;
800
+ month = 0;
801
+ year = parseInt(target.text(), 10)||0;
800
802
  this.viewDate.setUTCFullYear(year);
801
803
  this._trigger('changeYear', this.viewDate);
802
804
  if (this.o.minViewMode === 2) {
803
- this._setDate(UTCDate(year, month, day,0,0,0,0));
805
+ this._setDate(UTCDate(year, month, day));
804
806
  }
805
807
  }
806
808
  this.showMode(-1);
@@ -809,9 +811,9 @@
809
811
  break;
810
812
  case 'td':
811
813
  if (target.is('.day') && !target.is('.disabled')){
812
- var day = parseInt(target.text(), 10)||1;
813
- var year = this.viewDate.getUTCFullYear(),
814
- month = this.viewDate.getUTCMonth();
814
+ day = parseInt(target.text(), 10)||1;
815
+ year = this.viewDate.getUTCFullYear();
816
+ month = this.viewDate.getUTCMonth();
815
817
  if (target.is('.old')) {
816
818
  if (month === 0) {
817
819
  month = 11;
@@ -827,7 +829,7 @@
827
829
  month += 1;
828
830
  }
829
831
  }
830
- this._setDate(UTCDate(year, month, day,0,0,0,0));
832
+ this._setDate(UTCDate(year, month, day));
831
833
  }
832
834
  break;
833
835
  }
@@ -836,9 +838,9 @@
836
838
 
837
839
  _setDate: function(date, which){
838
840
  if (!which || which == 'date')
839
- this.date = new Date(date);
841
+ this.date = date && new Date(date);
840
842
  if (!which || which == 'view')
841
- this.viewDate = new Date(date);
843
+ this.viewDate = date && new Date(date);
842
844
  this.fill();
843
845
  this.setValue();
844
846
  this._trigger('changeDate');
@@ -857,6 +859,7 @@
857
859
  },
858
860
 
859
861
  moveMonth: function(date, dir){
862
+ if (!date) return undefined;
860
863
  if (!dir) return date;
861
864
  var new_date = new Date(date.valueOf()),
862
865
  day = new_date.getUTCDate(),
@@ -911,8 +914,7 @@
911
914
  return;
912
915
  }
913
916
  var dateChanged = false,
914
- dir, day, month,
915
- newDate, newViewDate;
917
+ dir, newDate, newViewDate;
916
918
  switch(e.keyCode){
917
919
  case 27: // escape
918
920
  this.hide();
@@ -923,16 +925,16 @@
923
925
  if (!this.o.keyboardNavigation) break;
924
926
  dir = e.keyCode == 37 ? -1 : 1;
925
927
  if (e.ctrlKey){
926
- newDate = this.moveYear(this.date, dir);
928
+ newDate = this.moveYear(this.date || UTCToday(), dir);
927
929
  newViewDate = this.moveYear(this.viewDate, dir);
928
930
  this._trigger('changeYear', this.viewDate);
929
931
  } else if (e.shiftKey){
930
- newDate = this.moveMonth(this.date, dir);
932
+ newDate = this.moveMonth(this.date || UTCToday(), dir);
931
933
  newViewDate = this.moveMonth(this.viewDate, dir);
932
934
  this._trigger('changeMonth', this.viewDate);
933
935
  } else {
934
- newDate = new Date(this.date);
935
- newDate.setUTCDate(this.date.getUTCDate() + dir);
936
+ newDate = new Date(this.date || UTCToday());
937
+ newDate.setUTCDate(newDate.getUTCDate() + dir);
936
938
  newViewDate = new Date(this.viewDate);
937
939
  newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
938
940
  }
@@ -950,15 +952,15 @@
950
952
  if (!this.o.keyboardNavigation) break;
951
953
  dir = e.keyCode == 38 ? -1 : 1;
952
954
  if (e.ctrlKey){
953
- newDate = this.moveYear(this.date, dir);
955
+ newDate = this.moveYear(this.date || UTCToday(), dir);
954
956
  newViewDate = this.moveYear(this.viewDate, dir);
955
957
  this._trigger('changeYear', this.viewDate);
956
958
  } else if (e.shiftKey){
957
- newDate = this.moveMonth(this.date, dir);
959
+ newDate = this.moveMonth(this.date || UTCToday(), dir);
958
960
  newViewDate = this.moveMonth(this.viewDate, dir);
959
961
  this._trigger('changeMonth', this.viewDate);
960
962
  } else {
961
- newDate = new Date(this.date);
963
+ newDate = new Date(this.date || UTCToday());
962
964
  newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
963
965
  newViewDate = new Date(this.viewDate);
964
966
  newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
@@ -1083,7 +1085,7 @@
1083
1085
  // Check if "de-DE" style date is available, if not language should
1084
1086
  // fallback to 2 letter code eg "de"
1085
1087
  if (!dates[lang]) {
1086
- lang = lang.split('-')[0]
1088
+ lang = lang.split('-')[0];
1087
1089
  if (!dates[lang])
1088
1090
  return;
1089
1091
  }
@@ -1099,8 +1101,7 @@
1099
1101
  $.fn.datepicker = function ( option ) {
1100
1102
  var args = Array.apply(null, arguments);
1101
1103
  args.shift();
1102
- var internal_return,
1103
- this_return;
1104
+ var internal_return;
1104
1105
  this.each(function () {
1105
1106
  var $this = $(this),
1106
1107
  data = $this.data('datepicker'),
@@ -1208,6 +1209,8 @@
1208
1209
  return {separators: separators, parts: parts};
1209
1210
  },
1210
1211
  parseDate: function(date, format, language) {
1212
+ if (!date)
1213
+ return undefined;
1211
1214
  if (date instanceof Date) return date;
1212
1215
  if (typeof format === 'string')
1213
1216
  format = DPGlobal.parseFormat(format);
@@ -1307,6 +1310,8 @@
1307
1310
  return date;
1308
1311
  },
1309
1312
  formatDate: function(date, format, language){
1313
+ if (!date)
1314
+ return '';
1310
1315
  if (typeof format === 'string')
1311
1316
  format = DPGlobal.parseFormat(format);
1312
1317
  var val = {
@@ -8,7 +8,7 @@
8
8
  daysShort: ["Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim"],
9
9
  daysMin: ["D", "L", "Ma", "Me", "J", "V", "S", "D"],
10
10
  months: ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"],
11
- monthsShort: ["Jan", "Fev", "Mar", "Avr", "Mai", "Jui", "Jul", "Aou", "Sep", "Oct", "Nov", "Dec"],
11
+ monthsShort: ["Jan", "Fév", "Mar", "Avr", "Mai", "Jui", "Jul", "Aou", "Sep", "Oct", "Nov", "Déc"],
12
12
  today: "Aujourd'hui",
13
13
  clear: "Effacer",
14
14
  weekStart: 1,
@@ -10,6 +10,8 @@
10
10
  months: ["იანვარი", "თებერვალი", "მარტი", "აპრილი", "მაისი", "ივნისი", "ივლისი", "აგვისტო", "სექტემბერი", "ოქტომები", "ნოემბერი", "დეკემბერი"],
11
11
  monthsShort: ["იან", "თებ", "მარ", "აპრ", "მაი", "ივნ", "ივლ", "აგვ", "სექ", "ოქტ", "ნოე", "დეკ"],
12
12
  today: "დღეს",
13
- clear: "გასუფთავება"
13
+ clear: "გასუფთავება",
14
+ weekStart: 1,
15
+ format: "dd.mm.yyyy"
14
16
  };
15
17
  }(jQuery));
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-datepicker-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1.8
4
+ version: 1.1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gonzalo Rodríguez-Baltanás Díaz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-27 00:00:00.000000000 Z
11
+ date: 2013-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties