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