bootstrap-datepicker-rails 1.0.0.2 → 1.0.0.3

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: 905d023a948c35fdd99fd341556ba6c245a83d77
4
- data.tar.gz: ad4663b35cd0f423f2625a5dacdd37204692ab3b
3
+ metadata.gz: 130087eee463e56eead64c0a83e939ec04a49db1
4
+ data.tar.gz: 787985d85b851d3ddb512f72c85ed4e070099aeb
5
5
  SHA512:
6
- metadata.gz: 3f483fb57fe0ddefd80594066700e0e76b9c66a0b4052862b75af5215b6a0ece3e8aedcb3a97a2fcab6510a36cd22c24768a02cd9d88d6fba76e32cf75035e76
7
- data.tar.gz: 8e7ec6fc5b3b35a7aacc1e2945b82d8841fb78569de2a267a476c53894221f2530888d3a468c23c47ee16e94b96f96327a039c7d3667af72ca16e7f3d718b75e
6
+ metadata.gz: 4042e4dba319189c8f6170e3235adfe0e57ba6bbedc84c2fcbeaf52ecf8eaca103a1a5f870aadbe937777b2a38532fd3dfe842c80a35d0ec98249dd2056191c4
7
+ data.tar.gz: a26f9ff1f29ad4eeb86a6de27a05d6a33fc691923c042c69c2a34469c9012b3021741c94a1850485be48e530b37033151337855de166786eb9009a19be6b168b
@@ -1,5 +1,5 @@
1
1
  module BootstrapDatepickerRails
2
2
  module Rails
3
- VERSION = "1.0.0.2"
3
+ VERSION = "1.0.0.3"
4
4
  end
5
5
  end
@@ -138,6 +138,7 @@
138
138
  this.setDaysOfWeekDisabled(options.daysOfWeekDisabled||this.element.data('date-days-of-week-disabled'));
139
139
  this.fillDow();
140
140
  this.fillMonths();
141
+ this.setRange(options.range);
141
142
 
142
143
  this._allow_update = true;
143
144
 
@@ -413,6 +414,50 @@
413
414
  this.picker.find('.datepicker-months td').html(html);
414
415
  },
415
416
 
417
+ setRange: function(range){
418
+ if (!range || !range.length)
419
+ delete this.range;
420
+ else
421
+ this.range = $.map(range, function(d){ return d.valueOf(); });
422
+ this.fill();
423
+ },
424
+
425
+ getClassNames: function(date){
426
+ var cls = [],
427
+ year = this.viewDate.getUTCFullYear(),
428
+ month = this.viewDate.getUTCMonth(),
429
+ currentDate = this.date.valueOf(),
430
+ today = new Date();
431
+ if (date.getUTCFullYear() < year || (date.getUTCFullYear() == year && date.getUTCMonth() < month)) {
432
+ cls.push('old');
433
+ } else if (date.getUTCFullYear() > year || (date.getUTCFullYear() == year && date.getUTCMonth() > month)) {
434
+ cls.push('new');
435
+ }
436
+ // Compare internal UTC date with local today, not UTC today
437
+ if (this.todayHighlight &&
438
+ date.getUTCFullYear() == today.getFullYear() &&
439
+ date.getUTCMonth() == today.getMonth() &&
440
+ date.getUTCDate() == today.getDate()) {
441
+ cls.push('today');
442
+ }
443
+ if (currentDate && date.valueOf() == currentDate) {
444
+ cls.push('active');
445
+ }
446
+ if (date.valueOf() < this.startDate || date.valueOf() > this.endDate ||
447
+ $.inArray(date.getUTCDay(), this.daysOfWeekDisabled) !== -1) {
448
+ cls.push('disabled');
449
+ }
450
+ if (this.range){
451
+ if (date > this.range[0] && date < this.range[this.range.length-1]){
452
+ cls.push('range');
453
+ }
454
+ if ($.inArray(date.valueOf(), this.range) != -1){
455
+ cls.push('selected');
456
+ }
457
+ }
458
+ return cls;
459
+ },
460
+
416
461
  fill: function() {
417
462
  var d = new Date(this.viewDate),
418
463
  year = d.getUTCFullYear(),
@@ -421,8 +466,7 @@
421
466
  startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
422
467
  endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
423
468
  endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
424
- currentDate = this.date && this.date.valueOf(),
425
- today = new Date();
469
+ currentDate = this.date && this.date.valueOf();
426
470
  this.picker.find('.datepicker-days thead th.switch')
427
471
  .text(dates[this.language].months[month]+' '+year);
428
472
  this.picker.find('tfoot th.today')
@@ -458,27 +502,9 @@
458
502
 
459
503
  }
