domquery-com 1.0.0
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/LICENSE +22 -0
- package/README.ko.md +273 -0
- package/README.md +272 -0
- package/domquery.js +6290 -0
- package/domquery.min.js +361 -0
- package/package.json +53 -0
- package/src/Kcolor.js +909 -0
- package/src/ajax.js +1220 -0
- package/src/alert.js +3516 -0
- package/src/animate.js +1775 -0
- package/src/lazyLoadImages.js +202 -0
- package/src/pulling.js +473 -0
- package/src/select.js +3154 -0
- package/src_min/Kcolor.min.js +45 -0
- package/src_min/ajax.min.js +61 -0
- package/src_min/alert.min.js +240 -0
- package/src_min/animate.min.js +118 -0
- package/src_min/lazyLoadImages.min.js +13 -0
- package/src_min/pulling.min.js +23 -0
- package/src_min/select.min.js +186 -0
package/src/Kcolor.js
ADDED
|
@@ -0,0 +1,909 @@
|
|
|
1
|
+
$.Kcolor = function(H, y, g) {
|
|
2
|
+
function T() {
|
|
3
|
+
function a(b) {
|
|
4
|
+
b && (b.setAttribute("title", ""), b.removeAttribute("title"), b.style.webkitTouchCallout = "none", b.style.webkitUserSelect = "none", b.style.webkitTapHighlightColor = "rgba(0,0,0,0)", b.style.outline = "none", "INPUT" === b.tagName && (b.style.webkitUserSelect = "text", b.style.userSelect = "text"), Array.from(b.children).forEach(c => {
|
|
5
|
+
a(c)
|
|
6
|
+
}))
|
|
7
|
+
}
|
|
8
|
+
a(e);
|
|
9
|
+
a(l);
|
|
10
|
+
e.addEventListener("mouseover", function(b) {
|
|
11
|
+
b.target && b.target.removeAttribute("title")
|
|
12
|
+
}, !0)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function G() {
|
|
16
|
+
if ("undefined" !==
|
|
17
|
+
typeof $ && $.isMobile) {
|
|
18
|
+
const a = $.isMobile();
|
|
19
|
+
return !0 === a.isMobile || !0 === a.isTablet
|
|
20
|
+
}
|
|
21
|
+
return !1
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function fa(a) {
|
|
25
|
+
return "number" === typeof a ? a : "object" === typeof a && null !== a ? G() ? a.mobile || 300 : a.pc || 300 : 300
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function qa(a) {
|
|
29
|
+
return "number" === typeof a ? a : "object" === typeof a && null !== a ? G() ? a.mobile || 0 : a.pc || 0 : 0
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function za(a) {
|
|
33
|
+
const b = [];
|
|
34
|
+
for (a = a && a.parentElement; a;) {
|
|
35
|
+
const c = window.getComputedStyle(a).overflowY;
|
|
36
|
+
("auto" === c || "scroll" === c) && a.scrollHeight > a.clientHeight && b.push(a);
|
|
37
|
+
a = a.parentElement
|
|
38
|
+
}
|
|
39
|
+
return b
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function ra(a) {
|
|
43
|
+
if (a &&
|
|
44
|
+
"function" === typeof a.focus) {
|
|
45
|
+
var b = window.pageYOffset || document.documentElement.scrollTop || 0,
|
|
46
|
+
c = window.pageXOffset || document.documentElement.scrollLeft || 0,
|
|
47
|
+
f = za(a).map(k => ({
|
|
48
|
+
el: k,
|
|
49
|
+
top: k.scrollTop,
|
|
50
|
+
left: k.scrollLeft
|
|
51
|
+
}));
|
|
52
|
+
try {
|
|
53
|
+
a.focus({
|
|
54
|
+
preventScroll: !0
|
|
55
|
+
})
|
|
56
|
+
} catch (k) {
|
|
57
|
+
a.focus()
|
|
58
|
+
}
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
window.scrollTo(c, b);
|
|
61
|
+
f.forEach(({
|
|
62
|
+
el: k,
|
|
63
|
+
top: m,
|
|
64
|
+
left: n
|
|
65
|
+
}) => {
|
|
66
|
+
k.scrollTop = m;
|
|
67
|
+
k.scrollLeft = n
|
|
68
|
+
})
|
|
69
|
+
}, 0)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function ha() {
|
|
74
|
+
console.log("Kcolor: clearColor \ud638\ucd9c - \ud3ec\uc778\ud130 \uc81c\uac70 \ubaa8\ub4dc");
|
|
75
|
+
r = !0;
|
|
76
|
+
p.style.display = "none";
|
|
77
|
+
v.value = 0;
|
|
78
|
+
w.value = 0;
|
|
79
|
+
x.value = 0;
|
|
80
|
+
t.value = "";
|
|
81
|
+
p.style.left = "50%";
|
|
82
|
+
p.style.top = "50%";
|
|
83
|
+
C = D = .5;
|
|
84
|
+
U()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function Aa() {
|
|
88
|
+
sa.innerHTML = "";
|
|
89
|
+
ta.forEach((a, b) => {
|
|
90
|
+
const c = document.createElement("div");
|
|
91
|
+
c.setAttribute("tabindex", "0");
|
|
92
|
+
c.setAttribute("title", "");
|
|
93
|
+
c.removeAttribute("title");
|
|
94
|
+
c.style.webkitTouchCallout = "none";
|
|
95
|
+
c.style.webkitUserSelect = "none";
|
|
96
|
+
c.style.webkitTapHighlightColor = "rgba(0,0,0,0)";
|
|
97
|
+
c.style.outline = "none";
|
|
98
|
+
b === ta.length - 1 ? (c.className = "fixed-color cancel-color", c.addEventListener("click", function(f) {
|
|
99
|
+
f.preventDefault();
|
|
100
|
+
f.stopPropagation();
|
|
101
|
+
ha();
|
|
102
|
+
G() && h.keepKeyboard && setTimeout(() => z.focus(), 0);
|
|
103
|
+
this.focus()
|
|
104
|
+
}, !1)) : (c.className = "fixed-color", c.style.backgroundColor = a, c.setAttribute("data-color", a), c.addEventListener("click", function(f) {
|
|
105
|
+
f.preventDefault();
|
|
106
|
+
f.stopPropagation();
|
|
107
|
+
f = this.getAttribute("data-color");
|
|
108
|
+
ia(f);
|
|
109
|
+
G() && h.keepKeyboard && setTimeout(() => z.focus(), 0);
|
|
110
|
+
this.focus()
|
|
111
|
+
}, !1));
|
|
112
|
+
sa.appendChild(c)
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function ja() {
|
|
117
|
+
ka.innerHTML = "";
|
|
118
|
+
for (var a = 0; 6 > a; a++) {
|
|
119
|
+
var b = document.createElement("div");
|
|
120
|
+
b.setAttribute("tabindex", "0");
|
|
121
|
+
b.setAttribute("title", "");
|
|
122
|
+
b.removeAttribute("title");
|
|
123
|
+
b.style.webkitTouchCallout = "none";
|
|
124
|
+
b.style.webkitUserSelect = "none";
|
|
125
|
+
b.style.webkitTapHighlightColor = "rgba(0,0,0,0)";
|
|
126
|
+
b.style.outline = "none";
|
|
127
|
+
if (5 === a) b.className = "recent-color reset-color", b.style.backgroundColor = "white", b.style.position = "relative", b.addEventListener("click", function(c) {
|
|
128
|
+
c.preventDefault();
|
|
129
|
+
c.stopPropagation();
|
|
130
|
+
try {
|
|
131
|
+
localStorage.removeItem("kcolor_recent_colors")
|
|
132
|
+
} catch (f) {
|
|
133
|
+
console.warn("Kcolor: \ub85c\uceec \uc2a4\ud1a0\ub9ac\uc9c0 \uc811\uadfc \uc624\ub958")
|
|
134
|
+
}
|
|
135
|
+
A = [];
|
|
136
|
+
ja();
|
|
137
|
+
ha()
|
|
138
|
+
}, !1);
|
|
139
|
+
else if (a < A.length) {
|
|
140
|
+
const c = A[a];
|
|
141
|
+
b.className = "recent-color filled";
|
|
142
|
+
"" === c ? (b.style.backgroundColor = "white", b.style.backgroundImage = "repeating-linear-gradient(45deg, #ccc, #ccc 5px, #fff 5px, #fff 10px)", b.setAttribute("data-color", "")) : (b.style.backgroundColor = c, b.style.backgroundImage = "none", b.setAttribute("data-color", c));
|
|
143
|
+
b.addEventListener("click", function(f) {
|
|
144
|
+
f.preventDefault();
|
|
145
|
+
f.stopPropagation();
|
|
146
|
+
f = this.getAttribute("data-color");
|
|
147
|
+
"" === f ? ha() : (ia(f), G() && h.keepKeyboard && setTimeout(() =>
|
|
148
|
+
z.focus(), 0), this.focus())
|
|
149
|
+
}, !1)
|
|
150
|
+
} else b.className = "recent-color", b.style.backgroundColor = "#ffffff";
|
|
151
|
+
ka.appendChild(b)
|
|
152
|
+
}
|
|
153
|
+
if (a = ka.querySelector(".reset-color")) b = document.createElement("div"), b.style.position = "absolute", b.style.top = "0", b.style.left = "0", b.style.width = "100%", b.style.height = "100%", b.style.background = "linear-gradient(to bottom right, transparent 45%, #ccc 45%, #ccc 55%, transparent 55%)", b.style.borderRadius = "10px", a.appendChild(b)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function la(a) {
|
|
157
|
+
const b = A.indexOf(a); - 1 !== b && A.splice(b, 1);
|
|
158
|
+
A.unshift(a);
|
|
159
|
+
6 < A.length && A.pop();
|
|
160
|
+
try {
|
|
161
|
+
localStorage.setItem("kcolor_recent_colors", JSON.stringify(A))
|
|
162
|
+
} catch (c) {
|
|
163
|
+
console.warn("Kcolor: \ub85c\uceec \uc2a4\ud1a0\ub9ac\uc9c0 \uc800\uc7a5 \uc624\ub958")
|
|
164
|
+
}
|
|
165
|
+
ja()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function ua(a, b, c) {
|
|
169
|
+
let f, k, m, n = Math.floor(a / 60) % 6,
|
|
170
|
+
V = a / 60 - n;
|
|
171
|
+
a = c * (1 - b);
|
|
172
|
+
let I = c * (1 - V * b);
|
|
173
|
+
b = c * (1 - (1 - V) * b);
|
|
174
|
+
switch (n) {
|
|
175
|
+
case 0:
|
|
176
|
+
f = c;
|
|
177
|
+
k = b;
|
|
178
|
+
m = a;
|
|
179
|
+
break;
|
|
180
|
+
case 1:
|
|
181
|
+
f = I;
|
|
182
|
+
k = c;
|
|
183
|
+
m = a;
|
|
184
|
+
break;
|
|
185
|
+
case 2:
|
|
186
|
+
f = a;
|
|
187
|
+
k = c;
|
|
188
|
+
m = b;
|
|
189
|
+
break;
|
|
190
|
+
case 3:
|
|
191
|
+
f = a;
|
|
192
|
+
k = I;
|
|
193
|
+
m = c;
|
|
194
|
+
break;
|
|
195
|
+
case 4:
|
|
196
|
+
f = b;
|
|
197
|
+
k = a;
|
|
198
|
+
m = c;
|
|
199
|
+
break;
|
|
200
|
+
case 5:
|
|
201
|
+
f = c, k = a, m = I
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
r: Math.round(255 * f),
|
|
205
|
+
g: Math.round(255 *
|
|
206
|
+
k),
|
|
207
|
+
b: Math.round(255 * m)
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function J(a, b, c) {
|
|
212
|
+
a = Math.max(0, Math.min(255, Math.round(a)));
|
|
213
|
+
b = Math.max(0, Math.min(255, Math.round(b)));
|
|
214
|
+
c = Math.max(0, Math.min(255, Math.round(c)));
|
|
215
|
+
return "#" + a.toString(16).padStart(2, "0") + b.toString(16).padStart(2, "0") + c.toString(16).padStart(2, "0")
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function ma(a) {
|
|
219
|
+
if ("transparent" === a) return {
|
|
220
|
+
r: 0,
|
|
221
|
+
g: 0,
|
|
222
|
+
b: 0,
|
|
223
|
+
a: 0
|
|
224
|
+
};
|
|
225
|
+
a = a.replace("#", "");
|
|
226
|
+
3 === a.length && (a = a[0] + a[0] + a[1] + a[1] + a[2] + a[2]);
|
|
227
|
+
if (!/^[0-9A-Fa-f]{6}$/.test(a)) return {
|
|
228
|
+
r: 0,
|
|
229
|
+
g: 0,
|
|
230
|
+
b: 0
|
|
231
|
+
};
|
|
232
|
+
try {
|
|
233
|
+
return {
|
|
234
|
+
r: parseInt(a.substring(0, 2), 16),
|
|
235
|
+
g: parseInt(a.substring(2,
|
|
236
|
+
4), 16),
|
|
237
|
+
b: parseInt(a.substring(4, 6), 16)
|
|
238
|
+
}
|
|
239
|
+
} catch (b) {
|
|
240
|
+
return console.warn("Kcolor: \uc0c9\uc0c1 \ubcc0\ud658 \uc624\ub958", b), {
|
|
241
|
+
r: 0,
|
|
242
|
+
g: 0,
|
|
243
|
+
b: 0
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function na(a, b, c) {
|
|
249
|
+
a /= 255;
|
|
250
|
+
b /= 255;
|
|
251
|
+
c /= 255;
|
|
252
|
+
const f = Math.max(a, b, c),
|
|
253
|
+
k = Math.min(a, b, c);
|
|
254
|
+
let m;
|
|
255
|
+
const n = f - k;
|
|
256
|
+
if (f === k) m = 0;
|
|
257
|
+
else {
|
|
258
|
+
switch (f) {
|
|
259
|
+
case a:
|
|
260
|
+
m = (b - c) / n + (b < c ? 6 : 0);
|
|
261
|
+
break;
|
|
262
|
+
case b:
|
|
263
|
+
m = (c - a) / n + 2;
|
|
264
|
+
break;
|
|
265
|
+
case c:
|
|
266
|
+
m = (a - b) / n + 4
|
|
267
|
+
}
|
|
268
|
+
m /= 6
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
h: Math.round(360 * m),
|
|
272
|
+
s: 0 === f ? 0 : n / f,
|
|
273
|
+
v: f
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function P() {
|
|
278
|
+
var a = ua(E, 1, 1);
|
|
279
|
+
a = J(a.r, a.g, a.b);
|
|
280
|
+
W.style.backgroundImage = `\n\t\tlinear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,1)),\n\t\tlinear-gradient(to right, rgba(255,255,255,1), ${a})\n\t\t`
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function Ba(a, b, c) {
|
|
284
|
+
const [f, k, m] = [a, b, c].map(n => {
|
|
285
|
+
n /= 255;
|
|
286
|
+
return .03928 >= n ? n / 12.92 : Math.pow((n + .055) / 1.055, 2.4)
|
|
287
|
+
});
|
|
288
|
+
return .2126 * f + .7152 * k + .0722 * m
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function K(a) {
|
|
292
|
+
r || "transparent" === a || "" === a ? u.classList.add("light-background") : (a = ma(a), .5 < Ba(a.r, a.g, a.b) ? u.classList.add("light-background") : u.classList.remove("light-background"))
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function U() {
|
|
296
|
+
const a = ua(E, D, C),
|
|
297
|
+
b = J(a.r, a.g, a.b);
|
|
298
|
+
r ? (u.style.backgroundColor = "transparent", u.style.backgroundImage = "repeating-linear-gradient(45deg, #ccc, #ccc 5px, #fff 5px, #fff 10px)") :
|
|
299
|
+
(u.style.backgroundColor = b, u.style.backgroundImage = "none");
|
|
300
|
+
v.value = a.r;
|
|
301
|
+
w.value = a.g;
|
|
302
|
+
x.value = a.b;
|
|
303
|
+
t.value = b.toUpperCase();
|
|
304
|
+
r || (p.style.backgroundColor = b);
|
|
305
|
+
K(b)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function X(a) {
|
|
309
|
+
a && a.preventDefault && a.preventDefault();
|
|
310
|
+
r && (r = !1, p.style.display = "block");
|
|
311
|
+
var b = W.getBoundingClientRect();
|
|
312
|
+
if (a.type.startsWith("touch")) {
|
|
313
|
+
var c = a.touches[0].clientX - b.left;
|
|
314
|
+
a = a.touches[0].clientY - b.top
|
|
315
|
+
} else c = a.clientX - b.left, a = a.clientY - b.top;
|
|
316
|
+
c = Math.max(0, Math.min(b.width, c));
|
|
317
|
+
a = Math.max(0, Math.min(b.height, a));
|
|
318
|
+
c /= b.width;
|
|
319
|
+
b = 1 - a / b.height;
|
|
320
|
+
D = c;
|
|
321
|
+
C = b;
|
|
322
|
+
p.style.left = `${100*c}%`;
|
|
323
|
+
p.style.top = `${100*(1-b)}%`;
|
|
324
|
+
U()
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function Y(a) {
|
|
328
|
+
a && a.preventDefault && a.preventDefault();
|
|
329
|
+
r && (r = !1, p.style.display = "block");
|
|
330
|
+
var b = oa.getBoundingClientRect();
|
|
331
|
+
a = a.type.startsWith("touch") ? a.touches[0].clientX - b.left : a.clientX - b.left;
|
|
332
|
+
a = Math.max(0, Math.min(b.width, a));
|
|
333
|
+
b = a / b.width;
|
|
334
|
+
E = 360 * b;
|
|
335
|
+
Q.style.left = `${100*b}%`;
|
|
336
|
+
P();
|
|
337
|
+
U()
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function Z() {
|
|
341
|
+
r && (r = !1, p.style.display = "block");
|
|
342
|
+
var a = parseInt(v.value) || 0;
|
|
343
|
+
let b = parseInt(w.value) || 0,
|
|
344
|
+
c = parseInt(x.value) || 0;
|
|
345
|
+
a = Math.max(0, Math.min(255, a));
|
|
346
|
+
b = Math.max(0, Math.min(255, b));
|
|
347
|
+
c = Math.max(0, Math.min(255, c));
|
|
348
|
+
v.value = a;
|
|
349
|
+
w.value = b;
|
|
350
|
+
x.value = c;
|
|
351
|
+
const f = J(a, b, c);
|
|
352
|
+
t.value = f.toUpperCase();
|
|
353
|
+
a = na(a, b, c);
|
|
354
|
+
E = a.h;
|
|
355
|
+
D = a.s;
|
|
356
|
+
C = a.v;
|
|
357
|
+
Q.style.left = `${E/360*100}%`;
|
|
358
|
+
P();
|
|
359
|
+
p.style.left = `${100*D}%`;
|
|
360
|
+
p.style.top = `${100*(1-C)}%`;
|
|
361
|
+
u.style.backgroundColor = f;
|
|
362
|
+
p.style.backgroundColor = f;
|
|
363
|
+
K(f)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function va() {
|
|
367
|
+
r && (r = !1, p.style.display = "block");
|
|
368
|
+
let a = t.value;
|
|
369
|
+
a.startsWith("#") || (a = "#" + a);
|
|
370
|
+
if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(a)) {
|
|
371
|
+
var b = ma(a);
|
|
372
|
+
v.value = b.r;
|
|
373
|
+
w.value = b.g;
|
|
374
|
+
x.value = b.b;
|
|
375
|
+
b = na(b.r, b.g, b.b);
|
|
376
|
+
E =
|
|
377
|
+
b.h;
|
|
378
|
+
D = b.s;
|
|
379
|
+
C = b.v;
|
|
380
|
+
Q.style.left = `${E/360*100}%`;
|
|
381
|
+
P();
|
|
382
|
+
p.style.left = `${100*D}%`;
|
|
383
|
+
p.style.top = `${100*(1-C)}%`;
|
|
384
|
+
u.style.backgroundColor = a;
|
|
385
|
+
p.style.backgroundColor = a;
|
|
386
|
+
t.value = a.toUpperCase();
|
|
387
|
+
K(a)
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function ia(a) {
|
|
392
|
+
r && "" !== a && "transparent" !== a && (r = !1, p.style.display = "block");
|
|
393
|
+
if ("transparent" === a || "" === a) v.value = 0, w.value = 0, x.value = 0, t.value = "" === a ? "" : "transparent", u.style.backgroundColor = "" === a ? "#ffffff" : "transparent", u.style.backgroundImage = "repeating-linear-gradient(45deg, #ccc, #ccc 5px, #fff 5px, #fff 10px)",
|
|
394
|
+
u.style.color = "#000000";
|
|
395
|
+
else {
|
|
396
|
+
u.style.backgroundImage = "none";
|
|
397
|
+
var b = ma(a);
|
|
398
|
+
v.value = b.r;
|
|
399
|
+
w.value = b.g;
|
|
400
|
+
x.value = b.b;
|
|
401
|
+
t.value = a.toUpperCase();
|
|
402
|
+
b = na(b.r, b.g, b.b);
|
|
403
|
+
E = b.h;
|
|
404
|
+
D = b.s;
|
|
405
|
+
C = b.v;
|
|
406
|
+
Q.style.left = `${E/360*100}%`;
|
|
407
|
+
P();
|
|
408
|
+
p.style.left = `${100*D}%`;
|
|
409
|
+
p.style.top = `${100*(1-C)}%`;
|
|
410
|
+
u.style.backgroundColor = a;
|
|
411
|
+
p.style.backgroundColor = a
|
|
412
|
+
}
|
|
413
|
+
K(a)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function Ca(a = t.value) {
|
|
417
|
+
console.log("Kcolor: applySelectedColor \ud638\ucd9c", {
|
|
418
|
+
hex: a,
|
|
419
|
+
hexInputValue: t.value,
|
|
420
|
+
isPointerRemoved: r
|
|
421
|
+
});
|
|
422
|
+
if (r) {
|
|
423
|
+
var b = t.value.trim();
|
|
424
|
+
b && "" !== b && "transparent" !== b || (a = "")
|
|
425
|
+
}
|
|
426
|
+
"transparent" ===
|
|
427
|
+
a ? ("INPUT" === d.tagName ? d.value = "transparent" : d.style.backgroundColor = "transparent", la("transparent"), R(!0), "function" === typeof y && y.call(d, "transparent")) : "" === a ? ("INPUT" === d.tagName ? d.value = "" : d.style.backgroundColor = "", la(""), R(!0), "function" === typeof y && y.call(d, "")) : ("INPUT" === d.tagName ? (d.value = a, b = new Event("change"), d.dispatchEvent(b)) : d.style.backgroundColor = a, d._kcolorUserSelected = !0, B = a, la(a), R(!0), "function" === typeof y && y.call(d, a))
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function Da() {
|
|
431
|
+
if ("INPUT" === d.tagName) B = d.value || "";
|
|
432
|
+
else if (B =
|
|
433
|
+
window.getComputedStyle(d).backgroundColor, "transparent" === B || "rgba(0, 0, 0, 0)" === B) B = "transparent";
|
|
434
|
+
else {
|
|
435
|
+
var a = B.match(/\d+/g);
|
|
436
|
+
if (a && 3 <= a.length) {
|
|
437
|
+
const b = parseInt(a[0]),
|
|
438
|
+
c = parseInt(a[1]);
|
|
439
|
+
a = parseInt(a[2]);
|
|
440
|
+
B = J(b, c, a)
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function L(a) {
|
|
446
|
+
a && a.preventDefault && a.preventDefault();
|
|
447
|
+
d.hasAttribute("data-kcolor") && "true" === d.getAttribute("data-kcolor") && (d._kcolorActive = !1);
|
|
448
|
+
e.parentNode ? "none" === e.style.display && (e.style.display = "block", !1 !== h.overlay && (l.style.display = "block")) : (!1 !== h.overlay && document.body.appendChild(l),
|
|
449
|
+
document.body.appendChild(e));
|
|
450
|
+
l._kcolorEventAdded || (l.addEventListener("click", function(m) {
|
|
451
|
+
m.target === l && (R(), m = fa(h.closeDuration), setTimeout(() => {
|
|
452
|
+
if (d && "function" === typeof d.focus && (d.focus(), "INPUT" === d.tagName && "text" === d.type)) {
|
|
453
|
+
const n = d.value.length;
|
|
454
|
+
d.setSelectionRange(n, n)
|
|
455
|
+
}
|
|
456
|
+
}, m))
|
|
457
|
+
}), l._kcolorEventAdded = !0);
|
|
458
|
+
h.onOpen();
|
|
459
|
+
var b = fa(h.openDuration) / 1E3 + "s";
|
|
460
|
+
e.style.transition = `transform ${b} ease, opacity ${b} ease`;
|
|
461
|
+
!1 !== h.overlay && (l.style.transition = `opacity ${b} ease`);
|
|
462
|
+
Da();
|
|
463
|
+
r = !1;
|
|
464
|
+
p.style.display = "block";
|
|
465
|
+
Aa();
|
|
466
|
+
ja();
|
|
467
|
+
var c = null;
|
|
468
|
+
if (!0 !== d._kcolorUserSelected && H) c = H;
|
|
469
|
+
else if ("INPUT" === d.tagName && d.value) c = d.value;
|
|
470
|
+
else if (b = window.getComputedStyle(d).backgroundColor, "transparent" !== b && "rgba(0, 0, 0, 0)" !== b && (b = b.match(/\d+/g)) && 3 <= b.length) {
|
|
471
|
+
c = parseInt(b[0]);
|
|
472
|
+
var f = parseInt(b[1]);
|
|
473
|
+
b = parseInt(b[2]);
|
|
474
|
+
c = J(c, f, b)
|
|
475
|
+
}
|
|
476
|
+
c || (c = H || "#FFFFFF");
|
|
477
|
+
c ? ia(c) : K("#FFFFFF");
|
|
478
|
+
if (G()) {
|
|
479
|
+
!1 !== h.overlay && (l.style.display = "block", l.style.opacity = "0");
|
|
480
|
+
let m = 0;
|
|
481
|
+
h.preserveScroll && "auto" === h.mobileMode && (m = window.pageYOffset || document.documentElement.scrollTop ||
|
|
482
|
+
0);
|
|
483
|
+
a = d.getBoundingClientRect();
|
|
484
|
+
const n = a.top,
|
|
485
|
+
V = a.left;
|
|
486
|
+
e.style.display = "block";
|
|
487
|
+
e.style.position = "absolute";
|
|
488
|
+
e.style.width = "262px";
|
|
489
|
+
e.style.maxWidth = "400px";
|
|
490
|
+
I();
|
|
491
|
+
requestAnimationFrame(() => {
|
|
492
|
+
!1 !== h.overlay && (l.style.opacity = "1");
|
|
493
|
+
e.classList.add("active");
|
|
494
|
+
T();
|
|
495
|
+
h.keepKeyboard && setTimeout(() => z.focus(), 0);
|
|
496
|
+
h.preserveScroll && "auto" === h.mobileMode && window.scrollTo({
|
|
497
|
+
top: m,
|
|
498
|
+
left: 0,
|
|
499
|
+
behavior: "auto"
|
|
500
|
+
})
|
|
501
|
+
});
|
|
502
|
+
setTimeout(I, 150);
|
|
503
|
+
setTimeout(I, 300);
|
|
504
|
+
|
|
505
|
+
function I() {
|
|
506
|
+
const M = window.pageYOffset || document.documentElement.scrollTop,
|
|
507
|
+
aa =
|
|
508
|
+
window.pageXOffset || document.documentElement.scrollLeft;
|
|
509
|
+
let ba = null != h.anchorX ? h.anchorX : V,
|
|
510
|
+
ca = null != h.anchorY ? h.anchorY : n,
|
|
511
|
+
da = aa + ba - e.offsetWidth,
|
|
512
|
+
ea = M + ca - e.offsetHeight - 10;
|
|
513
|
+
switch (h.align) {
|
|
514
|
+
case "bottom-right":
|
|
515
|
+
da = aa + ba - e.offsetWidth;
|
|
516
|
+
ea = M + ca + 10;
|
|
517
|
+
break;
|
|
518
|
+
case "top-left":
|
|
519
|
+
da = aa + ba;
|
|
520
|
+
ea = M + ca - e.offsetHeight - 10;
|
|
521
|
+
break;
|
|
522
|
+
case "bottom-left":
|
|
523
|
+
da = aa + ba, ea = M + ca + 10
|
|
524
|
+
}
|
|
525
|
+
e.style.left = da + "px";
|
|
526
|
+
e.style.top = ea + "px";
|
|
527
|
+
0 > parseInt(e.style.left) && (e.style.left = "10px");
|
|
528
|
+
parseInt(e.style.left) + e.offsetWidth > document.documentElement.clientWidth &&
|
|
529
|
+
(e.style.left = document.documentElement.clientWidth - e.offsetWidth - 10 + "px");
|
|
530
|
+
parseInt(e.style.top) < M && (e.style.top = M + n + 40 + "px")
|
|
531
|
+
}
|
|
532
|
+
} else {
|
|
533
|
+
e.style.position = "absolute";
|
|
534
|
+
e.style.width = "245px";
|
|
535
|
+
b = window.pageXOffset || document.documentElement.scrollLeft || 0;
|
|
536
|
+
c = window.pageYOffset || document.documentElement.scrollTop || 0;
|
|
537
|
+
f = window.innerWidth || document.documentElement.clientWidth;
|
|
538
|
+
const m = window.innerHeight || document.documentElement.clientHeight;
|
|
539
|
+
if (null != h.anchorX && null != h.anchorY) {
|
|
540
|
+
switch (h.align) {
|
|
541
|
+
case "bottom-right":
|
|
542
|
+
a =
|
|
543
|
+
b + h.anchorX - 245;
|
|
544
|
+
var k = c + h.anchorY + 10;
|
|
545
|
+
break;
|
|
546
|
+
case "top-left":
|
|
547
|
+
a = b + h.anchorX;
|
|
548
|
+
k = c + h.anchorY - 250 - 10;
|
|
549
|
+
break;
|
|
550
|
+
case "bottom-left":
|
|
551
|
+
a = b + h.anchorX;
|
|
552
|
+
k = c + h.anchorY + 10;
|
|
553
|
+
break;
|
|
554
|
+
default:
|
|
555
|
+
a = b + h.anchorX - 245, k = c + h.anchorY - 250 - 10
|
|
556
|
+
}
|
|
557
|
+
a + 245 > b + f && (a = b + f - 245 - 10);
|
|
558
|
+
k + 250 > c + m && (k = c + m - 250 - 10);
|
|
559
|
+
a = Math.max(b + 10, a);
|
|
560
|
+
k = Math.max(c + 10, k);
|
|
561
|
+
e.style.left = a + "px";
|
|
562
|
+
e.style.top = k + "px"
|
|
563
|
+
} else if (a) k = a.pageX || a.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft), a = a.pageY || a.clientY + (document.documentElement.scrollTop || document.body.scrollTop),
|
|
564
|
+
k + 245 > b + f && (k = b + f - 245 - 10), a + 250 > c + m && (a = c + m - 250 - 10), k = Math.max(b + 10, k), a = Math.max(c + 10, a), e.style.left = k + "px", e.style.top = a + "px";
|
|
565
|
+
else {
|
|
566
|
+
a = d.getBoundingClientRect();
|
|
567
|
+
k = a.left + b;
|
|
568
|
+
let n = a.bottom + c + 5;
|
|
569
|
+
k + 245 > b + f && (k = b + f - 245 - 10);
|
|
570
|
+
n + 250 > c + m && (n = a.top + c - 250 - 5);
|
|
571
|
+
k = Math.max(b + 10, k);
|
|
572
|
+
n = Math.max(c + 10, n);
|
|
573
|
+
e.style.left = k + "px";
|
|
574
|
+
e.style.top = n + "px"
|
|
575
|
+
}
|
|
576
|
+
e.style.display = "block";
|
|
577
|
+
!1 !== h.overlay && (l.style.display = "block");
|
|
578
|
+
requestAnimationFrame(() => {
|
|
579
|
+
!1 !== h.overlay && (l.style.opacity = "1");
|
|
580
|
+
e.classList.add("active");
|
|
581
|
+
T()
|
|
582
|
+
})
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function R(a = !1) {
|
|
587
|
+
const b = fa(h.closeDuration),
|
|
588
|
+
c = b / 1E3 + "s";
|
|
589
|
+
e.style.transition = `transform ${c} ease, opacity ${c} ease`;
|
|
590
|
+
!1 !== h.overlay && (l.style.transition = `opacity ${c} ease`);
|
|
591
|
+
e.classList.remove("active");
|
|
592
|
+
l.style.opacity = "0";
|
|
593
|
+
if (a) h.onClose("ok");
|
|
594
|
+
else h.onClose("cancel");
|
|
595
|
+
a || ("INPUT" === d.tagName ? d.value = B : d.style.backgroundColor = B);
|
|
596
|
+
setTimeout(() => {
|
|
597
|
+
d.hasAttribute("data-kcolor") && "true" === d.getAttribute("data-kcolor") ? (e.style.display = "none", !1 !== h.overlay && (l.style.display = "none")) : (e && e.parentNode && e.parentNode.removeChild(e),
|
|
598
|
+
l && l.parentNode && l.parentNode.removeChild(l));
|
|
599
|
+
d && (d._kcolorActive = !1, d._hasColorPicker = !1, d._kcolorInitialized = !1, d._kcolorInitialColor = null);
|
|
600
|
+
if (d && "function" === typeof d.focus && (d.focus(), "INPUT" === d.tagName && "text" === d.type)) {
|
|
601
|
+
const f = d.value.length;
|
|
602
|
+
d.setSelectionRange(f, f)
|
|
603
|
+
}
|
|
604
|
+
}, b)
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function S(a, b) {
|
|
608
|
+
a.value.length > b && (a.value = a.value.slice(0, b))
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
function wa() {
|
|
612
|
+
"none" !== pa.style.display ? (pa.style.display = "none", xa.style.display = "flex") : (xa.style.display = "none", pa.style.display = "flex");
|
|
613
|
+
setTimeout(() => {
|
|
614
|
+
G() &&
|
|
615
|
+
h.keepKeyboard && z && z.focus && z.focus({
|
|
616
|
+
preventScroll: !0
|
|
617
|
+
});
|
|
618
|
+
const a = document.activeElement;
|
|
619
|
+
a !== t && a !== v && a !== w && a !== x || a.blur()
|
|
620
|
+
}, 0)
|
|
621
|
+
}
|
|
622
|
+
const h = $.extend({
|
|
623
|
+
onOpen: function() {},
|
|
624
|
+
onClose: function() {},
|
|
625
|
+
anchorX: null,
|
|
626
|
+
anchorY: null,
|
|
627
|
+
align: "top-right",
|
|
628
|
+
mobileMode: "auto",
|
|
629
|
+
overlay: !0,
|
|
630
|
+
keepKeyboard: !1,
|
|
631
|
+
preserveScroll: !1,
|
|
632
|
+
openDuration: 300,
|
|
633
|
+
closeDuration: 300,
|
|
634
|
+
openDelay: 0
|
|
635
|
+
}, g || {});
|
|
636
|
+
if (!this.elements || 0 === this.elements.length) return console.warn("Kcolor: \uc120\ud0dd\ub41c \uc694\uc18c\uac00 \uc5c6\uc2b5\ub2c8\ub2e4."), this;
|
|
637
|
+
const d =
|
|
638
|
+
this.elements[0];
|
|
639
|
+
if (!d || !d.nodeType || 1 !== d.nodeType) return console.warn("Kcolor: \uc120\ud0dd\ub41c \uc694\uc18c\uac00 \uc720\ud6a8\ud55c DOM \uc694\uc18c\uac00 \uc544\ub2d9\ub2c8\ub2e4."), this;
|
|
640
|
+
if (document.querySelector(".color-picker-container.active")) return this;
|
|
641
|
+
g = d.hasAttribute("data-kcolor") && "true" === d.getAttribute("data-kcolor");
|
|
642
|
+
if (d._kcolorInitialized) {
|
|
643
|
+
if (d._kcolorActive && !g) return this;
|
|
644
|
+
d._kcolorActive = !1
|
|
645
|
+
} else d._kcolorInitialized = !0;
|
|
646
|
+
d._kcolorActive = !0;
|
|
647
|
+
if (!d._kcolorInitialColor) {
|
|
648
|
+
var F = null;
|
|
649
|
+
if (H) F = H;
|
|
650
|
+
else if ("INPUT" === d.tagName && d.value) F = d.value;
|
|
651
|
+
else if (g = window.getComputedStyle(d).backgroundColor, "transparent" === g || "rgba(0, 0, 0, 0)" === g) F = "transparent";
|
|
652
|
+
else if ((g = g && g.match(/\d+/g)) && 3 <= g.length) {
|
|
653
|
+
F = parseInt(g[0]);
|
|
654
|
+
const a = parseInt(g[1]);
|
|
655
|
+
g = parseInt(g[2]);
|
|
656
|
+
F = J(F, a, g)
|
|
657
|
+
}
|
|
658
|
+
F || (F = "transparent");
|
|
659
|
+
d._kcolorInitialColor = F
|
|
660
|
+
}
|
|
661
|
+
const ya = y;
|
|
662
|
+
y = function(a) {
|
|
663
|
+
d._kcolorActive = !1;
|
|
664
|
+
h.onClose();
|
|
665
|
+
"function" === typeof ya && ya.call(d, a)
|
|
666
|
+
};
|
|
667
|
+
"undefined" !== typeof $ && $.isMobile && $.isMobile();
|
|
668
|
+
g = Date.now();
|
|
669
|
+
d._hasColorPicker = !0;
|
|
670
|
+
let B = "",
|
|
671
|
+
r = !1,
|
|
672
|
+
A = [];
|
|
673
|
+
try {
|
|
674
|
+
var q = localStorage.getItem("kcolor_recent_colors");
|
|
675
|
+
q && (A = JSON.parse(q))
|
|
676
|
+
} catch (a) {
|
|
677
|
+
console.warn("Kcolor: \ub85c\uceec \uc2a4\ud1a0\ub9ac\uc9c0 \uc811\uadfc \uc624\ub958")
|
|
678
|
+
}
|
|
679
|
+
const ta = "#F1A1A1 #8BBCF2 #CEAEFC #B7E3A8 #FFFF7C transparent".split(" "),
|
|
680
|
+
l = document.createElement("div");
|
|
681
|
+
l.className = "color-picker-overlay";
|
|
682
|
+
l.style.display = "none";
|
|
683
|
+
l.style.position = "fixed";
|
|
684
|
+
l.style.top = "0";
|
|
685
|
+
l.style.left = "0";
|
|
686
|
+
l.style.right = "0";
|
|
687
|
+
l.style.bottom = "0";
|
|
688
|
+
l.style.backgroundColor = "rgba(0, 0, 0, 0)";
|
|
689
|
+
l.style.zIndex =
|
|
690
|
+
"999999";
|
|
691
|
+
l.style.opacity = "0";
|
|
692
|
+
l.setAttribute("title", "");
|
|
693
|
+
l.removeAttribute("title");
|
|
694
|
+
const e = document.createElement("div");
|
|
695
|
+
e.className = "color-picker-container";
|
|
696
|
+
e.style.display = "none";
|
|
697
|
+
e._kcolorElement = d;
|
|
698
|
+
e.style.position = "absolute";
|
|
699
|
+
e.style.zIndex = "1000000";
|
|
700
|
+
e.setAttribute("title", "");
|
|
701
|
+
e.removeAttribute("title");
|
|
702
|
+
q = document.createElement("style");
|
|
703
|
+
q.textContent = '\n\t\t.color-picker-container {\n\t\t\twidth: 245px;\n\t\t\tbox-sizing: border-box;\n\t\t\tborder-radius: 10px;\n\t\t\toverflow: hidden;\n\t\t\tbox-shadow: 0 8px 30px rgba(0,0,0,0.35);\n\t\t\tborder: 1px solid rgba(0,0,0,0.3);\n\t\t\tfont-family: \'Arial\', sans-serif;\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: column;\n\t\t\tbackground-color: white;\n\t\t\ttransform-origin: top left;\n\t\t\ttransform: scale(0.5);\n\t\t\topacity: 0;\n\t\t\ttransition: transform 0.3s ease, opacity 0.3s ease;\n\t\t\tborder-top: 5px solid white !important;\n\t\t}\n\n\t\t.color-picker-container.active {\n\t\t\ttransform: scale(1);\n\t\t\topacity: 1;\n\t\t}\n\n\t\t.color-picker-container,\n\t\t.color-picker-container *,\n\t\t.color-area,\n\t\t.color-slider,\n\t\t.fixed-color,\n\t\t.recent-color,\n\t\t.current-color {\n\t\t\t-webkit-touch-callout: none !important;\n\t\t\t-webkit-user-select: none !important;\n\t\t\t-khtml-user-select: none !important;\n\t\t\t-moz-user-select: none !important;\n\t\t\t-ms-user-select: none !important;\n\t\t\tuser-select: none !important;\n\t\t\t-webkit-tap-highlight-color: rgba(0,0,0,0) !important;\n\t\t\toutline: none !important;\n\t\t\tcursor: default !important;\n\t\t}\n\n\t\t.color-area {\n\t\t\tcursor: crosshair !important;\n\t\t}\n\n\t\t.color-slider {\n\t\t\tcursor: pointer !important;\n\t\t}\n\n\t\t.fixed-color, .recent-color, .current-color {\n\t\t\tcursor: pointer !important;\n\t\t}\n\n\t\t.input-group input {\n\t\t\tcursor: text !important;\n\t\t\t-webkit-user-select: text !important;\n\t\t\t-moz-user-select: text !important;\n\t\t\t-ms-user-select: text !important;\n\t\t\tuser-select: text !important;\n\t\t}\n\n\t\t@media (max-width: 600px),\n\t\t(max-device-width: 600px),\n\t\t(orientation: portrait and max-width: 600px),\n\t\t(orientation: landscape and max-device-height: 600px) {\n\t\t\t.color-picker-container {\n\t\t\t\twidth: 262px !important;\n\t\t\t\tmax-width: 400px !important;\n\t\t\t\tmargin: 0 auto !important;\n\t\t\t\tleft: 0 !important;\n\t\t\t\tright: 0 !important;\n\t\t\tbox-shadow: 0 8px 30px rgba(0,0,0,0.25);\n\t\t\tborder: 1px solid rgba(0,0,0,0.2);\n\t\t\t\tposition: fixed !important;\n\t\t\t\ttop: 0 !important;\n\t\t\t\tbottom: auto !important;\n\t\t\t\ttransform: translateY(-100%);\n\t\t\t\ttransform-origin: top center;\n\t\t\t\ttransition: transform 0.3s ease;\n\t\t\t\tborder-top: none !important;\n\t\t\t}\n\t\t\t.color-controls {\n\t\t\t\tmargin-top: 0 !important;\n\t\t\t}\n\t\t\t.color-picker-container.active {\n\t\t\t\ttransform: translateY(0);\n\t\t\t}\n\n\t\t\t.color-area {\n\t\t\t\theight: 152px !important;\n\t\t\t}\n\n\t\t\t.color-left-panel, .color-right-panel {\n\t\t\t\theight: 152px !important;\n\t\t\t}\n\n\t\t\t.color-left-panel {\n\t\t\t\tjustify-content: flex-start !important;\n\t\t\t\tpadding-top: 5px !important;\n\t\t\t}\n\n\t\t\t.color-right-panel {\n\t\t\t\tjustify-content: flex-start !important;\n\t\t\t\tpadding-top: 5px !important;\n\t\t\t}\n\n\t\t\t.fixed-color, .recent-color {\n\t\t\t\tmargin-bottom: 4px !important;\n\t\t\t}\n\t\t}\n\n\t\t.color-main-area {\n\t\t\tdisplay: flex;\n\t\t\tpadding: 0;\n\t\t\tmargin: 0;\n\t\t\tbackground-color: white;\n\t\t}\n\n\t\t.color-left-panel {\n\t\t\twidth: 32px;\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: column;\n\t\t\talign-items: center;\n\t\t\tjustify-content: flex-start;\n\t\t\tpadding: 4px;\n\t\t\tpadding-top: 5px;\n\t\t\tbackground-color: white;\n\t\t\theight: 180px;\n\t\t\toverflow: hidden;\n\t\t\tbox-sizing: border-box;\n\t\t}\n\n\t\t.color-center-panel {\n\t\t\tflex: 1;\n\t\t}\n\n\t\t.color-right-panel {\n\t\t\twidth: 32px;\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: column;\n\t\t\talign-items: center;\n\t\t\tjustify-content: flex-start;\n\t\t\tpadding: 4px;\n\t\t\tpadding-top: 5px;\n\t\t\tbackground-color: white;\n\t\t\theight: 180px;\n\t\t\toverflow: hidden;\n\t\t\tbox-sizing: border-box;\n\t\t}\n\n\t\t.color-left-panel::-webkit-scrollbar,\n\t\t.color-right-panel::-webkit-scrollbar {\n\t\t\twidth: 0;\n\t\t\tdisplay: none;\n\t\t}\n\n\t\t.color-left-panel, .color-right-panel {\n\t\t\t-ms-overflow-style: none;\n\t\t\tscrollbar-width: none;\n\t\t}\n\n\t\t.color-area {\n\t\t\tposition: relative;\n\t\t\twidth: 100%;\n\t\t\theight: 160px;\n\t\t\tbackground-image:\n\t\t\tlinear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,1)),\n\t\t\tlinear-gradient(to right, rgba(255,255,255,1), rgba(255,0,255,1));\n\t\t\tcursor: crosshair;\n\t\t\ttouch-action: none;\n\t\t\tmargin: 0;\n\t\t\toverflow: hidden;\n\t\t}\n\n\t\t.color-pointer {\n\t\t\tposition: absolute;\n\t\t\twidth: 12px;\n\t\t\theight: 12px;\n\t\t\tborder-radius: 50%;\n\t\t\tborder: 2px solid white;\n\t\t\tbox-shadow: 0 0 3px rgba(0,0,0,0.5);\n\t\t\ttransform: translate(-50%, -50%);\n\t\t\tz-index: 2;\n\t\t\tpointer-events: none;\n\t\t}\n\n\t\t.color-controls {\n\t\t\tbackground-color: white;\n\t\t\tpadding: 5px 10px;\n\t\t\tmargin-top: -20px;\n\t\t}\n\n\t\t.color-preview {\n\t\t\tdisplay: flex;\n\t\t\talign-items: center;\n\t\t\tmargin-bottom: 6px;\n\t\t\tpadding-left: 0;\n\t\t\tmargin-left: -5px;\n\t\t}\n\n\t\t.current-color {\n\t\t\tposition: relative;\n\t\t\twidth: 30px;\n\t\t\theight: 30px;\n\t\t\tborder-radius: 50%;\n\t\t\tmargin-left: 10px;\n\t\t\tborder: 1px solid #ddd;\n\t\t\tdisplay: flex;\n\t\t\talign-items: center;\n\t\t\tjustify-content: center;\n\t\t\tcursor: pointer;\n\t\t\tbackground-color: #097969;\n\t\t}\n\n\t\t.current-color::after {\n\t\t\tcontent: "OK";\n\t\t\tcolor: white;\n\t\t\tfont-size: 10px;\n\t\t\tfont-weight: bold;\n\t\t\ttext-shadow: 0 0 3px rgba(0,0,0,0.7);\n\t\t}\n\n\t\t.current-color.light-background::after {\n\t\t\tcolor: black;\n\t\t\ttext-shadow: 0 0 3px rgba(255,255,255,0.7);\n\t\t}\n\n\t\t.color-slider {\n\t\t\tflex-grow: 1;\n\t\t\theight: 16px;\n\t\t\tposition: relative;\n\t\t\tbackground: linear-gradient(to right,\n\t\t\t#ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000\n\t\t\t);\n\t\t\tborder-radius: 8px;\n\t\t\tcursor: pointer;\n\t\t\ttouch-action: none;\n\t\t\tmargin-left: 28px;\n\t\t\twidth: calc(100% - 80px);\n\t\t}\n\n\t\t.color-slider-thumb {\n\t\t\tposition: absolute;\n\t\t\twidth: 16px;\n\t\t\theight: 16px;\n\t\t\tbackground-color: white;\n\t\t\tborder-radius: 50%;\n\t\t\tborder: 2px solid white;\n\t\t\tbox-shadow: 0 0 3px rgba(0,0,0,0.5);\n\t\t\ttransform: translateX(-50%);\n\t\t\ttop: 0;\n\t\t}\n\n\t\t.rgb-inputs {\n\t\t\tdisplay: flex;\n\t\t\tjustify-content: space-between;\n\t\t\tmargin-top: 10px;\n\t\t\twidth: 100%;\n\t\t}\n\n\t\t.input-group {\n\t\t\ttext-align: center;\n\t\t\tflex-grow: 1;\n\t\t}\n\n\t\t.input-group input {\n\t\t\twidth: 90%;\n\t\t\tpadding: 5px;\n\t\t\ttext-align: center;\n\t\t\tborder: 1px solid #ddd;\n\t\t\tborder-radius: 4px;\n\t\t\tbox-sizing: border-box;\n\t\t\tfont-size: 12px;\n\t\t}\n\n\t\t.input-group label {\n\t\t\tdisplay: block;\n\t\t\tmargin-top: 3px;\n\t\t\tfont-size: 12px;\n\t\t\tcolor: #333;\n\t\t\tcursor: pointer;\n\t\t}\n\n\t\t.hex-input {\n\t\t\twidth: 100% !important;\n\t\t}\n\n\t\t.fixed-color:hover {\n\t\t\ttransform: scale(1.1);\n\t\t}\n\n\t\t.fixed-color:focus {\n\t\t\toutline: 2px solid #0078d7;\n\t\t\ttransform: scale(1.1);\n\t\t\tbox-shadow: 0 0 5px rgba(0,120,215,0.5);\n\t\t}\n\n\t\t.fixed-color.cancel-color {\n\t\t\tbackground-color: white;\n\t\t\tposition: relative;\n\t\t}\n\n\t\t.fixed-color.cancel-color::before {\n\t\t\tcontent: "";\n\t\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tleft: 0;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tbackground: linear-gradient(to bottom right, transparent 45%, red 45%, red 55%, transparent 55%);\n\t\t\tborder-radius: 6px;\n\t\t}\n\n\t\t.fixed-color {\n\t\t\twidth: 20px;\n\t\t\theight: 20px;\n\t\t\tborder-radius: 10px;\n\t\t\tmargin-bottom: 7px;\n\t\t\tborder: 1px solid #FFD8D8;\n\t\t\tcursor: pointer;\n\t\t\ttransition: transform 0.2s;\n\t\t\tbox-sizing: border-box;\n\t\t\tdisplay: block;\n\t\t\tflex-shrink: 0;\n\t\t\ttransform: translateZ(0);\n\t\t\taspect-ratio: 1/1;\n\t\t}\n\n\t\t.recent-color {\n\t\t\twidth: 20px;\n\t\t\theight: 20px;\n\t\t\tborder-radius: 10px;\n\t\t\tmargin-bottom: 7px;\n\t\t\tborder: 1px solid #ccc;\n\t\t\tcursor: pointer;\n\t\t\ttransition: transform 0.2s;\n\t\t\tbackground-color: white;\n\t\t\tbox-sizing: border-box;\n\t\t\tdisplay: block;\n\t\t\tflex-shrink: 0;\n\t\t\ttransform: translateZ(0);\n\t\t\taspect-ratio: 1/1;\n\t\t}\n\n\t\t.recent-color:hover {\n\t\t\ttransform: scale(1.1);\n\t\t}\n\n\t\t.recent-color:focus {\n\t\t\toutline: 2px solid #0078d7;\n\t\t\ttransform: scale(1.1);\n\t\t\tbox-shadow: 0 0 5px rgba(0,120,215,0.5);\n\t\t}\n\n\t\t.recent-color.filled {\n\t\t\tborder: 1px solid #bbb;\n\t\t}\n\n\t\t#keyboardMaintainer {\n\t\t\tposition: absolute;\n\t\t\topacity: 0;\n\t\t\theight: 1px;\n\t\t\twidth: 1px;\n\t\t\ttop: -9999px;\n\t\t\tleft: -9999px;\n\t\t\tz-index: -1;\n\t\t}\n\t\t.recent-color.cancel-color {\n\t\t\tbackground-color: white;\n\t\t\tposition: relative;\n\t\t}\n\t';
|
|
704
|
+
document.querySelector("style[data-kcolor-style]") || (q.setAttribute("data-kcolor-style", "true"), document.head.appendChild(q));
|
|
705
|
+
e.innerHTML = `\n\t<div class="color-main-area">\n\t<div class="color-left-panel" id="colorLeftPanel_${g}">\n\t\x3c!-- \uace0\uc815 \uc0c9\uc0c1\ub4e4\uc774 \uc5ec\uae30\uc5d0 \ub3d9\uc801\uc73c\ub85c \ucd94\uac00\ub429\ub2c8\ub2e4 --\x3e\n\t</div>\n\t<div class="color-center-panel">\n\t<div class="color-area" id="colorArea_${g}">\n\t<div class="color-pointer" id="colorPointer_${g}"></div>\n\t</div>\n\t</div>\n\t<div class="color-right-panel" id="colorRightPanel_${g}">\n\t\x3c!-- \ucd5c\uadfc \uc0c9\uc0c1\ub4e4\uc774 \uc5ec\uae30\uc5d0 \ub3d9\uc801\uc73c\ub85c \ucd94\uac00\ub429\ub2c8\ub2e4 --\x3e\n\t</div>\n\t</div>\n\n\t<div class="color-controls">\n\t<div class="color-preview">\n\t<div class="color-slider" id="hueSlider_${g}">\n\t<div class="color-slider-thumb" id="hueThumb_${g}"></div>\n\t</div>\n\t<div class="current-color" id="currentColor_${g}"></div>\n\t</div>\n\n\t<div class="rgb-inputs" id="rgb-mode_${g}">\n\t<div class="input-group">\n\t<input type="number" id="redInput_${g}" min="0" max="255" value="0" maxlength="3">\n\t<label class="mode-toggle-label">R</label>\n\t</div>\n\t<div class="input-group">\n\t<input type="number" id="greenInput_${g}" min="0" max="255" value="0" maxlength="3">\n\t<label class="mode-toggle-label">G</label>\n\t</div>\n\t<div class="input-group">\n\t<input type="number" id="blueInput_${g}" min="0" max="255" value="0" maxlength="3">\n\t<label class="mode-toggle-label">B</label>\n\t</div>\n\t</div>\n\n\t<div class="rgb-inputs" id="hex-mode_${g}" style="display: none;">\n\t<div class="input-group" style="width: 100%;">\n\t<input type="text" id="hexInput_${g}" class="hex-input" value="#000000" maxlength="7">\n\t<label class="mode-toggle-label">HEX</label>\n\t</div>\n\t</div>\n\t</div>\n\n\t\x3c!-- \ud0a4\ubcf4\ub4dc \uc720\uc9c0\ub97c \uc704\ud55c \ubcf4\uc774\uc9c0 \uc54a\ub294 \uc785\ub825 \ud544\ub4dc --\x3e\n <input type="text" id="keyboardMaintainer_${g}" class="keyboard-maintainer"\n style="position: fixed; opacity: 0; height: 1px; width: 1px; top: 0; left: 0; z-index: -1;">\n\t`;
|
|
706
|
+
!1 !== h.overlay && document.body.appendChild(l);
|
|
707
|
+
document.body.appendChild(e);
|
|
708
|
+
const W = e.querySelector(`#colorArea_${g}`),
|
|
709
|
+
p = e.querySelector(`#colorPointer_${g}`),
|
|
710
|
+
u = e.querySelector(`#currentColor_${g}`),
|
|
711
|
+
v = e.querySelector(`#redInput_${g}`),
|
|
712
|
+
w = e.querySelector(`#greenInput_${g}`),
|
|
713
|
+
x = e.querySelector(`#blueInput_${g}`),
|
|
714
|
+
t = e.querySelector(`#hexInput_${g}`),
|
|
715
|
+
oa = e.querySelector(`#hueSlider_${g}`),
|
|
716
|
+
Q = e.querySelector(`#hueThumb_${g}`),
|
|
717
|
+
pa = e.querySelector(`#rgb-mode_${g}`),
|
|
718
|
+
xa = e.querySelector(`#hex-mode_${g}`),
|
|
719
|
+
sa = e.querySelector(`#colorLeftPanel_${g}`),
|
|
720
|
+
ka = e.querySelector(`#colorRightPanel_${g}`),
|
|
721
|
+
z = e.querySelector(`#keyboardMaintainer_${g}`);
|
|
722
|
+
q = e.querySelector(`#rgb-mode_${g}`).querySelectorAll(".mode-toggle-label");
|
|
723
|
+
g = e.querySelector(`#hex-mode_${g}`).querySelector(".mode-toggle-label");
|
|
724
|
+
T();
|
|
725
|
+
e.addEventListener("click", function(a) {
|
|
726
|
+
a.stopPropagation();
|
|
727
|
+
var b = a.target && a.target.tagName ? a.target.tagName.toUpperCase() : "";
|
|
728
|
+
b = "INPUT" === b || "TEXTAREA" === b || "SELECT" === b;
|
|
729
|
+
a = !(!a.target || "function" !== typeof a.target.closest || !a.target.closest(".mode-toggle-label"));
|
|
730
|
+
!b && !a && G() && h.keepKeyboard && setTimeout(() => z && z.focus && z.focus({
|
|
731
|
+
preventScroll: !0
|
|
732
|
+
}), 0)
|
|
733
|
+
}, !1);
|
|
734
|
+
e.addEventListener("touchstart", function(a) {
|
|
735
|
+
a.stopPropagation()
|
|
736
|
+
}, {
|
|
737
|
+
passive: !0
|
|
738
|
+
});
|
|
739
|
+
let E = 0,
|
|
740
|
+
D = 0,
|
|
741
|
+
C = 1;
|
|
742
|
+
p.style.left = "0%";
|
|
743
|
+
p.style.top = "0%";
|
|
744
|
+
Q.style.left = "0%";
|
|
745
|
+
d._kcolorClickHandler && d.removeEventListener("click", d._kcolorClickHandler);
|
|
746
|
+
d._kcolorClickHandler = function(a) {
|
|
747
|
+
a.stopPropagation();
|
|
748
|
+
const b = d.hasAttribute("data-kcolor") && "true" === d.getAttribute("data-kcolor");
|
|
749
|
+
if (!d._kcolorActive || b) {
|
|
750
|
+
if (!b) {
|
|
751
|
+
var c = window.getSelection();
|
|
752
|
+
if (!c.rangeCount) return;
|
|
753
|
+
const f = c.toString(),
|
|
754
|
+
k = /\S/.test(f);
|
|
755
|
+
if (!f || !k) return;
|
|
756
|
+
c = c.getRangeAt(0);
|
|
757
|
+
if (c.collapsed) return;
|
|
758
|
+
c = c.toString();
|
|
759
|
+
if (!c || 0 === c.length) return
|
|
760
|
+
}
|
|
761
|
+
c = qa(h.openDelay);
|
|
762
|
+
0 < c ? setTimeout(() => {
|
|
763
|
+
b ? L() : L(a)
|
|
764
|
+
}, c) : b ? L() : L(a)
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
d.addEventListener("click", d._kcolorClickHandler);
|
|
768
|
+
let N = !1;
|
|
769
|
+
W.addEventListener("mousedown", function(a) {
|
|
770
|
+
N = !0;
|
|
771
|
+
X(a)
|
|
772
|
+
});
|
|
773
|
+
W.addEventListener("touchstart", function(a) {
|
|
774
|
+
N = !0;
|
|
775
|
+
X(a);
|
|
776
|
+
a.preventDefault()
|
|
777
|
+
}, {
|
|
778
|
+
passive: !1
|
|
779
|
+
});
|
|
780
|
+
let O = !1;
|
|
781
|
+
oa.addEventListener("mousedown", function(a) {
|
|
782
|
+
O = !0;
|
|
783
|
+
Y(a)
|
|
784
|
+
});
|
|
785
|
+
oa.addEventListener("touchstart",
|
|
786
|
+
function(a) {
|
|
787
|
+
O = !0;
|
|
788
|
+
Y(a);
|
|
789
|
+
a.preventDefault()
|
|
790
|
+
}, {
|
|
791
|
+
passive: !1
|
|
792
|
+
});
|
|
793
|
+
window.addEventListener("mousemove", function(a) {
|
|
794
|
+
N ? X(a) : O && Y(a)
|
|
795
|
+
});
|
|
796
|
+
window.addEventListener("touchmove", function(a) {
|
|
797
|
+
N ? (X(a), a.preventDefault()) : O && (Y(a), a.preventDefault())
|
|
798
|
+
}, {
|
|
799
|
+
passive: !1
|
|
800
|
+
});
|
|
801
|
+
window.addEventListener("mouseup", function() {
|
|
802
|
+
O = N = !1
|
|
803
|
+
});
|
|
804
|
+
window.addEventListener("touchend", function() {
|
|
805
|
+
O = N = !1
|
|
806
|
+
});
|
|
807
|
+
v.addEventListener("input", function() {
|
|
808
|
+
S(this, 3);
|
|
809
|
+
this.value = this.value.replace(/[^0-9]/g, "");
|
|
810
|
+
255 < parseInt(this.value) && (this.value = "255")
|
|
811
|
+
});
|
|
812
|
+
w.addEventListener("input",
|
|
813
|
+
function() {
|
|
814
|
+
S(this, 3);
|
|
815
|
+
this.value = this.value.replace(/[^0-9]/g, "");
|
|
816
|
+
255 < parseInt(this.value) && (this.value = "255")
|
|
817
|
+
});
|
|
818
|
+
x.addEventListener("input", function() {
|
|
819
|
+
S(this, 3);
|
|
820
|
+
this.value = this.value.replace(/[^0-9]/g, "");
|
|
821
|
+
255 < parseInt(this.value) && (this.value = "255")
|
|
822
|
+
});
|
|
823
|
+
t.addEventListener("input", function() {
|
|
824
|
+
"transparent" !== this.value && (S(this, 7), this.value.startsWith("#") || (this.value = "#" + this.value, S(this, 7)), this.value = this.value.replace(/[^#0-9A-Fa-f]/g, ""))
|
|
825
|
+
});
|
|
826
|
+
v.addEventListener("change", Z);
|
|
827
|
+
w.addEventListener("change",
|
|
828
|
+
Z);
|
|
829
|
+
x.addEventListener("change", Z);
|
|
830
|
+
t.addEventListener("change", va);
|
|
831
|
+
t.addEventListener("input", va);
|
|
832
|
+
q.forEach(a => {
|
|
833
|
+
a.addEventListener("click", function(b) {
|
|
834
|
+
b.stopPropagation();
|
|
835
|
+
b.preventDefault();
|
|
836
|
+
wa()
|
|
837
|
+
})
|
|
838
|
+
});
|
|
839
|
+
g && g.addEventListener("click", function(a) {
|
|
840
|
+
a.stopPropagation();
|
|
841
|
+
a.preventDefault();
|
|
842
|
+
wa()
|
|
843
|
+
});
|
|
844
|
+
v.addEventListener("click", a => a.stopPropagation());
|
|
845
|
+
w.addEventListener("click", a => a.stopPropagation());
|
|
846
|
+
x.addEventListener("click", a => a.stopPropagation());
|
|
847
|
+
t.addEventListener("click", a => a.stopPropagation());
|
|
848
|
+
q = a => {
|
|
849
|
+
if (a) {
|
|
850
|
+
var b =
|
|
851
|
+
() => setTimeout(() => ra(a), 0);
|
|
852
|
+
a.addEventListener("mousedown", b, {
|
|
853
|
+
passive: !0
|
|
854
|
+
});
|
|
855
|
+
a.addEventListener("touchstart", b, {
|
|
856
|
+
passive: !0
|
|
857
|
+
});
|
|
858
|
+
a.addEventListener("focus", () => ra(a))
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
q(v);
|
|
862
|
+
q(w);
|
|
863
|
+
q(x);
|
|
864
|
+
q(t);
|
|
865
|
+
u.addEventListener("click", function(a) {
|
|
866
|
+
a.stopPropagation();
|
|
867
|
+
a.preventDefault();
|
|
868
|
+
d && "input" === d.tagName.toLowerCase() && d._kcolorFocusHandler && (d.removeEventListener("focus", d._kcolorFocusHandler), d._focusHandlerPaused = !0);
|
|
869
|
+
Ca();
|
|
870
|
+
setTimeout(function() {
|
|
871
|
+
if (d && "function" === typeof d.focus) {
|
|
872
|
+
d.focus();
|
|
873
|
+
if ("INPUT" === d.tagName && "text" ===
|
|
874
|
+
d.type) {
|
|
875
|
+
const b = d.value.length;
|
|
876
|
+
d.setSelectionRange(b, b)
|
|
877
|
+
}
|
|
878
|
+
setTimeout(function() {
|
|
879
|
+
d && d._focusHandlerPaused && d._kcolorFocusHandler && (d.addEventListener("focus", d._kcolorFocusHandler), d._focusHandlerPaused = !1)
|
|
880
|
+
}, 1E3)
|
|
881
|
+
}
|
|
882
|
+
}, 0)
|
|
883
|
+
}, !1);
|
|
884
|
+
document._kcolorEscHandler || (document._kcolorEscHandler = function(a) {
|
|
885
|
+
"Escape" === a.key && (a = document.querySelector(".color-picker-container.active")) && a._kcolorElement && (a = a._kcolorElement) && a._kcolorHideFunction && a._kcolorHideFunction()
|
|
886
|
+
}, document.addEventListener("keydown", document._kcolorEscHandler));
|
|
887
|
+
d._kcolorHideFunction = R;
|
|
888
|
+
P();
|
|
889
|
+
U();
|
|
890
|
+
v.value = 255;
|
|
891
|
+
w.value = 255;
|
|
892
|
+
x.value = 255;
|
|
893
|
+
Z();
|
|
894
|
+
K("#FFFFFF");
|
|
895
|
+
T();
|
|
896
|
+
q = d.hasAttribute("data-kcolor") && "true" === d.getAttribute("data-kcolor");
|
|
897
|
+
q || "function" !== typeof y ? q && (d._kcolorActive = !1) : (q = qa(h.openDelay), 0 < q ? setTimeout(() => {
|
|
898
|
+
L()
|
|
899
|
+
}, q) : L());
|
|
900
|
+
window.closeKcolorPicker || (window.closeKcolorPicker = function() {
|
|
901
|
+
document.querySelectorAll(".color-picker-container.active").forEach(function(a) {
|
|
902
|
+
a._kcolorElement && a._kcolorElement._kcolorHideFunction && a._kcolorElement._kcolorHideFunction()
|
|
903
|
+
})
|
|
904
|
+
});
|
|
905
|
+
return this
|
|
906
|
+
};
|
|
907
|
+
$.fn.Kcolor = function(H, y, g) {
|
|
908
|
+
return $.Kcolor.call(this, H, y, g)
|
|
909
|
+
};
|