bootstrap-datetimepicker.min.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. !function (t) {
  2. function e() {
  3. return new Date(Date.UTC.apply(Date, arguments))
  4. }
  5. var i = function (e, i) {
  6. var n = this;
  7. 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) {
  8. 0 === t(e.target).closest(".datetimepicker").length && n.hide()
  9. }), 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()
  10. };
  11. i.prototype = {constructor: i, _events: [], _attachEvents: function () {
  12. this._detachEvents(), this.isInput ? this._events = [
  13. [this.element, {focus: t.proxy(this.show, this), keyup: t.proxy(this.update, this), keydown: t.proxy(this.keydown, this)}]
  14. ] : this.component && this.hasInput ? (this._events = [
  15. [this.element.find("input"), {focus: t.proxy(this.show, this), keyup: t.proxy(this.update, this), keydown: t.proxy(this.keydown, this)}],
  16. [this.component, {click: t.proxy(this.show, this)}]
  17. ], this.componentReset && this._events.push([this.componentReset, {click: t.proxy(this.reset, this)}])) : this.element.is("div") ? this.isInline = !0 : this._events = [
  18. [this.element, {click: t.proxy(this.show, this)}]
  19. ];
  20. for (var e, i, s = 0; s < this._events.length; s++)e = this._events[s][0], i = this._events[s][1], e.on(i)
  21. }, _detachEvents: function () {
  22. for (var t, e, i = 0; i < this._events.length; i++)t = this._events[i][0], e = this._events[i][1], t.off(e);
  23. this._events = []
  24. }, show: function (e) {
  25. 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})
  26. }, hide: function () {
  27. 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})))
  28. }, remove: function () {
  29. this._detachEvents(), this.picker.remove(), delete this.element.data().datetimepicker
  30. }, getDate: function () {
  31. var t = this.getUTCDate();
  32. return new Date(t.getTime() + 6e4 * t.getTimezoneOffset())
  33. }, getUTCDate: function () {
  34. return this.date
  35. }, setDate: function (t) {
  36. this.setUTCDate(new Date(t.getTime() - 6e4 * t.getTimezoneOffset()))
  37. }, setUTCDate: function (t) {
  38. 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})
  39. }, setFormat: function (t) {
  40. this.format = a.parseFormat(t, this.formatType);
  41. var e;
  42. this.isInput ? e = this.element : this.component && (e = this.element.find("input")), e && e.val() && this.setValue()
  43. }, setValue: function () {
  44. var e = this.getFormattedDate();
  45. 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))
  46. }, getFormattedDate: function (t) {
  47. return void 0 == t && (t = this.format), a.formatDate(this.date, t, this.language, this.formatType)
  48. }, setStartDate: function (t) {
  49. 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()
  50. }, setEndDate: function (t) {
  51. 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()
  52. }, setDaysOfWeekDisabled: function (e) {
  53. this.daysOfWeekDisabled = e || [], t.isArray(this.daysOfWeekDisabled) || (this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/)), this.daysOfWeekDisabled = t.map(this.daysOfWeekDisabled, function (t) {
  54. return parseInt(t, 10)
  55. }), this.update(), this.updateNavArrows()
  56. }, place: function () {
  57. if (!this.isInline) {
  58. var e, i, s, a = parseInt(this.element.parents().filter(function () {
  59. return"auto" != t(this).css("z-index")
  60. }).first().css("z-index")) + 10;
  61. 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})
  62. }
  63. }, update: function () {
  64. var t, e = !1;
  65. 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()
  66. }, fillDow: function () {
  67. for (var t = this.weekStart, e = "<tr>"; t < this.weekStart + 7;)e += '<th class="dow">' + s[this.language].daysMin[t++ % 7] + "</th>";
  68. e += "</tr>", this.picker.find(".datetimepicker-days thead").append(e)
  69. }, fillMonths: function () {
  70. for (var t = "", e = 0; 12 > e;)t += '<span class="month">' + s[this.language].monthsShort[e++] + "</span>";
  71. this.picker.find(".datetimepicker-months td").html(t)
  72. }, fill: function () {
  73. if (null != this.date && null != this.viewDate) {
  74. 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;
  75. if (this.picker.find(".datetimepicker-days thead th:eq(1)").text(s[this.language].months[h] + " " + n), "time" == this.formatViewType) {
  76. 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];
  77. 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())
  78. } 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);
  79. this.picker.find("tfoot th.today").text(s[this.language].today).toggle(this.todayBtn !== !1), this.updateNavArrows(), this.fillMonths();
  80. var y = e(n, h - 1, 28, 0, 0, 0, 0), T = a.getDaysInMonth(y.getUTCFullYear(), y.getUTCMonth());
  81. y.setUTCDate(T), y.setUTCDate(T - (y.getUTCDay() - this.weekStart + 7) % 7);
  82. var C = new Date(y);
  83. C.setUTCDate(C.getUTCDate() + 42), C = C.valueOf();
  84. 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);
  85. this.picker.find(".datetimepicker-days tbody").empty().append(M.join("")), M = [];
  86. for (var U = "", b = "", F = "", S = 0; 24 > S; S++) {
  87. var x = e(n, h, r, S);
  88. 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>"))
  89. }
  90. this.picker.find(".datetimepicker-hours td").html(M.join("")), M = [], U = "", b = "", F = "";
  91. for (var S = 0; 60 > S; S += this.minuteStep) {
  92. var x = e(n, h, r, o, S, 0);
  93. 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>"))
  94. }
  95. this.picker.find(".datetimepicker-minutes td").html(M.join(""));
  96. var H = this.date.getUTCFullYear(), V = this.picker.find(".datetimepicker-months").find("th:eq(1)").text(n).end().find("span").removeClass("active");
  97. 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);
  98. var Y = this.picker.find(".datetimepicker-years").find("th:eq(1)").text(n + "-" + (n + 9)).end().find("td");
  99. n -= 1;
  100. 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;
  101. Y.html(M), this.place()
  102. }
  103. }, updateNavArrows: function () {
  104. var t = new Date(this.viewDate), e = t.getUTCFullYear(), i = t.getUTCMonth(), s = t.getUTCDate(), a = t.getUTCHours();
  105. switch (this.viewMode) {
  106. case 0:
  107. 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"});
  108. break;
  109. case 1:
  110. 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"});
  111. break;
  112. case 2:
  113. 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"});
  114. break;
  115. case 3:
  116. case 4:
  117. 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"})
  118. }
  119. }, click: function (i) {
  120. i.stopPropagation(), i.preventDefault();
  121. var s = t(i.target).closest("span, td, th, legend");
  122. if (1 == s.length) {
  123. if (s.is(".disabled"))return this.element.trigger({type: "outOfRange", date: this.viewDate, startDate: this.startDate, endDate: this.endDate}), void 0;
  124. switch (s[0].nodeName.toLowerCase()) {
  125. case"th":
  126. switch (s[0].className) {
  127. case"switch":
  128. this.showMode(1);
  129. break;
  130. case"prev":
  131. case"next":
  132. var n = a.modes[this.viewMode].navStep * ("prev" == s[0].className ? -1 : 1);
  133. switch (this.viewMode) {
  134. case 0:
  135. this.viewDate = this.moveHour(this.viewDate, n);
  136. break;
  137. case 1:
  138. this.viewDate = this.moveDate(this.viewDate, n);
  139. break;
  140. case 2:
  141. this.viewDate = this.moveMonth(this.viewDate, n);
  142. break;
  143. case 3:
  144. case 4:
  145. this.viewDate = this.moveYear(this.viewDate, n)
  146. }
  147. this.fill();
  148. break;
  149. case"today":
  150. var h = new Date;
  151. 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()
  152. }
  153. break;
  154. case"span":
  155. if (!s.is(".disabled")) {
  156. 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();
  157. 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) {
  158. var m = this.viewMode;
  159. this.showMode(-1), this.fill(), m == this.viewMode && this.autoclose && this.hide()
  160. } else this.fill(), this.autoclose && this.hide()
  161. }
  162. break;
  163. case"td":
  164. if (s.is(".day") && !s.is(".disabled")) {
  165. 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();
  166. 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))
  167. }
  168. var m = this.viewMode;
  169. this.showMode(-1), this.fill(), m == this.viewMode && this.autoclose && this.hide()
  170. }
  171. }
  172. }, _setDate: function (t, e) {
  173. e && "date" != e || (this.date = t), e && "view" != e || (this.viewDate = t), this.fill(), this.setValue();
  174. var i;
  175. 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})
  176. }, moveMinute: function (t, e) {
  177. if (!e)return t;
  178. var i = new Date(t.valueOf());
  179. return i.setUTCMinutes(i.getUTCMinutes() + e * this.minuteStep), i
  180. }, moveHour: function (t, e) {
  181. if (!e)return t;
  182. var i = new Date(t.valueOf());
  183. return i.setUTCHours(i.getUTCHours() + e), i
  184. }, moveDate: function (t, e) {
  185. if (!e)return t;
  186. var i = new Date(t.valueOf());
  187. return i.setUTCDate(i.getUTCDate() + e), i
  188. }, moveMonth: function (t, e) {
  189. if (!e)return t;
  190. var i, s, a = new Date(t.valueOf()), n = a.getUTCDate(), h = a.getUTCMonth(), r = Math.abs(e);
  191. if (e = e > 0 ? 1 : -1, 1 == r)s = -1 == e ? function () {
  192. return a.getUTCMonth() == h
  193. } : function () {
  194. return a.getUTCMonth() != i
  195. }, i = h + e, a.setUTCMonth(i), (0 > i || i > 11) && (i = (i + 12) % 12); else {
  196. for (var o = 0; r > o; o++)a = this.moveMonth(a, e);
  197. i = a.getUTCMonth(), a.setUTCDate(n), s = function () {
  198. return i != a.getUTCMonth()
  199. }
  200. }
  201. for (; s();)a.setUTCDate(--n), a.setUTCMonth(i);
  202. return a
  203. }, moveYear: function (t, e) {
  204. return this.moveMonth(t, 12 * e)
  205. }, dateWithinRange: function (t) {
  206. return t >= this.startDate && t <= this.endDate
  207. }, keydown: function (t) {
  208. if (this.picker.is(":not(:visible)"))return 27 == t.keyCode && this.show(), void 0;
  209. var e, i, s, a = !1;
  210. switch (t.keyCode) {
  211. case 27:
  212. this.hide(), t.preventDefault();
  213. break;
  214. case 37:
  215. case 39:
  216. if (!this.keyboardNavigation)break;
  217. 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);
  218. break;
  219. case 38:
  220. case 40:
  221. if (!this.keyboardNavigation)break;
  222. 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);
  223. break;
  224. case 13:
  225. if (0 != this.viewMode) {
  226. var n = this.viewMode;
  227. this.showMode(-1), this.fill(), n == this.viewMode && this.autoclose && this.hide()
  228. } else this.fill(), this.autoclose && this.hide();
  229. t.preventDefault();
  230. break;
  231. case 9:
  232. this.hide()
  233. }
  234. if (a) {
  235. var h;
  236. this.isInput ? h = this.element : this.component && (h = this.element.find("input")), h && h.change(), this.element.trigger({type: "changeDate", date: this.date})
  237. }
  238. }, showMode: function (t) {
  239. if (t) {
  240. var e = Math.max(0, Math.min(a.modes.length - 1, this.viewMode + t));
  241. e >= this.minView && e <= this.maxView && (this.element.trigger({type: "changeMode", date: this.viewDate, oldViewMode: this.viewMode, newViewMode: e}), this.viewMode = e)
  242. }
  243. this.picker.find(">div").hide().filter(".datetimepicker-" + a.modes[this.viewMode].clsName).css("display", "block"), this.updateNavArrows()
  244. }, reset: function () {
  245. this._setDate(null, "date")
  246. }}, t.fn.datetimepicker = function (e) {
  247. var s = Array.apply(null, arguments);
  248. return s.shift(), this.each(function () {
  249. var a = t(this), n = a.data("datetimepicker"), h = "object" == typeof e && e;
  250. 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)
  251. })
  252. }, t.fn.datetimepicker.defaults = {}, t.fn.datetimepicker.Constructor = i;
  253. 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: [
  254. {clsName: "minutes", navFnc: "Hours", navStep: 1},
  255. {clsName: "hours", navFnc: "Date", navStep: 1},
  256. {clsName: "days", navFnc: "Month", navStep: 1},
  257. {clsName: "months", navFnc: "FullYear", navStep: 1},
  258. {clsName: "years", navFnc: "FullYear", navStep: 10}
  259. ], isLeapYear: function (t) {
  260. return t % 4 === 0 && t % 100 !== 0 || t % 400 === 0
  261. }, getDaysInMonth: function (t, e) {
  262. return[31, a.isLeapYear(t) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][e]
  263. }, getDefaultFormat: function (t, e) {
  264. if ("standard" == t)return"input" == e ? "yyyy-mm-dd hh:ii" : "yyyy-mm-dd hh:ii:ss";
  265. if ("php" == t)return"input" == e ? "Y-m-d H:i" : "Y-m-d H:i:s";
  266. throw new Error("Invalid format type.")
  267. }, validParts: function (t) {
  268. if ("standard" == t)return/hh?|HH?|p|P|ii?|ss?|dd?|DD?|mm?|MM?|yy(?:yy)?/g;
  269. if ("php" == t)return/[dDjlNwzFmMnStyYaABgGhHis]/g;
  270. throw new Error("Invalid format type.")
  271. }, nonpunctuation: /[^ -\/:-@\[-`{-~\t\n\rTZ]+/g, parseFormat: function (t, e) {
  272. var i = t.replace(this.validParts(e), "\x00").split("\x00"), s = t.match(this.validParts(e));
  273. if (!i || !i.length || !s || 0 == s.length)throw new Error("Invalid date format.");
  274. return{separators: i, parts: s}
  275. }, parseDate: function (a, n, h, r) {
  276. if (a instanceof Date) {
  277. var o = new Date(a.valueOf() - 6e4 * a.getTimezoneOffset());
  278. return o.setMilliseconds(0), o
  279. }
  280. 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)) {
  281. var d, l, c = /([-+]\d+)([dmwy])/, u = a.match(/([-+]\d+)([dmwy])/g);
  282. a = new Date;
  283. for (var m = 0; m < u.length; m++)switch (d = c.exec(u[m]), l = parseInt(d[1]), d[2]) {
  284. case"d":
  285. a.setUTCDate(a.getUTCDate() + l);
  286. break;
  287. case"m":
  288. a = i.prototype.moveMonth.call(i.prototype, a, l);
  289. break;
  290. case"w":
  291. a.setUTCDate(a.getUTCDate() + 7 * l);
  292. break;
  293. case"y":
  294. a = i.prototype.moveYear.call(i.prototype, a, l)
  295. }
  296. return e(a.getUTCFullYear(), a.getUTCMonth(), a.getUTCDate(), a.getUTCHours(), a.getUTCMinutes(), a.getUTCSeconds(), 0)
  297. }
  298. 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) {
  299. return t.setUTCHours(e)
  300. }, h: function (t, e) {
  301. return t.setUTCHours(e)
  302. }, HH: function (t, e) {
  303. return t.setUTCHours(12 == e ? 0 : e)
  304. }, H: function (t, e) {
  305. return t.setUTCHours(12 == e ? 0 : e)
  306. }, ii: function (t, e) {
  307. return t.setUTCMinutes(e)
  308. }, i: function (t, e) {
  309. return t.setUTCMinutes(e)
  310. }, ss: function (t, e) {
  311. return t.setUTCSeconds(e)
  312. }, s: function (t, e) {
  313. return t.setUTCSeconds(e)
  314. }, yyyy: function (t, e) {
  315. return t.setUTCFullYear(e)
  316. }, yy: function (t, e) {
  317. return t.setUTCFullYear(2e3 + e)
  318. }, m: function (t, e) {
  319. for (e -= 1; 0 > e;)e += 12;
  320. for (e %= 12, t.setUTCMonth(e); t.getUTCMonth() != e;)t.setUTCDate(t.getUTCDate() - 1);
  321. return t
  322. }, d: function (t, e) {
  323. return t.setUTCDate(e)
  324. }, p: function (t, e) {
  325. return t.setUTCHours(1 == e ? t.getUTCHours() + 12 : t.getUTCHours())
  326. }};
  327. 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) {
  328. for (var m = 0, w = n.parts.length; w > m; m++) {
  329. if (p = parseInt(u[m], 10), d = n.parts[m], isNaN(p))switch (d) {
  330. case"MM":
  331. v = t(s[h].months).filter(function () {
  332. var t = this.slice(0, u[m].length), e = u[m].slice(0, t.length);
  333. return t == e
  334. }), p = t.inArray(v[0], s[h].months) + 1;
  335. break;
  336. case"M":
  337. v = t(s[h].monthsShort).filter(function () {
  338. var t = this.slice(0, u[m].length), e = u[m].slice(0, t.length);
  339. return t == e
  340. }), p = t.inArray(v[0], s[h].monthsShort) + 1;
  341. break;
  342. case"p":
  343. case"P":
  344. p = t.inArray(u[m].toLowerCase(), s[h].meridiem)
  345. }
  346. f[d] = p
  347. }
  348. for (var y, m = 0; m < g.length; m++)y = g[m], y in f && !isNaN(f[y]) && D[y](a, f[y])
  349. }
  350. return a
  351. }, formatDate: function (e, i, n, h) {
  352. if (null == e)return"";
  353. var r;
  354. 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 {
  355. if ("php" != h)throw new Error("Invalid format type.");
  356. 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
  357. }
  358. 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]]);
  359. return e.join("")
  360. }, convertViewMode: function (t) {
  361. switch (t) {
  362. case 4:
  363. case"decade":
  364. t = 4;
  365. break;
  366. case 3:
  367. case"year":
  368. t = 3;
  369. break;
  370. case 2:
  371. case"month":
  372. t = 2;
  373. break;
  374. case 1:
  375. case"day":
  376. t = 1;
  377. break;
  378. case 0:
  379. case"hour":
  380. t = 0
  381. }
  382. return t
  383. }, 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>'};
  384. 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 () {
  385. return t.fn.datetimepicker = old, this
  386. }, t(document).on("focus.datetimepicker.data-api click.datetimepicker.data-api", '[data-provide="datetimepicker"]', function (e) {
  387. var i = t(this);
  388. i.data("datetimepicker") || (e.preventDefault(), i.datetimepicker("show"))
  389. }), t(function () {
  390. t('[data-provide="datetimepicker-inline"]').datetimepicker()
  391. })
  392. }(window.jQuery);