bootstrap-datepicker-rails 0.6.39 → 0.6.40

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.39"
3
+ VERSION = "0.6.40"
4
4
  end
5
5
  end
@@ -106,6 +106,23 @@
106
106
  break;
107
107
  }
108
108
 
109
+ this.minViewMode = options.minViewMode||this.element.data('date-min-view-mode')||0;
110
+ if (typeof this.minViewMode === 'string') {
111
+ switch (this.minViewMode) {
112
+ case 'months':
113
+ this.minViewMode = 1;
114
+ break;
115
+ case 'years':
116
+ this.minViewMode = 2;
117
+ break;
118
+ default:
119
+ this.minViewMode = 0;
120
+ break;
121
+ }
122
+ }
123
+
124
+ this.viewMode = this.startViewMode = Math.max(this.startViewMode, this.minViewMode);
125
+
109
126
  this.todayBtn = (options.todayBtn||this.element.data('date-today-btn')||false);
110
127
  this.todayHighlight = (options.todayHighlight||this.element.data('date-today-highlight')||false);
111
128
 
@@ -396,11 +413,19 @@
396
413
  if (prevMonth.getUTCDay() == this.weekStart) {
397
414
  html.push('<tr>');
398
415
  if(this.calendarWeeks){
399
- // adapted from https://github.com/timrwood/moment/blob/master/moment.js#L128
400
- var a = new Date(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth(), prevMonth.getUTCDate() - prevMonth.getDay() + 10 - (this.weekStart && this.weekStart%7 < 5 && 7)),
401
- b = new Date(a.getFullYear(), 0, 4),
402
- calWeek = ~~((a - b) / 864e5 / 7 + 1.5);
416
+ // ISO 8601: First week contains first thursday.
417
+ // ISO also states week starts on Monday, but we can be more abstract here.
418
+ var
419
+ // Start of current week: based on weekstart/current date
420
+ ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
421
+ // Thursday of this week
422
+ th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
423
+ // First Thursday of year, year from thursday
424
+ yth = new Date(+(yth = UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
425
+ // Calendar week: ms between thursdays, div ms per day, div 7 days
426
+ calWeek = (th - yth) / 864e5 / 7 + 1;
403
427
  html.push('<td class="cw">'+ calWeek +'</td>');
428
+
404
429
  }
405
430
  }
406
431
  clsName = '';
@@ -537,19 +562,29 @@
537
562
  if (!target.is('.disabled')) {
538
563
  this.viewDate.setUTCDate(1);
539
564
  if (target.is('.month')) {
565
+ var day = 1;
540
566
  var month = target.parent().find('span').index(target);
567
+ var year = this.viewDate.getUTCFullYear();
541
568
  this.viewDate.setUTCMonth(month);
542
569
  this.element.trigger({
543
570
  type: 'changeMonth',
544
571
  date: this.viewDate
545
572
  });
573
+ if ( this.minViewMode == 1 ) {
574
+ this._setDate(UTCDate(year, month, day,0,0,0,0));
575
+ }
546
576
  } else {
547
577
  var year = parseInt(target.text(), 10)||0;
578
+ var day = 1;
579
+ var month = 0;
548
580
  this.viewDate.setUTCFullYear(year);
549
581
  this.element.trigger({
550
582
  type: 'changeYear',
551
583
  date: this.viewDate
552
584
  });
585
+ if ( this.minViewMode == 2 ) {
586
+ this._setDate(UTCDate(year, month, day,0,0,0,0));
587
+ }
553
588
  }
554
589
  this.showMode(-1);
555
590
  this.fill();
@@ -746,7 +781,7 @@
746
781
 
747
782
  showMode: function(dir) {
748
783
  if (dir) {
749
- this.viewMode = Math.max(0, Math.min(2, this.viewMode + dir));
784
+ this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
750
785
  }
751
786
  /*
752
787
  vitalets: fixing bug of very special conditions:
@@ -1,4 +1,4 @@
1
- /**
1
+ /**
2
2
  * Lithuanian translation for bootstrap-datepicker
3
3
  * Šarūnas Gliebus <ssharunas@yahoo.co.uk>
4
4
  */
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.39
4
+ version: 0.6.40
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: 2013-02-02 00:00:00.000000000 Z
12
+ date: 2013-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -185,7 +185,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  segments:
187
187
  - 0
188
- hash: 1169219055907779204
188
+ hash: 1571691320889723959
189
189
  required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  none: false
191
191
  requirements:
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  version: '0'
195
195
  segments:
196
196
  - 0
197
- hash: 1169219055907779204
197
+ hash: 1571691320889723959
198
198
  requirements: []
199
199
  rubyforge_project:
200
200
  rubygems_version: 1.8.24