PageSourceSearch

https://kungligaslottet.se/download/18.46ca39931600d1b7b981b4d/1516026974947/datepicker.js

js kungligaslottet.se collected 2026-10-08 06:44:48 UTC 39,747 bytes, 1,524 lines download raw bytes

1/* jshint ignore:start */
2
3/*!
4 * Datepicker v0.6.4
5 * https://github.com/fengyuanchen/datepicker
6 *
7 * Copyright (c) 2014-2017 Chen Fengyuan
8 * Released under the MIT license
9 *
10 * Date: 2017-11-24T14:38:23.820Z
11 */
12
13(function (global, factory) {
14	typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jquery')) :
15	typeof define === 'function' && define.amd ? define(['jquery'], factory) :
16	(factory(global.jQuery));
17}(this, (function ($) { 'use strict';
18
19$ = $ && $.hasOwnProperty('default') ? $['default'] : $
vendor: 19,146 bytes, lines 19-830
19;
20
21var DEFAULTS = {
22  // Show the datepicker automatically when initialized
23  autoShow: false,
24
25  // Hide the datepicker automatically when picked
26  autoHide: false,
27
28  // Pick the initial date automatically when initialized
29  autoPick: false,
30
31  // Enable inline mode
32  inline: false,
33
34  // A element (or selector) for putting the datepicker
35  container: null,
36
37  // A element (or selector) for triggering the datepicker
38  trigger: null,
39
40  // The ISO language code (built-in: en-US)
41  language: '',
42
43  // The date string format
44  format: 'mm/dd/yyyy',
45
46  // The initial date
47  date: null,
48
49  // The start view date
50  startDate: null,
51
52  // The end view date
53  endDate: null,
54
55  // The start view when initialized
56  startView: 0, // 0 for days, 1 for months, 2 for years
57
58  // The start day of the week
59  // 0 for Sunday, 1 for Monday, 2 for Tuesday, 3 for Wednesday,
60  // 4 for Thursday, 5 for Friday, 6 for Saturday
61  weekStart: 0,
62
63  // Show year before month on the datepicker header
64  yearFirst: false,
65
66  // A string suffix to the year number.
67  yearSuffix: '',
68
69  // Days' name of the week.
70  days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
71
72  // Shorter days' name
73  daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
74
75  // Shortest days' name
76  daysMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
77
78  // Months' name
79  months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
80
81  // Shorter months' name
82  monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
83
84  // A element tag for each item of years, months and days
85  itemTag: 'li',
86
87  // A class (CSS) for muted date item
88  mutedClass: 'muted',
89
90  // A class (CSS) for picked date item
91  pickedClass: 'picked',
92
93  // A class (CSS) for disabled date item
94  disabledClass: 'disabled',
95
96  // A class (CSS) for highlight date item
97  highlightedClass: 'highlighted',
98
99  // The template of the datepicker
100  template: '<div class="datepicker-container">' + '<div class="datepicker-panel" data-view="years picker">' + '<ul>' + '<li data-view="years prev">&lsaquo;</li>' + '<li data-view="years current"></li>' + '<li data-view="years next">&rsaquo;</li>' + '</ul>' + '<ul data-view="years"></ul>' + '</div>' + '<div class="datepicker-panel" data-view="months picker">' + '<ul>' + '<li data-view="year prev">&lsaquo;</li>' + '<li data-view="year current"></li>' + '<li data-view="year next">&rsaquo;</li>' + '</ul>' + '<ul data-view="months"></ul>' + '</div>' + '<div class="datepicker-panel" data-view="days picker">' + '<ul>' + '<li data-view="month prev">&lsaquo;</li>' + '<li data-view="month current"></li>' + '<li data-view="month next">&rsaquo;</li>' + '</ul>' + '<ul data-view="week"></ul>' + '<ul data-view="days"></ul>' + '</div>' + '</div>',
101
102  // The offset top or bottom of the datepicker from the element
103  offset: 10,
104
105  // The `z-index` of the datepicker
106  zIndex: 1000,
107
108  // Filter each date item (return `false` to disable a date item)
109  filter: null,
110
111  // Event shortcuts
112  show: null,
113  hide: null,
114  pick: null
115};
116
117var WINDOW = typeof window !== 'undefined' ? window : {};
118var NAMESPACE = 'datepicker';
119var EVENT_CLICK = 'click.' + NAMESPACE;
120var EVENT_FOCUS = 'focus.' + NAMESPACE;
121var EVENT_HIDE = 'hide.' + NAMESPACE;
122var EVENT_KEYUP = 'keyup.' + NAMESPACE;
123var EVENT_PICK = 'pick.' + NAMESPACE;
124var EVENT_RESIZE = 'resize.' + NAMESPACE;
125var EVENT_SHOW = 'show.' + NAMESPACE;
126var CLASS_HIDE = NAMESPACE + '-hide';
127var LANGUAGES = {};
128var VIEWS = {
129  DAYS: 0,
130  MONTHS: 1,
131  YEARS: 2
132};
133
134var toString = Object.prototype.toString;
135
136
137function typeOf(obj) {
138  return toString.call(obj).slice(8, -1).toLowerCase();
139}
140
141function isString(value) {
142  return typeof value === 'string';
143}
144
145var isNaN = Number.isNaN || WINDOW.isNaN;
146
147function isNumber(value) {
148  return typeof value === 'number' && !isNaN(value);
149}
150
151function isUndefined(value) {
152  return typeof value === 'undefined';
153}
154
155function isDate(value) {
156  return typeOf(value) === 'date';
157}
158
159function proxy(fn, context) {
160  for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
161    args[_key - 2] = arguments[_key];
162  }
163
164  return function () {
165    for (var _len2 = arguments.length, args2 = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
166      args2[_key2] = arguments[_key2];
167    }
168
169    return fn.apply(context, args.concat(args2));
170  };
171}
172
173function selectorOf(view) {
174  return '[data-view="' + view + '"]';
175}
176
177function isLeapYear(year) {
178  return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
179}
180
181function getDaysInMonth(year, month) {
182  return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
183}
184
185function getMinDay(year, month, day) {
186  return Math.min(day, getDaysInMonth(year, month));
187}
188
189var formatParts = /(y|m|d)+/g;
190
191function parseFormat(format) {
192  var source = String(format).toLowerCase();
193  var parts = source.match(formatParts);
194
195  if (!parts || parts.length === 0) {
196    throw new Error('Invalid date format.');
197  }
198
199  format = {
200    source: source,
201    parts: parts
202  };
203
204  $.each(parts, function (i, part) {
205    switch (part) {
206      case 'dd':
207      case 'd':
208        format.hasDay = true;
209        break;
210
211      case 'mm':
212      case 'm':
213        format.hasMonth = true;
214        break;
215
216      case 'yyyy':
217      case 'yy':
218        format.hasYear = true;
219        break;
220
221      default:
222    }
223  });
224
225  return format;
226}
227
228var REGEXP_DIGITS = /\d+/g;
229
230var methods = {
231  // Show the datepicker
232  show: function show() {
233    if (!this.built) {
234      this.build();
235    }
236
237    if (this.shown) {
238      return;
239    }
240
241    if (this.trigger(EVENT_SHOW).isDefaultPrevented()) {
242      return;
243    }
244
245    this.shown = true;
246    this.$picker.removeClass(CLASS_HIDE).on(EVENT_CLICK, $.proxy(this.click, this));
247    this.showView(this.options.startView);
248
249    if (!this.inline) {
250      $(window).on(EVENT_RESIZE, this.onResize = proxy(this.place, this));
251      $(document).on(EVENT_CLICK, this.onGlobalClick = proxy(this.globalClick, this));
252      $(document).on(EVENT_KEYUP, this.onGlobalKeyup = proxy(this.globalKeyup, this));
253      this.place();
254    }
255  },
256
257
258  // Hide the datepicker
259  hide: function hide() {
260    if (!this.shown) {
261      return;
262    }
263
264    if (this.trigger(EVENT_HIDE).isDefaultPrevented()) {
265      return;
266    }
267
268    this.shown = false;
269    this.$picker.addClass(CLASS_HIDE).off(EVENT_CLICK, this.click);
270
271    if (!this.inline) {
272      $(window).off(EVENT_RESIZE, this.onResize);
273      $(document).off(EVENT_CLICK, this.onGlobalClick);
274      $(document).off(EVENT_KEYUP, this.onGlobalKeyup);
275    }
276  },
277  toggle: function toggle() {
278    if (this.shown) {
279      this.hide();
280    } else {
281      this.show();
282    }
283  },
284
285
286  // Update the datepicker with the current input value
287  update: function update() {
288    var value = this.getValue();
289
290    if (value === this.oldValue) {
291      return;
292    }
293
294    this.setDate(value, true);
295    this.oldValue = value;
296  },
297
298
299  /**
300   * Pick the current date to the element
301   *
302   * @param {String} _view (private)
303   */
304  pick: function pick(_view) {
305    var $this = this.$element;
306    var date = this.date;
307
308
309    if (this.trigger(EVENT_PICK, {
310      view: _view || '',
311      date: date
312    }).isDefaultPrevented()) {
313      return;
314    }
315
316    date = this.formatDate(this.date);
317    this.setValue(date);
318
319    if (this.isInput) {
320      $this.trigger('input');
321      $this.trigger('change');
322    }
323  },
324
325
326  // Reset the datepicker
327  reset: function reset() {
328    this.setDate(this.initialDate, true);
329    this.setValue(this.initialValue);
330
331    if (this.shown) {
332      this.showView(this.options.startView);
333    }
334  },
335
336
337  /**
338   * Get the month name with given argument or the current date
339   *
340   * @param {Number} month (optional)
341   * @param {Boolean} short (optional)
342   * @return {String} (month name)
343   */
344  getMonthName: function getMonthName(month, short) {
345    var options = this.options;
346    var monthsShort = options.monthsShort;
347    var months = options.months;
348
349
350    if ($.isNumeric(month)) {
351      month = Number(month);
352    } else if (isUndefined(short)) {
353      short = month;
354    }
355
356    if (short === true) {
357      months = monthsShort;
358    }
359
360    return months[isNumber(month) ? month : this.date.getMonth()];
361  },
362
363
364  /**
365   * Get the day name with given argument or the current date
366   *
367   * @param {Number} day (optional)
368   * @param {Boolean} short (optional)
369   * @param {Boolean} min (optional)
370   * @return {String} (day name)
371   */
372  getDayName: function getDayName(day, short, min) {
373    var options = this.options;
374    var days = options.days;
375
376
377    if ($.isNumeric(day)) {
378      day = Number(day);
379    } else {
380      if (isUndefined(min)) {
381        min = short;
382      }
383
384      if (isUndefined(short)) {
385        short = day;
386      }
387    }
388
389    if (min) {
390      days = options.daysMin;
391    } else if (short) {
392      days = options.daysShort;
393    }
394
395    return days[isNumber(day) ? day : this.date.getDay()];
396  },
397
398
399  /**
400   * Get the current date
401   *
402   * @param {Boolean} formatted (optional)
403   * @return {Date|String} (date)
404   */
405  getDate: function getDate(formatted) {
406    var date = this.date;
407
408
409    return formatted ? this.formatDate(date) : new Date(date);
410  },
411
412
413  /**
414   * Set the current date with a new date
415   *
416   * @param {Date} date
417   * @param {Boolean} _updated (private)
418   */
419  setDate: function setDate(date, _updated) {
420    var filter = this.options.filter;
421
422
423    if (isDate(date) || isString(date)) {
424      date = this.parseDate(date);
425
426      if ($.isFunction(filter) && filter.call(this.$element, date) === false) {
427        return;
428      }
429
430      this.date = date;
431      this.viewDate = new Date(date);
432
433      if (!_updated) {
434        this.pick();
435      }
436
437      if (this.built) {
438        this.render();
439      }
440    }
441  },
442
443
444  /**
445   * Set the start view date with a new date
446   *
447   * @param {Date} date
448   */
449  setStartDate: function setStartDate(date) {
450    if (isDate(date) || isString(date)) {
451      this.startDate = this.parseDate(date);
452
453      if (this.built) {
454        this.render();
455      }
456    }
457  },
458
459
460  /**
461   * Set the end view date with a new date
462   *
463   * @param {Date} date
464   */
465  setEndDate: function setEndDate(date) {
466    if (isDate(date) || isString(date)) {
467      this.endDate = this.parseDate(date);
468
469      if (this.built) {
470        this.render();
471      }
472    }
473  },
474
475
476  /**
477   * Parse a date string with the set date format
478   *
479   * @param {String} date
480   * @return {Date} (parsed date)
481   */
482  parseDate: function parseDate(date) {
483    var format = this.format;
484
485    var parts = [];
486
487    if (isDate(date)) {
488      return new Date(date.getFullYear(), date.getMonth(), date.getDate());
489    } else if (isString(date)) {
490      parts = date.match(REGEXP_DIGITS) || [];
491    }
492
493    date = new Date();
494
495    var length = format.parts.length;
496
497    var year = date.getFullYear();
498    var day = date.getDate();
499    var month = date.getMonth();
500
501    if (parts.length === length) {
502      $.each(parts, function (i, part) {
503        var value = parseInt(part, 10) || 1;
504
505        switch (format.parts[i]) {
506          case 'dd':
507          case 'd':
508            day = value;
509            break;
510
511          case 'mm':
512          case 'm':
513            month = value - 1;
514            break;
515
516          case 'yy':
517            year = 2000 + value;
518            break;
519
520          case 'yyyy':
521            year = value;
522            break;
523
524          default:
525        }
526      });
527    }
528
529    return new Date(year, month, day);
530  },
531
532
533  /**
534   * Format a date object to a string with the set date format
535   *
536   * @param {Date} date
537   * @return {String} (formatted date)
538   */
539  formatDate: function formatDate(date) {
540    var format = this.format;
541
542    var formatted = '';
543
544    if (isDate(date)) {
545      var year = date.getFullYear();
546      var values = {
547        d: date.getDate(),
548        m: date.getMonth() + 1,
549        yy: year.toString().substring(2),
550        yyyy: year
551      };
552
553      values.dd = (values.d < 10 ? '0' : '') + values.d;
554      values.mm = (values.m < 10 ? '0' : '') + values.m;
555      formatted = format.source;
556      $.each(format.parts, function (i, part) {
557        formatted = formatted.replace(part, values[part]);
558      });
559    }
560
561    return formatted;
562  },
563
564
565  // Destroy the datepicker and remove the instance from the target element
566  destroy: function destroy() {
567    this.unbind();
568    this.unbuild();
569    this.$element.removeData(NAMESPACE);
570  }
571};
572
573var handlers = {
574  click: function click(e) {
575    var $target = $(e.target);
576    var options = this.options,
577        viewDate = this.viewDate,
578        format = this.format;
579
580
581    e.stopPropagation();
582    e.preventDefault();
583
584    if ($target.hasClass('disabled')) {
585      return;
586    }
587
588    var view = $target.data('view');
589    var viewYear = viewDate.getFullYear();
590    var viewMonth = viewDate.getMonth();
591    var viewDay = viewDate.getDate();
592
593    switch (view) {
594      case 'years prev':
595      case 'years next':
596        {
597          viewYear = view === 'years prev' ? viewYear - 10 : viewYear + 10;
598          this.viewDate = new Date(viewYear, viewMonth, getMinDay(viewYear, viewMonth, viewDay));
599          this.renderYears();
600          break;
601        }
602
603      case 'year prev':
604      case 'year next':
605        viewYear = view === 'year prev' ? viewYear - 1 : viewYear + 1;
606        this.viewDate = new Date(viewYear, viewMonth, getMinDay(viewYear, viewMonth, viewDay));
607        this.renderMonths();
608        break;
609
610      case 'year current':
611        if (format.hasYear) {
612          this.showView(VIEWS.YEARS);
613        }
614
615        break;
616
617      case 'year picked':
618        if (format.hasMonth) {
619          this.showView(VIEWS.MONTHS);
620        } else {
621          $target.addClass(options.pickedClass).siblings().removeClass(options.pickedClass);
622          this.hideView();
623        }
624
625        this.pick('year');
626        break;
627
628      case 'year':
629        viewYear = parseInt($target.text(), 10);
630        this.date = new Date(viewYear, viewMonth, getMinDay(viewYear, viewMonth, viewDay));
631
632        if (format.hasMonth) {
633          this.viewDate = new Date(this.date);
634          this.showView(VIEWS.MONTHS);
635        } else {
636          $target.addClass(options.pickedClass).siblings().removeClass(options.pickedClass);
637          this.hideView();
638        }
639
640        this.pick('year');
641        break;
642
643      case 'month prev':
644      case 'month next':
645        viewMonth = view === 'month prev' ? viewMonth - 1 : viewMonth + 1;
646
647        if (viewMonth < 0) {
648          viewYear -= 1;
649          viewMonth += 12;
650        } else if (viewMonth > 11) {
651          viewYear += 1;
652          viewMonth -= 12;
653        }
654
655        this.viewDate = new Date(viewYear, viewMonth, getMinDay(viewYear, viewMonth, viewDay));
656        this.renderDays();
657        break;
658
659      case 'month current':
660        if (format.hasMonth) {
661          this.showView(VIEWS.MONTHS);
662        }
663
664        break;
665
666      case 'month picked':
667        if (format.hasDay) {
668          this.showView(VIEWS.DAYS);
669        } else {
670          $target.addClass(options.pickedClass).siblings().removeClass(options.pickedClass);
671          this.hideView();
672        }
673
674        this.pick('month');
675        break;
676
677      case 'month':
678        viewMonth = $.inArray($target.text(), options.monthsShort);
679        this.date = new Date(viewYear, viewMonth, getMinDay(viewYear, viewMonth, viewDay));
680
681        if (format.hasDay) {
682          this.viewDate = new Date(viewYear, viewMonth, getMinDay(viewYear, viewMonth, viewDay));
683          this.showView(VIEWS.DAYS);
684        } else {
685          $target.addClass(options.pickedClass).siblings().removeClass(options.pickedClass);
686          this.hideView();
687        }
688
689        this.pick('month');
690        break;
691
692      case 'day prev':
693      case 'day next':
694      case 'day':
695        if (view === 'day prev') {
696          viewMonth -= 1;
697        } else if (view === 'day next') {
698          viewMonth += 1;
699        }
700
701        viewDay = parseInt($target.text(), 10);
702        this.date = new Date(viewYear, viewMonth, viewDay);
703        this.viewDate = new Date(viewYear, viewMonth, viewDay);
704        this.renderDays();
705
706        if (view === 'day') {
707          this.hideView();
708        }
709
710        this.pick('day');
711        break;
712
713      case 'day picked':
714        this.hideView();
715        this.pick('day');
716        break;
717
718      default:
719    }
720  },
721  globalClick: function globalClick(_ref) {
722    var target = _ref.target;
723    var element = this.element,
724        $trigger = this.$trigger;
725
726    var trigger = $trigger[0];
727    var hidden = true;
728
729    while (target !== document) {
730      if (target === trigger || target === element) {
731        hidden = false;
732        break;
733      }
734
735      target = target.parentNode;
736    }
737
738    if (hidden) {
739      this.hide();
740    }
741  },
742  keyup: function keyup() {
743    this.update();
744  },
745  globalKeyup: function globalKeyup(_ref2) {
746    var target = _ref2.target,
747        key = _ref2.key,
748        keyCode = _ref2.keyCode;
749
750    if (this.isInput && target !== this.element && this.shown && (key === 'Tab' || keyCode === 9)) {
751      this.hide();
752    }
753  }
754};
755
756var render = {
757  render: function render() {
758    this.renderYears();
759    this.renderMonths();
760    this.renderDays();
761  },
762  renderWeek: function renderWeek() {
763    var _this = this;
764
765    var items = [];
766    var _options = this.options,
767        weekStart = _options.weekStart,
768        daysMin = _options.daysMin;
769
770
771    weekStart = parseInt(weekStart, 10) % 7;
772    daysMin = daysMin.slice(weekStart).concat(daysMin.slice(0, weekStart));
773    $.each(daysMin, function (i, day) {
774      items.push(_this.createItem({
775        text: day
776      }));
777    });
778
779    this.$week.html(items.join(''));
780  },
781  renderYears: function renderYears() {
782    var options = this.options,
783        startDate = this.startDate,
784        endDate = this.endDate;
785    var disabledClass = options.disabledClass,
786        filter = options.filter,
787        yearSuffix = options.yearSuffix;
788
789    var viewYear = this.viewDate.getFullYear();
790    var now = new Date();
791    var thisYear = now.getFullYear();
792    var year = this.date.getFullYear();
793    var start = -5;
794    var end = 6;
795    var items = [];
796    var prevDisabled = false;
797    var nextDisabled = false;
798    var i = void 0;
799
800    for (i = start; i <= end; i += 1) {
801      var date = new Date(viewYear + i, 1, 1);
802      var disabled = false;
803
804      if (startDate) {
805        disabled = date.getFullYear() < startDate.getFullYear();
806
807        if (i === start) {
808          prevDisabled = disabled;
809        }
810      }
811
812      if (!disabled && endDate) {
813        disabled = date.getFullYear() > endDate.getFullYear();
814
815        if (i === end) {
816          nextDisabled = disabled;
817        }
818      }
819
820      if (!disabled && filter) {
821        disabled = filter.call(this.$element, date) === false;
822      }
823
824      var picked = viewYear + i === year;
825      var view = picked ? 'year picked' : 'year';
826
827      items.push(this.createItem({
828        picked: picked,
829        disabled: disabled,
830        
830muted: i === start || i === en
vendor: 19,242 bytes, lines 830-1490
830d,
831        text: viewYear + i,
832        view: disabled ? 'year disabled' : view,
833        highlighted: date.getFullYear() === thisYear
834      }));
835    }
836
837    this.$yearsPrev.toggleClass(disabledClass, prevDisabled);
838    this.$yearsNext.toggleClass(disabledClass, nextDisabled);
839    this.$yearsCurrent.toggleClass(disabledClass, true).html(viewYear + start + yearSuffix + ' - ' + (viewYear + end) + yearSuffix);
840    this.$years.html(items.join(''));
841  },
842  renderMonths: function renderMonths() {
843    var options = this.options,
844        startDate = this.startDate,
845        endDate = this.endDate,
846        viewDate = this.viewDate;
847
848    var disabledClass = options.disabledClass || '';
849    var months = options.monthsShort;
850    var filter = $.isFunction(options.filter) && options.filter;
851    var viewYear = viewDate.getFullYear();
852    var now = new Date();
853    var thisYear = now.getFullYear();
854    var thisMonth = now.getMonth();
855    var year = this.date.getFullYear();
856    var month = this.date.getMonth();
857    var items = [];
858    var prevDisabled = false;
859    var nextDisabled = false;
860    var i = void 0;
861
862    for (i = 0; i <= 11; i += 1) {
863      var date = new Date(viewYear, i, 1);
864      var disabled = false;
865
866      if (startDate) {
867        prevDisabled = date.getFullYear() === startDate.getFullYear();
868        disabled = prevDisabled && date.getMonth() < startDate.getMonth();
869      }
870
871      if (!disabled && endDate) {
872        nextDisabled = date.getFullYear() === endDate.getFullYear();
873        disabled = nextDisabled && date.getMonth() > endDate.getMonth();
874      }
875
876      if (!disabled && filter) {
877        disabled = filter.call(this.$element, date) === false;
878      }
879
880      var picked = viewYear === year && i === month;
881      var view = picked ? 'month picked' : 'month';
882
883      items.push(this.createItem({
884        disabled: disabled,
885        picked: picked,
886        highlighted: viewYear === thisYear && date.getMonth() === thisMonth,
887        index: i,
888        text: months[i],
889        view: disabled ? 'month disabled' : view
890      }));
891    }
892
893    this.$yearPrev.toggleClass(disabledClass, prevDisabled);
894    this.$yearNext.toggleClass(disabledClass, nextDisabled);
895    this.$yearCurrent.toggleClass(disabledClass, prevDisabled && nextDisabled).html(viewYear + options.yearSuffix || '');
896    this.$months.html(items.join(''));
897  },
898  renderDays: function renderDays() {
899    var $element = this.$element,
900        options = this.options,
901        startDate = this.startDate,
902        endDate = this.endDate,
903        viewDate = this.viewDate,
904        currentDate = this.date;
905    var disabledClass = options.disabledClass,
906        filter = options.filter,
907        monthsShort = options.monthsShort,
908        weekStart = options.weekStart,
909        yearSuffix = options.yearSuffix;
910
911    var viewYear = viewDate.getFullYear();
912    var viewMonth = viewDate.getMonth();
913    var now = new Date();
914    var thisYear = now.getFullYear();
915    var thisMonth = now.getMonth();
916    var thisDay = now.getDate();
917    var year = currentDate.getFullYear();
918    var month = currentDate.getMonth();
919    var day = currentDate.getDate();
920    var length = void 0;
921    var i = void 0;
922    var n = void 0;
923
924    // Days of prev month
925    // -----------------------------------------------------------------------
926
927    var prevItems = [];
928    var prevViewYear = viewYear;
929    var prevViewMonth = viewMonth;
930    var prevDisabled = false;
931
932    if (viewMonth === 0) {
933      prevViewYear -= 1;
934      prevViewMonth = 11;
935    } else {
936      prevViewMonth -= 1;
937    }
938
939    // The length of the days of prev month
940    length = getDaysInMonth(prevViewYear, prevViewMonth);
941
942    // The first day of current month
943    var firstDay = new Date(viewYear, viewMonth, 1);
944
945    // The visible length of the days of prev month
946    // [0,1,2,3,4,5,6] - [0,1,2,3,4,5,6] => [-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6]
947    n = firstDay.getDay() - parseInt(weekStart, 10) % 7;
948
949    // [-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6] => [1,2,3,4,5,6,7]
950    if (n <= 0) {
951      n += 7;
952    }
953
954    if (startDate) {
955      prevDisabled = firstDay.getTime() <= startDate.getTime();
956    }
957
958    for (i = length - (n - 1); i <= length; i += 1) {
959      var prevViewDate = new Date(prevViewYear, prevViewMonth, i);
960      var disabled = false;
961
962      if (startDate) {
963        disabled = prevViewDate.getTime() < startDate.getTime();
964      }
965
966      if (!disabled && filter) {
967        disabled = filter.call($element, prevViewDate) === false;
968      }
969
970      prevItems.push(this.createItem({
971        disabled: disabled,
972        highlighted: prevViewYear === thisYear && prevViewMonth === thisMonth && prevViewDate.getDate() === thisDay,
973        muted: true,
974        picked: prevViewYear === year && prevViewMonth === month && i === day,
975        text: i,
976        view: 'day prev'
977      }));
978    }
979
980    // Days of next month
981    // -----------------------------------------------------------------------
982
983    var nextItems = [];
984    var nextViewYear = viewYear;
985    var nextViewMonth = viewMonth;
986    var nextDisabled = false;
987
988    if (viewMonth === 11) {
989      nextViewYear += 1;
990      nextViewMonth = 0;
991    } else {
992      nextViewMonth += 1;
993    }
994
995    // The length of the days of current month
996    length = getDaysInMonth(viewYear, viewMonth);
997
998    // The visible length of next month (42 means 6 rows and 7 columns)
999    n = 42 - (prevItems.length + length);
1000
1001    // The last day of current month
1002    var lastDate = new Date(viewYear, viewMonth, length);
1003
1004    if (endDate) {
1005      nextDisabled = lastDate.getTime() >= endDate.getTime();
1006    }
1007
1008    for (i = 1; i <= n; i += 1) {
1009      var date = new Date(nextViewYear, nextViewMonth, i);
1010      var picked = nextViewYear === year && nextViewMonth === month && i === day;
1011      var _disabled = false;
1012
1013      if (endDate) {
1014        _disabled = date.getTime() > endDate.getTime();
1015      }
1016
1017      if (!_disabled && filter) {
1018        _disabled = filter.call($element, date) === false;
1019      }
1020
1021      nextItems.push(this.createItem({
1022        disabled: _disabled,
1023        picked: picked,
1024        highlighted: nextViewYear === thisYear && nextViewMonth === thisMonth && date.getDate() === thisDay,
1025        muted: true,
1026        text: i,
1027        view: 'day next'
1028      }));
1029    }
1030
1031    // Days of current month
1032    // -----------------------------------------------------------------------
1033
1034    var items = [];
1035
1036    for (i = 1; i <= length; i += 1) {
1037      var _date = new Date(viewYear, viewMonth, i);
1038      var _disabled2 = false;
1039
1040      if (startDate) {
1041        _disabled2 = _date.getTime() < startDate.getTime();
1042      }
1043
1044      if (!_disabled2 && endDate) {
1045        _disabled2 = _date.getTime() > endDate.getTime();
1046      }
1047
1048      if (!_disabled2 && filter) {
1049        _disabled2 = filter.call($element, _date) === false;
1050      }
1051
1052      var _picked = viewYear === year && viewMonth === month && i === day;
1053      var view = _picked ? 'day picked' : 'day';
1054
1055      items.push(this.createItem({
1056        disabled: _disabled2,
1057        picked: _picked,
1058        highlighted: viewYear === thisYear && viewMonth === thisMonth && _date.getDate() === thisDay,
1059        text: i,
1060        view: _disabled2 ? 'day disabled' : view
1061      }));
1062    }
1063
1064    // Render days picker
1065    // -----------------------------------------------------------------------
1066
1067    this.$monthPrev.toggleClass(disabledClass, prevDisabled);
1068    this.$monthNext.toggleClass(disabledClass, nextDisabled);
1069    this.$monthCurrent.toggleClass(disabledClass, prevDisabled && nextDisabled).html(options.yearFirst ? viewYear + yearSuffix + ' ' + monthsShort[viewMonth] : monthsShort[viewMonth] + ' ' + viewYear + yearSuffix);
1070    this.$days.html(prevItems.join('') + items.join('') + nextItems.join(''));
1071  }
1072};
1073
1074var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1075
1076function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1077
1078// Classes
1079var CLASS_TOP_LEFT = NAMESPACE + '-top-left';
1080var CLASS_TOP_RIGHT = NAMESPACE + '-top-right';
1081var CLASS_BOTTOM_LEFT = NAMESPACE + '-bottom-left';
1082var CLASS_BOTTOM_RIGHT = NAMESPACE + '-bottom-right';
1083var CLASS_PLACEMENTS = [CLASS_TOP_LEFT, CLASS_TOP_RIGHT, CLASS_BOTTOM_LEFT, CLASS_BOTTOM_RIGHT].join(' ');
1084
1085var Datepicker = function () {
1086  function Datepicker(element) {
1087    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1088
1089    _classCallCheck(this, Datepicker);
1090
1091    this.$element = $(element);
1092    this.element = element;
1093    this.options = $.extend({}, DEFAULTS, LANGUAGES[options.language], options);
1094    this.built = false;
1095    this.shown = false;
1096    this.isInput = false;
1097    this.inline = false;
1098    this.initialValue = '';
1099    this.initialDate = null;
1100    this.startDate = null;
1101    this.endDate = null;
1102    this.init();
1103  }
1104
1105  _createClass(Datepicker, [{
1106    key: 'init',
1107    value: function init() {
1108      var $this = this.$element,
1109          options = this.options;
1110      var startDate = options.startDate,
1111          endDate = options.endDate,
1112          date = options.date;
1113
1114
1115      this.$trigger = $(options.trigger);
1116      this.isInput = $this.is('input') || $this.is('textarea');
1117      this.inline = options.inline && (options.container || !this.isInput);
1118      this.format = parseFormat(options.format);
1119
1120      var initialValue = this.getValue();
1121
1122      this.initialValue = initialValue;
1123      this.oldValue = initialValue;
1124      date = this.parseDate(date || initialValue);
1125
1126      if (startDate) {
1127        startDate = this.parseDate(startDate);
1128
1129        if (date.getTime() < startDate.getTime()) {
1130          date = new Date(startDate);
1131        }
1132
1133        this.startDate = startDate;
1134      }
1135
1136      if (endDate) {
1137        endDate = this.parseDate(endDate);
1138
1139        if (startDate && endDate.getTime() < startDate.getTime()) {
1140          endDate = new Date(startDate);
1141        }
1142
1143        if (date.getTime() > endDate.getTime()) {
1144          date = new Date(endDate);
1145        }
1146
1147        this.endDate = endDate;
1148      }
1149
1150      this.date = date;
1151      this.viewDate = new Date(date);
1152      this.initialDate = new Date(this.date);
1153      this.bind();
1154
1155      if (options.autoShow || this.inline) {
1156        this.show();
1157      }
1158
1159      if (options.autoPick) {
1160        this.pick();
1161      }
1162    }
1163  }, {
1164    key: 'build',
1165    value: function build() {
1166      if (this.built) {
1167        return;
1168      }
1169
1170      this.built = true;
1171
1172      var $this = this.$element,
1173          options = this.options;
1174
1175      var $picker = $(options.template);
1176
1177      this.$picker = $picker;
1178      this.$week = $picker.find(selectorOf('week'));
1179
1180      // Years view
1181      this.$yearsPicker = $picker.find(selectorOf('years picker'));
1182      this.$yearsPrev = $picker.find(selectorOf('years prev'));
1183      this.$yearsNext = $picker.find(selectorOf('years next'));
1184      this.$yearsCurrent = $picker.find(selectorOf('years current'));
1185      this.$years = $picker.find(selectorOf('years'));
1186
1187      // Months view
1188      this.$monthsPicker = $picker.find(selectorOf('months picker'));
1189      this.$yearPrev = $picker.find(selectorOf('year prev'));
1190      this.$yearNext = $picker.find(selectorOf('year next'));
1191      this.$yearCurrent = $picker.find(selectorOf('year current'));
1192      this.$months = $picker.find(selectorOf('months'));
1193
1194      // Days view
1195      this.$daysPicker = $picker.find(selectorOf('days picker'));
1196      this.$monthPrev = $picker.find(selectorOf('month prev'));
1197      this.$monthNext = $picker.find(selectorOf('month next'));
1198      this.$monthCurrent = $picker.find(selectorOf('month current'));
1199      this.$days = $picker.find(selectorOf('days'));
1200
1201      if (this.inline) {
1202        $(options.container || $this).append($picker.addClass(NAMESPACE + '-inline'));
1203      } else {
1204        $(document.body).append($picker.addClass(NAMESPACE + '-dropdown'));
1205        $picker.addClass(CLASS_HIDE);
1206      }
1207
1208      this.renderWeek();
1209    }
1210  }, {
1211    key: 'unbuild',
1212    value: function unbuild() {
1213      if (!this.built) {
1214        return;
1215      }
1216
1217      this.built = false;
1218      this.$picker.remove();
1219    }
1220  }, {
1221    key: 'bind',
1222    value: function bind() {
1223      var options = this.options,
1224          $this = this.$element;
1225
1226
1227      if ($.isFunction(options.show)) {
1228        $this.on(EVENT_SHOW, options.show);
1229      }
1230
1231      if ($.isFunction(options.hide)) {
1232        $this.on(EVENT_HIDE, options.hide);
1233      }
1234
1235      if ($.isFunction(options.pick)) {
1236        $this.on(EVENT_PICK, options.pick);
1237      }
1238
1239      if (this.isInput) {
1240        $this.on(EVENT_KEYUP, $.proxy(this.keyup, this));
1241      }
1242
1243      if (!this.inline) {
1244        if (options.trigger) {
1245          this.$trigger.on(EVENT_CLICK, $.proxy(this.toggle, this));
1246        } else if (this.isInput) {
1247          $this.on(EVENT_FOCUS, $.proxy(this.show, this));
1248        } else {
1249          $this.on(EVENT_CLICK, $.proxy(this.show, this));
1250        }
1251      }
1252    }
1253  }, {
1254    key: 'unbind',
1255    value: function unbind() {
1256      var $this = this.$element,
1257          options = this.options;
1258
1259
1260      if ($.isFunction(options.show)) {
1261        $this.off(EVENT_SHOW, options.show);
1262      }
1263
1264      if ($.isFunction(options.hide)) {
1265        $this.off(EVENT_HIDE, options.hide);
1266      }
1267
1268      if ($.isFunction(options.pick)) {
1269        $this.off(EVENT_PICK, options.pick);
1270      }
1271
1272      if (this.isInput) {
1273        $this.off(EVENT_KEYUP, this.keyup);
1274      }
1275
1276      if (!this.inline) {
1277        if (options.trigger) {
1278          this.$trigger.off(EVENT_CLICK, this.toggle);
1279        } else if (this.isInput) {
1280          $this.off(EVENT_FOCUS, this.show);
1281        } else {
1282          $this.off(EVENT_CLICK, this.show);
1283        }
1284      }
1285    }
1286  }, {
1287    key: 'showView',
1288    value: function showView(view) {
1289      var $yearsPicker = this.$yearsPicker,
1290          $monthsPicker = this.$monthsPicker,
1291          $daysPicker = this.$daysPicker,
1292          format = this.format;
1293
1294
1295      if (format.hasYear || format.hasMonth || format.hasDay) {
1296        switch (Number(view)) {
1297          case VIEWS.YEARS:
1298            $monthsPicker.addClass(CLASS_HIDE);
1299            $daysPicker.addClass(CLASS_HIDE);
1300
1301            if (format.hasYear) {
1302              this.renderYears();
1303              $yearsPicker.removeClass(CLASS_HIDE);
1304              this.place();
1305            } else {
1306              this.showView(VIEWS.DAYS);
1307            }
1308
1309            break;
1310
1311          case VIEWS.MONTHS:
1312            $yearsPicker.addClass(CLASS_HIDE);
1313            $daysPicker.addClass(CLASS_HIDE);
1314
1315            if (format.hasMonth) {
1316              this.renderMonths();
1317              $monthsPicker.removeClass(CLASS_HIDE);
1318              this.place();
1319            } else {
1320              this.showView(VIEWS.YEARS);
1321            }
1322
1323            break;
1324
1325          // case VIEWS.DAYS:
1326          default:
1327            $yearsPicker.addClass(CLASS_HIDE);
1328            $monthsPicker.addClass(CLASS_HIDE);
1329
1330            if (format.hasDay) {
1331              this.renderDays();
1332              $daysPicker.removeClass(CLASS_HIDE);
1333              this.place();
1334            } else {
1335              this.showView(VIEWS.MONTHS);
1336            }
1337        }
1338      }
1339    }
1340  }, {
1341    key: 'hideView',
1342    value: function hideView() {
1343      if (!this.inline && this.options.autoHide) {
1344        this.hide();
1345      }
1346    }
1347  }, {
1348    key: 'place',
1349    value: function place() {
1350      if (this.inline) {
1351        return;
1352      }
1353
1354      var $this = this.$element,
1355          options = this.options,
1356          $picker = this.$picker;
1357
1358      var containerWidth = $(document).outerWidth();
1359      var containerHeight = $(document).outerHeight();
1360      var elementWidth = $this.outerWidth();
1361      var elementHeight = $this.outerHeight();
1362      var width = $picker.width();
1363      var height = $picker.height();
1364
1365      var _$this$offset = $this.offset(),
1366          left = _$this$offset.left,
1367          top = _$this$offset.top;
1368
1369      var offset = parseFloat(options.offset);
1370      var placement = CLASS_TOP_LEFT;
1371
1372      if (isNaN(offset)) {
1373        offset = 10;
1374      }
1375
1376      if (top > height && top + elementHeight + height > containerHeight) {
1377        top -= height + offset;
1378        placement = CLASS_BOTTOM_LEFT;
1379      } else {
1380        top += elementHeight + offset;
1381      }
1382
1383      if (left + width > containerWidth) {
1384        left += elementWidth - width;
1385        placement = placement.replace('left', 'right');
1386      }
1387
1388      $picker.removeClass(CLASS_PLACEMENTS).addClass(placement).css({
1389        top: top,
1390        left: left,
1391        zIndex: parseInt(options.zIndex, 10)
1392      });
1393    }
1394
1395    // A shortcut for triggering custom events
1396
1397  }, {
1398    key: 'trigger',
1399    value: function trigger(type, data) {
1400      var e = $.Event(type, data);
1401
1402      this.$element.trigger(e);
1403
1404      return e;
1405    }
1406  }, {
1407    key: 'createItem',
1408    value: function createItem(data) {
1409      var options = this.options;
1410      var itemTag = options.itemTag;
1411
1412      var item = {
1413        text: '',
1414        view: '',
1415        muted: false,
1416        picked: false,
1417        disabled: false,
1418        highlighted: false
1419      };
1420      var classes = [];
1421
1422      $.extend(item, data);
1423
1424      if (item.muted) {
1425        classes.push(options.mutedClass);
1426      }
1427
1428      if (item.highlighted) {
1429        classes.push(options.highlightedClass);
1430      }
1431
1432      if (item.picked) {
1433        classes.push(options.pickedClass);
1434      }
1435
1436      if (item.disabled) {
1437        classes.push(options.disabledClass);
1438      }
1439
1440      return '<' + itemTag + ' class="' + classes.join(' ') + '" data-view="' + item.view + '">' + item.text + '</' + itemTag + '>';
1441    }
1442  }, {
1443    key: 'getValue',
1444    value: function getValue() {
1445      var $this = this.$element;
1446
1447      return this.isInput ? $this.val() : $this.text();
1448    }
1449  }, {
1450    key: 'setValue',
1451    value: function setValue() {
1452      var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1453
1454      var $this = this.$element;
1455
1456      if (this.isInput) {
1457        $this.val(value);
1458      } else {
1459        $this.text(value);
1460      }
1461    }
1462  }], [{
1463    key: 'setDefaults',
1464    value: function setDefaults() {
1465      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1466
1467      $.extend(DEFAULTS, LANGUAGES[options.language], options);
1468    }
1469  }]);
1470
1471  return Datepicker;
1472}();
1473
1474if ($.extend) {
1475  $.extend(Datepicker.prototype, render, handlers, methods);
1476}
1477
1478if ($.fn) {
1479  var AnotherDatepicker = $.fn.datepicker;
1480
1481  $.fn.datepicker = function jQueryDatepicker(option) {
1482    for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1483      args[_key - 1] = arguments[_key];
1484    }
1485
1486    var result = void 0;
1487
1488    this.each(function (i, element) {
1489      var $element = $(element);
1490      var 
1490data = $element.data(NAMESPACE);
1491
1492      if (!data) {
1493        if (/destroy/.test(option)) {
1494          return;
1495        }
1496
1497        var options = $.extend({}, $element.data(), $.isPlainObject(option) && option);
1498
1499        data = new Datepicker(element, options);
1500        $element.data(NAMESPACE, data);
1501      }
1502
1503      if (isString(option)) {
1504        var fn = data[option];
1505
1506        if ($.isFunction(fn)) {
1507          result = fn.apply(data, args);
1508        }
1509      }
1510    });
1511
1512    return isUndefined(result) ? this : result;
1513  };
1514
1515  $.fn.datepicker.Constructor = Datepicker;
1516  $.fn.datepicker.languages = LANGUAGES;
1517  $.fn.datepicker.setDefaults = Datepicker.setDefaults;
1518  $.fn.datepicker.noConflict = function noConflict() {
1519    $.fn.datepicker = AnotherDatepicker;
1520    return this;
1521  };
1522}
1523
1524})));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.