@xwadex/fesd 0.0.69 → 0.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fesd-bundle.js +196 -192
- package/dist/fesd-bundle.js.map +1 -1
- package/dist/image-preview-bundle.js +489 -362
- package/dist/image-preview-bundle.js.map +1 -1
- package/dist/tools-bundle.js +217 -324
- package/dist/tools-bundle.js.map +1 -1
- package/package.json +1 -1
package/dist/tools-bundle.js
CHANGED
|
@@ -1,172 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as
|
|
3
|
-
import { o as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
function J() {
|
|
1
|
+
import { p as $, B as A } from "./image-preview-bundle.js";
|
|
2
|
+
import { e as _, f as K, h as Q, i as J, j as Z, k as ee, l as te, n as re, q as oe, r as se, s as le, t as ie, v as ae, w as ce, x as ne, y as ue, z as de, E as fe, K as pe, L as me, N as ye, O as he, P as ve, Q as be, S as ge, V as Se, W as ke, X as xe, Y as Ee, $ as Ae } from "./image-preview-bundle.js";
|
|
3
|
+
import { o as j, z as D } from "./vendor-bundle.js";
|
|
4
|
+
import S from "validator";
|
|
5
|
+
import N from "flatpickr";
|
|
6
|
+
function W() {
|
|
8
7
|
if (!document.body.classList.contains("error") || document.querySelector(".back-home") == null) return;
|
|
9
|
-
let
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
e--,
|
|
8
|
+
let y, e = 5;
|
|
9
|
+
const r = document.querySelector(".back-home").getAttribute("href"), t = document.querySelector(".back-home .countdown");
|
|
10
|
+
y = setInterval(() => {
|
|
11
|
+
e--, t.textContent = e, e === 0 && (clearInterval(y), window.location.href = r);
|
|
13
12
|
}, 1e3);
|
|
14
13
|
}
|
|
15
|
-
function B(
|
|
16
|
-
if (
|
|
17
|
-
const
|
|
18
|
-
|
|
14
|
+
function B(y, e = y) {
|
|
15
|
+
if (y.complete) {
|
|
16
|
+
const t = new j().getColor(y), c = t[0] * 0.299 + t[1] * 0.587 + t[2] * 0.114;
|
|
17
|
+
C(c, e), e.classList.add("detected");
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
|
-
function
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
e.closest(
|
|
25
|
-
}) : e.classList.add("is-light") :
|
|
26
|
-
e.closest(
|
|
20
|
+
function C(y, e) {
|
|
21
|
+
const r = e.getAttribute("addClassEl");
|
|
22
|
+
y >= 192 ? r && r !== "" ? r.split(",").forEach((t) => {
|
|
23
|
+
e.closest(t) || console.error(`closest "${t}" not found`), e.closest(t)?.classList.add("is-light");
|
|
24
|
+
}) : e.classList.add("is-light") : r && r !== "" ? r.split(",").forEach((t) => {
|
|
25
|
+
e.closest(t) || console.error(`closest "${t}" not found`), e.closest(t)?.classList.add("is-dark");
|
|
27
26
|
}) : e.classList.add("is-dark");
|
|
28
27
|
}
|
|
29
|
-
function
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
else if (
|
|
34
|
-
const
|
|
35
|
-
|
|
28
|
+
function G(y, e, r) {
|
|
29
|
+
const t = document.createElement("canvas"), c = t.getContext("2d");
|
|
30
|
+
if (t.width = 50, t.height = 50, y !== "" && e === "")
|
|
31
|
+
c.fillStyle = y;
|
|
32
|
+
else if (y !== "" && e !== "") {
|
|
33
|
+
const u = c.createLinearGradient(0, 0, t.width, t.height);
|
|
34
|
+
u.addColorStop(0, y), u.addColorStop(1, e), c.fillStyle = u;
|
|
36
35
|
}
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
return
|
|
40
|
-
B(this,
|
|
41
|
-
}),
|
|
36
|
+
c.fillRect(0, 0, t.width, t.height);
|
|
37
|
+
const f = new Image();
|
|
38
|
+
return f.src = t.toDataURL(), f.crossOrigin = "Anonymous", f.addEventListener("load", function() {
|
|
39
|
+
B(this, r);
|
|
40
|
+
}), f;
|
|
42
41
|
}
|
|
43
|
-
function
|
|
42
|
+
function R() {
|
|
44
43
|
[...document.querySelectorAll(".detect-shade:not(.detected)")].forEach((e) => {
|
|
45
44
|
if (e.tagName === "IMG")
|
|
46
45
|
return;
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
46
|
+
const r = ["#FFF", "#FFFFFF", "#fff", "#ffffff"], t = ["#000", "#000000"], c = getComputedStyle(e).getPropertyValue("--start-color"), f = getComputedStyle(e).getPropertyValue("--end-color");
|
|
47
|
+
if (c === "" && f === "") {
|
|
49
48
|
console.error(e, "=> No color set!");
|
|
50
49
|
return;
|
|
51
|
-
} else if (
|
|
52
|
-
console.warn(e, "=> TypeError!! ( #FFF ) "),
|
|
50
|
+
} else if (r.indexOf(c) > 0) {
|
|
51
|
+
console.warn(e, "=> TypeError!! ( #FFF ) "), C(255, e);
|
|
53
52
|
return;
|
|
54
|
-
} else if (
|
|
55
|
-
console.warn(e, "=> TypeError!! ( #000 ) "),
|
|
53
|
+
} else if (t.indexOf(c) > 0) {
|
|
54
|
+
console.warn(e, "=> TypeError!! ( #000 ) "), C(0, e);
|
|
56
55
|
return;
|
|
57
56
|
}
|
|
58
|
-
|
|
57
|
+
G(c, f, e);
|
|
59
58
|
});
|
|
60
59
|
}
|
|
61
|
-
const
|
|
62
|
-
CG_A: function(l) {
|
|
63
|
-
h("html,body").delay(100).animate(
|
|
64
|
-
{ opacity: "0" },
|
|
65
|
-
{
|
|
66
|
-
queue: !0,
|
|
67
|
-
duration: 800,
|
|
68
|
-
easing: "easeOutQuad",
|
|
69
|
-
complete: function() {
|
|
70
|
-
window.location.assign(l);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
},
|
|
75
|
-
CG_B: function(l) {
|
|
76
|
-
h("main").append("<div id='CG_Abg'><div class='CG_Abg1'></div><div class='CG_Abg2'></div></div>"), h("body").delay(1200).animate(
|
|
77
|
-
{ opacity: "0" },
|
|
78
|
-
{
|
|
79
|
-
queue: !0,
|
|
80
|
-
duration: 200,
|
|
81
|
-
easing: "easeOutQuad",
|
|
82
|
-
complete: function() {
|
|
83
|
-
setTimeout(function() {
|
|
84
|
-
window.location.assign(l);
|
|
85
|
-
}, 100);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
);
|
|
89
|
-
},
|
|
90
|
-
CG_C: function(l) {
|
|
91
|
-
h("main").append("<div id='CG_Bbg'></div>"), h("body").delay(1200).animate(
|
|
92
|
-
{ opacity: "0" },
|
|
93
|
-
{
|
|
94
|
-
queue: !0,
|
|
95
|
-
duration: 200,
|
|
96
|
-
easing: "easeOutQuad",
|
|
97
|
-
complete: function() {
|
|
98
|
-
setTimeout(function() {
|
|
99
|
-
window.location.assign(l);
|
|
100
|
-
}, 100);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
|
-
},
|
|
105
|
-
CG_D: function(l) {
|
|
106
|
-
h("main").append("<div id='CG_Cbg'><div class='CG_Cbg1'></div><div class='CG_Cbg2'></div></div>"), h("body").delay(1200).animate(
|
|
107
|
-
{ opacity: "0" },
|
|
108
|
-
{
|
|
109
|
-
queue: !0,
|
|
110
|
-
duration: 200,
|
|
111
|
-
easing: "easeOutQuad",
|
|
112
|
-
complete: function() {
|
|
113
|
-
setTimeout(function() {
|
|
114
|
-
window.location.assign(l);
|
|
115
|
-
}, 100);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
}, U = (l) => {
|
|
121
|
-
M.CG_A(l);
|
|
122
|
-
}, I = (l, e) => {
|
|
123
|
-
l.preventDefault();
|
|
124
|
-
const t = h(l.currentTarget), o = t.attr("target"), n = t.attr("href");
|
|
125
|
-
let u;
|
|
126
|
-
if (e) {
|
|
127
|
-
if (t.is("[data-nolink]")) {
|
|
128
|
-
l.stopPropagation(), l.preventDefault();
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
t.hasClass("href-link") ? u = t.closest("[data-href]").attr("data-href") : u = n;
|
|
132
|
-
} else {
|
|
133
|
-
if (t.is("[data-nolink]")) {
|
|
134
|
-
l.stopPropagation(), l.preventDefault();
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
t.hasClass("click-block") ? u = t.closest("[data-href]").attr("data-href") : u = n;
|
|
138
|
-
}
|
|
139
|
-
let a = window.location.pathname.replace("http://", "").split("/");
|
|
140
|
-
a = c(a);
|
|
141
|
-
const s = u.replace("http://", "");
|
|
142
|
-
let d = s.split("/");
|
|
143
|
-
d = c(d);
|
|
144
|
-
function c(i) {
|
|
145
|
-
const r = i.pop();
|
|
146
|
-
return r.indexOf("#") > -1 || r.indexOf("html") > 0 ? i.push(r) : (r == "" || i.push(r), i.push("index.html")), i;
|
|
147
|
-
}
|
|
148
|
-
o == "_blank" || l.ctrlKey || l.metaKey ? window.open(u) : s.indexOf("jpg") > -1 || s.indexOf("javascript") > -1 || U(u);
|
|
149
|
-
}, z = (l) => {
|
|
150
|
-
const t = h(l.currentTarget).closest("[data-href]");
|
|
151
|
-
t.hasClass("isHover") || t.addClass("isHover");
|
|
152
|
-
}, H = (l) => {
|
|
153
|
-
const t = h(l.currentTarget).closest("[data-href]");
|
|
154
|
-
t.hasClass("isHover") && t.removeClass("isHover");
|
|
155
|
-
}, Z = (l = !0) => {
|
|
156
|
-
h.easing.jswing = h.easing.swing, h.extend(h.easing, {
|
|
157
|
-
def: "easeOutQuad",
|
|
158
|
-
easeOutQuad: function(e, t, o, n, u) {
|
|
159
|
-
return -n * (t /= u) * (t - 2) + o;
|
|
160
|
-
},
|
|
161
|
-
easeInOutCirc: function(e, t, o, n, u) {
|
|
162
|
-
return (t /= u / 2) < 1 ? -n / 2 * (Math.sqrt(1 - t * t) - 1) + o : n / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + o;
|
|
163
|
-
}
|
|
164
|
-
}), l ? (h("body").on("click", "a:not(.nocg), .href-link, [data-nolink]", (e) => I(e, l)), h("body").on("click", "a:not(.nocg)", function(e) {
|
|
165
|
-
e.stopPropagation();
|
|
166
|
-
})) : (h("body").on("click", "a:not(.nocg), .click-block, [data-nolink]", (e) => I(e, l)), h("body").on("click", "a:not(.nocg)", function(e) {
|
|
167
|
-
e.stopPropagation();
|
|
168
|
-
})), h("body").on("mouseenter", "[data-href] a", (e) => z(e)), h("body").on("mouseleave", "[data-href] a", (e) => H(e));
|
|
169
|
-
}, S = {
|
|
60
|
+
const k = {
|
|
170
61
|
"zh-TW": {
|
|
171
62
|
format: "格式錯誤",
|
|
172
63
|
input: "尚未填寫",
|
|
@@ -198,16 +89,16 @@ const M = {
|
|
|
198
89
|
select: ""
|
|
199
90
|
}
|
|
200
91
|
};
|
|
201
|
-
class
|
|
202
|
-
constructor(e,
|
|
92
|
+
class H {
|
|
93
|
+
constructor(e, r) {
|
|
203
94
|
this.element = document.querySelector(e), this.allField = this.element.querySelectorAll(`${e} [form-field]`), this.allInput = this.element.querySelectorAll(`${e} input`), this.allTextarea = this.element.querySelectorAll(`${e} textarea`), this.allCheckbox = this.element.querySelectorAll(`${e} input[type="checkbox"]`), this.allRadio = this.element.querySelectorAll(`${e} input[type="radio"]`), this.allFileUpload = this.element.querySelectorAll(`${e} .fake-file-upload`), this.allDropdown = this.element.querySelectorAll(`${e} dropdown-el`), this.submitEvent = new Event("submit");
|
|
204
|
-
const
|
|
95
|
+
const t = {
|
|
205
96
|
locale: "zh-TW",
|
|
206
97
|
datepicker: [
|
|
207
98
|
{
|
|
208
99
|
el: ".datepicker-input",
|
|
209
100
|
options: {
|
|
210
|
-
locale:
|
|
101
|
+
locale: D.Mandarin
|
|
211
102
|
}
|
|
212
103
|
}
|
|
213
104
|
],
|
|
@@ -229,13 +120,13 @@ class ee {
|
|
|
229
120
|
underField: !1,
|
|
230
121
|
detailOutput: !1
|
|
231
122
|
}
|
|
232
|
-
},
|
|
233
|
-
const
|
|
234
|
-
for (let
|
|
235
|
-
typeof
|
|
236
|
-
return
|
|
123
|
+
}, c = (f, u) => {
|
|
124
|
+
const l = { ...f };
|
|
125
|
+
for (let o of Object.keys(u))
|
|
126
|
+
typeof u[o] == "object" && o in f ? l[o] = Array.isArray(l[o]) ? [...u[o]] : c(f[o], u[o]) : l[o] = u[o];
|
|
127
|
+
return l;
|
|
237
128
|
};
|
|
238
|
-
this.options =
|
|
129
|
+
this.options = r ? c(t, r) : t, this.init();
|
|
239
130
|
}
|
|
240
131
|
init() {
|
|
241
132
|
const e = this;
|
|
@@ -245,66 +136,66 @@ class ee {
|
|
|
245
136
|
* 綁事件
|
|
246
137
|
*/
|
|
247
138
|
#e() {
|
|
248
|
-
const e = this, { datepicker:
|
|
249
|
-
function
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}),
|
|
253
|
-
|
|
139
|
+
const e = this, { datepicker: r, timepicker: t, clearEl: c, submitEl: f } = e.options;
|
|
140
|
+
function u() {
|
|
141
|
+
r.forEach((a) => {
|
|
142
|
+
N(a.el, a.options);
|
|
143
|
+
}), t.forEach((a) => {
|
|
144
|
+
N(a.el, a.options);
|
|
254
145
|
});
|
|
255
146
|
}
|
|
256
|
-
function
|
|
257
|
-
const
|
|
258
|
-
|
|
147
|
+
function l() {
|
|
148
|
+
const a = document.querySelector(c), i = document.querySelector(f);
|
|
149
|
+
a?.addEventListener("click", function() {
|
|
259
150
|
e.clear();
|
|
260
151
|
}), i?.addEventListener("click", function() {
|
|
261
152
|
e.submit();
|
|
262
153
|
});
|
|
263
154
|
}
|
|
264
|
-
function
|
|
265
|
-
const i =
|
|
266
|
-
if (
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
|
|
155
|
+
function o(a) {
|
|
156
|
+
const i = a.closest(".form-group");
|
|
157
|
+
if (a.files.length <= 0) return;
|
|
158
|
+
const s = a.closest(".file-wrap").querySelector(".fake-file-upload");
|
|
159
|
+
s.getAttribute("data-default");
|
|
160
|
+
const m = s.querySelector(".file-name"), E = Number(a.getAttribute("data-limit")), x = a.files[0], d = x.size / 1024 / 1024, L = x.name, p = a.cloneNode(!0);
|
|
161
|
+
d > E ? (i.classList.add("error"), i.classList.remove("success"), p.value = "") : (i.classList.remove("error"), i.classList.add("success")), m.textContent = L, p.removeAttribute("form-field field-type data-limit"), s.querySelector('input[type="file"]')?.remove(), s.append(p);
|
|
271
162
|
}
|
|
272
|
-
function
|
|
163
|
+
function n() {
|
|
273
164
|
e.element.addEventListener(
|
|
274
165
|
"input",
|
|
275
|
-
|
|
276
|
-
const { target: i } =
|
|
166
|
+
$(function(a) {
|
|
167
|
+
const { target: i } = a;
|
|
277
168
|
if (i.matches('[type="text"],[type="number"],[type="email"],[type="password"], textarea')) {
|
|
278
169
|
if (e.element.value = e.getValue(), !i.closest(".form-group").classList.contains("required") && i.hasAttribute("data-verify")) {
|
|
279
|
-
|
|
170
|
+
S.isEmpty(i.value) && (i.classList.remove("error"), i.classList.remove("success"), i.closest(".form-group").classList.remove("error"));
|
|
280
171
|
return;
|
|
281
172
|
}
|
|
282
|
-
const
|
|
283
|
-
[
|
|
173
|
+
const s = i.getAttribute("form-field"), m = {
|
|
174
|
+
[s]: e.element.value[s]
|
|
284
175
|
};
|
|
285
|
-
e.options.verify && e.verify(
|
|
176
|
+
e.options.verify && e.verify(m);
|
|
286
177
|
}
|
|
287
178
|
})
|
|
288
|
-
), e.element.addEventListener("change", (
|
|
289
|
-
const { target: i } =
|
|
290
|
-
let
|
|
291
|
-
i.matches('[type="radio"], [type="checkbox"]') && (e.element.value = e.getValue(),
|
|
292
|
-
[
|
|
293
|
-
}, e.verify(
|
|
294
|
-
[
|
|
295
|
-
}, e.verify(
|
|
296
|
-
}), e.allDropdown.forEach((
|
|
297
|
-
|
|
179
|
+
), e.element.addEventListener("change", (a) => {
|
|
180
|
+
const { target: i } = a;
|
|
181
|
+
let s, m;
|
|
182
|
+
i.matches('[type="radio"], [type="checkbox"]') && (e.element.value = e.getValue(), s = i.closest(".form-check").getAttribute("form-field"), m = {
|
|
183
|
+
[s]: e.element.value[s]
|
|
184
|
+
}, e.verify(m)), i.matches('[type="file"]') && (o(i), e.element.value = e.getValue(), s = i.getAttribute("form-field"), m = {
|
|
185
|
+
[s]: e.element.value[s]
|
|
186
|
+
}, e.verify(m));
|
|
187
|
+
}), e.allDropdown.forEach((a) => {
|
|
188
|
+
a.on("change", function() {
|
|
298
189
|
const i = this.getAttribute("form-field");
|
|
299
190
|
e.element.value = e.getValue();
|
|
300
|
-
const
|
|
301
|
-
[i]:
|
|
191
|
+
const s = e.element.value[i], m = typeof s == "object" && !Array.isArray(s) ? s.value : s, E = {
|
|
192
|
+
[i]: s
|
|
302
193
|
};
|
|
303
|
-
(Array.isArray(
|
|
194
|
+
(Array.isArray(m) && m.length > 0 || !Array.isArray(m) && !S.isEmpty(m)) && e.options.verify && e.verify(E);
|
|
304
195
|
});
|
|
305
196
|
});
|
|
306
197
|
}
|
|
307
|
-
|
|
198
|
+
u(), l(), n();
|
|
308
199
|
}
|
|
309
200
|
/**
|
|
310
201
|
* 取得表單所有的值
|
|
@@ -312,59 +203,59 @@ class ee {
|
|
|
312
203
|
*/
|
|
313
204
|
getValue() {
|
|
314
205
|
const e = this;
|
|
315
|
-
let
|
|
316
|
-
return [...e.allField].forEach((
|
|
317
|
-
const
|
|
318
|
-
switch (
|
|
206
|
+
let r = {};
|
|
207
|
+
return [...e.allField].forEach((t) => {
|
|
208
|
+
const c = t.getAttribute("form-field");
|
|
209
|
+
switch (t.getAttribute("field-type")) {
|
|
319
210
|
// 單選Radio
|
|
320
211
|
case "isRadio":
|
|
321
|
-
const
|
|
322
|
-
if (!
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
id: parseInt(
|
|
326
|
-
value:
|
|
212
|
+
const u = t.querySelector("input:checked");
|
|
213
|
+
if (!u) return;
|
|
214
|
+
const l = u.querySelector('input[type="text"]');
|
|
215
|
+
r[c] = {
|
|
216
|
+
id: parseInt(u.closest(".option-item").querySelector(".text").getAttribute("data-id")),
|
|
217
|
+
value: l ? l.value : u.closest(".option-item").querySelector(".text").textContent
|
|
327
218
|
};
|
|
328
219
|
break;
|
|
329
220
|
// 複選Checkbox
|
|
330
221
|
case "isCheckBox":
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
const
|
|
222
|
+
const o = t.querySelectorAll("input:checked");
|
|
223
|
+
r[c] = [...o].map((i) => {
|
|
224
|
+
const s = i.querySelector('input[type="text"]');
|
|
334
225
|
return {
|
|
335
226
|
id: parseInt(i.closest(".option-item").querySelector(".text").getAttribute("data-id")),
|
|
336
|
-
value:
|
|
227
|
+
value: s ? s.value : i.closest(".option-item").querySelector(".text").textContent
|
|
337
228
|
};
|
|
338
229
|
});
|
|
339
230
|
break;
|
|
340
231
|
// 下拉選單
|
|
341
232
|
case "isSelect":
|
|
342
|
-
switch (
|
|
233
|
+
switch (t.hasAttribute("multiple") ? "multiple" : "single") {
|
|
343
234
|
case "single":
|
|
344
|
-
|
|
345
|
-
value:
|
|
346
|
-
display:
|
|
235
|
+
r[c] = {
|
|
236
|
+
value: t.s.value.id ? t.s.value.id : "",
|
|
237
|
+
display: t.s.value.el ? t.s.value.el.textContent : ""
|
|
347
238
|
};
|
|
348
239
|
break;
|
|
349
240
|
case "multiple":
|
|
350
|
-
|
|
351
|
-
value:
|
|
352
|
-
display:
|
|
241
|
+
r[c] = {
|
|
242
|
+
value: t.s.value.map((i) => i.id),
|
|
243
|
+
display: t.s.value.map((i) => i.el.textContent)
|
|
353
244
|
};
|
|
354
245
|
break;
|
|
355
246
|
}
|
|
356
247
|
break;
|
|
357
248
|
// 檔案上傳
|
|
358
249
|
case "isFile":
|
|
359
|
-
const
|
|
360
|
-
|
|
250
|
+
const a = t.closest(".file-wrap")?.querySelector('input[type="file"]');
|
|
251
|
+
r[c] = a?.files ?? void 0;
|
|
361
252
|
break;
|
|
362
253
|
// 其他
|
|
363
254
|
default:
|
|
364
|
-
|
|
255
|
+
r[c] = t.value;
|
|
365
256
|
break;
|
|
366
257
|
}
|
|
367
|
-
}),
|
|
258
|
+
}), r;
|
|
368
259
|
}
|
|
369
260
|
/**
|
|
370
261
|
* 表單驗證
|
|
@@ -372,105 +263,105 @@ class ee {
|
|
|
372
263
|
* @returns
|
|
373
264
|
*/
|
|
374
265
|
verify(e) {
|
|
375
|
-
const
|
|
376
|
-
function
|
|
377
|
-
const
|
|
378
|
-
for (const
|
|
379
|
-
const
|
|
266
|
+
const r = this, { options: t } = r, c = r.element.value, f = e || c;
|
|
267
|
+
function u(l) {
|
|
268
|
+
const o = '<div class="validation-icon"></div>';
|
|
269
|
+
for (const n in l) {
|
|
270
|
+
const a = r.element.querySelector(`[form-field="${n}"]`), i = a.getAttribute("data-verify"), s = a.closest(".form-group");
|
|
380
271
|
switch (i) {
|
|
381
272
|
case "select":
|
|
382
|
-
const
|
|
383
|
-
|
|
273
|
+
const m = a.querySelector(".select-wrapper"), E = m.querySelector(".dropdown-icon");
|
|
274
|
+
m.querySelector(".validation-icon")?.remove(), m.insertBefore(A(o), E);
|
|
384
275
|
break;
|
|
385
276
|
case "radio":
|
|
386
277
|
case "checkbox":
|
|
387
|
-
|
|
278
|
+
s.querySelector(".validation-icon")?.remove(), s.append(A(o));
|
|
388
279
|
break;
|
|
389
280
|
case "file":
|
|
390
|
-
const
|
|
391
|
-
|
|
281
|
+
const x = a.closest(".file-wrap").querySelector(".fake-file-upload"), d = a.closest(".file-wrap").querySelector(".upload-icon");
|
|
282
|
+
x.querySelector(".validation-icon")?.remove(), d ? x.insertBefore(A(o), d) : x.append(A(o));
|
|
392
283
|
break;
|
|
393
284
|
default:
|
|
394
|
-
|
|
285
|
+
a.closest(".input-wrap").querySelector(".validation-icon")?.remove(), a.closest(".input-wrap").append(A(o));
|
|
395
286
|
break;
|
|
396
287
|
}
|
|
397
288
|
}
|
|
398
289
|
}
|
|
399
|
-
if (f
|
|
400
|
-
const
|
|
401
|
-
|
|
290
|
+
if (u(f), e) {
|
|
291
|
+
const l = Object.keys(f)[0];
|
|
292
|
+
r.element.querySelectorAll(`.error-text[name="${l}"]`).forEach((o) => o.remove());
|
|
402
293
|
} else
|
|
403
|
-
|
|
404
|
-
for (const
|
|
405
|
-
let
|
|
406
|
-
const
|
|
294
|
+
r.element.querySelectorAll(".error-text").forEach((l) => l.remove());
|
|
295
|
+
for (const l in f) {
|
|
296
|
+
let d = function(h, b, g) {
|
|
297
|
+
const v = r.element.querySelector(`[form-field="${l}"]`), F = [...r.element.querySelectorAll("[form-field]")].indexOf(v), q = (w) => `<p class="error-text" name="${l}" index="${F}">${a} - ${k[t.locale][w]}</p>`;
|
|
407
298
|
switch (b) {
|
|
408
299
|
case "underField":
|
|
409
|
-
if (!
|
|
410
|
-
|
|
300
|
+
if (!t.errorText.underField) return;
|
|
301
|
+
g.append(A(q(h)));
|
|
411
302
|
break;
|
|
412
303
|
case "detail":
|
|
413
|
-
if (!
|
|
414
|
-
|
|
304
|
+
if (!g) return;
|
|
305
|
+
g.append(A(q(h)));
|
|
415
306
|
break;
|
|
416
307
|
}
|
|
417
|
-
},
|
|
418
|
-
const
|
|
419
|
-
[...
|
|
420
|
-
const b = [...
|
|
421
|
-
|
|
308
|
+
}, L = function() {
|
|
309
|
+
const h = r.detailOutputEl.querySelectorAll(".error-text");
|
|
310
|
+
[...h].length > 0 ? r.element.classList.add("something-wrong") : r.element.classList.remove("something-wrong");
|
|
311
|
+
const b = [...h].sort((g, v) => g.getAttribute("index") - v.getAttribute("index"));
|
|
312
|
+
r.detailOutputEl && (r.detailOutputEl.textContent = ""), b.forEach((g) => r.detailOutputEl?.appendChild(g));
|
|
422
313
|
};
|
|
423
|
-
const
|
|
424
|
-
let
|
|
425
|
-
if (
|
|
426
|
-
switch (
|
|
314
|
+
const o = r.element.querySelector(`[form-field="${l}"]`), n = o.closest(".form-group"), a = n.querySelector(".subject")?.textContent, i = o.getAttribute("data-verify"), s = () => typeof c[l] == "object" && !Array.isArray(c[l]) ? i === "file" ? c[l] : c[l].value : c[l], m = () => i === "file" ? s() === void 0 ? !0 : s() && s().length === 0 : Array.isArray(s()) && s().length === 0 || !Array.isArray(s()) && S.isEmpty(s()), E = () => i === "file" ? s() === void 0 ? !1 : s() && s().length > 0 : Array.isArray(s()) && s().length > 0 || !Array.isArray(s()) && !S.isEmpty(s()), x = n.classList.contains("required");
|
|
315
|
+
let p;
|
|
316
|
+
if (x && m())
|
|
317
|
+
switch (o.classList.remove("success"), o.classList.add("error"), n.classList.add("error"), i) {
|
|
427
318
|
case "select":
|
|
428
|
-
|
|
319
|
+
p = o.querySelector(".validation-icon"), p.setAttribute("error-text", k[t.locale].select), d("select", "underField", n.parentNode), d("select", "detail", r.detailOutputEl);
|
|
429
320
|
break;
|
|
430
321
|
case "radio":
|
|
431
322
|
case "checkbox":
|
|
432
|
-
|
|
323
|
+
p = n.querySelector(".validation-icon"), p.setAttribute("error-text", k[t.locale].select), d("select", "underField", n.parentNode), d("select", "detail", r.detailOutputEl);
|
|
433
324
|
break;
|
|
434
325
|
case "file":
|
|
435
|
-
|
|
326
|
+
p = o.closest(".file-wrap").querySelector(".validation-icon"), p.setAttribute("error-text", k[t.locale].file), d("file", "underField", n.parentNode), d("file", "detail", r.detailOutputEl);
|
|
436
327
|
break;
|
|
437
328
|
default:
|
|
438
|
-
|
|
329
|
+
p = o.closest(".input-wrap").querySelector(".validation-icon"), p.setAttribute("error-text", k[t.locale].input), d("input", "underField", n.parentNode), d("input", "detail", r.detailOutputEl);
|
|
439
330
|
break;
|
|
440
331
|
}
|
|
441
|
-
if (
|
|
442
|
-
let
|
|
443
|
-
const
|
|
444
|
-
b.classList.toggle("error", !
|
|
445
|
-
const
|
|
446
|
-
|
|
332
|
+
if (E()) {
|
|
333
|
+
let h = function(b, g) {
|
|
334
|
+
const v = b.closest(".form-group");
|
|
335
|
+
b.classList.toggle("error", !g), b.classList.toggle("success", g);
|
|
336
|
+
const q = b.getAttribute("data-verify") === "phone" ? v.querySelector("*:not(input)[form-field]") : v.querySelector("*:not(dropdown-el)[form-field]"), w = !!q, O = b.classList.contains("success"), I = b.classList.contains("error"), V = q?.classList.contains("success"), T = q?.classList.contains("error");
|
|
337
|
+
w ? V && !T && O ? (v.classList.remove("error"), v.classList.add("success")) : (T || I) && (v.classList.remove("success"), v.classList.add("error")) : O ? (v.classList.remove("error"), v.classList.add("success")) : (v.classList.add("error"), v.classList.remove("success"));
|
|
447
338
|
};
|
|
448
339
|
switch (i) {
|
|
449
340
|
case "phone":
|
|
450
|
-
const b =
|
|
451
|
-
|
|
341
|
+
const b = n.querySelector("dropdown-el");
|
|
342
|
+
S.isMobilePhone(s()) ? (h(o, !0), b && b.classList.contains("success") && (n.classList.remove("error"), n.classList.add("success"))) : (h(o, !1), p = o.closest(".input-wrap").querySelector(".validation-icon"), p.setAttribute("error-text", k[t.locale].format), d("format", "underField", n.parentNode), d("format", "detail", r.detailOutputEl));
|
|
452
343
|
break;
|
|
453
344
|
case "password":
|
|
454
|
-
|
|
345
|
+
S.isStrongPassword(s(), {
|
|
455
346
|
minLength: 8,
|
|
456
347
|
minLowercase: 1,
|
|
457
348
|
minUppercase: 0,
|
|
458
349
|
minNumbers: 1,
|
|
459
350
|
minSymbols: 0
|
|
460
|
-
}) ?
|
|
351
|
+
}) ? h(o, !0) : (h(o, !1), p = o.closest(".input-wrap").querySelector(".validation-icon"), p.setAttribute("error-text", k[t.locale].format), d("format", "underField", n.parentNode), d("format", "detail", r.detailOutputEl));
|
|
461
352
|
break;
|
|
462
353
|
case "email":
|
|
463
|
-
|
|
354
|
+
S.isEmail(s()) ? h(o, !0) : (h(o, !1), p = o.closest(".input-wrap").querySelector(".validation-icon"), p.setAttribute("error-text", k[t.locale].format), d("format", "underField", n.parentNode), d("format", "detail", r.detailOutputEl));
|
|
464
355
|
break;
|
|
465
356
|
case "verifyCode":
|
|
466
|
-
|
|
357
|
+
S.isNumeric(s(), { no_symbols: !0 }) && S.isLength(s(), { min: 4, max: 4 }) ? h(o, !0) : (h(o, !1), p = o.closest(".input-wrap").querySelector(".validation-icon"), p.setAttribute("error-text", k[t.locale].format), d("format", "underField", n.parentNode), d("format", "detail", r.detailOutputEl));
|
|
467
358
|
break;
|
|
468
359
|
default:
|
|
469
|
-
|
|
360
|
+
h(o, !0);
|
|
470
361
|
break;
|
|
471
362
|
}
|
|
472
363
|
}
|
|
473
|
-
|
|
364
|
+
r.detailOutputEl && L();
|
|
474
365
|
}
|
|
475
366
|
}
|
|
476
367
|
/**
|
|
@@ -484,64 +375,66 @@ class ee {
|
|
|
484
375
|
* 清除表單所有欄位
|
|
485
376
|
*/
|
|
486
377
|
clear() {
|
|
487
|
-
const e = this, { allInput:
|
|
488
|
-
[...e.allField].forEach((
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
}), [...
|
|
492
|
-
|
|
493
|
-
}), [...
|
|
494
|
-
|
|
495
|
-
}), [...
|
|
496
|
-
|
|
497
|
-
}), [...
|
|
498
|
-
let
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
}), [...
|
|
502
|
-
|
|
503
|
-
document.querySelector(
|
|
378
|
+
const e = this, { allInput: r, allTextarea: t, allCheckbox: c, allFileUpload: f, allDropdown: u } = e;
|
|
379
|
+
[...e.allField].forEach((l) => {
|
|
380
|
+
const o = l.closest(".form-group");
|
|
381
|
+
o.classList.remove("success"), o.classList.remove("error"), l.classList.remove("success"), l.classList.remove("error"), l.closest(".form-grid").querySelector(".error-text")?.remove(), e.detailOutputEl && (e.detailOutputEl.textContent = "");
|
|
382
|
+
}), [...r].forEach((l) => {
|
|
383
|
+
l.value = "";
|
|
384
|
+
}), [...t].forEach((l) => {
|
|
385
|
+
l.value = "";
|
|
386
|
+
}), [...c].forEach((l) => {
|
|
387
|
+
l.checked = !1;
|
|
388
|
+
}), [...f].forEach((l) => {
|
|
389
|
+
let o = l.getAttribute("data-default");
|
|
390
|
+
const n = l.querySelector(".file-name"), a = l.closest(".file-wrap").querySelector('input[type="file"]');
|
|
391
|
+
n.classList.remove("is-upload"), n.textContent = o, a && (a.value = "");
|
|
392
|
+
}), [...u].forEach((l) => {
|
|
393
|
+
l.setAttribute("d4-value", ""), l.hasAttribute("control-elements") && [...l.getAttribute("control-elements").split(",")].forEach((n) => {
|
|
394
|
+
document.querySelector(n).classList.remove("disabled");
|
|
504
395
|
});
|
|
505
396
|
}), e.element.value = e.getValue();
|
|
506
397
|
}
|
|
507
398
|
}
|
|
508
399
|
export {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
400
|
+
H as CustomForm,
|
|
401
|
+
_ as ajaxUpdate,
|
|
402
|
+
K as appleDebug,
|
|
403
|
+
Q as bodyScrollbarInit,
|
|
404
|
+
J as cgpagechange,
|
|
405
|
+
Z as clickEvent,
|
|
406
|
+
ee as clickSwitchClass,
|
|
407
|
+
te as clickToggleClass,
|
|
408
|
+
C as colorPick,
|
|
409
|
+
re as countDown,
|
|
410
|
+
G as createColorCube,
|
|
411
|
+
$ as debounce,
|
|
412
|
+
oe as delay,
|
|
413
|
+
se as detectMacOSVersion,
|
|
522
414
|
B as detectShade,
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
415
|
+
W as errorPage,
|
|
416
|
+
k as errorText,
|
|
417
|
+
le as fixMobile100vh,
|
|
418
|
+
ie as formatFloat,
|
|
419
|
+
ae as getHrefLink,
|
|
420
|
+
ce as getSlideDataIndex,
|
|
421
|
+
ne as getSlidesCount,
|
|
422
|
+
ue as getTransformX,
|
|
423
|
+
de as getTransformY,
|
|
424
|
+
A as htmlStringToDOM,
|
|
425
|
+
fe as imagePreview,
|
|
426
|
+
R as init,
|
|
427
|
+
pe as isVideo,
|
|
428
|
+
me as letterGrow,
|
|
429
|
+
ye as loaded,
|
|
430
|
+
he as loading,
|
|
431
|
+
ve as numberGrow,
|
|
432
|
+
be as scrollLock,
|
|
433
|
+
ge as scrollUnlock,
|
|
434
|
+
Se as sleep,
|
|
435
|
+
ke as slideImgDetect,
|
|
436
|
+
xe as tabChange,
|
|
437
|
+
Ee as throttle,
|
|
438
|
+
Ae as wordAnimation
|
|
546
439
|
};
|
|
547
440
|
//# sourceMappingURL=tools-bundle.js.map
|