!function () { "use strict"; angular.module("angularjs-datetime-picker", []); var e = function (e) { "string" == typeof e && (e = new Date(e)); var t = new Date(e.getFullYear(), 0, 1), a = new Date(e.getFullYear(), 6, 1), n = Math.max(t.getTimezoneOffset(), a.getTimezoneOffset()), l = e.getTimezoneOffset() < n, r = l ? n - 60 : n, i = r >= 0 ? "-" : "+"; return i + ("0" + r / 60).slice(-2) + ":" + ("0" + r % 60).slice(-2) }, t = function (e, t, a) { var n = a("DatetimePickerCtrl"); return { open: function (e) { n.openDatetimePicker(e) }, close: function () { n.closeDatetimePicker() } } }; t.$inject = ["$compile", "$document", "$controller"], angular.module("angularjs-datetime-picker").factory("DatetimePicker", t); var a = function (e, t) { var a, n = this, l = function (e) { e && e.remove(), t[0].body.removeEventListener("click", n.closeDatetimePicker) }; this.openDatetimePicker = function (n) { this.closeDatetimePicker(); var l = angular.element("
"); n.dateFormat && l.attr("date-format", n.dateFormat), n.ngModel && l.attr("ng-model", n.ngModel), n.year && l.attr("year", parseInt(n.year)), n.month && l.attr("month", parseInt(n.month)), n.day && l.attr("day", parseInt(n.day)), n.hour && l.attr("hour", parseInt(n.hour)), n.minute && l.attr("minute", parseInt(n.minute)), ("" === n.dateOnly || n.dateOnly === !0) && l.attr("date-only", "true"), "false" === n.closeOnSelect && l.attr("close-on-select", "false"); var r = n.triggerEl; n.scope = n.scope || angular.element(r).scope(), a = e(l)(n.scope)[0], a.triggerEl = n.triggerEl, t[0].body.appendChild(a); var i = r.getBoundingClientRect(); a.style.position = "absolute", a.style.left = i.left + window.scrollX + "px", n.scope.$apply(); var o = a.getBoundingClientRect(); i.top < 300 || window.innerHeight - i.bottom > 300 ? a.style.top = i.bottom + window.scrollY + "px" : a.style.top = i.top - o.height + window.scrollY + "px", t[0].body.addEventListener("click", this.closeDatetimePicker) }, this.closeDatetimePicker = function (e) { var a = e && e.target, n = t[0].querySelector("div[datetime-picker-popup]"); e && a ? a.hasAttribute("datetime-picker") || n && n.contains(a) || l(n) : l(n) } }; a.$inject = ["$compile", "$document"], angular.module("angularjs-datetime-picker").controller("DatetimePickerCtrl", a); var n = ['
', '
', ' ', ' {{months[mv.month].shortName}} {{mv.year}}', ' ', "
", '
', '
{{::dayOfWeek.firstLetter}}
', '
{{::day}}
', '
{{::day}}
', '
{{::day}}
', "
", '
', ' Time : {{("0"+inputHour).slice(-2)}} : {{("0"+inputMinute).slice(-2)}}
', ' ', ' ', "
", "
"].join("\n"), l = function (t, a) { var l, r, i, o, c = function () { l = [], r = [], i = [], o = 0; for (var e = 1; 31 >= e; e++)l.push(e); for (var e = 0; 12 > e; e++)r.push({ fullName: t.DATETIME_FORMATS.MONTH[e], shortName: t.DATETIME_FORMATS.SHORTMONTH[e] }); for (var e = 0; 7 > e; e++) { var a = t.DATETIME_FORMATS.DAY[(e + o) % 7]; i.push({fullName: a, firstLetter: a.substr(0, 2)}) } o = t.DATETIME_FORMATS.FIRSTDAYOFWEEK || 0 }, d = function (e, t) { t > 11 ? e++ : 0 > t && e--, t = (t + 12) % 12; var a = new Date(e, t, 1), n = new Date(e, t + 1, 0), r = new Date(e, t, 0), i = n.getDate(), c = r.getDate(), d = a.getDay(), s = (d - o + 7) % 7 || 7, u = l.slice(0, 42 - (s + i)); return u.length > 7 && (u = u.slice(0, u.length - 7)), { year: e, month: t, days: l.slice(0, i), leadingDays: l.slice(-s - (31 - c), c), trailingDays: u } }, s = function (t, n, l, o) { c(); var s = l.dateFormat || "short"; t.months = r, t.daysOfWeek = i, t.inputHour, t.inputMinute, t.dateOnly === !0 && (n[0].querySelector("#adp-time").style.display = "none"), t.$applyAsync(function () { if (o.triggerEl = angular.element(n[0].triggerEl), l.ngModel) { var a = "" + o.triggerEl.scope().$eval(l.ngModel); if (a) { a.match(/[0-9]{2}:/) || (a += " 00:00:00"), a = a.replace(/([0-9]{2}-[0-9]{2})-([0-9]{4})/, "$2-$1"), a = a.replace(/([\/-][0-9]{2,4})\ ([0-9]{2}\:[0-9]{2}\:)/, "$1T$2"), a = a.replace(/EDT|EST|CDT|CST|MDT|PDT|PST|UT|GMT/g, ""), a = a.replace(/\s*\(\)\s*/, ""), a = a.replace(/[\-\+][0-9]{2}:?[0-9]{2}$/, ""), a += e(a); var r = new Date(a); t.selectedDate = new Date(r.getFullYear(), r.getMonth(), r.getDate(), r.getHours(), r.getMinutes(), r.getSeconds()) } } if (!t.selectedDate || isNaN(t.selectedDate.getTime())) { var i = new Date, c = t.year || i.getFullYear(), s = t.month ? t.month - 1 : i.getMonth(), u = t.day || i.getDate(), m = t.hour || i.getHours(), g = t.minute || i.getMinutes(); t.selectedDate = new Date(c, s, u, m, g, 0) } t.inputHour = t.selectedDate.getHours(), t.inputMinute = t.selectedDate.getMinutes(), t.mv = d(t.selectedDate.getFullYear(), t.selectedDate.getMonth()), t.mv.year == t.selectedDate.getFullYear() && t.mv.month == t.selectedDate.getMonth() ? t.selectedDay = t.selectedDate.getDate() : t.selectedDay = null }), t.addMonth = function (e) { t.mv = d(t.mv.year, t.mv.month + e) }, t.setDate = function (e) { var a = angular.element(e.target)[0]; -1 !== a.className.indexOf("selectable") && (t.updateNgModel(parseInt(a.innerHTML)), t.closeOnSelect !== !1 && o.closeDatetimePicker()) }, t.updateNgModel = function (e) { if (e = e ? e : t.selectedDate.getDate(), t.selectedDate = new Date(t.mv.year, t.mv.month, e, t.inputHour, t.inputMinute, 0), t.selectedDay = t.selectedDate.getDate(), l.ngModel) { var n, r = o.triggerEl.scope(); n = t.selectedDate r.$eval(l.ngModel + "= date", {date: n}) //n = r.$eval(l.ngModel) && "Date" === r.$eval(l.ngModel).constructor.name ? new Date(a(t.selectedDate, s)) : a(t.selectedDate, s), r.$eval(l.ngModel + "= date", {date: n}) } }, t.$on("$destroy", o.closeDatetimePicker) }; return { restrict: "A", template: n, controller: "DatetimePickerCtrl", replace: !0, scope: { year: "=", month: "=", day: "=", hour: "=", minute: "=", dateOnly: "=", closeOnSelect: "=" }, link: s } }; l.$inject = ["$locale", "dateFilter"], angular.module("angularjs-datetime-picker").directive("datetimePickerPopup", l); var r = function (e, t) { return { require: "ngModel", link: function (e, a, n, l) { e.$watch(n.ngModel, function (e) { if (e && "" != e) { var t = new Date(e); l.$setValidity("date", t ? !0 : !1); var a = new Date; n.hasOwnProperty("futureOnly") && l.$setValidity("future-only", a > t ? !1 : !0) l.$modelValue = t; } }), a[0].addEventListener("click", function () { t.open({ triggerEl: a[0], dateFormat: n.dateFormat, ngModel: n.ngModel, year: n.year, month: n.month, day: n.day, hour: n.hour, minute: n.minute, dateOnly: n.dateOnly, futureOnly: n.futureOnly, closeOnSelect: n.closeOnSelect }) }) } } }; r.$inject = ["$parse", "DatetimePicker"], angular.module("angularjs-datetime-picker").directive("datetimePicker", r) }();