',\r\n monthHtml = void 0,\r\n yearHtml = void 0,\r\n prev = true,\r\n next = true;\r\n\r\n for (arr = [], i = 0; i < 12; i++) {\r\n arr.push('
');\r\n }\r\n\r\n monthHtml = '
';\r\n\r\n if ($.isArray(opts.yearRange)) {\r\n i = opts.yearRange[0];\r\n j = opts.yearRange[1] + 1;\r\n } else {\r\n i = year - opts.yearRange;\r\n j = 1 + year + opts.yearRange;\r\n }\r\n\r\n for (arr = []; i < j && i <= opts.maxYear; i++) {\r\n if (i >= opts.minYear) {\r\n arr.push(\"
\");\r\n }\r\n }\r\n if (opts.yearRangeReverse) {\r\n arr.reverse();\r\n }\r\n\r\n yearHtml = \"
\";\r\n\r\n var leftArrow = '
';\r\n html += \"
\";\r\n\r\n html += '
';\r\n if (opts.showMonthAfterYear) {\r\n html += yearHtml + monthHtml;\r\n } else {\r\n html += monthHtml + yearHtml;\r\n }\r\n html += '
';\r\n\r\n if (isMinYear && (month === 0 || opts.minMonth >= month)) {\r\n prev = false;\r\n }\r\n\r\n if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {\r\n next = false;\r\n }\r\n\r\n var rightArrow = '
';\r\n html += \"
\";\r\n\r\n return html += '
';\r\n }\r\n\r\n /**\r\n * refresh the HTML\r\n */\r\n\r\n }, {\r\n key: \"draw\",\r\n value: function draw(force) {\r\n if (!this.isOpen && !force) {\r\n return;\r\n }\r\n var opts = this.options,\r\n minYear = opts.minYear,\r\n maxYear = opts.maxYear,\r\n minMonth = opts.minMonth,\r\n maxMonth = opts.maxMonth,\r\n html = '',\r\n randId = void 0;\r\n\r\n if (this._y <= minYear) {\r\n this._y = minYear;\r\n if (!isNaN(minMonth) && this._m < minMonth) {\r\n this._m = minMonth;\r\n }\r\n }\r\n if (this._y >= maxYear) {\r\n this._y = maxYear;\r\n if (!isNaN(maxMonth) && this._m > maxMonth) {\r\n this._m = maxMonth;\r\n }\r\n }\r\n\r\n randId = 'datepicker-title-' + Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 2);\r\n\r\n for (var c = 0; c < 1; c++) {\r\n this._renderDateDisplay();\r\n html += this.renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year, randId) + this.render(this.calendars[c].year, this.calendars[c].month, randId);\r\n }\r\n\r\n this.destroySelects();\r\n\r\n this.calendarEl.innerHTML = html;\r\n\r\n // Init Materialize Select\r\n var yearSelect = this.calendarEl.querySelector('.orig-select-year');\r\n var monthSelect = this.calendarEl.querySelector('.orig-select-month');\r\n M.FormSelect.init(yearSelect, {\r\n classes: 'select-year',\r\n dropdownOptions: { container: document.body, constrainWidth: false }\r\n });\r\n M.FormSelect.init(monthSelect, {\r\n classes: 'select-month',\r\n dropdownOptions: { container: document.body, constrainWidth: false }\r\n });\r\n\r\n // Add change handlers for select\r\n yearSelect.addEventListener('change', this._handleYearChange.bind(this));\r\n monthSelect.addEventListener('change', this._handleMonthChange.bind(this));\r\n\r\n if (typeof this.options.onDraw === 'function') {\r\n this.options.onDraw(this);\r\n }\r\n }\r\n\r\n /**\r\n * Setup Event Handlers\r\n */\r\n\r\n }, {\r\n key: \"_setupEventHandlers\",\r\n value: function _setupEventHandlers() {\r\n this._handleInputKeydownBound = this._handleInputKeydown.bind(this);\r\n this._handleInputClickBound = this._handleInputClick.bind(this);\r\n this._handleInputChangeBound = this._handleInputChange.bind(this);\r\n this._handleCalendarClickBound = this._handleCalendarClick.bind(this);\r\n this._finishSelectionBound = this._finishSelection.bind(this);\r\n this._handleMonthChange = this._handleMonthChange.bind(this);\r\n this._closeBound = this.close.bind(this);\r\n\r\n this.el.addEventListener('click', this._handleInputClickBound);\r\n this.el.addEventListener('keydown', this._handleInputKeydownBound);\r\n this.el.addEventListener('change', this._handleInputChangeBound);\r\n this.calendarEl.addEventListener('click', this._handleCalendarClickBound);\r\n this.doneBtn.addEventListener('click', this._finishSelectionBound);\r\n this.cancelBtn.addEventListener('click', this._closeBound);\r\n\r\n if (this.options.showClearBtn) {\r\n this._handleClearClickBound = this._handleClearClick.bind(this);\r\n this.clearBtn.addEventListener('click', this._handleClearClickBound);\r\n }\r\n }\r\n }, {\r\n key: \"_setupVariables\",\r\n value: function _setupVariables() {\r\n var _this56 = this;\r\n\r\n this.$modalEl = $(Datepicker._template);\r\n this.modalEl = this.$modalEl[0];\r\n\r\n this.calendarEl = this.modalEl.querySelector('.datepicker-calendar');\r\n\r\n this.yearTextEl = this.modalEl.querySelector('.year-text');\r\n this.dateTextEl = this.modalEl.querySelector('.date-text');\r\n if (this.options.showClearBtn) {\r\n this.clearBtn = this.modalEl.querySelector('.datepicker-clear');\r\n }\r\n this.doneBtn = this.modalEl.querySelector('.datepicker-done');\r\n this.cancelBtn = this.modalEl.querySelector('.datepicker-cancel');\r\n\r\n this.formats = {\r\n d: function () {\r\n return _this56.date.getDate();\r\n },\r\n dd: function () {\r\n var d = _this56.date.getDate();\r\n return (d < 10 ? '0' : '') + d;\r\n },\r\n ddd: function () {\r\n return _this56.options.i18n.weekdaysShort[_this56.date.getDay()];\r\n },\r\n dddd: function () {\r\n return _this56.options.i18n.weekdays[_this56.date.getDay()];\r\n },\r\n m: function () {\r\n return _this56.date.getMonth() + 1;\r\n },\r\n mm: function () {\r\n var m = _this56.date.getMonth() + 1;\r\n return (m < 10 ? '0' : '') + m;\r\n },\r\n mmm: function () {\r\n return _this56.options.i18n.monthsShort[_this56.date.getMonth()];\r\n },\r\n mmmm: function () {\r\n return _this56.options.i18n.months[_this56.date.getMonth()];\r\n },\r\n yy: function () {\r\n return ('' + _this56.date.getFullYear()).slice(2);\r\n },\r\n yyyy: function () {\r\n return _this56.date.getFullYear();\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * Remove Event Handlers\r\n */\r\n\r\n }, {\r\n key: \"_removeEventHandlers\",\r\n value: function _removeEventHandlers() {\r\n this.el.removeEventListener('click', this._handleInputClickBound);\r\n this.el.removeEventListener('keydown', this._handleInputKeydownBound);\r\n this.el.removeEventListener('change', this._handleInputChangeBound);\r\n this.calendarEl.removeEventListener('click', this._handleCalendarClickBound);\r\n }\r\n }, {\r\n key: \"_handleInputClick\",\r\n value: function _handleInputClick() {\r\n this.open();\r\n }\r\n }, {\r\n key: \"_handleInputKeydown\",\r\n value: function _handleInputKeydown(e) {\r\n if (e.which === M.keys.ENTER) {\r\n e.preventDefault();\r\n this.open();\r\n }\r\n }\r\n }, {\r\n key: \"_handleCalendarClick\",\r\n value: function _handleCalendarClick(e) {\r\n if (!this.isOpen) {\r\n return;\r\n }\r\n\r\n var $target = $(e.target);\r\n if (!$target.hasClass('is-disabled')) {\r\n if ($target.hasClass('datepicker-day-button') && !$target.hasClass('is-empty') && !$target.parent().hasClass('is-disabled')) {\r\n this.setDate(new Date(e.target.getAttribute('data-year'), e.target.getAttribute('data-month'), e.target.getAttribute('data-day')));\r\n if (this.options.autoClose) {\r\n this._finishSelection();\r\n }\r\n } else if ($target.closest('.month-prev').length) {\r\n this.prevMonth();\r\n } else if ($target.closest('.month-next').length) {\r\n this.nextMonth();\r\n }\r\n }\r\n }\r\n }, {\r\n key: \"_handleClearClick\",\r\n value: function _handleClearClick() {\r\n this.date = null;\r\n this.setInputValue();\r\n this.close();\r\n }\r\n }, {\r\n key: \"_handleMonthChange\",\r\n value: function _handleMonthChange(e) {\r\n this.gotoMonth(e.target.value);\r\n }\r\n }, {\r\n key: \"_handleYearChange\",\r\n value: function _handleYearChange(e) {\r\n this.gotoYear(e.target.value);\r\n }\r\n\r\n /**\r\n * change view to a specific month (zero-index, e.g. 0: January)\r\n */\r\n\r\n }, {\r\n key: \"gotoMonth\",\r\n value: function gotoMonth(month) {\r\n if (!isNaN(month)) {\r\n this.calendars[0].month = parseInt(month, 10);\r\n this.adjustCalendars();\r\n }\r\n }\r\n\r\n /**\r\n * change view to a specific full year (e.g. \"2012\")\r\n */\r\n\r\n }, {\r\n key: \"gotoYear\",\r\n value: function gotoYear(year) {\r\n if (!isNaN(year)) {\r\n this.calendars[0].year = parseInt(year, 10);\r\n this.adjustCalendars();\r\n }\r\n }\r\n }, {\r\n key: \"_handleInputChange\",\r\n value: function _handleInputChange(e) {\r\n var date = void 0;\r\n\r\n // Prevent change event from being fired when triggered by the plugin\r\n if (e.firedBy === this) {\r\n return;\r\n }\r\n if (this.options.parse) {\r\n date = this.options.parse(this.el.value, this.options.format);\r\n } else {\r\n date = new Date(Date.parse(this.el.value));\r\n }\r\n\r\n if (Datepicker._isDate(date)) {\r\n this.setDate(date);\r\n }\r\n }\r\n }, {\r\n key: \"renderDayName\",\r\n value: function renderDayName(opts, day, abbr) {\r\n day += opts.firstDay;\r\n while (day >= 7) {\r\n day -= 7;\r\n }\r\n return abbr ? opts.i18n.weekdaysAbbrev[day] : opts.i18n.weekdays[day];\r\n }\r\n\r\n /**\r\n * Set input value to the selected date and close Datepicker\r\n */\r\n\r\n }, {\r\n key: \"_finishSelection\",\r\n value: function _finishSelection() {\r\n this.setInputValue();\r\n this.close();\r\n }\r\n\r\n /**\r\n * Open Datepicker\r\n */\r\n\r\n }, {\r\n key: \"open\",\r\n value: function open() {\r\n if (this.isOpen) {\r\n return;\r\n }\r\n\r\n this.isOpen = true;\r\n if (typeof this.options.onOpen === 'function') {\r\n this.options.onOpen.call(this);\r\n }\r\n this.draw();\r\n this.modal.open();\r\n return this;\r\n }\r\n\r\n /**\r\n * Close Datepicker\r\n */\r\n\r\n }, {\r\n key: \"close\",\r\n value: function close() {\r\n if (!this.isOpen) {\r\n return;\r\n }\r\n\r\n this.isOpen = false;\r\n if (typeof this.options.onClose === 'function') {\r\n this.options.onClose.call(this);\r\n }\r\n this.modal.close();\r\n return this;\r\n }\r\n }], [{\r\n key: \"init\",\r\n value: function init(els, options) {\r\n return _get(Datepicker.__proto__ || Object.getPrototypeOf(Datepicker), \"init\", this).call(this, this, els, options);\r\n }\r\n }, {\r\n key: \"_isDate\",\r\n value: function _isDate(obj) {\r\n return (/Date/.test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime())\r\n );\r\n }\r\n }, {\r\n key: \"_isWeekend\",\r\n value: function _isWeekend(date) {\r\n var day = date.getDay();\r\n return day === 0 || day === 6;\r\n }\r\n }, {\r\n key: \"_setToStartOfDay\",\r\n value: function _setToStartOfDay(date) {\r\n if (Datepicker._isDate(date)) date.setHours(0, 0, 0, 0);\r\n }\r\n }, {\r\n key: \"_getDaysInMonth\",\r\n value: function _getDaysInMonth(year, month) {\r\n return [31, Datepicker._isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];\r\n }\r\n }, {\r\n key: \"_isLeapYear\",\r\n value: function _isLeapYear(year) {\r\n // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951\r\n return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;\r\n }\r\n }, {\r\n key: \"_compareDates\",\r\n value: function _compareDates(a, b) {\r\n // weak date comparison (use setToStartOfDay(date) to ensure correct result)\r\n return a.getTime() === b.getTime();\r\n }\r\n }, {\r\n key: \"_setToStartOfDay\",\r\n value: function _setToStartOfDay(date) {\r\n if (Datepicker._isDate(date)) date.setHours(0, 0, 0, 0);\r\n }\r\n\r\n /**\r\n * Get Instance\r\n */\r\n\r\n }, {\r\n key: \"getInstance\",\r\n value: function getInstance(el) {\r\n var domElem = !!el.jquery ? el[0] : el;\r\n return domElem.M_Datepicker;\r\n }\r\n }, {\r\n key: \"defaults\",\r\n get: function () {\r\n return _defaults;\r\n }\r\n }]);\r\n\r\n return Datepicker;\r\n }(Component);\r\n\r\n Datepicker._template = ['