View file Structura/Template/HTWF/scripts/php/datepicker.min.js

File size: 17.75Kb
/*!
 * Datepicker v0.2.1
 * https://github.com/fengyuanchen/datepicker
 *
 * Copyright (c) 2014-2015 Fengyuan Chen
 * Released under the MIT license
 *
 * Date: 2015-10-26T02:21:30.292Z
 */
!function (t) { "function" == typeof define && define.amd ? define("datepicker", ["jquery"], t) : t("object" == typeof exports ? require("jquery") : jQuery) }(function (t) { "use strict"; function e(t) { return "string" == typeof t } function i(t) { return "number" == typeof t && !isNaN(t) } function s(t) { return "undefined" == typeof t } function a(t) { return "object" != typeof t || null === t ? !1 : "[object Date]" === A.call(t) } function n(t, e) { var s = []; return i(e) && s.push(e), s.slice.apply(t, s) } function r(t, e) { var i = n(arguments, 2); return function () { return t.apply(e, i.concat(n(arguments))) } } function h(t) { return t % 4 === 0 && t % 100 !== 0 || t % 400 === 0 } function o(t, e) { return [31, h(t) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][e] } function l(t) { var e, i, s = String(t).toLowerCase(), a = s.match(b); if (!a || 0 === a.length) throw new Error("Invalid date format."); for (t = { source: s, parts: a }, e = a.length, i = 0; e > i; i++) switch (a[i]) { case "dd": case "d": t.hasDay = !0; break; case "mm": case "m": t.hasMonth = !0; break; case "yyyy": case "yy": t.hasYear = !0 } return t } function d(e, i) { this.$element = t(e), this.options = t.extend({}, d.DEFAULTS, t.isPlainObject(i) && i), this.isBuilt = !1, this.isShown = !1, this.isInput = !1, this.isInline = !1, this.initialValue = "", this.initialDate = null, this.startDate = null, this.endDate = null, this.init() } var u = t(window), c = window.document, f = t(c), p = "datepicker", w = "click." + p, m = "keyup." + p, y = "focus." + p, g = "resize." + p, v = "show." + p, D = "hide." + p, k = "pick." + p, b = /y+|m+|d+/g, $ = /\d+/g, x = /^\d{2,4}$/, C = "datepicker-inline", F = "datepicker-dropdown", S = "datepicker-top-left", I = "datepicker-top-right", M = "datepicker-bottom-left", V = "datepicker-bottom-right", T = [S, I, M, V].join(" "), Y = "datepicker-hide", N = Number, P = Math.min, A = Object.prototype.toString; d.prototype = { constructor: d, version: "0.2.1", init: function () { var e = this.options, i = this.$element, s = e.startDate, a = e.endDate, n = e.date; e.language && t.extend(e, d.LANGUAGES[e.language]), this.$trigger = t(e.trigger || i), this.isInput = i.is("input") || i.is("textarea"), this.isInline = e.inline && (e.container || !this.isInput), this.format = l(e.format), this.initialValue = this.getValue(), n = this.parseDate(n || this.initialValue), s && (s = this.parseDate(s), n.getTime() < s.getTime() && (n = new Date(s)), this.startDate = s), a && (a = this.parseDate(a), s && a.getTime() < s.getTime() && (a = new Date(s)), n.getTime() > a.getTime() && (n = new Date(a)), this.endDate = a), this.date = n, this.viewDate = new Date(n), this.initialDate = new Date(this.date), this.bind(), (e.autoshow || this.isInline) && this.show(), e.autopick && this.pick() }, build: function () { var e, i = this.options, s = this.$element; this.isBuilt || (this.isBuilt = !0, this.$picker = e = t(i.template), this.$week = e.find('[data-view="week"]'), this.$yearsPicker = e.find('[data-view="years picker"]'), this.$yearsPrev = e.find('[data-view="years prev"]'), this.$yearsNext = e.find('[data-view="years next"]'), this.$yearsCurrent = e.find('[data-view="years current"]'), this.$years = e.find('[data-view="years"]'), this.$monthsPicker = e.find('[data-view="months picker"]'), this.$yearPrev = e.find('[data-view="year prev"]'), this.$yearNext = e.find('[data-view="year next"]'), this.$yearCurrent = e.find('[data-view="year current"]'), this.$months = e.find('[data-view="months"]'), this.$daysPicker = e.find('[data-view="days picker"]'), this.$monthPrev = e.find('[data-view="month prev"]'), this.$monthNext = e.find('[data-view="month next"]'), this.$monthCurrent = e.find('[data-view="month current"]'), this.$days = e.find('[data-view="days"]'), this.isInline ? t(i.container || s).append(e.addClass(C)) : (t(c.body).append(e.addClass(F)), e.addClass(Y)), this.fillWeek()) }, unbuild: function () { this.isBuilt && (this.isBuilt = !1, this.$picker.remove()) }, bind: function () { var e = this.options, i = this.$element; t.isFunction(e.show) && i.on(v, e.show), t.isFunction(e.hide) && i.on(D, e.hide), t.isFunction(e.pick) && i.on(k, e.pick), this.isInput && (i.on(m, t.proxy(this.keyup, this)), e.trigger || i.on(y, t.proxy(this.show, this))), this.$trigger.on(w, t.proxy(this.show, this)) }, unbind: function () { var e = this.options, i = this.$element; t.isFunction(e.show) && i.off(v, e.show), t.isFunction(e.hide) && i.off(D, e.hide), t.isFunction(e.pick) && i.off(k, e.pick), this.isInput && (i.off(m, this.keyup), e.trigger || i.off(y, this.show)), this.$trigger.off(w, this.show) }, showView: function (t) { var e = this.$yearsPicker, i = this.$monthsPicker, s = this.$daysPicker, a = this.format; if (a.hasYear || a.hasMonth || a.hasDay) switch (N(t)) { case 2: case "years": i.addClass(Y), s.addClass(Y), a.hasYear ? (this.fillYears(), e.removeClass(Y)) : this.showView(0); break; case 1: case "months": e.addClass(Y), s.addClass(Y), a.hasMonth ? (this.fillMonths(), i.removeClass(Y)) : this.showView(2); break; default: e.addClass(Y), i.addClass(Y), a.hasDay ? (this.fillDays(), s.removeClass(Y)) : this.showView(1) } }, hideView: function () { this.options.autohide && this.hide() }, place: function () { var t = this.options, e = this.$element, i = this.$picker, s = f.outerWidth(), a = f.outerHeight(), n = e.outerWidth(), r = e.outerHeight(), h = i.width(), o = i.height(), l = e.offset(), d = l.left, u = l.top, c = parseFloat(t.offset) || 10, p = S; u > o && u + r + o > a ? (u -= o + c, p = M) : u += r + c, d + h > s && (d = d + n - h, p = p.replace("left", "right")), i.removeClass(T).addClass(p).css({ top: u, left: d, zIndex: parseInt(t.zIndex, 10) }) }, trigger: function (e, i) { var s = t.Event(e, i); return this.$element.trigger(s), s }, createItem: function (e) { var i = this.options, s = i.itemTag, a = { text: "", view: "", muted: !1, picked: !1, disabled: !1 }; return t.extend(a, e), "<" + s + " " + (a.disabled ? 'class="' + i.disabledClass + '"' : a.picked ? 'class="' + i.pickedClass + '"' : a.muted ? 'class="' + i.mutedClass + '"' : "") + (a.view ? ' data-view="' + a.view + '"' : "") + ">" + a.text + "</" + s + ">" }, fillAll: function () { this.fillYears(), this.fillMonths(), this.fillDays() }, fillWeek: function () { var e, i = this.options, s = parseInt(i.weekStart, 10) % 7, a = i.daysMin, n = ""; for (a = t.merge(a.slice(s), a.slice(0, s)), e = 0; 6 >= e; e++) n += this.createItem({ text: a[e] }); this.$week.html(n) }, fillYears: function () { var e, i = this.options, s = i.disabledClass || "", a = i.yearSuffix || "", n = t.isFunction(i.filter) && i.filter, r = this.startDate, h = this.endDate, o = this.viewDate, l = o.getFullYear(), d = o.getMonth(), u = o.getDate(), c = this.date, f = c.getFullYear(), p = !1, w = !1, m = !1, y = !1, g = !1, v = "", D = -5, k = 6; for (e = D; k >= e; e++) c = new Date(l + e, d, u), g = e === D || e === k, y = l + e === f, m = !1, r && (m = c.getFullYear() < r.getFullYear(), e === D && (p = m)), !m && h && (m = c.getFullYear() > h.getFullYear(), e === k && (w = m)), !m && n && (m = n.call(this.$element, c) === !1), v += this.createItem({ text: l + e, view: m ? "year disabled" : y ? "year picked" : "year", muted: g, picked: y, disabled: m }); this.$yearsPrev.toggleClass(s, p), this.$yearsNext.toggleClass(s, w), this.$yearsCurrent.toggleClass(s, !0).html(l + D + a + " - " + (l + k) + a), this.$years.html(v) }, fillMonths: function () { var e, i = this.options, s = i.disabledClass || "", a = i.monthsShort, n = t.isFunction(i.filter) && i.filter, r = this.startDate, h = this.endDate, o = this.viewDate, l = o.getFullYear(), d = o.getDate(), u = this.date, c = u.getFullYear(), f = u.getMonth(), p = !1, w = !1, m = !1, y = !1, g = ""; for (e = 0; 11 >= e; e++) u = new Date(l, e, d), y = l === c && e === f, m = !1, r && (p = u.getFullYear() === r.getFullYear(), m = p && u.getMonth() < r.getMonth()), !m && h && (w = u.getFullYear() === h.getFullYear(), m = w && u.getMonth() > h.getMonth()), !m && n && (m = n.call(this.$element, u) === !1), g += this.createItem({ index: e, text: a[e], view: m ? "month disabled" : y ? "month picked" : "month", picked: y, disabled: m }); this.$yearPrev.toggleClass(s, p), this.$yearNext.toggleClass(s, w), this.$yearCurrent.toggleClass(s, p && w).html(l + i.yearSuffix || ""), this.$months.html(g) }, fillDays: function () { var e, i, s, a = this.options, n = a.disabledClass || "", r = a.yearSuffix || "", h = a.monthsShort, l = parseInt(a.weekStart, 10) % 7, d = t.isFunction(a.filter) && a.filter, u = this.startDate, c = this.endDate, f = this.viewDate, p = f.getFullYear(), w = f.getMonth(), m = p, y = w, g = p, v = w, D = this.date, k = D.getFullYear(), b = D.getMonth(), $ = D.getDate(), x = !1, C = !1, F = !1, S = !1, I = [], M = [], V = [], T = 42; for (0 === w ? (m -= 1, y = 11) : y -= 1, e = o(m, y), D = new Date(p, w, 1), s = D.getDay() - l, 0 >= s && (s += 7), u && (x = D.getTime() <= u.getTime()), i = e - (s - 1) ; e >= i; i++) D = new Date(m, y, i), F = !1, u && (F = D.getTime() < u.getTime()), !F && d && (F = d.call(this.$element, D) === !1), I.push(this.createItem({ text: i, view: "day prev", muted: !0, disabled: F })); for (11 === w ? (g += 1, g = 0) : v += 1, e = o(p, w), s = T - (I.length + e), D = new Date(p, w, e), c && (C = D.getTime() >= c.getTime()), i = 1; s >= i; i++) D = new Date(g, v, i), F = !1, c && (F = D.getTime() > c.getTime()), !F && d && (F = d.call(this.$element, D) === !1), M.push(this.createItem({ text: i, view: "day next", muted: !0, disabled: F })); for (i = 1; e >= i; i++) D = new Date(p, w, i), S = p === k && w === b && i === $, F = !1, u && (F = D.getTime() < u.getTime()), !F && c && (F = D.getTime() > c.getTime()), !F && d && (F = d.call(this.$element, D) === !1), V.push(this.createItem({ text: i, view: F ? "day disabled" : S ? "day picked" : "day", picked: S, disabled: F })); this.$monthPrev.toggleClass(n, x), this.$monthNext.toggleClass(n, C), this.$monthCurrent.toggleClass(n, x && C).html(a.yearFirst ? p + r + " " + h[w] : h[w] + " " + p + r), this.$days.html(I.join("") + V.join(" ") + M.join("")) }, click: function (e) { var i, s, a, n, r, h, o = t(e.target), l = this.viewDate; if (e.stopPropagation(), e.preventDefault(), !o.hasClass("disabled")) switch (i = l.getFullYear(), s = l.getMonth(), a = l.getDate(), h = o.data("view")) { case "years prev": case "years next": i = "years prev" === h ? i - 10 : i + 10, r = o.text(), n = x.test(r), n && (i = parseInt(r, 10), this.date = new Date(i, s, P(a, 28))), this.viewDate = new Date(i, s, P(a, 28)), this.fillYears(), n && (this.showView(1), this.pick("year")); break; case "year prev": case "year next": i = "year prev" === h ? i - 1 : i + 1, this.viewDate = new Date(i, s, P(a, 28)), this.fillMonths(); break; case "year current": this.format.hasYear && this.showView(2); break; case "year picked": this.format.hasMonth ? this.showView(1) : this.hideView(); break; case "year": i = parseInt(o.text(), 10), this.date = new Date(i, s, P(a, 28)), this.viewDate = new Date(i, s, P(a, 28)), this.format.hasMonth ? this.showView(1) : this.hideView(), this.pick("year"); break; case "month prev": case "month next": s = "month prev" === h ? s - 1 : "month next" === h ? s + 1 : s, this.viewDate = new Date(i, s, P(a, 28)), this.fillDays(); break; case "month current": this.format.hasMonth && this.showView(1); break; case "month picked": this.format.hasDay ? this.showView(0) : this.hideView(); break; case "month": s = t.inArray(o.text(), this.options.monthsShort), this.date = new Date(i, s, P(a, 28)), this.viewDate = new Date(i, s, P(a, 28)), this.format.hasDay ? this.showView(0) : this.hideView(), this.pick("month"); break; case "day prev": case "day next": case "day": s = "day prev" === h ? s - 1 : "day next" === h ? s + 1 : s, a = parseInt(o.text(), 10), this.date = new Date(i, s, a), this.viewDate = new Date(i, s, a), this.fillDays(), "day" === h && this.hideView(), this.pick("day"); break; case "day picked": this.hideView(), this.pick("day") } }, clickDoc: function (t) { for (var e, i = t.target, s = this.$trigger[0]; i !== c;) { if (i === s) { e = !0; break } i = i.parentNode } e || this.hide() }, keyup: function () { this.update() }, getValue: function () { var t = this.$element, e = ""; return this.isInput ? e = t.val() : this.isInline ? this.options.container && (e = t.text()) : e = t.text(), e }, setValue: function (t) { var i = this.$element; t = e(t) ? t : "", this.isInput ? i.val(t) : this.isInline ? this.options.container && i.text(t) : i.text(t) }, show: function () { this.isBuilt || this.build(), this.isShown || this.trigger(v).isDefaultPrevented() || (this.isShown = !0, this.$picker.removeClass(Y).on(w, t.proxy(this.click, this)), this.showView(this.options.startView), this.isInline || (u.on(g, this._place = r(this.place, this)), f.on(w, this._clickDoc = r(this.clickDoc, this)), this.place())) }, hide: function () { this.isShown && (this.trigger(D).isDefaultPrevented() || (this.isShown = !1, this.$picker.addClass(Y).off(w, this.click), this.isInline || (u.off(g, this._place), f.off(w, this._clickDoc)))) }, update: function () { this.setDate(this.getValue(), !0) }, pick: function (t) { var e = this.$element, i = this.date; this.trigger(k, { view: t || "", date: i }).isDefaultPrevented() || (this.setValue(i = this.formatDate(this.date)), this.isInput && e.trigger("change")) }, reset: function () { this.setDate(this.initialDate, !0), this.setValue(this.initialValue), this.isShown && this.showView(this.options.startView) }, getMonthName: function (e, a) { var n = this.options, r = n.months; return t.isNumeric(e) ? e = N(e) : s(a) && (a = e), a === !0 && (r = n.monthsShort), r[i(e) ? e : this.date.getMonth()] }, getDayName: function (e, a, n) { var r = this.options, h = r.days; return t.isNumeric(e) ? e = N(e) : (s(n) && (n = a), s(a) && (a = e)), h = n === !0 ? r.daysMin : a === !0 ? r.daysShort : h, h[i(e) ? e : this.date.getDay()] }, getDate: function (t) { var e = this.date; return t ? this.formatDate(e) : new Date(e) }, setDate: function (i, s) { var n = this.options.filter; if (a(i) || e(i)) { if (i = this.parseDate(i), t.isFunction(n) && n.call(this.$element, i) === !1) return; this.date = i, this.viewDate = new Date(i), s || this.pick(), this.isBuilt && this.fillAll() } }, setStartDate: function (t) { (a(t) || e(t)) && (this.startDate = this.parseDate(t), this.isBuilt && this.fillAll()) }, setEndDate: function (t) { (a(t) || e(t)) && (this.endDate = this.parseDate(t), this.isBuilt && this.fillAll()) }, parseDate: function (t) { var i, s, n, r, h, o, l = this.format, d = []; if (a(t)) return new Date(t); if (e(t) && (d = t.match($) || []), t = new Date, s = t.getFullYear(), n = t.getDate(), r = t.getMonth(), i = l.parts.length, d.length === i) for (o = 0; i > o; o++) switch (h = parseInt(d[o], 10) || 1, l.parts[o]) { case "dd": case "d": n = h; break; case "mm": case "m": r = h - 1; break; case "yy": s = 2e3 + h; break; case "yyyy": s = h } return new Date(s, r, n) }, formatDate: function (t) { var e, i, s, n, r, h = this.format, o = ""; if (a(t)) for (o = h.source, i = t.getFullYear(), n = { d: t.getDate(), m: t.getMonth() + 1, yy: i.toString().substring(2), yyyy: i }, n.dd = (n.d < 10 ? "0" : "") + n.d, n.mm = (n.m < 10 ? "0" : "") + n.m, e = h.parts.length, r = 0; e > r; r++) s = h.parts[r], o = o.replace(s, n[s]); return o }, destroy: function () { this.unbind(), this.unbuild(), this.$element.removeData(p) } }, d.LANGUAGES = {}, d.DEFAULTS = { autoshow: !1, autohide: !1, autopick: !1, inline: !1, container: null, trigger: null, language: "", format: "mm/dd/yyyy", date: null, startDate: null, endDate: null, startView: 0, weekStart: 0, yearFirst: !1, yearSuffix: "", days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 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"], itemTag: "li", mutedClass: "muted", pickedClass: "picked", disabledClass: "disabled", 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>', offset: 10, zIndex: 1, filter: null, show: null, hide: null, pick: null }, d.setDefaults = function (e) { t.extend(d.DEFAULTS, t.isPlainObject(e) && e) }, d.other = t.fn.datepicker, t.fn.datepicker = function (i) { var a, r = n(arguments, 1); return this.each(function () { var s, n, h = t(this), o = h.data(p); if (!o) { if (/destroy/.test(i)) return; s = t.extend({}, h.data(), t.isPlainObject(i) && i), h.data(p, o = new d(this, s)) } e(i) && t.isFunction(n = o[i]) && (a = n.apply(o, r)) }), s(a) ? this : a }, t.fn.datepicker.Constructor = d, t.fn.datepicker.languages = d.LANGUAGES, t.fn.datepicker.setDefaults = d.setDefaults, t.fn.datepicker.noConflict = function () { return t.fn.datepicker = d.other, this } });

/*
* Schiocco - Copyright (c) Federico Schiocchet - Schiocco (www.Schiocco.it) - Framework Y (www.framework-y.com)
*/

(function ($) {
    jQuery('[data-toggle="datepicker"]').datepicker();
}(jQuery));