/*! laydate-v5.0.8 日期与时间组件 mit license http://www.layui.com/laydate/ by 贤心 */
;!function () {
"use strict";
var e = window.layui && layui.define, t = {
getpath: function () {
var e = document.scripts, t = e[e.length - 1], n = t.src;
if (!t.getattribute("merge"))return n.substring(0, n.lastindexof("/") + 1)
}(), getstyle: function (e, t) {
var n = e.currentstyle ? e.currentstyle : window.getcomputedstyle(e, null);
return n[n.getpropertyvalue ? "getpropertyvalue" : "getattribute"](t)
}, link: function (e, a, i) {
if (n.path) {
var r = document.getelementsbytagname("head")[0], o = document.createelement("link");
"string" == typeof a && (i = a);
var s = (i || e).replace(/\.|\//g, ""), l = "layuicss-" + s, d = 0;
o.rel = "stylesheet", o.href = n.path + e, o.id = l, document.getelementbyid(l) || r.appendchild(o), "function" == typeof a && !function c() {
return ++d > 80 ? window.console && console.error("laydate.css: invalid") : void(1989 === parseint(t.getstyle(document.getelementbyid(l), "width")) ? a() : settimeout(c, 100))
}()
}
}
}, n = {
v: "5.0.8",
config: {},
index: window.laydate && window.laydate.v ? 1e5 : 0,
path: t.getpath,
set: function (e) {
var n = this;
return n.config = t.extend({}, n.config, e), n
},
ready: function (a) {
var i = "laydate", r = "", o = (e ? "modules/laydate/" : "theme/") + "default/laydate.css?v=" + n.v + r;
return e ? layui.addcss(o, a, i) : t.link(o, a, i), this
}
}, a = function () {
var e = this;
return {
hint: function (t) {
e.hint.call(e, t)
}, config: e.config
}
}, i = "laydate", r = ".layui-laydate", o = "layui-this", s = "laydate-disabled", l = "开始日期超出了结束日期
建议重新选择", d = [100, 2e5], c = "layui-laydate-static", m = "layui-laydate-list", u = "laydate-selected", h = "layui-laydate-hint", y = "laydate-day-prev", f = "laydate-day-next", p = "layui-laydate-footer", g = ".laydate-btns-confirm", v = "laydate-time-text", d = ".laydate-btns-time", t = function (e) {
var t = this;
t.index = ++n.index, t.config = w.extend({}, t.config, n.config, e), n.ready(function () {
t.init()
})
}, w = function (e) {
return new c(e)
}, c = function (e) {
for (var t = 0, n = "object" == typeof e ? [e] : (this.selector = e, document.queryselectorall(e || null)); t < n.length; t++)this.push(n[t])
};
c.prototype = [], c.prototype.constructor = c, w.extend = function () {
var e = 1, t = arguments, n = function (e, t) {
e = e || (t.constructor === array ? [] : {});
for (var a in t)e[a] = t[a] && t[a].constructor === object ? n(e[a], t[a]) : t[a];
return e
};
for (t[0] = "object" == typeof t[0] ? t[0] : {}; e < t.length; e++)"object" == typeof t[e] && n(t[0], t[e]);
return t[0]
}, w.ie = function () {
var e = navigator.useragent.tolowercase();
return !!(window.activexobject || "activexobject" in window) && ((e.match(/msie\s(\d+)/) || [])[1] || "11")
}(), w.stope = function (e) {
e = e || window.event, e.stoppropagation ? e.stoppropagation() : e.cancelbubble = !0
}, w.each = function (e, t) {
var n, a = this;
if ("function" != typeof t)return a;
if (e = e || [], e.constructor === object) {
for (n in e)if (t.call(e[n], n, e[n]))break
} else for (n = 0; n < e.length && !t.call(e[n], n, e[n]); n++);
return a
}, w.digit = function (e, t, n) {
var a = "";
e = string(e), t = t || 2;
for (var i = e.length; i < t; i++)a += "0";
return e < math.pow(10, t) ? a + (0 | e) : e
}, w.elem = function (e, t) {
var n = document.createelement(e);
return w.each(t || {}, function (e, t) {
n.setattribute(e, t)
}), n
}, c.addstr = function (e, t) {
return e = e.replace(/\s+/, " "), t = t.replace(/\s+/, " ").split(" "), w.each(t, function (t, n) {
new regexp("\\b" + n + "\\b").test(e) || (e = e + " " + n)
}), e.replace(/^\s|\s$/, "")
}, c.removestr = function (e, t) {
return e = e.replace(/\s+/, " "), t = t.replace(/\s+/, " ").split(" "), w.each(t, function (t, n) {
var a = new regexp("\\b" + n + "\\b");
a.test(e) && (e = e.replace(a, ""))
}), e.replace(/\s+/, " ").replace(/^\s|\s$/, "")
}, c.prototype.find = function (e) {
var t = this, n = 0, a = [], i = "object" == typeof e;
return this.each(function (r, o) {
for (var s = i ? [e] : o.queryselectorall(e || null); n < s.length; n++)a.push(s[n]);
t.shift()
}), i || (t.selector = (t.selector ? t.selector + " " : "") + e), w.each(a, function (e, n) {
t.push(n)
}), t
}, c.prototype.each = function (e) {
return w.each.call(this, this, e)
}, c.prototype.addclass = function (e, t) {
return this.each(function (n, a) {
a.classname = c[t ? "removestr" : "addstr"](a.classname, e)
})
}, c.prototype.removeclass = function (e) {
return this.addclass(e, !0)
}, c.prototype.hasclass = function (e) {
var t = !1;
return this.each(function (n, a) {
new regexp("\\b" + e + "\\b").test(a.classname) && (t = !0)
}), t
}, c.prototype.attr = function (e, t) {
var n = this;
return void 0 === t ? function () {
if (n.length > 0)return n[0].getattribute(e)
}() : n.each(function (n, a) {
a.setattribute(e, t)
})
}, c.prototype.removeattr = function (e) {
return this.each(function (t, n) {
n.removeattribute(e)
})
}, c.prototype.html = function (e) {
return this.each(function (t, n) {
n.innerhtml = e
})
}, c.prototype.val = function (e) {
return this.each(function (t, n) {
n.value = e
})
}, c.prototype.append = function (e) {
return this.each(function (t, n) {
"object" == typeof e ? n.appendchild(e) : n.innerhtml = n.innerhtml + e
})
}, c.prototype.remove = function (e) {
return this.each(function (t, n) {
e ? n.removechild(e) : n.parentnode.removechild(n)
})
}, c.prototype.on = function (e, t) {
return this.each(function (n, a) {
a.attachevent ? a.attachevent("on" + e, function (e) {
e.target = e.srcelement, t.call(a, e)
}) : a.addeventlistener(e, t, !1)
})
}, c.prototype.off = function (e, t) {
return this.each(function (n, a) {
a.detachevent ? a.detachevent("on" + e, t) : a.removeeventlistener(e, t, !1)
})
}, t.isleapyear = function (e) {
return e % 4 === 0 && e % 100 !== 0 || e % 400 === 0
}, t.prototype.config = {
type: "date",
range: !1,
format: "yyyy-mm-dd",
value: null,
min: "1900-1-1",
max: "2099-12-31",
trigger: "focus",
show: !1,
showbottom: !0,
btns: ["clear", "now", "confirm"],
lang: "cn",
theme: "default",
position: null,
calendar: !1,
mark: {},
zindex: null,
done: null,
change: null
}, t.prototype.lang = function () {
var e = this, t = e.config, n = {
cn: {
weeks: ["日", "一", "二", "三", "四", "五", "六"],
time: ["时", "分", "秒"],
timetips: "选择时间",
starttime: "开始时间",
endtime: "结束时间",
datetips: "返回日期",
month: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"],
tools: {confirm: "确定", clear: "清空", now: "现在"}
},
en: {
weeks: ["su", "mo", "tu", "we", "th", "fr", "sa"],
time: ["hours", "minutes", "seconds"],
timetips: "select time",
starttime: "start time",
endtime: "end time",
datetips: "select date",
month: ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"],
tools: {confirm: "confirm", clear: "clear", now: "now"}
}
};
return n[t.lang] || n.cn
}, t.prototype.init = function () {
var e = this, t = e.config, n = "yyyy|y|mm|m|dd|d|hh|h|mm|m|ss|s", a = "static" === t.position, i = {
year: "yyyy",
month: "yyyy-mm",
date: "yyyy-mm-dd",
time: "hh:mm:ss",
datetime: "yyyy-mm-dd hh:mm:ss"
};
t.elem = w(t.elem), t.eventelem = w(t.eventelem), t.elem[0] && (t.range === !0 && (t.range = "-"), t.format === i.date && (t.format = i[t.type]), e.format = t.format.match(new regexp(n + "|.", "g")) || [], e.exp_if = "", e.exp_split = "", w.each(e.format, function (t, a) {
var i = new regexp(n).test(a) ? "\\d{" + function () {
return new regexp(n).test(e.format[0 === t ? t + 1 : t - 1] || "") ? /^yyyy|y$/.test(a) ? 4 : a.length : /^yyyy$/.test(a) ? "1,4" : /^y$/.test(a) ? "1,308" : "1,2"
}() + "}" : "\\" + a;
e.exp_if = e.exp_if + i, e.exp_split = e.exp_split + "(" + i + ")"
}), e.exp_if = new regexp("^" + (t.range ? e.exp_if + "\\s\\" + t.range + "\\s" + e.exp_if : e.exp_if) + "$"), e.exp_split = new regexp("^" + e.exp_split + "$", ""), e.isinput(t.elem[0]) || "focus" === t.trigger && (t.trigger = "click"), t.elem.attr("lay-key") || (t.elem.attr("lay-key", e.index), t.eventelem.attr("lay-key", e.index)), t.mark = w.extend({}, t.calendar && "cn" === t.lang ? {
"0-1-1": "元旦",
"0-2-14": "情人",
"0-3-8": "妇女",
"0-3-12": "植树",
"0-4-1": "愚人",
"0-5-1": "劳动",
"0-5-4": "青年",
"0-6-1": "儿童",
"0-9-10": "教师",
"0-9-18": "国耻",
"0-10-1": "国庆",
"0-12-25": "圣诞"
} : {}, t.mark), w.each(["min", "max"], function (e, n) {
var a = [], i = [];
if ("number" == typeof t[n]) {
var r = t[n], o = (new date).gettime(), s = 864e5, l = new date(r ? r < s ? o + r * s : r : o);
a = [l.getfullyear(), l.getmonth() + 1, l.getdate()], r < s || (i = [l.gethours(), l.getminutes(), l.getseconds()])
} else a = (t[n].match(/\d+-\d+-\d+/) || [""])[0].split("-"), i = (t[n].match(/\d+:\d+:\d+/) || [""])[0].split(":");
t[n] = {
year: 0 | a[0] || (new date).getfullyear(),
month: a[1] ? (0 | a[1]) - 1 : (new date).getmonth(),
date: 0 | a[2] || (new date).getdate(),
hours: 0 | i[0],
minutes: 0 | i[1],
seconds: 0 | i[2]
}
}), e.elemid = "layui-laydate" + t.elem.attr("lay-key"), (t.show || a) && e.render(), a || e.events(), t.value && (t.value.constructor === date ? e.setvalue(e.parse(0, e.systemdate(t.value))) : e.setvalue(t.value)))
}, t.prototype.render = function () {
var e = this, t = e.config, n = e.lang(), a = "static" === t.position, i = e.elem = w.elem("div", {
id: e.elemid,
"class": ["layui-laydate", t.range ? " layui-laydate-range" : "", a ? " " + c : "", t.theme && "default" !== t.theme && !/^#/.test(t.theme) ? " laydate-theme-" + t.theme : ""].join("")
}), r = e.elemmain = [], o = e.elemheader = [], s = e.elemcont = [], l = e.table = [], d = e.footer = w.elem("div", {"class": p});
if (t.zindex && (i.style.zindex = t.zindex), w.each(new array(2), function (e) {
if (!t.range && e > 0)return !0;
var a = w.elem("div", {"class": "layui-laydate-header"}), i = [function () {
var e = w.elem("i", {"class": "layui-icon laydate-icon laydate-prev-y"});
return e.innerhtml = "", e
}(), function () {
var e = w.elem("i", {"class": "layui-icon laydate-icon laydate-prev-m"});
return e.innerhtml = "", e
}(), function () {
var e = w.elem("div", {"class": "laydate-set-ym"}), t = w.elem("span"), n = w.elem("span");
return e.appendchild(t), e.appendchild(n), e
}(), function () {
var e = w.elem("i", {"class": "layui-icon laydate-icon laydate-next-m"});
return e.innerhtml = "", e
}(), function () {
var e = w.elem("i", {"class": "layui-icon laydate-icon laydate-next-y"});
return e.innerhtml = "", e
}()], d = w.elem("div", {"class": "layui-laydate-content"}), c = w.elem("table"), m = w.elem("thead"), u = w.elem("tr");
w.each(i, function (e, t) {
a.appendchild(t)
}), m.appendchild(u), w.each(new array(6), function (e) {
var t = c.insertrow(0);
w.each(new array(7), function (a) {
if (0 === e) {
var i = w.elem("th");
i.innerhtml = n.weeks[a], u.appendchild(i)
}
t.insertcell(a)
})
}), c.insertbefore(m, c.children[0]), d.appendchild(c), r[e] = w.elem("div", {"class": "layui-laydate-main laydate-main-list-" + e}), r[e].appendchild(a), r[e].appendchild(d), o.push(i), s.push(d), l.push(c)
}), w(d).html(function () {
var e = [], i = [];
return "datetime" === t.type && e.push('' + n.timetips + ""), w.each(t.btns, function (e, r) {
var o = n.tools[r] || "btn";
t.range && "now" === r || (a && "clear" === r && (o = "cn" === t.lang ? "重置" : "reset"), i.push('' + o + ""))
}), e.push('
"), e.join("")
}()), w.each(r, function (e, t) {
i.appendchild(t)
}), t.showbottom && i.appendchild(d), /^#/.test(t.theme)) {
var m = w.elem("style"), u = ["#{{id}} .layui-laydate-header{background-color:{{theme}};}", "#{{id}} .layui-this{background-color:{{theme}} !important;}"].join("").replace(/{{id}}/g, e.elemid).replace(/{{theme}}/g, t.theme);
"stylesheet" in m ? (m.setattribute("type", "text/css"), m.stylesheet.csstext = u) : m.innerhtml = u, w(i).addclass("laydate-theme-molv"), i.appendchild(m)
}
e.remove(t.thiselemdate), a ? t.elem.append(i) : (document.body.appendchild(i), e.position()), e.checkdate().calendar(), e.changeevent(), t.thiselemdate = e.elemid, "function" == typeof t.ready && t.ready(w.extend({}, t.datetime, {month: t.datetime.month + 1}))
}, t.prototype.remove = function (e) {
var t = this, n = (t.config, w("#" + (e || t.elemid)));
return n.hasclass(c) || t.checkdate(function () {
n.remove()
}), t
}, t.prototype.position = function () {
var e = this, t = e.config, n = e.bindelem || t.elem[0], a = n.getboundingclientrect(), i = e.elem.offsetwidth, r = e.elem.offsetheight, o = function (e) {
return e = e ? "scrollleft" : "scrolltop", document.body[e] | document.documentelement[e]
}, s = function (e) {
return document.documentelement[e ? "clientwidth" : "clientheight"]
}, l = 5, d = a.left, c = a.bottom;
d + i + l > s("width") && (d = s("width") - i - l), c + r + l > s() && (c = a.top > r ? a.top - r : s() - r, c -= 2 * l), t.position && (e.elem.style.position = t.position), e.elem.style.left = d + ("fixed" === t.position ? 0 : o(1)) + "px", e.elem.style.top = c + ("fixed" === t.position ? 0 : o()) + "px"
}, t.prototype.hint = function (e) {
var t = this, n = (t.config, w.elem("div", {"class": h}));
n.innerhtml = e || "", w(t.elem).find("." + h).remove(), t.elem.appendchild(n), cleartimeout(t.hintimer), t.hintimer = settimeout(function () {
w(t.elem).find("." + h).remove()
}, 3e3)
}, t.prototype.getasym = function (e, t, n) {
return n ? t-- : t++, t < 0 && (t = 11, e--), t > 11 && (t = 0, e++), [e, t]
}, t.prototype.systemdate = function (e) {
var t = e || new date;
return {
year: t.getfullyear(),
month: t.getmonth(),
date: t.getdate(),
hours: e ? e.gethours() : 0,
minutes: e ? e.getminutes() : 0,
seconds: e ? e.getseconds() : 0
}
}, t.prototype.checkdate = function (e) {
var t, a, i = this, r = (new date, i.config), o = r.datetime = r.datetime || i.systemdate(), s = i.bindelem || r.elem[0], l = (i.isinput(s) ? "val" : "html", i.isinput(s) ? s.value : "static" === r.position ? "" : s.innerhtml), c = function (e) {
e.year > d[1] && (e.year = d[1], a = !0), e.month > 11 && (e.month = 11, a = !0), e.hours > 23 && (e.hours = 0, a = !0), e.minutes > 59 && (e.minutes = 0, e.hours++, a = !0), e.seconds > 59 && (e.seconds = 0, e.minutes++, a = !0), t = n.getenddate(e.month + 1, e.year), e.date > t && (e.date = t, a = !0)
}, m = function (e, t, n) {
var o = ["starttime", "endtime"];
t = (t.match(i.exp_split) || []).slice(1), n = n || 0, r.range && (i[o[n]] = i[o[n]] || {}), w.each(i.format, function (s, l) {
var c = parsefloat(t[s]);
t[s].length < l.length && (a = !0), /yyyy|y/.test(l) ? (c < d[0] && (c = d[0], a = !0), e.year = c) : /mm|m/.test(l) ? (c < 1 && (c = 1, a = !0), e.month = c - 1) : /dd|d/.test(l) ? (c < 1 && (c = 1, a = !0), e.date = c) : /hh|h/.test(l) ? (c < 1 && (c = 0, a = !0), e.hours = c, r.range && (i[o[n]].hours = c)) : /mm|m/.test(l) ? (c < 1 && (c = 0, a = !0), e.minutes = c, r.range && (i[o[n]].minutes = c)) : /ss|s/.test(l) && (c < 1 && (c = 0, a = !0), e.seconds = c, r.range && (i[o[n]].seconds = c))
}), c(e)
};
return "limit" === e ? (c(o), i) : (l = l || r.value, "string" == typeof l && (l = l.replace(/\s+/g, " ").replace(/^\s|\s$/g, "")), i.startstate && !i.endstate && (delete i.startstate, i.endstate = !0), "string" == typeof l && l ? i.exp_if.test(l) ? r.range ? (l = l.split(" " + r.range + " "), i.startdate = i.startdate || i.systemdate(), i.enddate = i.enddate || i.systemdate(), r.datetime = w.extend({}, i.startdate), w.each([i.startdate, i.enddate], function (e, t) {
m(t, l[e], e)
})) : m(o, l) : (i.hint("日期格式不合法
必须遵循下述格式:
" + (r.range ? r.format + " " + r.range + " " + r.format : r.format) + "
已为你重置"), a = !0) : l && l.constructor === date ? r.datetime = i.systemdate(l) : (r.datetime = i.systemdate(), delete i.startstate, delete i.endstate, delete i.startdate, delete i.enddate, delete i.starttime, delete i.endtime), c(o), a && l && i.setvalue(r.range ? i.enddate ? i.parse() : "" : i.parse()), e && e(), i)
}, t.prototype.mark = function (e, t) {
var n, a = this, i = a.config;
return w.each(i.mark, function (e, a) {
var i = e.split("-");
i[0] != t[0] && 0 != i[0] || i[1] != t[1] && 0 != i[1] || i[2] != t[2] || (n = a || t[2])
}), n && e.html('' + n + ""), a
}, t.prototype.limit = function (e, t, n, a) {
var i, r = this, o = r.config, l = {}, d = o[n > 41 ? "enddate" : "datetime"], c = w.extend({}, d, t || {});
return w.each({now: c, min: o.min, max: o.max}, function (e, t) {
l[e] = r.newdate(w.extend({year: t.year, month: t.month, date: t.date}, function () {
var e = {};
return w.each(a, function (n, a) {
e[a] = t[a]
}), e
}())).gettime()
}), i = l.now < l.min || l.now > l.max, e && e[i ? "addclass" : "removeclass"](s), i
}, t.prototype.calendar = function (e) {
var t, a, i, r = this, s = r.config, l = e || s.datetime, c = new date, m = r.lang(), u = "date" !== s.type && "datetime" !== s.type, h = e ? 1 : 0, y = w(r.table[h]).find("td"), f = w(r.elemheader[h][2]).find("span");
if (l.year < d[0] && (l.year = d[0], r.hint("最低只能支持到公元" + d[0] + "年")), l.year > d[1] && (l.year = d[1], r.hint("最高只能支持到公元" + d[1] + "年")), r.firstdate || (r.firstdate = w.extend({}, l)), c.setfullyear(l.year, l.month, 1), t = c.getday(), a = n.getenddate(l.month || 12, l.year), i = n.getenddate(l.month + 1, l.year), w.each(y, function (e, n) {
var d = [l.year, l.month], c = 0;
n = w(n), n.removeattr("class"), e < t ? (c = a - t + e, n.addclass("laydate-day-prev"), d = r.getasym(l.year, l.month, "sub")) : e >= t && e < i + t ? (c = e - t, s.range || c + 1 === l.date && n.addclass(o)) : (c = e - i - t, n.addclass("laydate-day-next"), d = r.getasym(l.year, l.month)), d[1]++, d[2] = c + 1, n.attr("lay-ymd", d.join("-")).html(d[2]), r.mark(n, d).limit(n, {
year: d[0],
month: d[1] - 1,
date: d[2]
}, e)
}), w(f[0]).attr("lay-ym", l.year + "-" + (l.month + 1)), w(f[1]).attr("lay-ym", l.year + "-" + (l.month + 1)), "cn" === s.lang ? (w(f[0]).attr("lay-type", "year").html(l.year + "年"), w(f[1]).attr("lay-type", "month").html(l.month + 1 + "月")) : (w(f[0]).attr("lay-type", "month").html(m.month[l.month]), w(f[1]).attr("lay-type", "year").html(l.year)), u && (s.range && (e ? r.enddate = r.enddate || {
year: l.year + ("year" === s.type ? 1 : 0),
month: l.month + ("month" === s.type ? 0 : -1)
} : r.startdate = r.startdate || {
year: l.year,
month: l.month
}, e && (r.listym = [[r.startdate.year, r.startdate.month + 1], [r.enddate.year, r.enddate.month + 1]], r.list(s.type, 0).list(s.type, 1), "time" === s.type ? r.setbtnstatus("时间", w.extend({}, r.systemdate(), r.starttime), w.extend({}, r.systemdate(), r.endtime)) : r.setbtnstatus(!0))), s.range || (r.listym = [[l.year, l.month + 1]], r.list(s.type, 0))), s.range && !e) {
var p = r.getasym(l.year, l.month);
r.calendar(w.extend({}, l, {year: p[0], month: p[1]}))
}
return s.range || r.limit(w(r.footer).find(g), null, 0, ["hours", "minutes", "seconds"]), s.range && e && !u && r.stamprange(), r
}, t.prototype.list = function (e, t) {
var n = this, a = n.config, i = a.datetime, r = n.lang(), l = a.range && "date" !== a.type && "datetime" !== a.type, d = w.elem("ul", {
"class": m + " " + {
year: "laydate-year-list",
month: "laydate-month-list",
time: "laydate-time-list"
}[e]
}), c = n.elemheader[t], u = w(c[2]).find("span"), h = n.elemcont[t || 0], y = w(h).find("." + m)[0], f = "cn" === a.lang, p = f ? "年" : "", t = n.listym[t] || {}, c = ["hours", "minutes", "seconds"], x = ["starttime", "endtime"][t];
if (t[0] < 1 && (t[0] = 1), "year" === e) {
var m, b = m = t[0] - 7;
b < 1 && (b = m = 1), w.each(new array(15), function (e) {
var i = w.elem("li", {"lay-ym": m}), r = {year: m};
m == t[0] && w(i).addclass(o), i.innerhtml = m + p, d.appendchild(i), m < n.firstdate.year ? (r.month = a.min.month, r.date = a.min.date) : m >= n.firstdate.year && (r.month = a.max.month, r.date = a.max.date), n.limit(w(i), r, t), m++
}), w(u[f ? 0 : 1]).attr("lay-ym", m - 8 + "-" + t[1]).html(b + p + " - " + (m - 1 + p))
} else if ("month" === e)w.each(new array(12), function (e) {
var i = w.elem("li", {"lay-ym": e}), s = {year: t[0], month: e};
e + 1 == t[1] && w(i).addclass(o), i.innerhtml = r.month[e] + (f ? "月" : ""), d.appendchild(i), t[0] < n.firstdate.year ? s.date = a.min.date : t[0] >= n.firstdate.year && (s.date = a.max.date), n.limit(w(i), s, t)
}), w(u[f ? 0 : 1]).attr("lay-ym", t[0] + "-" + t[1]).html(t[0] + p); else if ("time" === e) {
var e = function () {
w(d).find("ol").each(function (e, a) {
w(a).find("li").each(function (a, i) {
n.limit(w(i), [{hours: a}, {hours: n[x].hours, minutes: a}, {
hours: n[x].hours,
minutes: n[x].minutes,
seconds: a
}][e], t, [["hours"], ["hours", "minutes"], ["hours", "minutes", "seconds"]][e])
})
}), a.range || n.limit(w(n.footer).find(g), n[x], 0, ["hours", "minutes", "seconds"])
};
a.range ? n[x] || (n[x] = {
hours: 0,
minutes: 0,
seconds: 0
}) : n[x] = i, w.each([24, 60, 60], function (e, t) {
var a = w.elem("li"), i = ["" + r.time[e] + "
"];
w.each(new array(t), function (t) {
i.push("- " + w.digit(t, 2) + "
")
}), a.innerhtml = i.join("") + "
", d.appendchild(a)
}), e()
}
if (y && h.removechild(y), h.appendchild(d), "year" === e || "month" === e)w(n.elemmain[t]).addclass("laydate-ym-show"), w(d).find("li").on("click", function () {
var r = 0 | w(this).attr("lay-ym");
if (!w(this).hasclass(s)) {
if (0 === t)i[e] = r, l && (n.startdate[e] = r), n.limit(w(n.footer).find(g), null, 0); else if (l)n.enddate[e] = r; else {
var c = "year" === e ? n.getasym(r, t[1] - 1, "sub") : n.getasym(t[0], r, "sub");
w.extend(i, {year: c[0], month: c[1]})
}
"year" === a.type || "month" === a.type ? (w(d).find("." + o).removeclass(o), w(this).addclass(o), "month" === a.type && "year" === e && (n.listym[t][0] = r, l && (n[["startdate", "enddate"][t]].year = r), n.list("month", t))) : (n.checkdate("limit").calendar(), n.closelist()), n.setbtnstatus(), a.range || n.done(null, "change"), w(n.footer).find(d).removeclass(s)
}
}); else {
var s = w.elem("span", {"class": v}), k = function () {
w(d).find("ol").each(function (e) {
var t = this, a = w(t).find("li");
t.scrolltop = 30 * (n[x][c[e]] - 2), t.scrolltop <= 0 && a.each(function (e, n) {
if (!w(this).hasclass(s))return t.scrolltop = 30 * (e - 2), !0
})
})
}, h = w(c[2]).find("." + v);
k(), s.innerhtml = a.range ? [r.starttime, r.endtime][t] : r.timetips, w(n.elemmain[t]).addclass("laydate-time-show"), h[0] && h.remove(), c[2].appendchild(s), w(d).find("ol").each(function (e) {
var t = this;
w(t).find("li").on("click", function () {
var r = 0 | this.innerhtml;
w(this).hasclass(s) || (a.range ? n[x][c[e]] = r : i[c[e]] = r, w(t).find("." + o).removeclass(o), w(this).addclass(o), e(), k(), (n.enddate || "time" === a.type) && n.done(null, "change"), n.setbtnstatus())
})
})
}
return n
}, t.prototype.listym = [], t.prototype.closelist = function () {
var e = this;
e.config;
w.each(e.elemcont, function (t, n) {
w(this).find("." + m).remove(), w(e.elemmain[t]).removeclass("laydate-ym-show laydate-time-show")
}), w(e.elem).find("." + v).remove()
}, t.prototype.setbtnstatus = function (e, t, n) {
var a, i = this, r = i.config, o = w(i.footer).find(g), d = r.range && "date" !== r.type && "time" !== r.type;
d && (t = t || i.startdate, n = n || i.enddate, a = i.newdate(t).gettime() > i.newdate(n).gettime(), i.limit(null, t) || i.limit(null, n) ? o.addclass(s) : o[a ? "addclass" : "removeclass"](s), e && a && i.hint("string" == typeof e ? l.replace(/日期/g, e) : l))
}, t.prototype.parse = function (e, t) {
var n = this, a = n.config, i = t || (e ? w.extend({}, n.enddate, n.endtime) : a.range ? w.extend({}, n.startdate, n.starttime) : a.datetime), r = n.format.concat();
return w.each(r, function (e, t) {
/yyyy|y/.test(t) ? r[e] = w.digit(i.year, t.length) : /mm|m/.test(t) ? r[e] = w.digit(i.month + 1, t.length) : /dd|d/.test(t) ? r[e] = w.digit(i.date, t.length) : /hh|h/.test(t) ? r[e] = w.digit(i.hours, t.length) : /mm|m/.test(t) ? r[e] = w.digit(i.minutes, t.length) : /ss|s/.test(t) && (r[e] = w.digit(i.seconds, t.length))
}), a.range && !e ? r.join("") + " " + a.range + " " + n.parse(1) : r.join("")
}, t.prototype.newdate = function (e) {
return new date(e.year || 1, e.month || 0, e.date || 1, e.hours || 0, e.minutes || 0, e.seconds || 0)
}, t.prototype.setvalue = function (e) {
var t = this, n = t.config, a = t.bindelem || n.elem[0], i = t.isinput(a) ? "val" : "html";
return "static" === n.position || w(a)[i](e || ""), this
}, t.prototype.stamprange = function () {
var e, t, n = this, a = n.config, i = w(n.elem).find("td");
if (a.range && !n.enddate && w(n.footer).find(g).addclass(s), n.enddate)return e = n.newdate({
year: n.startdate.year,
month: n.startdate.month,
date: n.startdate.date
}).gettime(), t = n.newdate({
year: n.enddate.year,
month: n.enddate.month,
date: n.enddate.date
}).gettime(), e > t ? n.hint(l) : void w.each(i, function (a, i) {
var r = w(i).attr("lay-ymd").split("-"), s = n.newdate({year: r[0], month: r[1] - 1, date: r[2]}).gettime();
w(i).removeclass(u + " " + o), s !== e && s !== t || w(i).addclass(w(i).hasclass(y) || w(i).hasclass(f) ? u : o), s > e && s < t && w(i).addclass(u)
})
}, t.prototype.done = function (e, t) {
var n = this, a = n.config, i = w.extend({}, n.startdate ? w.extend(n.startdate, n.starttime) : a.datetime), r = w.extend({}, w.extend(n.enddate, n.endtime));
return w.each([i, r], function (e, t) {
"month" in t && w.extend(t, {month: t.month + 1})
}), e = e || [n.parse(), i, r], "function" == typeof a[t || "done"] && a[t || "done"].apply(a, e), n
}, t.prototype.choose = function (e) {
var t = this, n = t.config, a = n.datetime, i = w(t.elem).find("td"), r = e.attr("lay-ymd").split("-"), l = function (e) {
new date;
e && w.extend(a, r), n.range && (t.startdate ? w.extend(t.startdate, r) : t.startdate = w.extend({}, r, t.starttime), t.startymd = r)
};
if (r = {year: 0 | r[0], month: (0 | r[1]) - 1, date: 0 | r[2]}, !e.hasclass(s))if (n.range) {
if (w.each(["starttime", "endtime"], function (e, n) {
t[n] = t[n] || {hours: 0, minutes: 0, seconds: 0}
}), t.endstate)l(), delete t.endstate, delete t.enddate, t.startstate = !0, i.removeclass(o + " " + u), e.addclass(o); else if (t.startstate) {
if (e.addclass(o), t.enddate ? w.extend(t.enddate, r) : t.enddate = w.extend({}, r, t.endtime), t.newdate(r).gettime() < t.newdate(t.startymd).gettime()) {
var d = w.extend({}, t.enddate, {
hours: t.startdate.hours,
minutes: t.startdate.minutes,
seconds: t.startdate.seconds
});
w.extend(t.enddate, t.startdate, {
hours: t.enddate.hours,
minutes: t.enddate.minutes,
seconds: t.enddate.seconds
}), t.startdate = d
}
n.showbottom || t.done(), t.stamprange(), t.endstate = !0, t.done(null, "change")
} else e.addclass(o), l(), t.startstate = !0;
w(t.footer).find(g)[t.enddate ? "removeclass" : "addclass"](s)
} else"static" === n.position ? (l(!0), t.calendar().done().done(null, "change")) : "date" === n.type ? (l(!0), t.setvalue(t.parse()).remove().done()) : "datetime" === n.type && (l(!0), t.calendar().done(null, "change"))
}, t.prototype.tool = function (e, t) {
var n = this, a = n.config, i = a.datetime, r = "static" === a.position, o = {
datetime: function () {
w(e).hasclass(s) || (n.list("time", 0), a.range && n.list("time", 1), w(e).attr("lay-type", "date").html(n.lang().datetips))
}, date: function () {
n.closelist(), w(e).attr("lay-type", "datetime").html(n.lang().timetips)
}, clear: function () {
n.setvalue("").remove(), r && (w.extend(i, n.firstdate), n.calendar()), a.range && (delete n.startstate, delete n.endstate, delete n.enddate, delete n.starttime, delete n.endtime), n.done(["", {}, {}])
}, now: function () {
var e = new date;
w.extend(i, n.systemdate(), {
hours: e.gethours(),
minutes: e.getminutes(),
seconds: e.getseconds()
}), n.setvalue(n.parse()).remove(), r && n.calendar(), n.done()
}, confirm: function () {
if (a.range) {
if (!n.enddate)return n.hint("请先选择日期范围");
if (w(e).hasclass(s))return n.hint("time" === a.type ? l.replace(/日期/g, "时间") : l)
} else if (w(e).hasclass(s))return n.hint("不在有效日期或时间范围内");
n.done(), n.setvalue(n.parse()).remove()
}
};
o[t] && o[t]()
}, t.prototype.change = function (e) {
var t = this, n = t.config, a = n.datetime, i = n.range && ("year" === n.type || "month" === n.type), r = t.elemcont[e || 0], o = t.listym[e], s = function (s) {
var l = ["startdate", "enddate"][e], d = w(r).find(".laydate-year-list")[0], c = w(r).find(".laydate-month-list")[0];
return d && (o[0] = s ? o[0] - 15 : o[0] + 15, t.list("year", e)), c && (s ? o[0]-- : o[0]++, t.list("month", e)), (d || c) && (w.extend(a, {year: o[0]}), i && (t[l].year = o[0]), n.range || t.done(null, "change"), t.setbtnstatus(), n.range || t.limit(w(t.footer).find(g), {year: o[0]})), d || c
};
return {
prevyear: function () {
s("sub") || (a.year--, t.checkdate("limit").calendar(), n.range || t.done(null, "change"))
}, prevmonth: function () {
var e = t.getasym(a.year, a.month, "sub");
w.extend(a, {
year: e[0],
month: e[1]
}), t.checkdate("limit").calendar(), n.range || t.done(null, "change")
}, nextmonth: function () {
var e = t.getasym(a.year, a.month);
w.extend(a, {
year: e[0],
month: e[1]
}), t.checkdate("limit").calendar(), n.range || t.done(null, "change")
}, nextyear: function () {
s() || (a.year++, t.checkdate("limit").calendar(), n.range || t.done(null, "change"))
}
}
}, t.prototype.changeevent = function () {
var e = this;
e.config;
w(e.elem).on("click", function (e) {
w.stope(e)
}), w.each(e.elemheader, function (t, n) {
w(n[0]).on("click", function (n) {
e.change(t).prevyear()
}), w(n[1]).on("click", function (n) {
e.change(t).prevmonth()
}), w(n[2]).find("span").on("click", function (n) {
var a = w(this), i = a.attr("lay-ym"), r = a.attr("lay-type");
i && (i = i.split("-"), e.listym[t] = [0 | i[0], 0 | i[1]], e.list(r, t), w(e.footer).find(d).addclass(s))
}), w(n[3]).on("click", function (n) {
e.change(t).nextmonth()
}), w(n[4]).on("click", function (n) {
e.change(t).nextyear()
})
}), w.each(e.table, function (t, n) {
var a = w(n).find("td");
a.on("click", function () {
e.choose(w(this))
})
}), w(e.footer).find("span").on("click", function () {
var t = w(this).attr("lay-type");
e.tool(this, t)
})
}, t.prototype.isinput = function (e) {
return /input|textarea/.test(e.tagname.tolocalelowercase())
}, t.prototype.events = function () {
var e = this, t = e.config, n = function (n, a) {
n.on(t.trigger, function () {
a && (e.bindelem = this), e.render()
})
};
t.elem[0] && !t.elem[0].eventhandler && (n(t.elem, "bind"), n(t.eventelem), w(document).on("click", function (n) {
n.target !== t.elem[0] && n.target !== t.eventelem[0] && n.target !== w(t.closestop)[0] && e.remove()
}).on("keydown", function (t) {
13 === t.keycode && w("#" + e.elemid)[0] && e.elemid === t.thiselem && (t.preventdefault(), w(e.footer).find(g)[0].click())
}), w(window).on("resize", function () {
return !(!e.elem || !w(r)[0]) && void e.position()
}), t.elem[0].eventhandler = !0)
}, n.render = function (e) {
var t = new t(e);
return a.call(t)
}, n.getenddate = function (e, t) {
var n = new date;
return n.setfullyear(t || n.getfullyear(), e || n.getmonth() + 1, 1), new date(n.gettime() - 864e5).getdate()
}, window.lay = window.lay || w, e ? (n.ready(), layui.define(function (e) {
n.path = layui.cache.dir, e(i, n)
})) : "function" == typeof define && define.amd ? define(function () {
return n
}) : function () {
n.ready(), window.laydate = n
}()
}();