123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- !function (t) {
- function e() {
- return new Date(Date.UTC.apply(Date, arguments))
- }
- var i = function (e, i) {
- var n = this;
- this.element = t(e), this.language = i.language || this.element.data("date-language") || "en", this.language = this.language in s ? this.language : "en", this.isRTL = s[this.language].rtl || !1, this.formatType = i.formatType || this.element.data("format-type") || "standard", this.format = a.parseFormat(i.format || this.element.data("date-format") || a.getDefaultFormat(this.formatType, "input"), this.formatType), this.isInline = !1, this.isVisible = !1, this.isInput = this.element.is("input"), this.component = this.element.is(".date") ? this.element.find(".add-on .icon-th, .add-on .icon-time, .add-on .icon-calendar").parent() : !1, this.componentReset = this.element.is(".date") ? this.element.find(".add-on .icon-remove").parent() : !1, this.hasInput = this.component && this.element.find("input").length, this.component && 0 === this.component.length && (this.component = !1), this.linkField = i.linkField || this.element.data("link-field") || !1, this.linkFormat = a.parseFormat(i.linkFormat || this.element.data("link-format") || a.getDefaultFormat(this.formatType, "link"), this.formatType), this.minuteStep = i.minuteStep || this.element.data("minute-step") || 5, this.pickerPosition = i.pickerPosition || this.element.data("picker-position") || "bottom-right", this.showMeridian = i.showMeridian || this.element.data("show-meridian") || !1, this.initialDate = i.initialDate || new Date, this._attachEvents(), this.formatViewType = "datetime", "formatViewType"in i ? this.formatViewType = i.formatViewType : "formatViewType"in this.element.data() && (this.formatViewType = this.element.data("formatViewType")), this.minView = 0, "minView"in i ? this.minView = i.minView : "minView"in this.element.data() && (this.minView = this.element.data("min-view")), this.minView = a.convertViewMode(this.minView), this.maxView = a.modes.length - 1, "maxView"in i ? this.maxView = i.maxView : "maxView"in this.element.data() && (this.maxView = this.element.data("max-view")), this.maxView = a.convertViewMode(this.maxView), this.startViewMode = 2, "startView"in i ? this.startViewMode = i.startView : "startView"in this.element.data() && (this.startViewMode = this.element.data("start-view")), this.startViewMode = a.convertViewMode(this.startViewMode), this.viewMode = this.startViewMode, this.viewSelect = this.minView, "viewSelect"in i ? this.viewSelect = i.viewSelect : "viewSelect"in this.element.data() && (this.viewSelect = this.element.data("view-select")), this.viewSelect = a.convertViewMode(this.viewSelect), this.forceParse = !0, "forceParse"in i ? this.forceParse = i.forceParse : "dateForceParse"in this.element.data() && (this.forceParse = this.element.data("date-force-parse")), this.picker = i.container ? t(a.template).appendTo(i.container).on({click: t.proxy(this.click, this), mousedown: t.proxy(this.mousedown, this)}) : t(a.template).appendTo(this.isInline ? this.element : "body").on({click: t.proxy(this.click, this), mousedown: t.proxy(this.mousedown, this)}), this.isInline ? this.picker.addClass("datetimepicker-inline") : this.picker.addClass("datetimepicker-dropdown-" + this.pickerPosition + " dropdown-menu"), this.isRTL && (this.picker.addClass("datetimepicker-rtl"), this.picker.find(".prev i, .next i").toggleClass("icon-arrow-left icon-arrow-right")), t(document).on("mousedown", function (e) {
- 0 === t(e.target).closest(".datetimepicker").length && n.hide()
- }), this.autoclose = !1, "autoclose"in i ? this.autoclose = i.autoclose : "dateAutoclose"in this.element.data() && (this.autoclose = this.element.data("date-autoclose")), this.keyboardNavigation = !0, "keyboardNavigation"in i ? this.keyboardNavigation = i.keyboardNavigation : "dateKeyboardNavigation"in this.element.data() && (this.keyboardNavigation = this.element.data("date-keyboard-navigation")), this.todayBtn = i.todayBtn || this.element.data("date-today-btn") || !1, this.todayHighlight = i.todayHighlight || this.element.data("date-today-highlight") || !1, this.weekStart = (i.weekStart || this.element.data("date-weekstart") || s[this.language].weekStart || 0) % 7, this.weekEnd = (this.weekStart + 6) % 7, this.startDate = -1 / 0, this.endDate = 1 / 0, this.daysOfWeekDisabled = [], this.setStartDate(i.startDate || this.element.data("date-startdate")), this.setEndDate(i.endDate || this.element.data("date-enddate")), this.setDaysOfWeekDisabled(i.daysOfWeekDisabled || this.element.data("date-days-of-week-disabled")), this.fillDow(), this.fillMonths(), this.update(), this.showMode(), this.isInline && this.show()
- };
- i.prototype = {constructor: i, _events: [], _attachEvents: function () {
- this._detachEvents(), 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.componentReset && this._events.push([this.componentReset, {click: t.proxy(this.reset, this)}])) : this.element.is("div") ? this.isInline = !0 : this._events = [
- [this.element, {click: t.proxy(this.show, this)}]
- ];
- for (var e, i, s = 0; s < this._events.length; s++)e = this._events[s][0], i = this._events[s][1], e.on(i)
- }, _detachEvents: function () {
- for (var t, e, i = 0; i < this._events.length; i++)t = this._events[i][0], e = this._events[i][1], t.off(e);
- this._events = []
- }, show: function (e) {
- this.picker.show(), this.height = this.component ? this.component.outerHeight() : this.element.outerHeight(), this.forceParse && this.update(), this.place(), t(window).on("resize", t.proxy(this.place, this)), e && (e.stopPropagation(), e.preventDefault()), this.isVisible = !0, this.element.trigger({type: "show", date: this.date})
- }, hide: function () {
- this.isVisible && (this.isInline || (this.picker.hide(), t(window).off("resize", this.place), this.viewMode = this.startViewMode, this.showMode(), this.isInput || t(document).off("mousedown", this.hide), this.forceParse && (this.isInput && this.element.val() || this.hasInput && this.element.find("input").val()) && this.setValue(), this.isVisible = !1, this.element.trigger({type: "hide", date: this.date})))
- }, remove: function () {
- this._detachEvents(), this.picker.remove(), delete this.element.data().datetimepicker
- }, 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) {
- t >= this.startDate && t <= this.endDate ? (this.date = t, this.setValue(), this.viewDate = this.date, this.fill()) : this.element.trigger({type: "outOfRange", date: t, startDate: this.startDate, endDate: this.endDate})
- }, setFormat: function (t) {
- this.format = a.parseFormat(t, this.formatType);
- var e;
- this.isInput ? e = this.element : this.component && (e = this.element.find("input")), e && e.val() && this.setValue()
- }, setValue: function () {
- var e = this.getFormattedDate();
- this.isInput ? this.element.val(e) : (this.component && this.element.find("input").val(e), this.element.data("date", e)), this.linkField && t("#" + this.linkField).val(this.getFormattedDate(this.linkFormat))
- }, getFormattedDate: function (t) {
- return void 0 == t && (t = this.format), a.formatDate(this.date, t, this.language, this.formatType)
- }, setStartDate: function (t) {
- this.startDate = t || -1 / 0, this.startDate !== -1 / 0 && (this.startDate = a.parseDate(this.startDate, this.format, this.language, this.formatType)), this.update(), this.updateNavArrows()
- }, setEndDate: function (t) {
- this.endDate = t || 1 / 0, 1 / 0 !== this.endDate && (this.endDate = a.parseDate(this.endDate, this.format, this.language, this.formatType)), this.update(), this.updateNavArrows()
- }, setDaysOfWeekDisabled: function (e) {
- this.daysOfWeekDisabled = e || [], t.isArray(this.daysOfWeekDisabled) || (this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/)), this.daysOfWeekDisabled = t.map(this.daysOfWeekDisabled, function (t) {
- return parseInt(t, 10)
- }), this.update(), this.updateNavArrows()
- }, place: function () {
- if (!this.isInline) {
- var e, i, s, a = parseInt(this.element.parents().filter(function () {
- return"auto" != t(this).css("z-index")
- }).first().css("z-index")) + 10;
- this.component ? (e = this.component.offset(), s = e.left, ("bottom-left" == this.pickerPosition || "top-left" == this.pickerPosition) && (s += this.component.outerWidth() - this.picker.outerWidth())) : (e = this.element.offset(), s = e.left), i = "top-left" == this.pickerPosition || "top-right" == this.pickerPosition ? e.top - this.picker.outerHeight() : e.top + this.height, this.picker.css({top: i, left: s, zIndex: a})
- }
- }, update: function () {
- var t, e = !1;
- arguments && arguments.length && ("string" == typeof arguments[0] || arguments[0]instanceof Date) ? (t = arguments[0], e = !0) : t = this.element.data("date") || (this.isInput ? this.element.val() : this.element.find("input").val()) || this.initialDate, t || (t = new Date, e = !1), this.date = a.parseDate(t, this.format, this.language, this.formatType), e && this.setValue(), this.viewDate = this.date < this.startDate ? new Date(this.startDate) : this.date > this.endDate ? new Date(this.endDate) : new Date(this.date), this.fill()
- }, fillDow: function () {
- for (var t = this.weekStart, e = "<tr>"; t < this.weekStart + 7;)e += '<th class="dow">' + s[this.language].daysMin[t++ % 7] + "</th>";
- e += "</tr>", this.picker.find(".datetimepicker-days thead").append(e)
- }, fillMonths: function () {
- for (var t = "", e = 0; 12 > e;)t += '<span class="month">' + s[this.language].monthsShort[e++] + "</span>";
- this.picker.find(".datetimepicker-months td").html(t)
- }, fill: function () {
- if (null != this.date && null != this.viewDate) {
- var i = new Date(this.viewDate), n = i.getUTCFullYear(), h = i.getUTCMonth(), r = i.getUTCDate(), o = i.getUTCHours(), d = i.getUTCMinutes(), l = this.startDate !== -1 / 0 ? this.startDate.getUTCFullYear() : -1 / 0, c = this.startDate !== -1 / 0 ? this.startDate.getUTCMonth() : -1 / 0, u = 1 / 0 !== this.endDate ? this.endDate.getUTCFullYear() : 1 / 0, m = 1 / 0 !== this.endDate ? this.endDate.getUTCMonth() : 1 / 0, p = new e(this.date.getUTCFullYear(), this.date.getUTCMonth(), this.date.getUTCDate()).valueOf(), v = new Date;
- if (this.picker.find(".datetimepicker-days thead th:eq(1)").text(s[this.language].months[h] + " " + n), "time" == this.formatViewType) {
- var f = o % 12 ? o % 12 : 12, g = (10 > f ? "0" : "") + f, D = (10 > d ? "0" : "") + d, w = s[this.language].meridiem[12 > o ? 0 : 1];
- this.picker.find(".datetimepicker-hours thead th:eq(1)").text(g + ":" + D + " " + w.toUpperCase()), this.picker.find(".datetimepicker-minutes thead th:eq(1)").text(g + ":" + D + " " + w.toUpperCase())
- } else this.picker.find(".datetimepicker-hours thead th:eq(1)").text(r + " " + s[this.language].months[h] + " " + n), this.picker.find(".datetimepicker-minutes thead th:eq(1)").text(r + " " + s[this.language].months[h] + " " + n);
- this.picker.find("tfoot th.today").text(s[this.language].today).toggle(this.todayBtn !== !1), this.updateNavArrows(), this.fillMonths();
- var y = e(n, h - 1, 28, 0, 0, 0, 0), T = a.getDaysInMonth(y.getUTCFullYear(), y.getUTCMonth());
- y.setUTCDate(T), y.setUTCDate(T - (y.getUTCDay() - this.weekStart + 7) % 7);
- var C = new Date(y);
- C.setUTCDate(C.getUTCDate() + 42), C = C.valueOf();
- for (var k, M = []; y.valueOf() < C;)y.getUTCDay() == this.weekStart && M.push("<tr>"), k = "", y.getUTCFullYear() < n || y.getUTCFullYear() == n && y.getUTCMonth() < h ? k += " old" : (y.getUTCFullYear() > n || y.getUTCFullYear() == n && y.getUTCMonth() > h) && (k += " new"), this.todayHighlight && y.getUTCFullYear() == v.getFullYear() && y.getUTCMonth() == v.getMonth() && y.getUTCDate() == v.getDate() && (k += " today"), y.valueOf() == p && (k += " active"), (y.valueOf() + 864e5 <= this.startDate || y.valueOf() > this.endDate || -1 !== t.inArray(y.getUTCDay(), this.daysOfWeekDisabled)) && (k += " disabled"), M.push('<td class="day' + k + '">' + y.getUTCDate() + "</td>"), y.getUTCDay() == this.weekEnd && M.push("</tr>"), y.setUTCDate(y.getUTCDate() + 1);
- this.picker.find(".datetimepicker-days tbody").empty().append(M.join("")), M = [];
- for (var U = "", b = "", F = "", S = 0; 24 > S; S++) {
- var x = e(n, h, r, S);
- k = "", x.valueOf() + 36e5 <= this.startDate || x.valueOf() > this.endDate ? k += " disabled" : o == S && (k += " active"), this.showMeridian && 2 == s[this.language].meridiem.length ? (b = 12 > S ? s[this.language].meridiem[0] : s[this.language].meridiem[1], b != F && ("" != F && M.push("</fieldset>"), M.push('<fieldset class="hour"><legend>' + b.toUpperCase() + "</legend>")), F = b, U = S % 12 ? S % 12 : 12, M.push('<span class="hour' + k + " hour_" + (12 > S ? "am" : "pm") + '">' + U + "</span>"), 23 == S && M.push("</fieldset>")) : (U = S + ":00", M.push('<span class="hour' + k + '">' + U + "</span>"))
- }
- this.picker.find(".datetimepicker-hours td").html(M.join("")), M = [], U = "", b = "", F = "";
- for (var S = 0; 60 > S; S += this.minuteStep) {
- var x = e(n, h, r, o, S, 0);
- k = "", x.valueOf() < this.startDate || x.valueOf() > this.endDate ? k += " disabled" : Math.floor(d / this.minuteStep) == Math.floor(S / this.minuteStep) && (k += " active"), this.showMeridian && 2 == s[this.language].meridiem.length ? (b = 12 > o ? s[this.language].meridiem[0] : s[this.language].meridiem[1], b != F && ("" != F && M.push("</fieldset>"), M.push('<fieldset class="minute"><legend>' + b.toUpperCase() + "</legend>")), F = b, U = o % 12 ? o % 12 : 12, M.push('<span class="minute' + k + '">' + U + ":" + (10 > S ? "0" + S : S) + "</span>"), 59 == S && M.push("</fieldset>")) : (U = S + ":00", M.push('<span class="minute' + k + '">' + o + ":" + (10 > S ? "0" + S : S) + "</span>"))
- }
- this.picker.find(".datetimepicker-minutes td").html(M.join(""));
- var H = this.date.getUTCFullYear(), V = this.picker.find(".datetimepicker-months").find("th:eq(1)").text(n).end().find("span").removeClass("active");
- H == n && V.eq(this.date.getUTCMonth()).addClass("active"), (l > n || n > u) && V.addClass("disabled"), n == l && V.slice(0, c).addClass("disabled"), n == u && V.slice(m + 1).addClass("disabled"), M = "", n = 10 * parseInt(n / 10, 10);
- var Y = this.picker.find(".datetimepicker-years").find("th:eq(1)").text(n + "-" + (n + 9)).end().find("td");
- n -= 1;
- for (var S = -1; 11 > S; S++)M += '<span class="year' + (-1 == S || 10 == S ? " old" : "") + (H == n ? " active" : "") + (l > n || n > u ? " disabled" : "") + '">' + n + "</span>", n += 1;
- Y.html(M), this.place()
- }
- }, updateNavArrows: function () {
- var t = new Date(this.viewDate), e = t.getUTCFullYear(), i = t.getUTCMonth(), s = t.getUTCDate(), a = t.getUTCHours();
- switch (this.viewMode) {
- case 0:
- this.startDate !== -1 / 0 && e <= this.startDate.getUTCFullYear() && i <= this.startDate.getUTCMonth() && s <= this.startDate.getUTCDate() && a <= this.startDate.getUTCHours() ? this.picker.find(".prev").css({visibility: "hidden"}) : this.picker.find(".prev").css({visibility: "visible"}), 1 / 0 !== this.endDate && e >= this.endDate.getUTCFullYear() && i >= this.endDate.getUTCMonth() && s >= this.endDate.getUTCDate() && a >= this.endDate.getUTCHours() ? this.picker.find(".next").css({visibility: "hidden"}) : this.picker.find(".next").css({visibility: "visible"});
- break;
- case 1:
- this.startDate !== -1 / 0 && e <= this.startDate.getUTCFullYear() && i <= this.startDate.getUTCMonth() && s <= this.startDate.getUTCDate() ? this.picker.find(".prev").css({visibility: "hidden"}) : this.picker.find(".prev").css({visibility: "visible"}), 1 / 0 !== this.endDate && e >= this.endDate.getUTCFullYear() && i >= this.endDate.getUTCMonth() && s >= this.endDate.getUTCDate() ? this.picker.find(".next").css({visibility: "hidden"}) : this.picker.find(".next").css({visibility: "visible"});
- break;
- case 2:
- this.startDate !== -1 / 0 && e <= this.startDate.getUTCFullYear() && i <= this.startDate.getUTCMonth() ? this.picker.find(".prev").css({visibility: "hidden"}) : this.picker.find(".prev").css({visibility: "visible"}), 1 / 0 !== this.endDate && e >= this.endDate.getUTCFullYear() && i >= this.endDate.getUTCMonth() ? this.picker.find(".next").css({visibility: "hidden"}) : this.picker.find(".next").css({visibility: "visible"});
- break;
- case 3:
- case 4:
- this.startDate !== -1 / 0 && e <= this.startDate.getUTCFullYear() ? this.picker.find(".prev").css({visibility: "hidden"}) : this.picker.find(".prev").css({visibility: "visible"}), 1 / 0 !== this.endDate && e >= this.endDate.getUTCFullYear() ? this.picker.find(".next").css({visibility: "hidden"}) : this.picker.find(".next").css({visibility: "visible"})
- }
- }, click: function (i) {
- i.stopPropagation(), i.preventDefault();
- var s = t(i.target).closest("span, td, th, legend");
- if (1 == s.length) {
- if (s.is(".disabled"))return this.element.trigger({type: "outOfRange", date: this.viewDate, startDate: this.startDate, endDate: this.endDate}), void 0;
- switch (s[0].nodeName.toLowerCase()) {
- case"th":
- switch (s[0].className) {
- case"switch":
- this.showMode(1);
- break;
- case"prev":
- case"next":
- var n = a.modes[this.viewMode].navStep * ("prev" == s[0].className ? -1 : 1);
- switch (this.viewMode) {
- case 0:
- this.viewDate = this.moveHour(this.viewDate, n);
- break;
- case 1:
- this.viewDate = this.moveDate(this.viewDate, n);
- break;
- case 2:
- this.viewDate = this.moveMonth(this.viewDate, n);
- break;
- case 3:
- case 4:
- this.viewDate = this.moveYear(this.viewDate, n)
- }
- this.fill();
- break;
- case"today":
- var h = new Date;
- h = e(h.getFullYear(), h.getMonth(), h.getDate(), h.getHours(), h.getMinutes(), h.getSeconds(), 0), this.viewMode = this.startViewMode, this.showMode(0), this._setDate(h), this.fill(), this.autoclose && this.hide()
- }
- break;
- case"span":
- if (!s.is(".disabled")) {
- var r = this.viewDate.getUTCFullYear(), o = this.viewDate.getUTCMonth(), d = this.viewDate.getUTCDate(), l = this.viewDate.getUTCHours(), c = this.viewDate.getUTCMinutes(), u = this.viewDate.getUTCSeconds();
- if (s.is(".month") ? (this.viewDate.setUTCDate(1), o = s.parent().find("span").index(s), d = this.viewDate.getUTCDate(), this.viewDate.setUTCMonth(o), this.element.trigger({type: "changeMonth", date: this.viewDate}), this.viewSelect >= 3 && this._setDate(e(r, o, d, l, c, u, 0))) : s.is(".year") ? (this.viewDate.setUTCDate(1), r = parseInt(s.text(), 10) || 0, this.viewDate.setUTCFullYear(r), this.element.trigger({type: "changeYear", date: this.viewDate}), this.viewSelect >= 4 && this._setDate(e(r, o, d, l, c, u, 0))) : s.is(".hour") ? (l = parseInt(s.text(), 10) || 0, (s.hasClass("hour_am") || s.hasClass("hour_pm")) && (12 == l && s.hasClass("hour_am") ? l = 0 : 12 != l && s.hasClass("hour_pm") && (l += 12)), this.viewDate.setUTCHours(l), this.element.trigger({type: "changeHour", date: this.viewDate}), this.viewSelect >= 1 && this._setDate(e(r, o, d, l, c, u, 0))) : s.is(".minute") && (c = parseInt(s.text().substr(s.text().indexOf(":") + 1), 10) || 0, this.viewDate.setUTCMinutes(c), this.element.trigger({type: "changeMinute", date: this.viewDate}), this.viewSelect >= 0 && this._setDate(e(r, o, d, l, c, u, 0))), 0 != this.viewMode) {
- var m = this.viewMode;
- this.showMode(-1), this.fill(), m == this.viewMode && this.autoclose && this.hide()
- } else this.fill(), this.autoclose && this.hide()
- }
- break;
- case"td":
- if (s.is(".day") && !s.is(".disabled")) {
- var d = parseInt(s.text(), 10) || 1, r = this.viewDate.getUTCFullYear(), o = this.viewDate.getUTCMonth(), l = this.viewDate.getUTCHours(), c = this.viewDate.getUTCMinutes(), u = this.viewDate.getUTCSeconds();
- s.is(".old") ? 0 === o ? (o = 11, r -= 1) : o -= 1 : s.is(".new") && (11 == o ? (o = 0, r += 1) : o += 1), this.viewDate.setUTCFullYear(r), this.viewDate.setUTCMonth(o), this.viewDate.setUTCDate(d), this.element.trigger({type: "changeDay", date: this.viewDate}), this.viewSelect >= 2 && this._setDate(e(r, o, d, l, c, u, 0))
- }
- var m = this.viewMode;
- this.showMode(-1), this.fill(), m == this.viewMode && this.autoclose && this.hide()
- }
- }
- }, _setDate: function (t, e) {
- e && "date" != e || (this.date = t), e && "view" != e || (this.viewDate = t), this.fill(), this.setValue();
- var i;
- this.isInput ? i = this.element : this.component && (i = this.element.find("input")), i && (i.change(), this.autoclose && (!e || "date" == e)), this.element.trigger({type: "changeDate", date: this.date})
- }, moveMinute: function (t, e) {
- if (!e)return t;
- var i = new Date(t.valueOf());
- return i.setUTCMinutes(i.getUTCMinutes() + e * this.minuteStep), i
- }, moveHour: function (t, e) {
- if (!e)return t;
- var i = new Date(t.valueOf());
- return i.setUTCHours(i.getUTCHours() + e), i
- }, moveDate: function (t, e) {
- if (!e)return t;
- var i = new Date(t.valueOf());
- return i.setUTCDate(i.getUTCDate() + e), i
- }, moveMonth: function (t, e) {
- if (!e)return t;
- var i, s, a = new Date(t.valueOf()), n = a.getUTCDate(), h = a.getUTCMonth(), r = Math.abs(e);
- if (e = e > 0 ? 1 : -1, 1 == r)s = -1 == e ? function () {
- return a.getUTCMonth() == h
- } : function () {
- return a.getUTCMonth() != i
- }, i = h + e, a.setUTCMonth(i), (0 > i || i > 11) && (i = (i + 12) % 12); else {
- for (var o = 0; r > o; o++)a = this.moveMonth(a, e);
- i = a.getUTCMonth(), a.setUTCDate(n), s = function () {
- return i != a.getUTCMonth()
- }
- }
- for (; s();)a.setUTCDate(--n), a.setUTCMonth(i);
- return a
- }, moveYear: function (t, e) {
- return this.moveMonth(t, 12 * e)
- }, dateWithinRange: function (t) {
- return t >= this.startDate && t <= this.endDate
- }, keydown: function (t) {
- if (this.picker.is(":not(:visible)"))return 27 == t.keyCode && this.show(), void 0;
- var e, i, s, a = !1;
- switch (t.keyCode) {
- case 27:
- this.hide(), t.preventDefault();
- break;
- case 37:
- case 39:
- if (!this.keyboardNavigation)break;
- e = 37 == t.keyCode ? -1 : 1, viewMode = this.viewMode, t.ctrlKey ? viewMode += 2 : t.shiftKey && (viewMode += 1), 4 == viewMode ? (i = this.moveYear(this.date, e), s = this.moveYear(this.viewDate, e)) : 3 == viewMode ? (i = this.moveMonth(this.date, e), s = this.moveMonth(this.viewDate, e)) : 2 == viewMode ? (i = this.moveDate(this.date, e), s = this.moveDate(this.viewDate, e)) : 1 == viewMode ? (i = this.moveHour(this.date, e), s = this.moveHour(this.viewDate, e)) : 0 == viewMode && (i = this.moveMinute(this.date, e), s = this.moveMinute(this.viewDate, e)), this.dateWithinRange(i) && (this.date = i, this.viewDate = s, this.setValue(), this.update(), t.preventDefault(), a = !0);
- break;
- case 38:
- case 40:
- if (!this.keyboardNavigation)break;
- e = 38 == t.keyCode ? -1 : 1, viewMode = this.viewMode, t.ctrlKey ? viewMode += 2 : t.shiftKey && (viewMode += 1), 4 == viewMode ? (i = this.moveYear(this.date, e), s = this.moveYear(this.viewDate, e)) : 3 == viewMode ? (i = this.moveMonth(this.date, e), s = this.moveMonth(this.viewDate, e)) : 2 == viewMode ? (i = this.moveDate(this.date, 7 * e), s = this.moveDate(this.viewDate, 7 * e)) : 1 == viewMode ? this.showMeridian ? (i = this.moveHour(this.date, 6 * e), s = this.moveHour(this.viewDate, 6 * e)) : (i = this.moveHour(this.date, 4 * e), s = this.moveHour(this.viewDate, 4 * e)) : 0 == viewMode && (i = this.moveMinute(this.date, 4 * e), s = this.moveMinute(this.viewDate, 4 * e)), this.dateWithinRange(i) && (this.date = i, this.viewDate = s, this.setValue(), this.update(), t.preventDefault(), a = !0);
- break;
- case 13:
- if (0 != this.viewMode) {
- var n = this.viewMode;
- this.showMode(-1), this.fill(), n == this.viewMode && this.autoclose && this.hide()
- } else this.fill(), this.autoclose && this.hide();
- t.preventDefault();
- break;
- case 9:
- this.hide()
- }
- if (a) {
- var h;
- this.isInput ? h = this.element : this.component && (h = this.element.find("input")), h && h.change(), this.element.trigger({type: "changeDate", date: this.date})
- }
- }, showMode: function (t) {
- if (t) {
- var e = Math.max(0, Math.min(a.modes.length - 1, this.viewMode + t));
- e >= this.minView && e <= this.maxView && (this.element.trigger({type: "changeMode", date: this.viewDate, oldViewMode: this.viewMode, newViewMode: e}), this.viewMode = e)
- }
- this.picker.find(">div").hide().filter(".datetimepicker-" + a.modes[this.viewMode].clsName).css("display", "block"), this.updateNavArrows()
- }, reset: function () {
- this._setDate(null, "date")
- }}, t.fn.datetimepicker = function (e) {
- var s = Array.apply(null, arguments);
- return s.shift(), this.each(function () {
- var a = t(this), n = a.data("datetimepicker"), h = "object" == typeof e && e;
- n || a.data("datetimepicker", n = new i(this, t.extend({}, t.fn.datetimepicker.defaults, h))), "string" == typeof e && "function" == typeof n[e] && n[e].apply(n, s)
- })
- }, t.fn.datetimepicker.defaults = {}, t.fn.datetimepicker.Constructor = i;
- var s = t.fn.datetimepicker.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"], meridiem: ["am", "pm"], suffix: ["st", "nd", "rd", "th"], today: "Today"}}, a = {modes: [
- {clsName: "minutes", navFnc: "Hours", navStep: 1},
- {clsName: "hours", navFnc: "Date", navStep: 1},
- {clsName: "days", navFnc: "Month", navStep: 1},
- {clsName: "months", navFnc: "FullYear", navStep: 1},
- {clsName: "years", navFnc: "FullYear", navStep: 10}
- ], isLeapYear: function (t) {
- return t % 4 === 0 && t % 100 !== 0 || t % 400 === 0
- }, getDaysInMonth: function (t, e) {
- return[31, a.isLeapYear(t) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][e]
- }, getDefaultFormat: function (t, e) {
- if ("standard" == t)return"input" == e ? "yyyy-mm-dd hh:ii" : "yyyy-mm-dd hh:ii:ss";
- if ("php" == t)return"input" == e ? "Y-m-d H:i" : "Y-m-d H:i:s";
- throw new Error("Invalid format type.")
- }, validParts: function (t) {
- if ("standard" == t)return/hh?|HH?|p|P|ii?|ss?|dd?|DD?|mm?|MM?|yy(?:yy)?/g;
- if ("php" == t)return/[dDjlNwzFmMnStyYaABgGhHis]/g;
- throw new Error("Invalid format type.")
- }, nonpunctuation: /[^ -\/:-@\[-`{-~\t\n\rTZ]+/g, parseFormat: function (t, e) {
- var i = t.replace(this.validParts(e), "\x00").split("\x00"), s = t.match(this.validParts(e));
- if (!i || !i.length || !s || 0 == s.length)throw new Error("Invalid date format.");
- return{separators: i, parts: s}
- }, parseDate: function (a, n, h, r) {
- if (a instanceof Date) {
- var o = new Date(a.valueOf() - 6e4 * a.getTimezoneOffset());
- return o.setMilliseconds(0), o
- }
- if (/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(a) && (n = this.parseFormat("yyyy-mm-dd", r)), /^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}$/.test(a) && (n = this.parseFormat("yyyy-mm-dd hh:ii", r)), /^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}\:\d{1,2}[Z]{0,1}$/.test(a) && (n = this.parseFormat("yyyy-mm-dd hh:ii:ss", r)), /^[-+]\d+[dmwy]([\s,]+[-+]\d+[dmwy])*$/.test(a)) {
- var d, l, c = /([-+]\d+)([dmwy])/, u = a.match(/([-+]\d+)([dmwy])/g);
- a = new Date;
- for (var m = 0; m < u.length; m++)switch (d = c.exec(u[m]), l = parseInt(d[1]), d[2]) {
- case"d":
- a.setUTCDate(a.getUTCDate() + l);
- break;
- case"m":
- a = i.prototype.moveMonth.call(i.prototype, a, l);
- break;
- case"w":
- a.setUTCDate(a.getUTCDate() + 7 * l);
- break;
- case"y":
- a = i.prototype.moveYear.call(i.prototype, a, l)
- }
- return e(a.getUTCFullYear(), a.getUTCMonth(), a.getUTCDate(), a.getUTCHours(), a.getUTCMinutes(), a.getUTCSeconds(), 0)
- }
- var p, v, d, u = a && a.match(this.nonpunctuation) || [], a = new Date(0, 0, 0, 0, 0, 0, 0), f = {}, g = ["hh", "h", "ii", "i", "ss", "s", "yyyy", "yy", "M", "MM", "m", "mm", "D", "DD", "d", "dd", "H", "HH", "p", "P"], D = {hh: function (t, e) {
- return t.setUTCHours(e)
- }, h: function (t, e) {
- return t.setUTCHours(e)
- }, HH: function (t, e) {
- return t.setUTCHours(12 == e ? 0 : e)
- }, H: function (t, e) {
- return t.setUTCHours(12 == e ? 0 : e)
- }, ii: function (t, e) {
- return t.setUTCMinutes(e)
- }, i: function (t, e) {
- return t.setUTCMinutes(e)
- }, ss: function (t, e) {
- return t.setUTCSeconds(e)
- }, s: function (t, e) {
- return t.setUTCSeconds(e)
- }, 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)
- }, p: function (t, e) {
- return t.setUTCHours(1 == e ? t.getUTCHours() + 12 : t.getUTCHours())
- }};
- if (D.M = D.MM = D.mm = D.m, D.dd = D.d, D.P = D.p, a = e(a.getFullYear(), a.getMonth(), a.getDate(), a.getHours(), a.getMinutes(), a.getSeconds()), u.length == n.parts.length) {
- for (var m = 0, w = n.parts.length; w > m; m++) {
- if (p = parseInt(u[m], 10), d = n.parts[m], isNaN(p))switch (d) {
- case"MM":
- v = t(s[h].months).filter(function () {
- var t = this.slice(0, u[m].length), e = u[m].slice(0, t.length);
- return t == e
- }), p = t.inArray(v[0], s[h].months) + 1;
- break;
- case"M":
- v = t(s[h].monthsShort).filter(function () {
- var t = this.slice(0, u[m].length), e = u[m].slice(0, t.length);
- return t == e
- }), p = t.inArray(v[0], s[h].monthsShort) + 1;
- break;
- case"p":
- case"P":
- p = t.inArray(u[m].toLowerCase(), s[h].meridiem)
- }
- f[d] = p
- }
- for (var y, m = 0; m < g.length; m++)y = g[m], y in f && !isNaN(f[y]) && D[y](a, f[y])
- }
- return a
- }, formatDate: function (e, i, n, h) {
- if (null == e)return"";
- var r;
- if ("standard" == h)r = {yy: e.getUTCFullYear().toString().substring(2), yyyy: e.getUTCFullYear(), m: e.getUTCMonth() + 1, M: s[n].monthsShort[e.getUTCMonth()], MM: s[n].months[e.getUTCMonth()], d: e.getUTCDate(), D: s[n].daysShort[e.getUTCDay()], DD: s[n].days[e.getUTCDay()], p: 2 == s[n].meridiem.length ? s[n].meridiem[e.getUTCHours() < 12 ? 0 : 1] : "", h: e.getUTCHours(), i: e.getUTCMinutes(), s: e.getUTCSeconds()}, r.H = r.h % 12 == 0 ? 12 : r.h % 12, r.HH = (r.H < 10 ? "0" : "") + r.H, r.P = r.p.toUpperCase(), r.hh = (r.h < 10 ? "0" : "") + r.h, r.ii = (r.i < 10 ? "0" : "") + r.i, r.ss = (r.s < 10 ? "0" : "") + r.s, r.dd = (r.d < 10 ? "0" : "") + r.d, r.mm = (r.m < 10 ? "0" : "") + r.m; else {
- if ("php" != h)throw new Error("Invalid format type.");
- r = {y: e.getUTCFullYear().toString().substring(2), Y: e.getUTCFullYear(), F: s[n].months[e.getUTCMonth()], M: s[n].monthsShort[e.getUTCMonth()], n: e.getUTCMonth() + 1, t: a.getDaysInMonth(e.getUTCFullYear(), e.getUTCMonth()), j: e.getUTCDate(), l: s[n].days[e.getUTCDay()], D: s[n].daysShort[e.getUTCDay()], w: e.getUTCDay(), N: 0 == e.getUTCDay() ? 7 : e.getUTCDay(), S: e.getUTCDate() % 10 <= s[n].suffix.length ? s[n].suffix[e.getUTCDate() % 10 - 1] : "", a: 2 == s[n].meridiem.length ? s[n].meridiem[e.getUTCHours() < 12 ? 0 : 1] : "", g: e.getUTCHours() % 12 == 0 ? 12 : e.getUTCHours() % 12, G: e.getUTCHours(), i: e.getUTCMinutes(), s: e.getUTCSeconds()}, r.m = (r.n < 10 ? "0" : "") + r.n, r.d = (r.j < 10 ? "0" : "") + r.j, r.A = r.a.toString().toUpperCase(), r.h = (r.g < 10 ? "0" : "") + r.g, r.H = (r.G < 10 ? "0" : "") + r.G, r.i = (r.i < 10 ? "0" : "") + r.i, r.s = (r.s < 10 ? "0" : "") + r.s
- }
- for (var e = [], o = t.extend([], i.separators), d = 0, l = i.parts.length; l > d; d++)o.length && e.push(o.shift()), e.push(r[i.parts[d]]);
- return e.join("")
- }, convertViewMode: function (t) {
- switch (t) {
- case 4:
- case"decade":
- t = 4;
- break;
- case 3:
- case"year":
- t = 3;
- break;
- case 2:
- case"month":
- t = 2;
- break;
- case 1:
- case"day":
- t = 1;
- break;
- case 0:
- case"hour":
- t = 0
- }
- return t
- }, headTemplate: '<thead><tr><th class="prev"><i class="icon-arrow-left"/></th><th colspan="5" class="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></tfoot>'};
- a.template = '<div class="datetimepicker"><div class="datetimepicker-minutes"><table class=" table-condensed">' + a.headTemplate + a.contTemplate + a.footTemplate + '</table></div><div class="datetimepicker-hours"><table class=" table-condensed">' + a.headTemplate + a.contTemplate + a.footTemplate + '</table></div><div class="datetimepicker-days"><table class=" table-condensed">' + a.headTemplate + "<tbody></tbody>" + a.footTemplate + '</table></div><div class="datetimepicker-months"><table class="table-condensed">' + a.headTemplate + a.contTemplate + a.footTemplate + '</table></div><div class="datetimepicker-years"><table class="table-condensed">' + a.headTemplate + a.contTemplate + a.footTemplate + "</table></div></div>", t.fn.datetimepicker.DPGlobal = a, t.fn.datetimepicker.noConflict = function () {
- return t.fn.datetimepicker = old, this
- }, t(document).on("focus.datetimepicker.data-api click.datetimepicker.data-api", '[data-provide="datetimepicker"]', function (e) {
- var i = t(this);
- i.data("datetimepicker") || (e.preventDefault(), i.datetimepicker("show"))
- }), t(function () {
- t('[data-provide="datetimepicker-inline"]').datetimepicker()
- })
- }(window.jQuery);
|