bootstrap-datepicker-rails 0.6.35 → 0.6.36

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,14 +7,9 @@ task :update do
7
7
  system("cp bootstrap-datepicker-src/css/datepicker.css vendor/assets/stylesheets/bootstrap-datepicker.css")
8
8
  system("cp bootstrap-datepicker-src/js/bootstrap-datepicker.js vendor/assets/javascripts/bootstrap-datepicker/core.js")
9
9
  system("cp -R bootstrap-datepicker-src/js/locales/ vendor/assets/javascripts/bootstrap-datepicker/locales/")
10
- fixes
11
10
  system("git status")
12
11
  end
13
12
 
14
- def fixes
15
-
16
- end
17
-
18
13
  desc "Build"
19
14
  task "build" do
20
15
  system("gem build bootstrap-datepicker-rails.gemspec")
@@ -1,5 +1,5 @@
1
1
  module BootstrapDatepickerRails
2
2
  module Rails
3
- VERSION = "0.6.35"
3
+ VERSION = "0.6.36"
4
4
  end
5
5
  end
@@ -74,7 +74,7 @@
74
74
  }
75
75
  $(document).on('mousedown', function (e) {
76
76
  // Clicked outside the datepicker, hide it
77
- if ($(e.target).closest('.datepicker').length === 0) {
77
+ if ($(e.target).closest('.datepicker.datepicker-inline, .datepicker.datepicker-dropdown').length === 0) {
78
78
  that.hide();
79
79
  }
80
80
  });
@@ -108,6 +108,18 @@
108
108
  this.todayBtn = (options.todayBtn||this.element.data('date-today-btn')||false);
109
109
  this.todayHighlight = (options.todayHighlight||this.element.data('date-today-highlight')||false);
110
110
 
111
+ this.calendarWeeks = false;
112
+ if ('calendarWeeks' in options) {
113
+ this.calendarWeeks = options.calendarWeeks;
114
+ } else if ('dateCalendarWeeks' in this.element.data()) {
115
+ this.calendarWeeks = this.element.data('date-calendar-weeks');
116
+ }
117
+ if (this.calendarWeeks)
118
+ this.picker.find('tfoot th.today')
119
+ .attr('colspan', function(i, val){
120
+ return parseInt(val) + 1;
121
+ });
122
+
111
123
  this.weekStart = ((options.weekStart||this.element.data('date-weekstart')||dates[this.language].weekStart||0) % 7);
112
124
  this.weekEnd = ((this.weekStart + 6) % 7);
113
125
  this.startDate = -Infinity;
@@ -197,6 +209,7 @@
197
209
 
198
210
  hide: function(e){
199
211
  if(this.isInline) return;
212
+ if (!this.picker.is(':visible')) return;
200
213
  this.picker.hide();
201
214
  $(window).off('resize', this.place);
202
215
  this.viewMode = this.startViewMode;
@@ -339,6 +352,11 @@
339
352
  fillDow: function(){
340
353
  var dowCnt = this.weekStart,
341
354
  html = '<tr>';
355
+ if(this.calendarWeeks){
356
+ var cell = '<th class="cw">&nbsp;</th>';
357
+ html += cell;
358
+ this.picker.find('.datepicker-days thead tr:first-child').prepend(cell);
359
+ }
342
360
  while (dowCnt < this.weekStart + 7) {
343
361
  html += '<th class="dow">'+dates[this.language].daysMin[(dowCnt++)%7]+'</th>';
344
362
  }
@@ -365,7 +383,7 @@
365
383
  endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
366
384
  currentDate = this.date && this.date.valueOf(),
367
385
  today = new Date();
368
- this.picker.find('.datepicker-days thead th:eq(1)')
386
+ this.picker.find('.datepicker-days thead th.switch')
369
387
  .text(dates[this.language].months[month]+' '+year);
370
388
  this.picker.find('tfoot th.today')
371
389
  .text(dates[this.language].today)
@@ -384,6 +402,13 @@
384
402
  while(prevMonth.valueOf() < nextMonth) {
385
403
  if (prevMonth.getUTCDay() == this.weekStart) {
386
404
  html.push('<tr>');
405
+ if(this.calendarWeeks){
406
+ // adapted from https://github.com/timrwood/moment/blob/master/moment.js#L128
407
+ var a = new Date(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth(), prevMonth.getUTCDate() - prevMonth.getDay() + 10 - (this.weekStart && this.weekStart%7 < 5 && 7)),
408
+ b = new Date(a.getFullYear(), 0, 4),
409
+ calWeek = ~~((a - b) / 864e5 / 7 + 1.5);
410
+ html.push('<td class="cw">'+ calWeek +'</td>');
411
+ }
387
412
  }
388
413
  clsName = '';
389
414
  if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
@@ -282,6 +282,16 @@
282
282
  .datepicker tfoot tr:first-child th:hover {
283
283
  background: #eeeeee;
284
284
  }
285
+ .datepicker .cw {
286
+ font-size: 10px;
287
+ width: 12px;
288
+ padding: 0 2px 0 5px;
289
+ vertical-align: middle;
290
+ }
291
+ .datepicker thead tr:first-child th.cw {
292
+ cursor: default;
293
+ background-color: transparent;
294
+ }
285
295
  .input-append.date .add-on i,
286
296
  .input-prepend.date .add-on i {
287
297
  display: block;
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.35
4
+ version: 0.6.36
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-01-05 00:00:00.000000000 Z
12
+ date: 2013-01-10 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: 2691647704383687083
188
+ hash: -1858460667918718624
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: 2691647704383687083
197
+ hash: -1858460667918718624
198
198
  requirements: []
199
199
  rubyforge_project:
200
200
  rubygems_version: 1.8.24