bootstrap-rails-engine 3.0.0.0 → 3.0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8538d9ef41c6b159d6bac8fb5fe37cddc1dc68e4
4
- data.tar.gz: 2817c5435fbc8ac279c5db99d424fadeab9a14ba
3
+ metadata.gz: ffa482320ac13c29e423cb18695304f4632c7cee
4
+ data.tar.gz: bb292d62f9317f8b8115e96e6f51d2d0f350fddd
5
5
  SHA512:
6
- metadata.gz: 797794db77a3826bde20eefb0a5b74e980306d311018a496791f720da7d164cc04e8244dc29f93cc82721c4dc6a240e3a81d196b1498d578444424a7a6a72a40
7
- data.tar.gz: 2e21ee7ef5b835bf79b7d91f38fd95a6a8302a3c534f20e9de0e1868449c24a3d30b5535ee83afae1dc104623df6a0b319585e1fae3ba94cc9b06b523f3faaf8
6
+ metadata.gz: 5c5210c1270ce45d01e30db66c815498068c2b6a70376af3ced618460ab04afcc3e6b9bd441b2d510bbfd4aa9da5c0a8f71f8552d6bed00c89fe5403c66453bc
7
+ data.tar.gz: d55ebb196aeb0545c5486a8fbb92b8915a7fc7a5ff8a4b172f1dc17e0d4857570235567ec47f31058ef4887b89f17ab921dd1b486e4b51f95140367e93dfff39
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
  Make [Twitter Bootstrap](http://twitter.github.com/bootstrap) into Rails Engine. [Bootstrap-datepicker](https://github.com/eternicode/bootstrap-datepicker) is also included.
3
3
 
4
4
  ## Version
5
- * Bootstrap 3.0.0rc1
6
- * Bootstrap-datepicker 1.1.3
5
+ * Bootstrap 3.0.0rc2
6
+ * Bootstrap-datepicker 1.2.0rc1
7
7
 
8
8
  ### Older Versions
9
9
 
@@ -35,6 +35,8 @@ and
35
35
 
36
36
  then remove corresponding lines in application.js and application.css.
37
37
 
38
+ If you use [font-awesome-rails](https://github.com/bokmann/font-awesome-rails), you can also use fontawesome_stylesheet_inclue_tag for CDN.
39
+
38
40
  ### Options
39
41
 
40
42
  Set :compressed to use minimized library locally like this:
@@ -47,6 +49,10 @@ Remember to add assets name in confign/environments/production.rb:
47
49
 
48
50
  config.assets.precompile += %w( bootstrap/bootstrap.min.js)
49
51
 
52
+ ## ISSUES
53
+
54
+ If you happen to use [bootstrap-sass](https://github.com/thomas-mcdonald/bootstrap-sass), which might be included from rails_admin, it will be used first, thus, you might have problem using stylesheet from this gem. Use CDN instead.
55
+
50
56
  ## License
51
57
 
52
58
  Copyright (c) 2012-2013 Yen-Ju Chen
@@ -20,6 +20,8 @@
20
20
 
21
21
  (function( $ ) {
22
22
 
23
+ var $window = $(window);
24
+
23
25
  function UTCDate(){
24
26
  return new Date(Date.UTC.apply(Date, arguments));
25
27
  }
@@ -28,6 +30,7 @@
28
30
  return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
29
31
  }
30
32
 
33
+
31
34
  // Picker object
32
35
 
33
36
  var Datepicker = function(element, options) {
@@ -70,8 +73,8 @@
70
73
 
71
74
  this._allow_update = false;
72
75
 
73
- this.setStartDate(this.o.startDate);
74
- this.setEndDate(this.o.endDate);
76
+ this.setStartDate(this._o.startDate);
77
+ this.setEndDate(this._o.endDate);
75
78
  this.setDaysOfWeekDisabled(this.o.daysOfWeekDisabled);
76
79
 
77
80
  this.fillDow();
@@ -102,7 +105,7 @@
102
105
  if (!dates[lang]) {
103
106
  lang = lang.split('-')[0];
104
107
  if (!dates[lang])
105
- lang = $.fn.datepicker.defaults.language;
108
+ lang = defaults.language;
106
109
  }
107
110
  o.language = lang;
108
111
 
@@ -137,12 +140,26 @@
137
140
  o.weekStart %= 7;
138
141
  o.weekEnd = ((o.weekStart + 6) % 7);
139
142
 
140
- var format = DPGlobal.parseFormat(o.format)
143
+ var format = DPGlobal.parseFormat(o.format);
141
144
  if (o.startDate !== -Infinity) {
142
- o.startDate = DPGlobal.parseDate(o.startDate, format, o.language);
145
+ if (!!o.startDate) {
146
+ if (o.startDate instanceof Date)
147
+ o.startDate = this._local_to_utc(this._zero_time(o.startDate));
148
+ else
149
+ o.startDate = DPGlobal.parseDate(o.startDate, format, o.language);
150
+ } else {
151
+ o.startDate = -Infinity;
152
+ }
143
153
  }
144
154
  if (o.endDate !== Infinity) {
145
- o.endDate = DPGlobal.parseDate(o.endDate, format, o.language);
155
+ if (!!o.endDate) {
156
+ if (o.endDate instanceof Date)
157
+ o.endDate = this._local_to_utc(this._zero_time(o.endDate));
158
+ else
159
+ o.endDate = DPGlobal.parseDate(o.endDate, format, o.language);
160
+ } else {
161
+ o.endDate = Infinity;
162
+ }
146
163
  }
147
164
 
148
165
  o.daysOfWeekDisabled = o.daysOfWeekDisabled||[];
@@ -151,6 +168,38 @@
151
168
  o.daysOfWeekDisabled = $.map(o.daysOfWeekDisabled, function (d) {
152
169
  return parseInt(d, 10);
153
170
  });
171
+
172
+ var plc = String(o.orientation).toLowerCase().split(/\s+/g),
173
+ _plc = o.orientation.toLowerCase();
174
+ plc = $.grep(plc, function(word){
175
+ return (/^auto|left|right|top|bottom$/).test(word);
176
+ });
177
+ o.orientation = {x: 'auto', y: 'auto'};
178
+ if (!_plc || _plc === 'auto')
179
+ ; // no action
180
+ else if (plc.length === 1){
181
+ switch(plc[0]){
182
+ case 'top':
183
+ case 'bottom':
184
+ o.orientation.y = plc[0];
185
+ break;
186
+ case 'left':
187
+ case 'right':
188
+ o.orientation.x = plc[0];
189
+ break;
190
+ }
191
+ }
192
+ else {
193
+ _plc = $.grep(plc, function(word){
194
+ return (/^left|right$/).test(word);
195
+ });
196
+ o.orientation.x = _plc[0] || 'auto';
197
+
198
+ _plc = $.grep(plc, function(word){
199
+ return (/^top|bottom$/).test(word);
200
+ });
201
+ o.orientation.y = _plc[0] || 'auto';
202
+ }
154
203
  },
155
204
  _events: [],
156
205
  _secondaryEvents: [],
@@ -214,9 +263,9 @@
214
263
  // Clicked outside the datepicker, hide it
215
264
  if (!(
216
265
  this.element.is(e.target) ||
217
- this.element.find(e.target).size() ||
266
+ this.element.find(e.target).length ||
218
267
  this.picker.is(e.target) ||
219
- this.picker.find(e.target).size()
268
+ this.picker.find(e.target).length
220
269
  )) {
221
270
  this.hide();
222
271
  }
@@ -240,7 +289,7 @@
240
289
  },
241
290
  _trigger: function(event, altdate){
242
291
  var date = altdate || this.date,
243
- local_date = new Date(date.getTime() + (date.getTimezoneOffset()*60000));
292
+ local_date = this._utc_to_local(date);
244
293
 
245
294
  this.element.trigger({
246
295
  type: event,
@@ -295,9 +344,21 @@
295
344
  }
296
345
  },
297
346
 
347
+ _utc_to_local: function(utc){
348
+ return new Date(utc.getTime() + (utc.getTimezoneOffset()*60000));
349
+ },
350
+ _local_to_utc: function(local){
351
+ return new Date(local.getTime() - (local.getTimezoneOffset()*60000));
352
+ },
353
+ _zero_time: function(local){
354
+ return new Date(local.getFullYear(), local.getMonth(), local.getDate());
355
+ },
356
+ _zero_utc_time: function(utc){
357
+ return new Date(Date.UTC(utc.getUTCFullYear(), utc.getUTCMonth(), utc.getUTCDate()));
358
+ },
359
+
298
360
  getDate: function() {
299
- var d = this.getUTCDate();
300
- return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
361
+ return this._utc_to_local(this.getUTCDate());
301
362
  },
302
363
 
303
364
  getUTCDate: function() {
@@ -305,7 +366,7 @@
305
366
  },
306
367
 
307
368
  setDate: function(d) {
308
- this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
369
+ this.setUTCDate(this._local_to_utc(d));
309
370
  },
310
371
 
311
372
  setUTCDate: function(d) {
@@ -317,10 +378,10 @@
317
378
  var formatted = this.getFormattedDate();
318
379
  if (!this.isInput) {
319
380
  if (this.component){
320
- this.element.find('input').val(formatted);
381
+ this.element.find('input').val(formatted).change();
321
382
  }
322
383
  } else {
323
- this.element.val(formatted);
384
+ this.element.val(formatted).change();
324
385
  }
325
386
  },
326
387
 
@@ -350,14 +411,64 @@
350
411
 
351
412
  place: function(){
352
413
  if(this.isInline) return;
414
+ var calendarWidth = this.picker.outerWidth(),
415
+ calendarHeight = this.picker.outerHeight(),
416
+ visualPadding = 10,
417
+ windowWidth = $window.width(),
418
+ windowHeight = $window.height(),
419
+ scrollTop = $window.scrollTop();
420
+
353
421
  var zIndex = parseInt(this.element.parents().filter(function() {
354
422
  return $(this).css('z-index') != 'auto';
355
423
  }).first().css('z-index'))+10;
356
424
  var offset = this.component ? this.component.parent().offset() : this.element.offset();
357
- var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(true);
425
+ var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(false);
426
+ var width = this.component ? this.component.outerWidth(true) : this.element.outerWidth(false);
427
+ var left = offset.left,
428
+ top = offset.top;
429
+
430
+ this.picker.removeClass(
431
+ 'datepicker-orient-top datepicker-orient-bottom '+
432
+ 'datepicker-orient-right datepicker-orient-left'
433
+ );
434
+
435
+ if (this.o.orientation.x !== 'auto') {
436
+ this.picker.addClass('datepicker-orient-' + this.o.orientation.x);
437
+ if (this.o.orientation.x === 'right')
438
+ left -= calendarWidth - width;
439
+ }
440
+ // auto x orientation is best-placement: if it crosses a window
441
+ // edge, fudge it sideways
442
+ else {
443
+ // Default to left
444
+ this.picker.addClass('datepicker-orient-left');
445
+ if (offset.left < 0)
446
+ left -= offset.left - visualPadding;
447
+ else if (offset.left + calendarWidth > windowWidth)
448
+ left = windowWidth - calendarWidth - visualPadding;
449
+ }
450
+
451
+ // auto y orientation is best-situation: top or bottom, no fudging,
452
+ // decision based on which shows more of the calendar
453
+ var yorient = this.o.orientation.y,
454
+ top_overflow, bottom_overflow;
455
+ if (yorient === 'auto') {
456
+ top_overflow = -scrollTop + offset.top - calendarHeight;
457
+ bottom_overflow = scrollTop + windowHeight - (offset.top + height + calendarHeight);
458
+ if (Math.max(top_overflow, bottom_overflow) === bottom_overflow)
459
+ yorient = 'top';
460
+ else
461
+ yorient = 'bottom';
462
+ }
463
+ this.picker.addClass('datepicker-orient-' + yorient);
464
+ if (yorient === 'top')
465
+ top += height;
466
+ else
467
+ top -= calendarHeight + parseInt(this.picker.css('padding-top'));
468
+
358
469
  this.picker.css({
359
- top: offset.top + height,
360
- left: offset.left,
470
+ top: top,
471
+ left: left,
361
472
  zIndex: zIndex
362
473
  });
363
474
  },
@@ -366,9 +477,12 @@
366
477
  update: function(){
367
478
  if (!this._allow_update) return;
368
479
 
369
- var date, fromArgs = false;
480
+ var oldDate = new Date(this.date),
481
+ date, fromArgs = false;
370
482
  if(arguments && arguments.length && (typeof arguments[0] === 'string' || arguments[0] instanceof Date)) {
371
483
  date = arguments[0];
484
+ if (date instanceof Date)
485
+ date = this._local_to_utc(date);
372
486
  fromArgs = true;
373
487
  } else {
374
488
  date = this.isInput ? this.element.val() : this.element.data('date') || this.element.find('input').val();
@@ -377,14 +491,27 @@
377
491
 
378
492
  this.date = DPGlobal.parseDate(date, this.o.format, this.o.language);
379
493
 
380
- if(fromArgs) this.setValue();
494
+ if (fromArgs) {
495
+ // setting date by clicking
496
+ this.setValue();
497
+ } else if (date) {
498
+ // setting date by typing
499
+ if (oldDate.getTime() !== this.date.getTime())
500
+ this._trigger('changeDate');
501
+ } else {
502
+ // clearing date
503
+ this._trigger('clearDate');
504
+ }
381
505
 
382
506
  if (this.date < this.o.startDate) {
383
507
  this.viewDate = new Date(this.o.startDate);
508
+ this.date = new Date(this.o.startDate);
384
509
  } else if (this.date > this.o.endDate) {
385
510
  this.viewDate = new Date(this.o.endDate);
511
+ this.date = new Date(this.o.endDate);
386
512
  } else {
387
513
  this.viewDate = new Date(this.date);
514
+ this.date = new Date(this.date);
388
515
  }
389
516
  this.fill();
390
517
  },
@@ -508,19 +635,21 @@
508
635
  clsName = this.getClassNames(prevMonth);
509
636
  clsName.push('day');
510
637
 
511
- var before = this.o.beforeShowDay(prevMonth);
512
- if (before === undefined)
513
- before = {};
514
- else if (typeof(before) === 'boolean')
515
- before = {enabled: before};
516
- else if (typeof(before) === 'string')
517
- before = {classes: before};
518
- if (before.enabled === false)
519
- clsName.push('disabled');
520
- if (before.classes)
521
- clsName = clsName.concat(before.classes.split(/\s+/));
522
- if (before.tooltip)
523
- tooltip = before.tooltip;
638
+ if (this.o.beforeShowDay !== $.noop){
639
+ var before = this.o.beforeShowDay(this._utc_to_local(prevMonth));
640
+ if (before === undefined)
641
+ before = {};
642
+ else if (typeof(before) === 'boolean')
643
+ before = {enabled: before};
644
+ else if (typeof(before) === 'string')
645
+ before = {classes: before};
646
+ if (before.enabled === false)
647
+ clsName.push('disabled');
648
+ if (before.classes)
649
+ clsName = clsName.concat(before.classes.split(/\s+/));
650
+ if (before.tooltip)
651
+ tooltip = before.tooltip;
652
+ }
524
653
 
525
654
  clsName = $.unique(clsName);
526
655
  html.push('<td class="'+clsName.join(' ')+'"' + (tooltip ? ' title="'+tooltip+'"' : '') + '>'+prevMonth.getUTCDate() + '</td>');
@@ -616,10 +745,13 @@
616
745
  switch(this.viewMode){
617
746
  case 0:
618
747
  this.viewDate = this.moveMonth(this.viewDate, dir);
748
+ this._trigger('changeMonth', this.viewDate);
619
749
  break;
620
750
  case 1:
621
751
  case 2:
622
752
  this.viewDate = this.moveYear(this.viewDate, dir);
753
+ if (this.viewMode === 1)
754
+ this._trigger('changeYear', this.viewDate);
623
755
  break;
624
756
  }
625
757
  this.fill();
@@ -716,9 +848,9 @@
716
848
  }
717
849
  if (element) {
718
850
  element.change();
719
- if (this.o.autoclose && (!which || which == 'date')) {
720
- this.hide();
721
- }
851
+ }
852
+ if (this.o.autoclose && (!which || which == 'date')) {
853
+ this.hide();
722
854
  }
723
855
  },
724
856
 
@@ -791,9 +923,11 @@
791
923
  if (e.ctrlKey){
792
924
  newDate = this.moveYear(this.date, dir);
793
925
  newViewDate = this.moveYear(this.viewDate, dir);
926
+ this._trigger('changeYear', this.viewDate);
794
927
  } else if (e.shiftKey){
795
928
  newDate = this.moveMonth(this.date, dir);
796
929
  newViewDate = this.moveMonth(this.viewDate, dir);
930
+ this._trigger('changeMonth', this.viewDate);
797
931
  } else {
798
932
  newDate = new Date(this.date);
799
933
  newDate.setUTCDate(this.date.getUTCDate() + dir);
@@ -816,9 +950,11 @@
816
950
  if (e.ctrlKey){
817
951
  newDate = this.moveYear(this.date, dir);
818
952
  newViewDate = this.moveYear(this.viewDate, dir);
953
+ this._trigger('changeYear', this.viewDate);
819
954
  } else if (e.shiftKey){
820
955
  newDate = this.moveMonth(this.date, dir);
821
956
  newViewDate = this.moveMonth(this.viewDate, dir);
957
+ this._trigger('changeMonth', this.viewDate);
822
958
  } else {
823
959
  newDate = new Date(this.date);
824
960
  newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
@@ -950,7 +1086,7 @@
950
1086
  return;
951
1087
  }
952
1088
  var d = dates[lang];
953
- $.each($.fn.datepicker.locale_opts, function(i,k){
1089
+ $.each(locale_opts, function(i,k){
954
1090
  if (k in d)
955
1091
  out[k] = d[k];
956
1092
  });
@@ -970,10 +1106,10 @@
970
1106
  if (!data) {
971
1107
  var elopts = opts_from_el(this, 'date'),
972
1108
  // Preliminary otions
973
- xopts = $.extend({}, $.fn.datepicker.defaults, elopts, options),
1109
+ xopts = $.extend({}, defaults, elopts, options),
974
1110
  locopts = opts_from_locale(xopts.language),
975
1111
  // Options priority: js args, data-attrs, locales, defaults
976
- opts = $.extend({}, $.fn.datepicker.defaults, locopts, elopts, options);
1112
+ opts = $.extend({}, defaults, locopts, elopts, options);
977
1113
  if ($this.is('.input-daterange') || opts.inputs){
978
1114
  var ropts = {
979
1115
  inputs: opts.inputs || $this.find('input').toArray()
@@ -996,7 +1132,7 @@
996
1132
  return this;
997
1133
  };
998
1134
 
999
- $.fn.datepicker.defaults = {
1135
+ var defaults = $.fn.datepicker.defaults = {
1000
1136
  autoclose: false,
1001
1137
  beforeShowDay: $.noop,
1002
1138
  calendarWeeks: false,
@@ -1008,6 +1144,7 @@
1008
1144
  keyboardNavigation: true,
1009
1145
  language: 'en',
1010
1146
  minViewMode: 0,
1147
+ orientation: "auto",
1011
1148
  rtl: false,
1012
1149
  startDate: -Infinity,
1013
1150
  startView: 0,
@@ -1015,7 +1152,7 @@
1015
1152
  todayHighlight: false,
1016
1153
  weekStart: 0
1017
1154
  };
1018
- $.fn.datepicker.locale_opts = [
1155
+ var locale_opts = $.fn.datepicker.locale_opts = [
1019
1156
  'format',
1020
1157
  'rtl',
1021
1158
  'weekStart'
@@ -1105,6 +1242,8 @@
1105
1242
  yyyy: function(d,v){ return d.setUTCFullYear(v); },
1106
1243
  yy: function(d,v){ return d.setUTCFullYear(2000+v); },
1107
1244
  m: function(d,v){
1245
+ if (isNaN(d))
1246
+ return d;
1108
1247
  v -= 1;
1109
1248
  while (v<0) v += 12;
1110
1249
  v %= 12;
@@ -1153,10 +1292,14 @@
1153
1292
  }
1154
1293
  parsed[part] = val;
1155
1294
  }
1156
- for (var i=0, s; i<setters_order.length; i++){
1295
+ for (var i=0, _date, s; i<setters_order.length; i++){
1157
1296
  s = setters_order[i];
1158
- if (s in parsed && !isNaN(parsed[s]))
1159
- setters_map[s](date, parsed[s]);
1297
+ if (s in parsed && !isNaN(parsed[s])){
1298
+ _date = new Date(date);
1299
+ setters_map[s](_date, parsed[s]);
1300
+ if (!isNaN(_date))
1301
+ date = _date;
1302
+ }
1160
1303
  }
1161
1304
  }
1162
1305
  return date;
@@ -1187,9 +1330,9 @@
1187
1330
  },
1188
1331
  headTemplate: '<thead>'+
1189
1332
  '<tr>'+
1190
- '<th class="prev"><i class="icon-arrow-left"/></th>'+
1333
+ '<th class="prev">&laquo;</th>'+
1191
1334
  '<th colspan="5" class="datepicker-switch"></th>'+
1192
- '<th class="next"><i class="icon-arrow-right"/></th>'+
1335
+ '<th class="next">&raquo;</th>'+
1193
1336
  '</tr>'+
1194
1337
  '</thead>',
1195
1338
  contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
@@ -1,4 +1,20 @@
1
- /* bootstrap-datepicker.js 1.1.3
1
+ /* =========================================================
2
+ * bootstrap-datepicker.js
2
3
  * http://www.eyecon.ro/bootstrap-datepicker
3
- */
4
- !function(t){function e(){return new Date(Date.UTC.apply(Date,arguments))}function a(e,a){var i,s=t(e).data(),n={},h=new RegExp("^"+a.toLowerCase()+"([A-Z])"),a=new RegExp("^"+a.toLowerCase());for(var r in s)a.test(r)&&(i=r.replace(h,function(t,e){return e.toLowerCase()}),n[i]=s[r]);return n}function i(e){var a={};if(r[e]||(e=e.split("-")[0],r[e])){var i=r[e];return t.each(t.fn.datepicker.locale_opts,function(t,e){e in i&&(a[e]=i[e])}),a}}var s=function(e,a){this._process_options(a),this.element=t(e),this.isInline=!1,this.isInput=this.element.is("input"),this.component=this.element.is(".date")?this.element.find(".add-on, .btn"):!1,this.hasInput=this.component&&this.element.find("input").length,this.component&&0===this.component.length&&(this.component=!1),this.picker=t(o.template),this._buildEvents(),this._attachEvents(),this.isInline?this.picker.addClass("datepicker-inline").appendTo(this.element):this.picker.addClass("datepicker-dropdown dropdown-menu"),this.o.rtl&&(this.picker.addClass("datepicker-rtl"),this.picker.find(".prev i, .next i").toggleClass("icon-arrow-left icon-arrow-right")),this.viewMode=this.o.startView,this.o.calendarWeeks&&this.picker.find("tfoot th.today").attr("colspan",function(t,e){return parseInt(e)+1}),this._allow_update=!1,this.setStartDate(this.o.startDate),this.setEndDate(this.o.endDate),this.setDaysOfWeekDisabled(this.o.daysOfWeekDisabled),this.fillDow(),this.fillMonths(),this._allow_update=!0,this.update(),this.showMode(),this.isInline&&this.show()};s.prototype={constructor:s,_process_options:function(e){this._o=t.extend({},this._o,e);var a=this.o=t.extend({},this._o),i=a.language;switch(r[i]||(i=i.split("-")[0],r[i]||(i=t.fn.datepicker.defaults.language)),a.language=i,a.startView){case 2:case"decade":a.startView=2;break;case 1:case"year":a.startView=1;break;default:a.startView=0}switch(a.minViewMode){case 1:case"months":a.minViewMode=1;break;case 2:case"years":a.minViewMode=2;break;default:a.minViewMode=0}a.startView=Math.max(a.startView,a.minViewMode),a.weekStart%=7,a.weekEnd=(a.weekStart+6)%7;var s=o.parseFormat(a.format);a.startDate!==-1/0&&(a.startDate=o.parseDate(a.startDate,s,a.language)),1/0!==a.endDate&&(a.endDate=o.parseDate(a.endDate,s,a.language)),a.daysOfWeekDisabled=a.daysOfWeekDisabled||[],t.isArray(a.daysOfWeekDisabled)||(a.daysOfWeekDisabled=a.daysOfWeekDisabled.split(/[,\s]*/)),a.daysOfWeekDisabled=t.map(a.daysOfWeekDisabled,function(t){return parseInt(t,10)})},_events:[],_secondaryEvents:[],_applyEvents:function(t){for(var e,a,i=0;i<t.length;i++)e=t[i][0],a=t[i][1],e.on(a)},_unapplyEvents:function(t){for(var e,a,i=0;i<t.length;i++)e=t[i][0],a=t[i][1],e.off(a)},_buildEvents:function(){this.isInput?this._events=[[this.element,{focus:t.proxy(this.show,this),keyup:t.proxy(this.update,this),keydown:t.proxy(this.keydown,this)}]]:this.component&&this.hasInput?this._events=[[this.element.find("input"),{focus:t.proxy(this.show,this),keyup:t.proxy(this.update,this),keydown:t.proxy(this.keydown,this)}],[this.component,{click:t.proxy(this.show,this)}]]:this.element.is("div")?this.isInline=!0:this._events=[[this.element,{click:t.proxy(this.show,this)}]],this._secondaryEvents=[[this.picker,{click:t.proxy(this.click,this)}],[t(window),{resize:t.proxy(this.place,this)}],[t(document),{mousedown:t.proxy(function(t){this.element.is(t.target)||this.element.find(t.target).size()||this.picker.is(t.target)||this.picker.find(t.target).size()||this.hide()},this)}]]},_attachEvents:function(){this._detachEvents(),this._applyEvents(this._events)},_detachEvents:function(){this._unapplyEvents(this._events)},_attachSecondaryEvents:function(){this._detachSecondaryEvents(),this._applyEvents(this._secondaryEvents)},_detachSecondaryEvents:function(){this._unapplyEvents(this._secondaryEvents)},_trigger:function(e,a){var i=a||this.date,s=new Date(i.getTime()+6e4*i.getTimezoneOffset());this.element.trigger({type:e,date:s,format:t.proxy(function(t){var e=t||this.o.format;return o.formatDate(i,e,this.o.language)},this)})},show:function(t){this.isInline||this.picker.appendTo("body"),this.picker.show(),this.height=this.component?this.component.outerHeight():this.element.outerHeight(),this.place(),this._attachSecondaryEvents(),t&&t.preventDefault(),this._trigger("show")},hide:function(){this.isInline||this.picker.is(":visible")&&(this.picker.hide().detach(),this._detachSecondaryEvents(),this.viewMode=this.o.startView,this.showMode(),this.o.forceParse&&(this.isInput&&this.element.val()||this.hasInput&&this.element.find("input").val())&&this.setValue(),this._trigger("hide"))},remove:function(){this.hide(),this._detachEvents(),this._detachSecondaryEvents(),this.picker.remove(),delete this.element.data().datepicker,this.isInput||delete this.element.data().date},getDate:function(){var t=this.getUTCDate();return new Date(t.getTime()+6e4*t.getTimezoneOffset())},getUTCDate:function(){return this.date},setDate:function(t){this.setUTCDate(new Date(t.getTime()-6e4*t.getTimezoneOffset()))},setUTCDate:function(t){this.date=t,this.setValue()},setValue:function(){var t=this.getFormattedDate();this.isInput?this.element.val(t):this.component&&this.element.find("input").val(t)},getFormattedDate:function(t){return void 0===t&&(t=this.o.format),o.formatDate(this.date,t,this.o.language)},setStartDate:function(t){this._process_options({startDate:t}),this.update(),this.updateNavArrows()},setEndDate:function(t){this._process_options({endDate:t}),this.update(),this.updateNavArrows()},setDaysOfWeekDisabled:function(t){this._process_options({daysOfWeekDisabled:t}),this.update(),this.updateNavArrows()},place:function(){if(!this.isInline){var e=parseInt(this.element.parents().filter(function(){return"auto"!=t(this).css("z-index")}).first().css("z-index"))+10,a=this.component?this.component.parent().offset():this.element.offset(),i=this.component?this.component.outerHeight(!0):this.element.outerHeight(!0);this.picker.css({top:a.top+i,left:a.left,zIndex:e})}},_allow_update:!0,update:function(){if(this._allow_update){var t,e=!1;arguments&&arguments.length&&("string"==typeof arguments[0]||arguments[0]instanceof Date)?(t=arguments[0],e=!0):(t=this.isInput?this.element.val():this.element.data("date")||this.element.find("input").val(),delete this.element.data().date),this.date=o.parseDate(t,this.o.format,this.o.language),e&&this.setValue(),this.viewDate=this.date<this.o.startDate?new Date(this.o.startDate):this.date>this.o.endDate?new Date(this.o.endDate):new Date(this.date),this.fill()}},fillDow:function(){var t=this.o.weekStart,e="<tr>";if(this.o.calendarWeeks){var a='<th class="cw">&nbsp;</th>';e+=a,this.picker.find(".datepicker-days thead tr:first-child").prepend(a)}for(;t<this.o.weekStart+7;)e+='<th class="dow">'+r[this.o.language].daysMin[t++%7]+"</th>";e+="</tr>",this.picker.find(".datepicker-days thead").append(e)},fillMonths:function(){for(var t="",e=0;12>e;)t+='<span class="month">'+r[this.o.language].monthsShort[e++]+"</span>";this.picker.find(".datepicker-months td").html(t)},setRange:function(e){e&&e.length?this.range=t.map(e,function(t){return t.valueOf()}):delete this.range,this.fill()},getClassNames:function(e){var a=[],i=this.viewDate.getUTCFullYear(),s=this.viewDate.getUTCMonth(),n=this.date.valueOf(),h=new Date;return e.getUTCFullYear()<i||e.getUTCFullYear()==i&&e.getUTCMonth()<s?a.push("old"):(e.getUTCFullYear()>i||e.getUTCFullYear()==i&&e.getUTCMonth()>s)&&a.push("new"),this.o.todayHighlight&&e.getUTCFullYear()==h.getFullYear()&&e.getUTCMonth()==h.getMonth()&&e.getUTCDate()==h.getDate()&&a.push("today"),n&&e.valueOf()==n&&a.push("active"),(e.valueOf()<this.o.startDate||e.valueOf()>this.o.endDate||-1!==t.inArray(e.getUTCDay(),this.o.daysOfWeekDisabled))&&a.push("disabled"),this.range&&(e>this.range[0]&&e<this.range[this.range.length-1]&&a.push("range"),-1!=t.inArray(e.valueOf(),this.range)&&a.push("selected")),a},fill:function(){var a,i=new Date(this.viewDate),s=i.getUTCFullYear(),n=i.getUTCMonth(),h=this.o.startDate!==-1/0?this.o.startDate.getUTCFullYear():-1/0,d=this.o.startDate!==-1/0?this.o.startDate.getUTCMonth():-1/0,l=1/0!==this.o.endDate?this.o.endDate.getUTCFullYear():1/0,c=1/0!==this.o.endDate?this.o.endDate.getUTCMonth():1/0;this.date&&this.date.valueOf(),this.picker.find(".datepicker-days thead th.datepicker-switch").text(r[this.o.language].months[n]+" "+s),this.picker.find("tfoot th.today").text(r[this.o.language].today).toggle(this.o.todayBtn!==!1),this.picker.find("tfoot th.clear").text(r[this.o.language].clear).toggle(this.o.clearBtn!==!1),this.updateNavArrows(),this.fillMonths();var p=e(s,n-1,28,0,0,0,0),u=o.getDaysInMonth(p.getUTCFullYear(),p.getUTCMonth());p.setUTCDate(u),p.setUTCDate(u-(p.getUTCDay()-this.o.weekStart+7)%7);var f=new Date(p);f.setUTCDate(f.getUTCDate()+42),f=f.valueOf();for(var v,g=[];p.valueOf()<f;){if(p.getUTCDay()==this.o.weekStart&&(g.push("<tr>"),this.o.calendarWeeks)){var D=new Date(+p+864e5*((this.o.weekStart-p.getUTCDay()-7)%7)),m=new Date(+D+864e5*((11-D.getUTCDay())%7)),y=new Date(+(y=e(m.getUTCFullYear(),0,1))+864e5*((11-y.getUTCDay())%7)),w=(m-y)/864e5/7+1;g.push('<td class="cw">'+w+"</td>")}v=this.getClassNames(p),v.push("day");var k=this.o.beforeShowDay(p);void 0===k?k={}:"boolean"==typeof k?k={enabled:k}:"string"==typeof k&&(k={classes:k}),k.enabled===!1&&v.push("disabled"),k.classes&&(v=v.concat(k.classes.split(/\s+/))),k.tooltip&&(a=k.tooltip),v=t.unique(v),g.push('<td class="'+v.join(" ")+'"'+(a?' title="'+a+'"':"")+">"+p.getUTCDate()+"</td>"),p.getUTCDay()==this.o.weekEnd&&g.push("</tr>"),p.setUTCDate(p.getUTCDate()+1)}this.picker.find(".datepicker-days tbody").empty().append(g.join(""));var T=this.date&&this.date.getUTCFullYear(),C=this.picker.find(".datepicker-months").find("th:eq(1)").text(s).end().find("span").removeClass("active");T&&T==s&&C.eq(this.date.getUTCMonth()).addClass("active"),(h>s||s>l)&&C.addClass("disabled"),s==h&&C.slice(0,d).addClass("disabled"),s==l&&C.slice(c+1).addClass("disabled"),g="",s=10*parseInt(s/10,10);var U=this.picker.find(".datepicker-years").find("th:eq(1)").text(s+"-"+(s+9)).end().find("td");s-=1;for(var M=-1;11>M;M++)g+='<span class="year'+(-1==M?" old":10==M?" new":"")+(T==s?" active":"")+(h>s||s>l?" disabled":"")+'">'+s+"</span>",s+=1;U.html(g)},updateNavArrows:function(){if(this._allow_update){var t=new Date(this.viewDate),e=t.getUTCFullYear(),a=t.getUTCMonth();switch(this.viewMode){case 0:this.o.startDate!==-1/0&&e<=this.o.startDate.getUTCFullYear()&&a<=this.o.startDate.getUTCMonth()?this.picker.find(".prev").css({visibility:"hidden"}):this.picker.find(".prev").css({visibility:"visible"}),1/0!==this.o.endDate&&e>=this.o.endDate.getUTCFullYear()&&a>=this.o.endDate.getUTCMonth()?this.picker.find(".next").css({visibility:"hidden"}):this.picker.find(".next").css({visibility:"visible"});break;case 1:case 2:this.o.startDate!==-1/0&&e<=this.o.startDate.getUTCFullYear()?this.picker.find(".prev").css({visibility:"hidden"}):this.picker.find(".prev").css({visibility:"visible"}),1/0!==this.o.endDate&&e>=this.o.endDate.getUTCFullYear()?this.picker.find(".next").css({visibility:"hidden"}):this.picker.find(".next").css({visibility:"visible"})}}},click:function(a){a.preventDefault();var i=t(a.target).closest("span, td, th");if(1==i.length)switch(i[0].nodeName.toLowerCase()){case"th":switch(i[0].className){case"datepicker-switch":this.showMode(1);break;case"prev":case"next":var s=o.modes[this.viewMode].navStep*("prev"==i[0].className?-1:1);switch(this.viewMode){case 0:this.viewDate=this.moveMonth(this.viewDate,s);break;case 1:case 2:this.viewDate=this.moveYear(this.viewDate,s)}this.fill();break;case"today":var n=new Date;n=e(n.getFullYear(),n.getMonth(),n.getDate(),0,0,0),this.showMode(-2);var h="linked"==this.o.todayBtn?null:"view";this._setDate(n,h);break;case"clear":var r;this.isInput?r=this.element:this.component&&(r=this.element.find("input")),r&&r.val("").change(),this._trigger("changeDate"),this.update(),this.o.autoclose&&this.hide()}break;case"span":if(!i.is(".disabled")){if(this.viewDate.setUTCDate(1),i.is(".month")){var d=1,l=i.parent().find("span").index(i),c=this.viewDate.getUTCFullYear();this.viewDate.setUTCMonth(l),this._trigger("changeMonth",this.viewDate),1===this.o.minViewMode&&this._setDate(e(c,l,d,0,0,0,0))}else{var c=parseInt(i.text(),10)||0,d=1,l=0;this.viewDate.setUTCFullYear(c),this._trigger("changeYear",this.viewDate),2===this.o.minViewMode&&this._setDate(e(c,l,d,0,0,0,0))}this.showMode(-1),this.fill()}break;case"td":if(i.is(".day")&&!i.is(".disabled")){var d=parseInt(i.text(),10)||1,c=this.viewDate.getUTCFullYear(),l=this.viewDate.getUTCMonth();i.is(".old")?0===l?(l=11,c-=1):l-=1:i.is(".new")&&(11==l?(l=0,c+=1):l+=1),this._setDate(e(c,l,d,0,0,0,0))}}},_setDate:function(t,e){e&&"date"!=e||(this.date=new Date(t)),e&&"view"!=e||(this.viewDate=new Date(t)),this.fill(),this.setValue(),this._trigger("changeDate");var a;this.isInput?a=this.element:this.component&&(a=this.element.find("input")),a&&(a.change(),!this.o.autoclose||e&&"date"!=e||this.hide())},moveMonth:function(t,e){if(!e)return t;var a,i,s=new Date(t.valueOf()),n=s.getUTCDate(),h=s.getUTCMonth(),r=Math.abs(e);if(e=e>0?1:-1,1==r)i=-1==e?function(){return s.getUTCMonth()==h}:function(){return s.getUTCMonth()!=a},a=h+e,s.setUTCMonth(a),(0>a||a>11)&&(a=(a+12)%12);else{for(var o=0;r>o;o++)s=this.moveMonth(s,e);a=s.getUTCMonth(),s.setUTCDate(n),i=function(){return a!=s.getUTCMonth()}}for(;i();)s.setUTCDate(--n),s.setUTCMonth(a);return s},moveYear:function(t,e){return this.moveMonth(t,12*e)},dateWithinRange:function(t){return t>=this.o.startDate&&t<=this.o.endDate},keydown:function(t){if(this.picker.is(":not(:visible)"))return 27==t.keyCode&&this.show(),void 0;var e,a,i,s=!1;switch(t.keyCode){case 27:this.hide(),t.preventDefault();break;case 37:case 39:if(!this.o.keyboardNavigation)break;e=37==t.keyCode?-1:1,t.ctrlKey?(a=this.moveYear(this.date,e),i=this.moveYear(this.viewDate,e)):t.shiftKey?(a=this.moveMonth(this.date,e),i=this.moveMonth(this.viewDate,e)):(a=new Date(this.date),a.setUTCDate(this.date.getUTCDate()+e),i=new Date(this.viewDate),i.setUTCDate(this.viewDate.getUTCDate()+e)),this.dateWithinRange(a)&&(this.date=a,this.viewDate=i,this.setValue(),this.update(),t.preventDefault(),s=!0);break;case 38:case 40:if(!this.o.keyboardNavigation)break;e=38==t.keyCode?-1:1,t.ctrlKey?(a=this.moveYear(this.date,e),i=this.moveYear(this.viewDate,e)):t.shiftKey?(a=this.moveMonth(this.date,e),i=this.moveMonth(this.viewDate,e)):(a=new Date(this.date),a.setUTCDate(this.date.getUTCDate()+7*e),i=new Date(this.viewDate),i.setUTCDate(this.viewDate.getUTCDate()+7*e)),this.dateWithinRange(a)&&(this.date=a,this.viewDate=i,this.setValue(),this.update(),t.preventDefault(),s=!0);break;case 13:this.hide(),t.preventDefault();break;case 9:this.hide()}if(s){this._trigger("changeDate");var n;this.isInput?n=this.element:this.component&&(n=this.element.find("input")),n&&n.change()}},showMode:function(t){t&&(this.viewMode=Math.max(this.o.minViewMode,Math.min(2,this.viewMode+t))),this.picker.find(">div").hide().filter(".datepicker-"+o.modes[this.viewMode].clsName).css("display","block"),this.updateNavArrows()}};var n=function(e,a){this.element=t(e),this.inputs=t.map(a.inputs,function(t){return t.jquery?t[0]:t}),delete a.inputs,t(this.inputs).datepicker(a).bind("changeDate",t.proxy(this.dateUpdated,this)),this.pickers=t.map(this.inputs,function(e){return t(e).data("datepicker")}),this.updateDates()};n.prototype={updateDates:function(){this.dates=t.map(this.pickers,function(t){return t.date}),this.updateRanges()},updateRanges:function(){var e=t.map(this.dates,function(t){return t.valueOf()});t.each(this.pickers,function(t,a){a.setRange(e)})},dateUpdated:function(e){var a=t(e.target).data("datepicker"),i=a.getUTCDate(),s=t.inArray(e.target,this.inputs),n=this.inputs.length;if(-1!=s){if(i<this.dates[s])for(;s>=0&&i<this.dates[s];)this.pickers[s--].setUTCDate(i);else if(i>this.dates[s])for(;n>s&&i>this.dates[s];)this.pickers[s++].setUTCDate(i);this.updateDates()}},remove:function(){t.map(this.pickers,function(t){t.remove()}),delete this.element.data().datepicker}};var h=t.fn.datepicker;t.fn.datepicker=function(e){var h=Array.apply(null,arguments);h.shift();var r;return this.each(function(){var o=t(this),d=o.data("datepicker"),l="object"==typeof e&&e;if(!d){var c=a(this,"date"),p=t.extend({},t.fn.datepicker.defaults,c,l),u=i(p.language),f=t.extend({},t.fn.datepicker.defaults,u,c,l);if(o.is(".input-daterange")||f.inputs){var v={inputs:f.inputs||o.find("input").toArray()};o.data("datepicker",d=new n(this,t.extend(f,v)))}else o.data("datepicker",d=new s(this,f))}return"string"==typeof e&&"function"==typeof d[e]&&(r=d[e].apply(d,h),void 0!==r)?!1:void 0}),void 0!==r?r:this},t.fn.datepicker.defaults={autoclose:!1,beforeShowDay:t.noop,calendarWeeks:!1,clearBtn:!1,daysOfWeekDisabled:[],endDate:1/0,forceParse:!0,format:"mm/dd/yyyy",keyboardNavigation:!0,language:"en",minViewMode:0,rtl:!1,startDate:-1/0,startView:0,todayBtn:!1,todayHighlight:!1,weekStart:0},t.fn.datepicker.locale_opts=["format","rtl","weekStart"],t.fn.datepicker.Constructor=s;var r=t.fn.datepicker.dates={en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa","Su"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],today:"Today",clear:"Clear"}},o={modes:[{clsName:"days",navFnc:"Month",navStep:1},{clsName:"months",navFnc:"FullYear",navStep:1},{clsName:"years",navFnc:"FullYear",navStep:10}],isLeapYear:function(t){return 0===t%4&&0!==t%100||0===t%400},getDaysInMonth:function(t,e){return[31,o.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]},validParts:/dd?|DD?|mm?|MM?|yy(?:yy)?/g,nonpunctuation:/[^ -\/:-@\[\u3400-\u9fff-`{-~\t\n\r]+/g,parseFormat:function(t){var e=t.replace(this.validParts,"\0").split("\0"),a=t.match(this.validParts);if(!e||!e.length||!a||0===a.length)throw new Error("Invalid date format.");return{separators:e,parts:a}},parseDate:function(a,i,n){if(a instanceof Date)return a;if("string"==typeof i&&(i=o.parseFormat(i)),/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(a)){var h,d,l=/([\-+]\d+)([dmwy])/,c=a.match(/([\-+]\d+)([dmwy])/g);a=new Date;for(var p=0;p<c.length;p++)switch(h=l.exec(c[p]),d=parseInt(h[1]),h[2]){case"d":a.setUTCDate(a.getUTCDate()+d);break;case"m":a=s.prototype.moveMonth.call(s.prototype,a,d);break;case"w":a.setUTCDate(a.getUTCDate()+7*d);break;case"y":a=s.prototype.moveYear.call(s.prototype,a,d)}return e(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),0,0,0)}var u,f,h,c=a&&a.match(this.nonpunctuation)||[],a=new Date,v={},g=["yyyy","yy","M","MM","m","mm","d","dd"],D={yyyy:function(t,e){return t.setUTCFullYear(e)},yy:function(t,e){return t.setUTCFullYear(2e3+e)},m:function(t,e){for(e-=1;0>e;)e+=12;for(e%=12,t.setUTCMonth(e);t.getUTCMonth()!=e;)t.setUTCDate(t.getUTCDate()-1);return t},d:function(t,e){return t.setUTCDate(e)}};D.M=D.MM=D.mm=D.m,D.dd=D.d,a=e(a.getFullYear(),a.getMonth(),a.getDate(),0,0,0);var m=i.parts.slice();if(c.length!=m.length&&(m=t(m).filter(function(e,a){return-1!==t.inArray(a,g)}).toArray()),c.length==m.length){for(var p=0,y=m.length;y>p;p++){if(u=parseInt(c[p],10),h=m[p],isNaN(u))switch(h){case"MM":f=t(r[n].months).filter(function(){var t=this.slice(0,c[p].length),e=c[p].slice(0,t.length);return t==e}),u=t.inArray(f[0],r[n].months)+1;break;case"M":f=t(r[n].monthsShort).filter(function(){var t=this.slice(0,c[p].length),e=c[p].slice(0,t.length);return t==e}),u=t.inArray(f[0],r[n].monthsShort)+1}v[h]=u}for(var w,p=0;p<g.length;p++)w=g[p],w in v&&!isNaN(v[w])&&D[w](a,v[w])}return a},formatDate:function(e,a,i){"string"==typeof a&&(a=o.parseFormat(a));var s={d:e.getUTCDate(),D:r[i].daysShort[e.getUTCDay()],DD:r[i].days[e.getUTCDay()],m:e.getUTCMonth()+1,M:r[i].monthsShort[e.getUTCMonth()],MM:r[i].months[e.getUTCMonth()],yy:e.getUTCFullYear().toString().substring(2),yyyy:e.getUTCFullYear()};s.dd=(s.d<10?"0":"")+s.d,s.mm=(s.m<10?"0":"")+s.m;for(var e=[],n=t.extend([],a.separators),h=0,d=a.parts.length;d>=h;h++)n.length&&e.push(n.shift()),e.push(s[a.parts[h]]);return e.join("")},headTemplate:'<thead><tr><th class="prev"><i class="icon-arrow-left"/></th><th colspan="5" class="datepicker-switch"></th><th class="next"><i class="icon-arrow-right"/></th></tr></thead>',contTemplate:'<tbody><tr><td colspan="7"></td></tr></tbody>',footTemplate:'<tfoot><tr><th colspan="7" class="today"></th></tr><tr><th colspan="7" class="clear"></th></tr></tfoot>'};o.template='<div class="datepicker"><div class="datepicker-days"><table class=" table-condensed">'+o.headTemplate+"<tbody></tbody>"+o.footTemplate+"</table>"+"</div>"+'<div class="datepicker-months">'+'<table class="table-condensed">'+o.headTemplate+o.contTemplate+o.footTemplate+"</table>"+"</div>"+'<div class="datepicker-years">'+'<table class="table-condensed">'+o.headTemplate+o.contTemplate+o.footTemplate+"</table>"+"</div>"+"</div>",t.fn.datepicker.DPGlobal=o,t.fn.datepicker.noConflict=function(){return t.fn.datepicker=h,this},t(document).on("focus.datepicker.data-api click.datepicker.data-api",'[data-provide="datepicker"]',function(e){var a=t(this);a.data("datepicker")||(e.preventDefault(),a.datepicker("show"))}),t(function(){t('[data-provide="datepicker-inline"]').datepicker()})}(window.jQuery);
4
+ * =========================================================
5
+ * Copyright 2012 Stefan Petre
6
+ * Improvements by Andrew Rowls
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ * ========================================================= */
20
+ !function(t){function e(){return new Date(Date.UTC.apply(Date,arguments))}function i(e,i){var a,s=t(e).data(),n={},r=new RegExp("^"+i.toLowerCase()+"([A-Z])"),i=new RegExp("^"+i.toLowerCase());for(var h in s)i.test(h)&&(a=h.replace(r,function(t,e){return e.toLowerCase()}),n[a]=s[h]);return n}function a(e){var i={};if(l[e]||(e=e.split("-")[0],l[e])){var a=l[e];return t.each(d,function(t,e){e in a&&(i[e]=a[e])}),i}}var s=t(window),n=function(e,i){this._process_options(i),this.element=t(e),this.isInline=!1,this.isInput=this.element.is("input"),this.component=this.element.is(".date")?this.element.find(".add-on, .btn"):!1,this.hasInput=this.component&&this.element.find("input").length,this.component&&0===this.component.length&&(this.component=!1),this.picker=t(c.template),this._buildEvents(),this._attachEvents(),this.isInline?this.picker.addClass("datepicker-inline").appendTo(this.element):this.picker.addClass("datepicker-dropdown dropdown-menu"),this.o.rtl&&(this.picker.addClass("datepicker-rtl"),this.picker.find(".prev i, .next i").toggleClass("icon-arrow-left icon-arrow-right")),this.viewMode=this.o.startView,this.o.calendarWeeks&&this.picker.find("tfoot th.today").attr("colspan",function(t,e){return parseInt(e)+1}),this._allow_update=!1,this.setStartDate(this._o.startDate),this.setEndDate(this._o.endDate),this.setDaysOfWeekDisabled(this.o.daysOfWeekDisabled),this.fillDow(),this.fillMonths(),this._allow_update=!0,this.update(),this.showMode(),this.isInline&&this.show()};n.prototype={constructor:n,_process_options:function(e){this._o=t.extend({},this._o,e);var i=this.o=t.extend({},this._o),a=i.language;switch(l[a]||(a=a.split("-")[0],l[a]||(a=o.language)),i.language=a,i.startView){case 2:case"decade":i.startView=2;break;case 1:case"year":i.startView=1;break;default:i.startView=0}switch(i.minViewMode){case 1:case"months":i.minViewMode=1;break;case 2:case"years":i.minViewMode=2;break;default:i.minViewMode=0}i.startView=Math.max(i.startView,i.minViewMode),i.weekStart%=7,i.weekEnd=(i.weekStart+6)%7;var s=c.parseFormat(i.format);i.startDate!==-1/0&&(i.startDate=i.startDate?i.startDate instanceof Date?this._local_to_utc(this._zero_time(i.startDate)):c.parseDate(i.startDate,s,i.language):-1/0),1/0!==i.endDate&&(i.endDate=i.endDate?i.endDate instanceof Date?this._local_to_utc(this._zero_time(i.endDate)):c.parseDate(i.endDate,s,i.language):1/0),i.daysOfWeekDisabled=i.daysOfWeekDisabled||[],t.isArray(i.daysOfWeekDisabled)||(i.daysOfWeekDisabled=i.daysOfWeekDisabled.split(/[,\s]*/)),i.daysOfWeekDisabled=t.map(i.daysOfWeekDisabled,function(t){return parseInt(t,10)});var n=String(i.orientation).toLowerCase().split(/\s+/g),r=i.orientation.toLowerCase();if(n=t.grep(n,function(t){return/^auto|left|right|top|bottom$/.test(t)}),i.orientation={x:"auto",y:"auto"},r&&"auto"!==r)if(1===n.length)switch(n[0]){case"top":case"bottom":i.orientation.y=n[0];break;case"left":case"right":i.orientation.x=n[0]}else r=t.grep(n,function(t){return/^left|right$/.test(t)}),i.orientation.x=r[0]||"auto",r=t.grep(n,function(t){return/^top|bottom$/.test(t)}),i.orientation.y=r[0]||"auto";else;},_events:[],_secondaryEvents:[],_applyEvents:function(t){for(var e,i,a=0;a<t.length;a++)e=t[a][0],i=t[a][1],e.on(i)},_unapplyEvents:function(t){for(var e,i,a=0;a<t.length;a++)e=t[a][0],i=t[a][1],e.off(i)},_buildEvents:function(){this.isInput?this._events=[[this.element,{focus:t.proxy(this.show,this),keyup:t.proxy(this.update,this),keydown:t.proxy(this.keydown,this)}]]:this.component&&this.hasInput?this._events=[[this.element.find("input"),{focus:t.proxy(this.show,this),keyup:t.proxy(this.update,this),keydown:t.proxy(this.keydown,this)}],[this.component,{click:t.proxy(this.show,this)}]]:this.element.is("div")?this.isInline=!0:this._events=[[this.element,{click:t.proxy(this.show,this)}]],this._secondaryEvents=[[this.picker,{click:t.proxy(this.click,this)}],[t(window),{resize:t.proxy(this.place,this)}],[t(document),{mousedown:t.proxy(function(t){this.element.is(t.target)||this.element.find(t.target).length||this.picker.is(t.target)||this.picker.find(t.target).length||this.hide()},this)}]]},_attachEvents:function(){this._detachEvents(),this._applyEvents(this._events)},_detachEvents:function(){this._unapplyEvents(this._events)},_attachSecondaryEvents:function(){this._detachSecondaryEvents(),this._applyEvents(this._secondaryEvents)},_detachSecondaryEvents:function(){this._unapplyEvents(this._secondaryEvents)},_trigger:function(e,i){var a=i||this.date,s=this._utc_to_local(a);this.element.trigger({type:e,date:s,format:t.proxy(function(t){var e=t||this.o.format;return c.formatDate(a,e,this.o.language)},this)})},show:function(t){this.isInline||this.picker.appendTo("body"),this.picker.show(),this.height=this.component?this.component.outerHeight():this.element.outerHeight(),this.place(),this._attachSecondaryEvents(),t&&t.preventDefault(),this._trigger("show")},hide:function(){this.isInline||this.picker.is(":visible")&&(this.picker.hide().detach(),this._detachSecondaryEvents(),this.viewMode=this.o.startView,this.showMode(),this.o.forceParse&&(this.isInput&&this.element.val()||this.hasInput&&this.element.find("input").val())&&this.setValue(),this._trigger("hide"))},remove:function(){this.hide(),this._detachEvents(),this._detachSecondaryEvents(),this.picker.remove(),delete this.element.data().datepicker,this.isInput||delete this.element.data().date},_utc_to_local:function(t){return new Date(t.getTime()+6e4*t.getTimezoneOffset())},_local_to_utc:function(t){return new Date(t.getTime()-6e4*t.getTimezoneOffset())},_zero_time:function(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())},_zero_utc_time:function(t){return new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()))},getDate:function(){return this._utc_to_local(this.getUTCDate())},getUTCDate:function(){return this.date},setDate:function(t){this.setUTCDate(this._local_to_utc(t))},setUTCDate:function(t){this.date=t,this.setValue()},setValue:function(){var t=this.getFormattedDate();this.isInput?this.element.val(t).change():this.component&&this.element.find("input").val(t).change()},getFormattedDate:function(t){return void 0===t&&(t=this.o.format),c.formatDate(this.date,t,this.o.language)},setStartDate:function(t){this._process_options({startDate:t}),this.update(),this.updateNavArrows()},setEndDate:function(t){this._process_options({endDate:t}),this.update(),this.updateNavArrows()},setDaysOfWeekDisabled:function(t){this._process_options({daysOfWeekDisabled:t}),this.update(),this.updateNavArrows()},place:function(){if(!this.isInline){var e=this.picker.outerWidth(),i=this.picker.outerHeight(),a=10,n=s.width(),r=s.height(),h=s.scrollTop(),o=parseInt(this.element.parents().filter(function(){return"auto"!=t(this).css("z-index")}).first().css("z-index"))+10,d=this.component?this.component.parent().offset():this.element.offset(),l=this.component?this.component.outerHeight(!0):this.element.outerHeight(!1),c=this.component?this.component.outerWidth(!0):this.element.outerWidth(!1),p=d.left,u=d.top;this.picker.removeClass("datepicker-orient-top datepicker-orient-bottom datepicker-orient-right datepicker-orient-left"),"auto"!==this.o.orientation.x?(this.picker.addClass("datepicker-orient-"+this.o.orientation.x),"right"===this.o.orientation.x&&(p-=e-c)):(this.picker.addClass("datepicker-orient-left"),d.left<0?p-=d.left-a:d.left+e>n&&(p=n-e-a));var f,g,v=this.o.orientation.y;"auto"===v&&(f=-h+d.top-i,g=h+r-(d.top+l+i),v=Math.max(f,g)===g?"top":"bottom"),this.picker.addClass("datepicker-orient-"+v),"top"===v?u+=l:u-=i+parseInt(this.picker.css("padding-top")),this.picker.css({top:u,left:p,zIndex:o})}},_allow_update:!0,update:function(){if(this._allow_update){var t,e=new Date(this.date),i=!1;arguments&&arguments.length&&("string"==typeof arguments[0]||arguments[0]instanceof Date)?(t=arguments[0],t instanceof Date&&(t=this._local_to_utc(t)),i=!0):(t=this.isInput?this.element.val():this.element.data("date")||this.element.find("input").val(),delete this.element.data().date),this.date=c.parseDate(t,this.o.format,this.o.language),i?this.setValue():t?e.getTime()!==this.date.getTime()&&this._trigger("changeDate"):this._trigger("clearDate"),this.date<this.o.startDate?(this.viewDate=new Date(this.o.startDate),this.date=new Date(this.o.startDate)):this.date>this.o.endDate?(this.viewDate=new Date(this.o.endDate),this.date=new Date(this.o.endDate)):(this.viewDate=new Date(this.date),this.date=new Date(this.date)),this.fill()}},fillDow:function(){var t=this.o.weekStart,e="<tr>";if(this.o.calendarWeeks){var i='<th class="cw">&nbsp;</th>';e+=i,this.picker.find(".datepicker-days thead tr:first-child").prepend(i)}for(;t<this.o.weekStart+7;)e+='<th class="dow">'+l[this.o.language].daysMin[t++%7]+"</th>";e+="</tr>",this.picker.find(".datepicker-days thead").append(e)},fillMonths:function(){for(var t="",e=0;12>e;)t+='<span class="month">'+l[this.o.language].monthsShort[e++]+"</span>";this.picker.find(".datepicker-months td").html(t)},setRange:function(e){e&&e.length?this.range=t.map(e,function(t){return t.valueOf()}):delete this.range,this.fill()},getClassNames:function(e){var i=[],a=this.viewDate.getUTCFullYear(),s=this.viewDate.getUTCMonth(),n=this.date.valueOf(),r=new Date;return e.getUTCFullYear()<a||e.getUTCFullYear()==a&&e.getUTCMonth()<s?i.push("old"):(e.getUTCFullYear()>a||e.getUTCFullYear()==a&&e.getUTCMonth()>s)&&i.push("new"),this.o.todayHighlight&&e.getUTCFullYear()==r.getFullYear()&&e.getUTCMonth()==r.getMonth()&&e.getUTCDate()==r.getDate()&&i.push("today"),n&&e.valueOf()==n&&i.push("active"),(e.valueOf()<this.o.startDate||e.valueOf()>this.o.endDate||-1!==t.inArray(e.getUTCDay(),this.o.daysOfWeekDisabled))&&i.push("disabled"),this.range&&(e>this.range[0]&&e<this.range[this.range.length-1]&&i.push("range"),-1!=t.inArray(e.valueOf(),this.range)&&i.push("selected")),i},fill:function(){var i,a=new Date(this.viewDate),s=a.getUTCFullYear(),n=a.getUTCMonth(),r=this.o.startDate!==-1/0?this.o.startDate.getUTCFullYear():-1/0,h=this.o.startDate!==-1/0?this.o.startDate.getUTCMonth():-1/0,o=1/0!==this.o.endDate?this.o.endDate.getUTCFullYear():1/0,d=1/0!==this.o.endDate?this.o.endDate.getUTCMonth():1/0;this.date&&this.date.valueOf(),this.picker.find(".datepicker-days thead th.datepicker-switch").text(l[this.o.language].months[n]+" "+s),this.picker.find("tfoot th.today").text(l[this.o.language].today).toggle(this.o.todayBtn!==!1),this.picker.find("tfoot th.clear").text(l[this.o.language].clear).toggle(this.o.clearBtn!==!1),this.updateNavArrows(),this.fillMonths();var p=e(s,n-1,28,0,0,0,0),u=c.getDaysInMonth(p.getUTCFullYear(),p.getUTCMonth());p.setUTCDate(u),p.setUTCDate(u-(p.getUTCDay()-this.o.weekStart+7)%7);var f=new Date(p);f.setUTCDate(f.getUTCDate()+42),f=f.valueOf();for(var g,v=[];p.valueOf()<f;){if(p.getUTCDay()==this.o.weekStart&&(v.push("<tr>"),this.o.calendarWeeks)){var D=new Date(+p+864e5*((this.o.weekStart-p.getUTCDay()-7)%7)),m=new Date(+D+864e5*((11-D.getUTCDay())%7)),y=new Date(+(y=e(m.getUTCFullYear(),0,1))+864e5*((11-y.getUTCDay())%7)),w=(m-y)/864e5/7+1;v.push('<td class="cw">'+w+"</td>")}if(g=this.getClassNames(p),g.push("day"),this.o.beforeShowDay!==t.noop){var k=this.o.beforeShowDay(this._utc_to_local(p));void 0===k?k={}:"boolean"==typeof k?k={enabled:k}:"string"==typeof k&&(k={classes:k}),k.enabled===!1&&g.push("disabled"),k.classes&&(g=g.concat(k.classes.split(/\s+/))),k.tooltip&&(i=k.tooltip)}g=t.unique(g),v.push('<td class="'+g.join(" ")+'"'+(i?' title="'+i+'"':"")+">"+p.getUTCDate()+"</td>"),p.getUTCDay()==this.o.weekEnd&&v.push("</tr>"),p.setUTCDate(p.getUTCDate()+1)}this.picker.find(".datepicker-days tbody").empty().append(v.join(""));var C=this.date&&this.date.getUTCFullYear(),T=this.picker.find(".datepicker-months").find("th:eq(1)").text(s).end().find("span").removeClass("active");C&&C==s&&T.eq(this.date.getUTCMonth()).addClass("active"),(r>s||s>o)&&T.addClass("disabled"),s==r&&T.slice(0,h).addClass("disabled"),s==o&&T.slice(d+1).addClass("disabled"),v="",s=10*parseInt(s/10,10);var _=this.picker.find(".datepicker-years").find("th:eq(1)").text(s+"-"+(s+9)).end().find("td");s-=1;for(var U=-1;11>U;U++)v+='<span class="year'+(-1==U?" old":10==U?" new":"")+(C==s?" active":"")+(r>s||s>o?" disabled":"")+'">'+s+"</span>",s+=1;_.html(v)},updateNavArrows:function(){if(this._allow_update){var t=new Date(this.viewDate),e=t.getUTCFullYear(),i=t.getUTCMonth();switch(this.viewMode){case 0:this.o.startDate!==-1/0&&e<=this.o.startDate.getUTCFullYear()&&i<=this.o.startDate.getUTCMonth()?this.picker.find(".prev").css({visibility:"hidden"}):this.picker.find(".prev").css({visibility:"visible"}),1/0!==this.o.endDate&&e>=this.o.endDate.getUTCFullYear()&&i>=this.o.endDate.getUTCMonth()?this.picker.find(".next").css({visibility:"hidden"}):this.picker.find(".next").css({visibility:"visible"});break;case 1:case 2:this.o.startDate!==-1/0&&e<=this.o.startDate.getUTCFullYear()?this.picker.find(".prev").css({visibility:"hidden"}):this.picker.find(".prev").css({visibility:"visible"}),1/0!==this.o.endDate&&e>=this.o.endDate.getUTCFullYear()?this.picker.find(".next").css({visibility:"hidden"}):this.picker.find(".next").css({visibility:"visible"})}}},click:function(i){i.preventDefault();var a=t(i.target).closest("span, td, th");if(1==a.length)switch(a[0].nodeName.toLowerCase()){case"th":switch(a[0].className){case"datepicker-switch":this.showMode(1);break;case"prev":case"next":var s=c.modes[this.viewMode].navStep*("prev"==a[0].className?-1:1);switch(this.viewMode){case 0:this.viewDate=this.moveMonth(this.viewDate,s),this._trigger("changeMonth",this.viewDate);break;case 1:case 2:this.viewDate=this.moveYear(this.viewDate,s),1===this.viewMode&&this._trigger("changeYear",this.viewDate)}this.fill();break;case"today":var n=new Date;n=e(n.getFullYear(),n.getMonth(),n.getDate(),0,0,0),this.showMode(-2);var r="linked"==this.o.todayBtn?null:"view";this._setDate(n,r);break;case"clear":var h;this.isInput?h=this.element:this.component&&(h=this.element.find("input")),h&&h.val("").change(),this._trigger("changeDate"),this.update(),this.o.autoclose&&this.hide()}break;case"span":if(!a.is(".disabled")){if(this.viewDate.setUTCDate(1),a.is(".month")){var o=1,d=a.parent().find("span").index(a),l=this.viewDate.getUTCFullYear();this.viewDate.setUTCMonth(d),this._trigger("changeMonth",this.viewDate),1===this.o.minViewMode&&this._setDate(e(l,d,o,0,0,0,0))}else{var l=parseInt(a.text(),10)||0,o=1,d=0;this.viewDate.setUTCFullYear(l),this._trigger("changeYear",this.viewDate),2===this.o.minViewMode&&this._setDate(e(l,d,o,0,0,0,0))}this.showMode(-1),this.fill()}break;case"td":if(a.is(".day")&&!a.is(".disabled")){var o=parseInt(a.text(),10)||1,l=this.viewDate.getUTCFullYear(),d=this.viewDate.getUTCMonth();a.is(".old")?0===d?(d=11,l-=1):d-=1:a.is(".new")&&(11==d?(d=0,l+=1):d+=1),this._setDate(e(l,d,o,0,0,0,0))}}},_setDate:function(t,e){e&&"date"!=e||(this.date=new Date(t)),e&&"view"!=e||(this.viewDate=new Date(t)),this.fill(),this.setValue(),this._trigger("changeDate");var i;this.isInput?i=this.element:this.component&&(i=this.element.find("input")),i&&i.change(),!this.o.autoclose||e&&"date"!=e||this.hide()},moveMonth:function(t,e){if(!e)return t;var i,a,s=new Date(t.valueOf()),n=s.getUTCDate(),r=s.getUTCMonth(),h=Math.abs(e);if(e=e>0?1:-1,1==h)a=-1==e?function(){return s.getUTCMonth()==r}:function(){return s.getUTCMonth()!=i},i=r+e,s.setUTCMonth(i),(0>i||i>11)&&(i=(i+12)%12);else{for(var o=0;h>o;o++)s=this.moveMonth(s,e);i=s.getUTCMonth(),s.setUTCDate(n),a=function(){return i!=s.getUTCMonth()}}for(;a();)s.setUTCDate(--n),s.setUTCMonth(i);return s},moveYear:function(t,e){return this.moveMonth(t,12*e)},dateWithinRange:function(t){return t>=this.o.startDate&&t<=this.o.endDate},keydown:function(t){if(this.picker.is(":not(:visible)"))return 27==t.keyCode&&this.show(),void 0;var e,i,a,s=!1;switch(t.keyCode){case 27:this.hide(),t.preventDefault();break;case 37:case 39:if(!this.o.keyboardNavigation)break;e=37==t.keyCode?-1:1,t.ctrlKey?(i=this.moveYear(this.date,e),a=this.moveYear(this.viewDate,e),this._trigger("changeYear",this.viewDate)):t.shiftKey?(i=this.moveMonth(this.date,e),a=this.moveMonth(this.viewDate,e),this._trigger("changeMonth",this.viewDate)):(i=new Date(this.date),i.setUTCDate(this.date.getUTCDate()+e),a=new Date(this.viewDate),a.setUTCDate(this.viewDate.getUTCDate()+e)),this.dateWithinRange(i)&&(this.date=i,this.viewDate=a,this.setValue(),this.update(),t.preventDefault(),s=!0);break;case 38:case 40:if(!this.o.keyboardNavigation)break;e=38==t.keyCode?-1:1,t.ctrlKey?(i=this.moveYear(this.date,e),a=this.moveYear(this.viewDate,e),this._trigger("changeYear",this.viewDate)):t.shiftKey?(i=this.moveMonth(this.date,e),a=this.moveMonth(this.viewDate,e),this._trigger("changeMonth",this.viewDate)):(i=new Date(this.date),i.setUTCDate(this.date.getUTCDate()+7*e),a=new Date(this.viewDate),a.setUTCDate(this.viewDate.getUTCDate()+7*e)),this.dateWithinRange(i)&&(this.date=i,this.viewDate=a,this.setValue(),this.update(),t.preventDefault(),s=!0);break;case 13:this.hide(),t.preventDefault();break;case 9:this.hide()}if(s){this._trigger("changeDate");var n;this.isInput?n=this.element:this.component&&(n=this.element.find("input")),n&&n.change()}},showMode:function(t){t&&(this.viewMode=Math.max(this.o.minViewMode,Math.min(2,this.viewMode+t))),this.picker.find(">div").hide().filter(".datepicker-"+c.modes[this.viewMode].clsName).css("display","block"),this.updateNavArrows()}};var r=function(e,i){this.element=t(e),this.inputs=t.map(i.inputs,function(t){return t.jquery?t[0]:t}),delete i.inputs,t(this.inputs).datepicker(i).bind("changeDate",t.proxy(this.dateUpdated,this)),this.pickers=t.map(this.inputs,function(e){return t(e).data("datepicker")}),this.updateDates()};r.prototype={updateDates:function(){this.dates=t.map(this.pickers,function(t){return t.date}),this.updateRanges()},updateRanges:function(){var e=t.map(this.dates,function(t){return t.valueOf()});t.each(this.pickers,function(t,i){i.setRange(e)})},dateUpdated:function(e){var i=t(e.target).data("datepicker"),a=i.getUTCDate(),s=t.inArray(e.target,this.inputs),n=this.inputs.length;if(-1!=s){if(a<this.dates[s])for(;s>=0&&a<this.dates[s];)this.pickers[s--].setUTCDate(a);else if(a>this.dates[s])for(;n>s&&a>this.dates[s];)this.pickers[s++].setUTCDate(a);this.updateDates()}},remove:function(){t.map(this.pickers,function(t){t.remove()}),delete this.element.data().datepicker}};var h=t.fn.datepicker;t.fn.datepicker=function(e){var s=Array.apply(null,arguments);s.shift();var h;return this.each(function(){var d=t(this),l=d.data("datepicker"),c="object"==typeof e&&e;if(!l){var p=i(this,"date"),u=t.extend({},o,p,c),f=a(u.language),g=t.extend({},o,f,p,c);if(d.is(".input-daterange")||g.inputs){var v={inputs:g.inputs||d.find("input").toArray()};d.data("datepicker",l=new r(this,t.extend(g,v)))}else d.data("datepicker",l=new n(this,g))}return"string"==typeof e&&"function"==typeof l[e]&&(h=l[e].apply(l,s),void 0!==h)?!1:void 0}),void 0!==h?h:this};var o=t.fn.datepicker.defaults={autoclose:!1,beforeShowDay:t.noop,calendarWeeks:!1,clearBtn:!1,daysOfWeekDisabled:[],endDate:1/0,forceParse:!0,format:"mm/dd/yyyy",keyboardNavigation:!0,language:"en",minViewMode:0,orientation:"auto",rtl:!1,startDate:-1/0,startView:0,todayBtn:!1,todayHighlight:!1,weekStart:0},d=t.fn.datepicker.locale_opts=["format","rtl","weekStart"];t.fn.datepicker.Constructor=n;var l=t.fn.datepicker.dates={en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa","Su"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],today:"Today",clear:"Clear"}},c={modes:[{clsName:"days",navFnc:"Month",navStep:1},{clsName:"months",navFnc:"FullYear",navStep:1},{clsName:"years",navFnc:"FullYear",navStep:10}],isLeapYear:function(t){return 0===t%4&&0!==t%100||0===t%400},getDaysInMonth:function(t,e){return[31,c.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]},validParts:/dd?|DD?|mm?|MM?|yy(?:yy)?/g,nonpunctuation:/[^ -\/:-@\[\u3400-\u9fff-`{-~\t\n\r]+/g,parseFormat:function(t){var e=t.replace(this.validParts,"\0").split("\0"),i=t.match(this.validParts);if(!e||!e.length||!i||0===i.length)throw new Error("Invalid date format.");return{separators:e,parts:i}},parseDate:function(i,a,s){if(i instanceof Date)return i;if("string"==typeof a&&(a=c.parseFormat(a)),/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(i)){var r,h,o=/([\-+]\d+)([dmwy])/,d=i.match(/([\-+]\d+)([dmwy])/g);i=new Date;for(var p=0;p<d.length;p++)switch(r=o.exec(d[p]),h=parseInt(r[1]),r[2]){case"d":i.setUTCDate(i.getUTCDate()+h);break;case"m":i=n.prototype.moveMonth.call(n.prototype,i,h);break;case"w":i.setUTCDate(i.getUTCDate()+7*h);break;case"y":i=n.prototype.moveYear.call(n.prototype,i,h)}return e(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate(),0,0,0)}var u,f,r,d=i&&i.match(this.nonpunctuation)||[],i=new Date,g={},v=["yyyy","yy","M","MM","m","mm","d","dd"],D={yyyy:function(t,e){return t.setUTCFullYear(e)},yy:function(t,e){return t.setUTCFullYear(2e3+e)},m:function(t,e){if(isNaN(t))return t;for(e-=1;0>e;)e+=12;for(e%=12,t.setUTCMonth(e);t.getUTCMonth()!=e;)t.setUTCDate(t.getUTCDate()-1);return t},d:function(t,e){return t.setUTCDate(e)}};D.M=D.MM=D.mm=D.m,D.dd=D.d,i=e(i.getFullYear(),i.getMonth(),i.getDate(),0,0,0);var m=a.parts.slice();if(d.length!=m.length&&(m=t(m).filter(function(e,i){return-1!==t.inArray(i,v)}).toArray()),d.length==m.length){for(var p=0,y=m.length;y>p;p++){if(u=parseInt(d[p],10),r=m[p],isNaN(u))switch(r){case"MM":f=t(l[s].months).filter(function(){var t=this.slice(0,d[p].length),e=d[p].slice(0,t.length);return t==e}),u=t.inArray(f[0],l[s].months)+1;break;case"M":f=t(l[s].monthsShort).filter(function(){var t=this.slice(0,d[p].length),e=d[p].slice(0,t.length);return t==e}),u=t.inArray(f[0],l[s].monthsShort)+1}g[r]=u}for(var w,k,p=0;p<v.length;p++)k=v[p],k in g&&!isNaN(g[k])&&(w=new Date(i),D[k](w,g[k]),isNaN(w)||(i=w))}return i},formatDate:function(e,i,a){"string"==typeof i&&(i=c.parseFormat(i));var s={d:e.getUTCDate(),D:l[a].daysShort[e.getUTCDay()],DD:l[a].days[e.getUTCDay()],m:e.getUTCMonth()+1,M:l[a].monthsShort[e.getUTCMonth()],MM:l[a].months[e.getUTCMonth()],yy:e.getUTCFullYear().toString().substring(2),yyyy:e.getUTCFullYear()};s.dd=(s.d<10?"0":"")+s.d,s.mm=(s.m<10?"0":"")+s.m;for(var e=[],n=t.extend([],i.separators),r=0,h=i.parts.length;h>=r;r++)n.length&&e.push(n.shift()),e.push(s[i.parts[r]]);return e.join("")},headTemplate:'<thead><tr><th class="prev">&laquo;</th><th colspan="5" class="datepicker-switch"></th><th class="next">&raquo;</th></tr></thead>',contTemplate:'<tbody><tr><td colspan="7"></td></tr></tbody>',footTemplate:'<tfoot><tr><th colspan="7" class="today"></th></tr><tr><th colspan="7" class="clear"></th></tr></tfoot>'};c.template='<div class="datepicker"><div class="datepicker-days"><table class=" table-condensed">'+c.headTemplate+"<tbody></tbody>"+c.footTemplate+"</table>"+"</div>"+'<div class="datepicker-months">'+'<table class="table-condensed">'+c.headTemplate+c.contTemplate+c.footTemplate+"</table>"+"</div>"+'<div class="datepicker-years">'+'<table class="table-condensed">'+c.headTemplate+c.contTemplate+c.footTemplate+"</table>"+"</div>"+"</div>",t.fn.datepicker.DPGlobal=c,t.fn.datepicker.noConflict=function(){return t.fn.datepicker=h,this},t(document).on("focus.datepicker.data-api click.datepicker.data-api",'[data-provide="datepicker"]',function(e){var i=t(this);i.data("datepicker")||(e.preventDefault(),i.datepicker("show"))}),t(function(){t('[data-provide="datepicker-inline"]').datepicker()})}(window.jQuery);