460
504
  }
461
- clsName = '';
462
- if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
463
- clsName += ' old';
464
- } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
465
- clsName += ' new';
466
- }
467
- // Compare internal UTC date with local today, not UTC today
468
- if (this.todayHighlight &&
469
- prevMonth.getUTCFullYear() == today.getFullYear() &&
470
- prevMonth.getUTCMonth() == today.getMonth() &&
471
- prevMonth.getUTCDate() == today.getDate()) {
472
- clsName += ' today';
473
- }
474
- if (currentDate && prevMonth.valueOf() == currentDate) {
475
- clsName += ' active';
476
- }
477
- if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
478
- $.inArray(prevMonth.getUTCDay(), this.daysOfWeekDisabled) !== -1) {
479
- clsName += ' disabled';
480
- }
481
- html.push('<td class="day'+clsName+'">'+prevMonth.getUTCDate() + '</td>');
505
+ clsName = this.getClassNames(prevMonth);
506
+ clsName.push('day');
507
+ html.push('<td class="'+clsName.join(' ')+'">'+prevMonth.getUTCDate() + '</td>');
482
508
  if (prevMonth.getUTCDay() == this.weekEnd) {
483
509
  html.push('</tr>');
484
510
  }
@@ -829,6 +855,57 @@
829
855
  }
830
856
  };
831
857
 
858
+ var DateRangePicker = function(element, options){
859
+ this.element = $(element);
860
+ this.inputs = $.map(options.inputs, function(i){ return i.jquery ? i[0] : i; });
861
+ delete options.inputs;
862
+
863
+ $(this.inputs)
864
+ .datepicker(options)
865
+ .bind('changeDate', $.proxy(this.dateUpdated, this));
866
+
867
+ this.pickers = $.map(this.inputs, function(i){ return $(i).data('datepicker'); });
868
+ this.updateDates();
869
+ };
870
+ DateRangePicker.prototype = {
871
+ updateDates: function(){
872
+ this.dates = $.map(this.pickers, function(i){ return i.date; });
873
+ this.updateRanges();
874
+ },
875
+ updateRanges: function(){
876
+ var range = $.map(this.dates, function(d){ return d.valueOf(); });
877
+ $.each(this.pickers, function(i, p){
878
+ p.setRange(range);
879
+ });
880
+ },
881
+ dateUpdated: function(e){
882
+ var dp = $(e.target).data('datepicker'),
883
+ new_date = e.date,
884
+ i = $.inArray(e.target, this.inputs),
885
+ l = this.inputs.length;
886
+ if (i == -1) return;
887
+
888
+ if (new_date < this.dates[i]){
889
+ // Date being moved earlier/left
890
+ while (i>=0 && new_date < this.dates[i]){
891
+ this.pickers[i--].setUTCDate(new_date);
892
+ }
893
+ }
894
+ else if (new_date > this.dates[i]){
895
+ // Date being moved later/right
896
+ while (i<l && new_date > this.dates[i]){
897
+ this.pickers[i++].setUTCDate(new_date);
898
+ }
899
+ }
900
+ this.updateDates();
901
+ },
902
+ remove: function(){
903
+ $.map(this.pickers, function(p){ p.remove(); });
904
+ delete this.element.data().datepicker;
905
+ }
906
+ };
907
+
908
+ var old = $.fn.datepicker;
832
909
  $.fn.datepicker = function ( option ) {
833
910
  var args = Array.apply(null, arguments);
834
911
  args.shift();
@@ -837,7 +914,15 @@
837
914
  data = $this.data('datepicker'),
838
915
  options = typeof option == 'object' && option;
839
916
  if (!data) {
840
- $this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options))));
917
+ if ($this.is('.input-daterange') || options.inputs){
918
+ var opts = {
919
+ inputs: options.inputs || $this.find('input').toArray()
920
+ };
921
+ $this.data('datepicker', (data = new DateRangePicker(this, $.extend(opts, $.fn.datepicker.defaults,options))));
922
+ }
923
+ else{
924
+ $this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options))));
925
+ }
841
926
  }
