;
layui.define("layer",
function(e) {
"use strict";
var t = layui.$,
i = layui.layer,
a = layui.hint(),
n = layui.device(),
l = "form",
r = ".layui-form",
s = "layui-this",
o = "layui-hide",
u = "layui-disabled",
c = function() {
this.config = {
verify: {
required: [/[\S]+/, "必填项不能为空"],
phone: [/^1\d{10}$/, "请输入正确的手机号"],
email: [/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
url: [/(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
number: function(e) {
if (!e || isNaN(e)) return "只能填写数字"
},
date: [/^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
identity: [/(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
}
}
};
c.prototype.set = function(e) {
var i = this;
return t.extend(!0, i.config, e),
i
},
c.prototype.verify = function(e) {
var i = this;
return t.extend(!0, i.config.verify, e),
i
},
c.prototype.on = function(e, t) {
return layui.onevent.call(this, l, e, t)
},
c.prototype.render = function(e, i) {
var n = this,
c = t(r +
function() {
return i ? '[lay-filter="' + i + '"]': ""
} ()),
d = {
select: function() {
var e, i = "请选择",
a = "layui-form-select",
n = "layui-select-title",
r = "layui-select-none",
d = "",
f = c.find("select"),
y = function(i, l) {
t(i.target).parent().hasClass(n) && !l || (t("." + a).removeClass(a + "ed " + a + "up"), e && d && e.val(d)),
e = null
},
h = function(i, c, f) {
var h = t(this),
p = i.find("." + n),
m = p.find("input"),
k = i.find("dl"),
g = k.children("dd");
if (!c) {
var x = function() {
var e = i.offset().top + i.outerHeight() + 5 - v.scrollTop(),
t = k.outerHeight();
i.addClass(a + "ed"),
g.removeClass(o),
e + t > v.height() && e >= t && i.addClass(a + "up")
},
b = function(e) {
i.removeClass(a + "ed " + a + "up"),
m.blur(),
e || C(m.val(),
function(e) {
e && (d = k.find("." + s).html(), m && m.val(d))
})
};
p.on("click",
function(e) {
i.hasClass(a + "ed") ? b() : (y(e, !0), x()),
k.find("." + r).remove()
}),
p.find(".layui-edge").on("click",
function() {
m.focus()
}),
m.on("keyup",
function(e) {
var t = e.keyCode;
9 === t && x()
}).on("keydown",
function(e) {
var t = e.keyCode;
9 === t ? b() : 13 === t && e.preventDefault()
});
var C = function(e, i, a) {
var n = 0;
layui.each(g,
function() {
var i = t(this),
l = i.text(),
r = l.indexOf(e) === -1; ("" === e || "blur" === a ? e !== l: r) && n++,
"keyup" === a && i[r ? "addClass": "removeClass"](o)
});
var l = n === g.length;
return i(l),
l
},
w = function(e) {
var t = this.value,
i = e.keyCode;
return 9 !== i && 13 !== i && 37 !== i && 38 !== i && 39 !== i && 40 !== i && (C(t,
function(e) {
e ? k.find("." + r)[0] || k.append('
无匹配项
') : k.find("." + r).remove()
},
"keyup"), void("" === t && k.find("." + r).remove()))
};
f && m.on("keyup", w).on("blur",
function(t) {
e = m,
d = k.find("." + s).html(),
setTimeout(function() {
C(m.val(),
function(e) {
d || m.val("")
},
"blur")
},
200)
}),
g.on("click",
function() {
var e = t(this),
a = e.attr("lay-value"),
n = h.attr("lay-filter");
return ! e.hasClass(u) && (e.hasClass("layui-select-tips") ? m.val("") : (m.val(e.text()), e.addClass(s)), e.siblings().removeClass(s), h.val(a).removeClass("layui-form-danger"), layui.event.call(this, l, "select(" + n + ")", {
elem: h[0],
value: a,
othis: i
}), b(!0), !1)
}),
i.find("dl>dt").on("click",
function(e) {
return ! 1
}),
t(document).off("click", y).on("click", y)
}
};
f.each(function(e, l) {
var r = t(this),
o = r.next("." + a),
c = this.disabled,
d = l.value,
f = t(l.options[l.selectedIndex]),
y = l.options[0];
if ("string" == typeof r.attr("lay-ignore")) return r.show();
var v = "string" == typeof r.attr("lay-search"),
p = y ? y.value ? i: y.innerHTML || i: i,
m = t(['
', '
', '
', '
' +
function(e) {
var t = [];
return layui.each(e,
function(e, a) {
0 !== e || a.value ? "optgroup" === a.tagName.toLowerCase() ? t.push("
" + a.label + "
") : t.push('
' + a.innerHTML + "
") : t.push('
' + (a.innerHTML || i) + "
")
}),
0 === t.length && t.push('
没有选项
'),
t.join("")
} (r.find("*")) + "
", "
"].join(""));
o[0] && o.remove(),
r.after(m),
h.call(this, m, c, v)
})
},
checkbox: function() {
var e = {
checkbox: ["layui-form-checkbox", "layui-form-checked", "checkbox"],
_switch: ["layui-form-switch", "layui-form-onswitch", "switch"]
},
i = c.find("input[type=checkbox]"),
a = function(e, i) {
var a = t(this);
e.on("click",
function() {
var t = a.attr("lay-filter"),
n = (a.attr("lay-text") || "").split("|");
a[0].disabled || (a[0].checked ? (a[0].checked = !1, e.removeClass(i[1]).find("em").text(n[1])) : (a[0].checked = !0, e.addClass(i[1]).find("em").text(n[0])), layui.event.call(a[0], l, i[2] + "(" + t + ")", {
elem: a[0],
value: a[0].value,
othis: e
}))
})
};
i.each(function(i, n) {
var l = t(this),
r = l.attr("lay-skin"),
s = (l.attr("lay-text") || "").split("|"),
o = this.disabled;
"switch" === r && (r = "_" + r);
var c = e[r] || e.checkbox;
if ("string" == typeof l.attr("lay-ignore")) return l.show();
var d = l.next("." + c[0]),
f = t(['