842
927
  if (typeof option == 'string' && typeof data[option] == 'function') {
843
928
  data[option].apply(data, args);
@@ -1043,4 +1128,32 @@
1043
1128
 
1044
1129
  $.fn.datepicker.DPGlobal = DPGlobal;
1045
1130
 
1131
+
1132
+ /* DATEPICKER NO CONFLICT
1133
+ * =================== */
1134
+
1135
+ $.fn.datepicker.noConflict = function(){
1136
+ $.fn.datepicker = old;
1137
+ return this;
1138
+ };
1139
+
1140
+
1141
+ /* DATEPICKER DATA-API
1142
+ * ================== */
1143
+
1144
+ $(document).on(
1145
+ 'focus.datepicker.data-api click.datepicker.data-api',
1146
+ '[data-provide="datepicker"]',
1147
+ function(e){
1148
+ var $this = $(this);
1149
+ if ($this.data('datepicker')) return;
1150
+ e.preventDefault();
1151
+ // component click requires us to explicitly show it
1152
+ $this.datepicker('show');
1153
+ }
1154
+ );
1155
+ $(function(){
1156
+ $('[data-provide="datepicker-inline"]').datepicker();
1157
+ });
1158
+
1046
1159
  }( window.jQuery );
@@ -145,6 +145,118 @@
145
145
  .datepicker table tr td.today.disabled:hover.active {
146
146
  background-color: #fbf069 \9;
147
147
  }
148
+ .datepicker table tr td.range,
149
+ .datepicker table tr td.range:hover,
150
+ .datepicker table tr td.range.disabled,
151
+ .datepicker table tr td.range.disabled:hover {
152
+ background: #eeeeee;
153
+ -webkit-border-radius: 0;
154
+ -moz-border-radius: 0;
155
+ border-radius: 0;
156
+ }
157
+ .datepicker table tr td.range.today,
158
+ .datepicker table tr td.range.today:hover,
159
+ .datepicker table tr td.range.today.disabled,
160
+ .datepicker table tr td.range.today.disabled:hover {
161
+ background-color: #f3d17a;
162
+ background-image: -moz-linear-gradient(top, #f3c17a, #f3e97a);
163
+ background-image: -ms-linear-gradient(top, #f3c17a, #f3e97a);
164
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f3c17a), to(#f3e97a));
165
+ background-image: -webkit-linear-gradient(top, #f3c17a, #f3e97a);
166
+ background-image: -o-linear-gradient(top, #f3c17a, #f3e97a);
167
+ background-image: linear-gradient(top, #f3c17a, #f3e97a);
168
+ background-repeat: repeat-x;
169
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f3c17a', endColorstr='#f3e97a', GradientType=0);
170
+ border-color: #f3e97a #f3e97a #edde34;
171
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
172
+ filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
173
+ -webkit-border-radius: 0;
174
+ -moz-border-radius: 0;
175
+ border-radius: 0;
176
+ }
177
+ .datepicker table tr td.range.today:hover,
178
+ .datepicker table tr td.range.today:hover:hover,
179
+ .datepicker table tr td.range.today.disabled:hover,
180
+ .datepicker table tr td.range.today.disabled:hover:hover,
181
+ .datepicker table tr td.range.today:active,
182
+ .datepicker table tr td.range.today:hover:active,
183
+ .datepicker table tr td.range.today.disabled:active,
184
+ .datepicker table tr td.range.today.disabled:hover:active,
185
+ .datepicker table tr td.range.today.active,
186
+ .datepicker table tr td.range.today:hover.active,
187
+ .datepicker table tr td.range.today.disabled.active,
188
+ .datepicker table tr td.range.today.disabled:hover.active,
189
+ .datepicker table tr td.range.today.disabled,
190
+ .datepicker table tr td.range.today:hover.disabled,
191
+ .datepicker table tr td.range.today.disabled.disabled,
192
+ .datepicker table tr td.range.today.disabled:hover.disabled,
193
+ .datepicker table tr td.range.today[disabled],
194
+ .datepicker table tr td.range.today:hover[disabled],
195
+ .datepicker table tr td.range.today.disabled[disabled],
196
+ .datepicker table tr td.range.today.disabled:hover[disabled] {
197
+ background-color: #f3e97a;
198
+ }
199
+ .datepicker table tr td.range.today:active,
200
+ .datepicker table tr td.range.today:hover:active,
201
+ .datepicker table tr td.range.today.disabled:active,
202
+ .datepicker table tr td.range.today.disabled:hover:active,
203
+ .datepicker table tr td.range.today.active,
204
+ .datepicker table tr td.range.today:hover.active,
205
+ .datepicker table tr td.range.today.disabled.active,
206
+ .datepicker table tr td.range.today.disabled:hover.active {
207
+ background-color: #efe24b \9;
208
+ }
209
+ .datepicker table tr td.selected,
210
+ .datepicker table tr td.selected:hover,
211
+ .datepicker table tr td.selected.disabled,
212
+ .datepicker table tr td.selected.disabled:hover {
213
+ background-color: #9e9e9e;
214
+ background-image: -moz-linear-gradient(top, #b3b3b3, #808080);
215
+ background-image: -ms-linear-gradient(top, #b3b3b3, #808080);
216
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#b3b3b3), to(#808080));
217
+ background-image: -webkit-linear-gradient(top, #b3b3b3, #808080);
218
+ background-image: -o-linear-gradient(top, #b3b3b3, #808080);
219
+ background-image: linear-gradient(top, #b3b3b3, #808080);
220
+ background-repeat: repeat-x;
221
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#b3b3b3', endColorstr='#808080', GradientType=0);
222
+ border-color: #808080 #808080 #595959;
223
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
224
+ filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
225
+ color: #fff;
226
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
227
+ }
228
+ .datepicker table tr td.selected:hover,
229
+ .datepicker table tr td.selected:hover:hover,
230
+ .datepicker table tr td.selected.disabled:hover,
231
+ .datepicker table tr td.selected.disabled:hover:hover,
232
+ .datepicker table tr td.selected:active,
233
+ .datepicker table tr td.selected:hover:active,
234
+ .datepicker table tr td.selected.disabled:active,
235
+ .datepicker table tr td.selected.disabled:hover:active,
236
+ .datepicker table tr td.selected.active,
237
+ .datepicker table tr td.selected:hover.active,
238
+ .datepicker table tr td.selected.disabled.active,
239
+ .datepicker table tr td.selected.disabled:hover.active,
240
+ .datepicker table tr td.selected.disabled,
241
+ .datepicker table tr td.selected:hover.disabled,
242
+ .datepicker table tr td.selected.disabled.disabled,
243
+ .datepicker table tr td.selected.disabled:hover.disabled,
244
+ .datepicker table tr td.selected[disabled],
245
+ .datepicker table tr td.selected:hover[disabled],
246
+ .datepicker table tr td.selected.disabled[disabled],
247
+ .datepicker table tr td.selected.disabled:hover[disabled] {
248
+ background-color: #808080;
249
+ }
250
+ .datepicker table tr td.selected:active,
251
+ .datepicker table tr td.selected:hover:active,
252
+ .datepicker table tr td.selected.disabled:active,
253
+ .datepicker table tr td.selected.disabled:hover:active,
254
+ .datepicker table tr td.selected.active,
255
+ .datepicker table tr td.selected:hover.active,
256
+ .datepicker table tr td.selected.disabled.active,
257
+ .datepicker table tr td.selected.disabled:hover.active {
258
+ background-color: #666666 \9;
259
+ }
148
260
  .datepicker table tr td.active,
149
261
  .datepicker table tr td.active:hover,
150
262
  .datepicker table tr td.active.disabled,
@@ -299,3 +411,32 @@
299
411
  width: 16px;
300
412
  height: 16px;
301
413
  }
414
+ .input-daterange input {
415
+ text-align: center;
416
+ }
417
+ .input-daterange input:first-child {
418
+ -webkit-border-radius: 3px 0 0 3px;
419
+ -moz-border-radius: 3px 0 0 3px;
420
+ border-radius: 3px 0 0 3px;
421
+ }
422
+ .input-daterange input:last-child {
423
+ -webkit-border-radius: 0 3px 3px 0;
424
+ -moz-border-radius: 0 3px 3px 0;
425
+ border-radius: 0 3px 3px 0;
426
+ }
427
+ .input-daterange .add-on {
428
+ display: inline-block;
429
+ width: auto;
430
+ min-width: 16px;
431
+ height: 18px;
432
+ padding: 4px 5px;
433
+ font-weight: normal;
434
+ line-height: 18px;
435
+ text-align: center;
436
+ text-shadow: 0 1px 0 #ffffff;
437
+ vertical-align: middle;
438
+ background-color: #eeeeee;
439
+ border: 1px solid #ccc;
440
+ margin-left: -5px;
441
+ margin-right: -5px;
442
+ }
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.0.0.2
4
+ version: 1.0.0.3
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-03-24 00:00:00.000000000 Z
11
+ date: 2013-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties