frColorPicker

ColorPicker for Font Rendering (Customized)

目前為 2023-03-29 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/437214/1167998/frColorPicker.js

  1. // ==UserScript==
  2. // @name frColorPicker
  3. // @version 6.1.0
  4. // @author F9y4ng
  5. // @license GPL-3.0-only
  6. // @description ColorPicker for Font Rendering (Customized)
  7. // ==/UserScript==
  8.  
  9. !(function (p, E, F) {
  10. "object" === typeof module && "object" === typeof module.exports
  11. ? (module.exports = p.document
  12. ? E(p, F)
  13. : function (y) {
  14. if (!y.document) throw Error("No Document!");
  15. return E(y, F);
  16. })
  17. : E(p, F);
  18. })(
  19. "undefined" !== typeof window ? window : this,
  20. function (p, E) {
  21. p.self === p.top &&
  22. p.trustedTypes &&
  23. p.trustedTypes.createPolicy &&
  24. (E = p.trustedTypes.createPolicy(
  25. (function (y) {
  26. y = void 0 === y ? "fr#ColorPicker" : y;
  27. for (
  28. var G = [
  29. { host: "teams.live.com", policy: "gapi#gapi" },
  30. { host: "github.dev", policy: "standaloneColorizer" },
  31. { host: "vscode.dev", policy: "standaloneColorizer" },
  32. ],
  33. H = 0;
  34. H < G.length;
  35. H++
  36. )
  37. if (location.hostname.startsWith(G[H].host)) {
  38. y = G[H].policy;
  39. break;
  40. }
  41. return y;
  42. })(),
  43. {
  44. createHTML: function (y) {
  45. return y;
  46. },
  47. }
  48. ));
  49. var F = (function () {
  50. function y(b, d) {
  51. d = void 0 === d ? "" : d;
  52. for (b = Number(b - 1) || 8; 0 < b; --b) d += "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"[Math.floor(62 * Math.random())];
  53. return "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(26 * Math.random())].concat(d);
  54. }
  55. var G = y(9),
  56. H = y(8),
  57. L = y(12),
  58. M = y(8),
  59. N = y(7),
  60. O = y(7),
  61. C = !isNaN(parseFloat(p.mozInnerScreenX)),
  62. K = "CSS1Compat" === document.compatMode ? document.documentElement : document.body,
  63. a = {
  64. initialized: !1,
  65. instances: [],
  66. readyQueue: [],
  67. base64Data:
  68. "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAQCAYAAACcN8ZaAAAAAXNSR0IArs4c6QAAAFNJREFUSEtjnDlz5n8GPODs2bP4pBmMjY3xypOin3HUMUhhiRyyoyGDnMhGQwZXlhu8IZOWloa3nKFmOYItdJDLIcZRxyAF0WjI4MpNoyEz5EIGAMmNh+nDrPy/AAAAAElFTkSuQmCC",
  69. register: function () {
  70. "undefined" !== typeof p &&
  71. p.document &&
  72. ("loading" === p.document.readyState
  73. ? p.document.addEventListener("DOMContentLoaded", a.pub.init, !1)
  74. : p.document.body
  75. ? a.pub.init()
  76. : p.addEventListener("load", a.pub.init, !1));
  77. },
  78. checkZoomRatio: function (b) {
  79. b = C
  80. ? (b = p.getComputedStyle(document.body, null).getPropertyValue("transform")) && "none" !== b
  81. ? Number(b.split(",")[3]) || 1
  82. : 1
  83. : Number(p.getComputedStyle(document.body, null).getPropertyValue("zoom")) || 1;
  84. return b;
  85. },
  86. getInstances: function () {
  87. for (var b = [], d = 0; d < a.instances.length; d += 1) a.instances[d] && a.instances[d].targetElement && b.push(a.instances[d]);
  88. return b;
  89. },
  90. createEl: function (b) {
  91. b = p.document.createElement(b);
  92. a.setData(b, "gui", !0);
  93. return b;
  94. },
  95. node: function (b) {
  96. if (!b) return null;
  97. if ("string" === typeof b) {
  98. var d = null;
  99. try {
  100. d = p.document.querySelector(b) || p.document.querySelector("fr-configure").shadowRoot.querySelector(b);
  101. } catch (e) {
  102. return null;
  103. }
  104. d || console.warn("No element matche: %s", b);
  105. return d;
  106. }
  107. return a.isNode(b) ? b : null;
  108. },
  109. isNode: function (b) {
  110. return "object" === typeof Node ? b instanceof Node : b && "object" === typeof b && "number" === typeof b.nodeType && "string" === typeof b.nodeName;
  111. },
  112. nodeName: function (b) {
  113. return b && b.nodeName ? b.nodeName.toLowerCase() : !1;
  114. },
  115. removeChildren: function (b) {
  116. for (; b.firstChild; ) b.removeChild(b.firstChild);
  117. },
  118. isTextInput: function (b) {
  119. return b && "input" === a.nodeName(b) && "text" === b.type.toLowerCase();
  120. },
  121. isButton: function (b) {
  122. if (!b) return !1;
  123. var d = a.nodeName(b);
  124. return "button" === d || ("input" === d && -1 < ["button", "submit", "reset"].indexOf(b.type.toLowerCase()));
  125. },
  126. isButtonEmpty: function (b) {
  127. switch (a.nodeName(b)) {
  128. case "input":
  129. return !b.value || "" === b.value.trim();
  130. case "button":
  131. return "" === b.textContent.trim();
  132. }
  133. return null;
  134. },
  135. isPassiveEventSupported: (function () {
  136. var b = !1;
  137. try {
  138. var d = Object.defineProperty({}, "passive", {
  139. get: function () {
  140. b = !0;
  141. },
  142. });
  143. p.addEventListener("testPassive", null, d);
  144. p.removeEventListener("testPassive", null, d);
  145. } catch (e) {
  146. console.error(e);
  147. }
  148. return b;
  149. })(),
  150. isColorAttrSupported: (function () {
  151. var b = p.document.createElement("input");
  152. return b.setAttribute && (b.setAttribute("type", "color"), b.type && "color" == b.type.toLowerCase()) ? !0 : !1;
  153. })(),
  154. dataProp: "_data_frcolorpicker",
  155. setData: function () {
  156. var b = arguments[0];
  157. if (3 === arguments.length) {
  158. b = b.hasOwnProperty(a.dataProp) ? b[a.dataProp] : (b[a.dataProp] = {});
  159. var d = arguments[1];
  160. b[d] = arguments[2];
  161. return !0;
  162. }
  163. if (2 === arguments.length && "object" === typeof arguments[1]) {
  164. b = b.hasOwnProperty(a.dataProp) ? b[a.dataProp] : (b[a.dataProp] = {});
  165. var e = arguments[1];
  166. for (d in e) e.hasOwnProperty(d) && (b[d] = e[d]);
  167. return !0;
  168. }
  169. throw Error("Invalid arguments");
  170. },
  171. removeData: function () {
  172. var b = arguments[0];
  173. if (!b.hasOwnProperty(a.dataProp)) return !0;
  174. for (var d = 1; d < arguments.length; d += 1) delete b[a.dataProp][arguments[d]];
  175. return !0;
  176. },
  177. getData: function (b, d, e) {
  178. if (!b.hasOwnProperty(a.dataProp))
  179. if (void 0 !== e) b[a.dataProp] = {};
  180. else return;
  181. b = b[a.dataProp];
  182. b.hasOwnProperty(d) || void 0 === e || (b[d] = e);
  183. return b[d];
  184. },
  185. getDataAttr: function (b, d) {
  186. return b.getAttribute("data-" + d);
  187. },
  188. setDataAttr: function (b, d, e) {
  189. b.setAttribute("data-" + d, e);
  190. },
  191. _attachedGroupEvents: {},
  192. attachGroupEvent: function (b, d, e, g) {
  193. a._attachedGroupEvents.hasOwnProperty(b) || (a._attachedGroupEvents[b] = []);
  194. a._attachedGroupEvents[b].push([d, e, g]);
  195. d.addEventListener(e, g, !1);
  196. },
  197. detachGroupEvents: function (b) {
  198. if (a._attachedGroupEvents.hasOwnProperty(b)) {
  199. for (var d = 0; d < a._attachedGroupEvents[b].length; d += 1) {
  200. var e = a._attachedGroupEvents[b][d];
  201. e[0].removeEventListener(e[1], e[2], !1);
  202. }
  203. delete a._attachedGroupEvents[b];
  204. }
  205. },
  206. preventDefault: function (b) {
  207. b.preventDefault && b.preventDefault();
  208. b.returnValue = !1;
  209. },
  210. triggerEvent: function (b, d, e, g) {
  211. if (b) {
  212. if ("function" === typeof Event) var h = new Event(d, { bubbles: e, cancelable: g });
  213. else (h = p.document.createEvent("Event")), h.initEvent(d, e, g);
  214. if (!h) return !1;
  215. a.setData(h, "internal", !0);
  216. b.dispatchEvent(h);
  217. return !0;
  218. }
  219. },
  220. triggerInputEvent: function (b, d, e, g) {
  221. b && a.isTextInput(b) && a.triggerEvent(b, d, e, g);
  222. },
  223. eventKey: function (b) {
  224. var d = { 9: "Tab", 13: "Enter", 27: "Escape" };
  225. return "string" === typeof b.code ? b.code : void 0 !== b.keyCode && d.hasOwnProperty(b.keyCode) ? d[b.keyCode] : null;
  226. },
  227. strList: function (b) {
  228. return b ? b.replace(/^\s+|\s+$/g, "").split(/\s+/) : [];
  229. },
  230. hasClass: function (b, d) {
  231. return d ? (void 0 !== b.classList ? b.classList.contains(d) : -1 != (" " + b.className.replace(/\s+/g, " ") + " ").indexOf(" " + d + " ")) : !1;
  232. },
  233. addClass: function (b, d) {
  234. d = a.strList(d);
  235. if (void 0 !== b.classList) for (var e = 0; e < d.length; e += 1) b.classList.add(d[e]);
  236. else for (e = 0; e < d.length; e += 1) a.hasClass(b, d[e]) || (b.className += (b.className ? " " : "") + d[e]);
  237. },
  238. removeClass: function (b, d) {
  239. d = a.strList(d);
  240. if (void 0 !== b.classList) for (var e = 0; e < d.length; e += 1) b.classList.remove(d[e]);
  241. else for (e = 0; e < d.length; e += 1) b.className = b.className.replace(new RegExp("^\\s*" + d[e] + "\\s*|\\s*" + d[e] + "\\s*$|\\s+" + d[e] + "(\\s+)", "g"), "$1");
  242. },
  243. getCompStyle: function (b) {
  244. return b instanceof ShadowRoot ? {} : (b = p.getComputedStyle ? p.getComputedStyle(b) : b.currentStyle) ? b : {};
  245. },
  246. setStyle: function (b, d, e, g) {
  247. e = e ? "important" : "";
  248. var h = null,
  249. l;
  250. for (l in d)
  251. if (d.hasOwnProperty(l)) {
  252. var m = null;
  253. null === d[l]
  254. ? (h || (h = a.getData(b, "origStyle")), h && h.hasOwnProperty(l) && (m = h[l]))
  255. : (g && (h || (h = a.getData(b, "origStyle", {})), h.hasOwnProperty(l) || (h[l] = b.style[l])), (m = d[l]));
  256. null !== m && b.style.setProperty(l, m, e);
  257. }
  258. },
  259. hexColor: function (b, d, e) {
  260. return "#" + (("0" + Math.round(b).toString(16)).slice(-2) + ("0" + Math.round(d).toString(16)).slice(-2) + ("0" + Math.round(e).toString(16)).slice(-2)).toUpperCase();
  261. },
  262. hexaColor: function (b, d, e, g) {
  263. return (
  264. "#" +
  265. (
  266. ("0" + Math.round(b).toString(16)).slice(-2) +
  267. ("0" + Math.round(d).toString(16)).slice(-2) +
  268. ("0" + Math.round(e).toString(16)).slice(-2) +
  269. ("0" + Math.round(255 * g).toString(16)).slice(-2)
  270. ).toUpperCase()
  271. );
  272. },
  273. rgbColor: function (b, d, e) {
  274. return "rgb(" + Math.round(b) + "," + Math.round(d) + "," + Math.round(e) + ")";
  275. },
  276. rgbaColor: function (b, d, e, g) {
  277. return "rgba(" + Math.round(b) + "," + Math.round(d) + "," + Math.round(e) + "," + Math.round(100 * (void 0 === g || null === g ? 1 : g)) / 100 + ")";
  278. },
  279. linearGradient: (function () {
  280. var b = (function () {
  281. for (var d = ["", "-webkit-", "-moz-", "-o-", "-ms-"], e = p.document.createElement("div"), g = 0; g < d.length; g += 1) {
  282. var h = d[g] + "linear-gradient",
  283. l = h + "(to right, rgba(0,0,0,0), rgba(0,0,0,0))";
  284. e.style && (e.style.background = l);
  285. if (e.style && e.style.background) return h;
  286. }
  287. return "linear-gradient";
  288. })();
  289. return function () {
  290. return b + "(" + Array.prototype.join.call(arguments, ", ") + ")";
  291. };
  292. })(),
  293. setBorderRadius: function (b, d) {
  294. a.setStyle(b, { "border-radius": d || "0" });
  295. },
  296. setBoxShadow: function (b, d) {
  297. a.setStyle(b, { "box-shadow": d || "none" });
  298. },
  299. getElementPos: function (b, d) {
  300. var e = a.checkZoomRatio();
  301. var g = b.getBoundingClientRect();
  302. b = C ? g.left * e : g.left;
  303. e = C ? g.top * e : g.top;
  304. d || ((d = a.getViewPos()), (b += d[0]), (e += d[1]));
  305. return [b, e];
  306. },
  307. getElementSize: function (b) {
  308. return [b.offsetWidth, b.offsetHeight];
  309. },
  310. getAbsPointerPos: function (b) {
  311. var d = a.checkZoomRatio(),
  312. e = 0,
  313. g = 0;
  314. "undefined" !== typeof b.changedTouches && b.changedTouches.length
  315. ? ((e = b.changedTouches[0].x * d), (g = b.changedTouches[0].y * d))
  316. : "number" === typeof b.x && ((e = b.x * d), (g = b.y * d));
  317. return { x: e, y: g };
  318. },
  319. getRelPointerPos: function (b) {
  320. var d = (b.target || b.srcElement).getBoundingClientRect(),
  321. e = a.checkZoomRatio(),
  322. g = 0,
  323. h = 0;
  324. "undefined" !== typeof b.changedTouches && b.changedTouches.length
  325. ? ((g = b.changedTouches[0].x * e), (h = b.changedTouches[0].y * e))
  326. : "number" === typeof b.x && ((g = b.x * e), (h = b.y * e));
  327. return {
  328. x: g - (C ? d.left * e : d.left),
  329. y: h - (C ? d.top * e : d.top),
  330. };
  331. },
  332. getViewPos: function () {
  333. var b = p.document.documentElement;
  334. return [(p.pageXOffset || b.scrollLeft) - (b.clientLeft || 0), (p.pageYOffset || b.scrollTop) - (b.clientTop || 0)];
  335. },
  336. getViewSize: function () {
  337. var b = p.document.documentElement;
  338. return [p.innerWidth || b.clientWidth, p.innerHeight || b.clientHeight];
  339. },
  340. RGB_HSV: function (b, d, e) {
  341. b /= 255;
  342. d /= 255;
  343. e /= 255;
  344. var g = Math.min(Math.min(b, d), e),
  345. h = Math.max(Math.max(b, d), e),
  346. l = h - g;
  347. if (0 === l) return [null, 0, 100 * h];
  348. b = b === g ? 3 + (e - d) / l : d === g ? 5 + (b - e) / l : 1 + (d - b) / l;
  349. return [60 * (6 === b ? 0 : b), (l / h) * 100, 100 * h];
  350. },
  351. HSV_RGB: function (b, d, e) {
  352. e = (e / 100) * 255;
  353. if (null === b) return [e, e, e];
  354. b /= 60;
  355. d /= 100;
  356. var g = Math.floor(b),
  357. h = e * (1 - d);
  358. b = e * (1 - d * (g % 2 ? b - g : 1 - (b - g)));
  359. switch (g) {
  360. case 6:
  361. case 0:
  362. return [e, b, h];
  363. case 1:
  364. return [b, e, h];
  365. case 2:
  366. return [h, e, b];
  367. case 3:
  368. return [h, b, e];
  369. case 4:
  370. return [b, h, e];
  371. case 5:
  372. return [e, h, b];
  373. }
  374. },
  375. parseColorString: function (b) {
  376. var d = { rgba: null, format: null },
  377. e;
  378. if ((e = b.match(/^\W*([0-9A-F]{3,8})\W*$|^currentcolor$/i))) {
  379. if ("currentcolor" === e[0].toLowerCase()) return (d.format = "hexa"), (d.rgba = [255, 255, 255, 255]), d;
  380. if (8 === e[1].length)
  381. (d.format = "hexa"),
  382. (d.rgba = [parseInt(e[1].slice(0, 2), 16), parseInt(e[1].slice(2, 4), 16), parseInt(e[1].slice(4, 6), 16), parseInt(e[1].slice(6, 8), 16) / 255]);
  383. else if (6 === e[1].length) (d.format = "hex"), (d.rgba = [parseInt(e[1].slice(0, 2), 16), parseInt(e[1].slice(2, 4), 16), parseInt(e[1].slice(4, 6), 16), 1]);
  384. else if (3 === e[1].length)
  385. (d.format = "hex"),
  386. (d.rgba = [parseInt(e[1].charAt(0) + e[1].charAt(0), 16), parseInt(e[1].charAt(1) + e[1].charAt(1), 16), parseInt(e[1].charAt(2) + e[1].charAt(2), 16), 1]);
  387. else return !1;
  388. return d;
  389. }
  390. if ((e = b.match(/^\W*rgba?\(([^)]*)\)\W*$/i))) {
  391. b = e[1].split(",");
  392. e = /^\s*(\d+|\d*\.\d+|\d+\.\d*)\s*$/;
  393. var g, h, l, m;
  394. if (3 <= b.length && (g = b[0].match(e)) && (h = b[1].match(e)) && (l = b[2].match(e)))
  395. return (
  396. (d.format = "rgb"),
  397. (d.rgba = [parseFloat(g[1]) || 0, parseFloat(h[1]) || 0, parseFloat(l[1]) || 0, 1]),
  398. 4 <= b.length && (m = b[3].match(e)) && ((d.format = "rgba"), (d.rgba[3] = parseFloat(m[1]) || 0)),
  399. d
  400. );
  401. }
  402. return !1;
  403. },
  404. isAlphaFormat: function (b) {
  405. switch (b.toLowerCase()) {
  406. case "hexa":
  407. case "rgba":
  408. return !0;
  409. }
  410. return !1;
  411. },
  412. scaleCanvasForHighDPR: function (b) {
  413. var d = p.devicePixelRatio || 1;
  414. b.width *= d;
  415. b.height *= d;
  416. b.getContext("2d").scale(d, d);
  417. },
  418. genColorPreviewCanvas: function (b, d, e, g) {
  419. var h = Math.round(a.pub.previewSeparator.length),
  420. l = a.pub.chessboardSize,
  421. m = a.pub.chessboardColor1,
  422. r = a.pub.chessboardColor2;
  423. e = e ? e : 2 * l;
  424. var v = 2 * l,
  425. u = a.createEl("canvas"),
  426. z = u.getContext("2d");
  427. u.width = e;
  428. u.height = v;
  429. g && a.scaleCanvasForHighDPR(u);
  430. z.fillStyle = m;
  431. z.fillRect(0, 0, e, v);
  432. z.fillStyle = r;
  433. for (g = 0; g < e; g += 2 * l) z.fillRect(g, 0, l, l), z.fillRect(g + l, l, l, l);
  434. b && ((z.fillStyle = b), z.fillRect(0, 0, e, v));
  435. b = null;
  436. switch (d) {
  437. case "left":
  438. b = 0;
  439. z.clearRect(0, 0, h / 2, v);
  440. break;
  441. case "right":
  442. (b = e - h), z.clearRect(e - h / 2, 0, h / 2, v);
  443. }
  444. if (null !== b)
  445. for (z.lineWidth = 1, d = 0; d < a.pub.previewSeparator.length; d += 1)
  446. z.beginPath(), (z.strokeStyle = a.pub.previewSeparator[d]), z.moveTo(0.5 + b + d, 0), z.lineTo(0.5 + b + d, v), z.stroke();
  447. return { canvas: u, width: e, height: v };
  448. },
  449. genColorPreviewGradient: function (b, d, e) {
  450. return a.linearGradient.apply(
  451. this,
  452. d && e
  453. ? ["to " + { left: "right", right: "left" }[d], b + " 0%", b + " " + e + "px", "rgba(0,0,0,0) " + (e + 1) + "px", "rgba(0,0,0,0) 100%"]
  454. : ["to right", b + " 0%", b + " 100%"]
  455. );
  456. },
  457. redrawPosition: function () {
  458. if (a.picker && a.picker.owner) {
  459. var b = a.picker.owner;
  460. if (b.fixed) {
  461. var d = a.getElementPos(b.targetElement, !0);
  462. var e = [0, 0];
  463. } else (d = a.getElementPos(b.targetElement)), (e = a.getViewPos());
  464. var g = a.getElementSize(b.targetElement),
  465. h = a.getViewSize(),
  466. l = a.getPickerDims(b);
  467. l = [l.borderW, l.borderH];
  468. switch (b.position.toLowerCase()) {
  469. case "left":
  470. var m = 1;
  471. var r = 0;
  472. var v = -1;
  473. break;
  474. case "right":
  475. m = 1;
  476. r = 0;
  477. v = 1;
  478. break;
  479. case "top":
  480. m = 0;
  481. r = 1;
  482. v = -1;
  483. break;
  484. default:
  485. (m = 0), (v = r = 1);
  486. }
  487. var u = (g[r] + l[r]) / 2;
  488. e = b.smartPosition
  489. ? [
  490. -e[m] + d[m] + l[m] > h[m] ? (-e[m] + d[m] + g[m] / 2 > h[m] / 2 && 0 <= d[m] + g[m] - l[m] ? d[m] + g[m] - l[m] : d[m]) : d[m],
  491. -e[r] + d[r] + g[r] + l[r] - u + u * v > h[r]
  492. ? -e[r] + d[r] + g[r] / 2 > h[r] / 2 && 0 <= d[r] + g[r] - u - u * v
  493. ? d[r] + g[r] - u - u * v - 4
  494. : d[r] + g[r] - u + u * v + 4
  495. : 0 <= d[r] + g[r] - u + u * v
  496. ? d[r] + g[r] - u + u * v - 4
  497. : d[r] + g[r] - u - u * v + 4,
  498. ]
  499. : [d[m], d[r] + g[r] - u + u * v - 4];
  500. a._drawPosition(b, e[m], e[r], b.fixed ? "fixed" : "absolute", (e[0] + l[0] > d[0] || e[0] < d[0] + g[0]) && e[1] + l[1] < d[1] + g[1]);
  501. }
  502. },
  503. _drawPosition: function (b, d, e, g, h) {
  504. h = h ? 0 : b.shadowBlur;
  505. var l = a.checkZoomRatio();
  506. a.picker.wrap.style.left = d + "px";
  507. a.picker.wrap.style.top = e + "px";
  508. C &&
  509. l &&
  510. 1 !== l &&
  511. ((a.picker.wrap.style.left = d / l - K.getBoundingClientRect().left + "px"), (a.picker.wrap.style.top = e / l - K.getBoundingClientRect().top + "px"));
  512. a.picker.wrap.style.position = g;
  513. a.setBoxShadow(a.picker.boxS, b.shadow ? new a.BoxShadow(0, h, b.shadowBlur, 0, b.shadowColor) : null);
  514. },
  515. getPickerDims: function (b) {
  516. var d = 2 * b.controlBorderWidth + b.width,
  517. e = 2 * b.controlBorderWidth + b.height,
  518. g = 2 * b.controlBorderWidth + 2 * a.getControlPadding(b) + b.sliderSize;
  519. a.getSliderChannel(b) && (d += g);
  520. b.hasAlphaChannel() && (d += g);
  521. b.closeButton && (e += 2 * b.controlBorderWidth + b.padding + b.buttonHeight);
  522. g = d + 2 * b.padding;
  523. var h = e + 2 * b.padding;
  524. return {
  525. contentW: d,
  526. contentH: e,
  527. paddedW: g,
  528. paddedH: h,
  529. borderW: g + 2 * b.borderWidth,
  530. borderH: h + 2 * b.borderWidth,
  531. };
  532. },
  533. getControlPadding: function (b) {
  534. return Math.max(b.padding / 2, 2 * b.pointerBorderWidth + b.pointerThickness - b.controlBorderWidth);
  535. },
  536. getPadYChannel: function (b) {
  537. switch (b.mode.charAt(1).toLowerCase()) {
  538. case "v":
  539. return "v";
  540. }
  541. return "s";
  542. },
  543. getSliderChannel: function (b) {
  544. if (2 < b.mode.length)
  545. switch (b.mode.charAt(2).toLowerCase()) {
  546. case "s":
  547. return "s";
  548. case "v":
  549. return "v";
  550. }
  551. return null;
  552. },
  553. triggerCallback: function (b, d) {
  554. if (b[d]) {
  555. var e = null;
  556. if ("string" === typeof b[d])
  557. try {
  558. e = new Function(b[d]);
  559. } catch (g) {
  560. console.error(g);
  561. }
  562. else e = b[d];
  563. e && e.call(b);
  564. }
  565. },
  566. triggerGlobal: function (b) {
  567. for (var d = a.getInstances(), e = 0; e < d.length; e += 1) d[e].trigger(b);
  568. },
  569. _pointerMoveEvent: { mouse: "mousemove", touch: "touchmove" },
  570. _pointerEndEvent: { mouse: "mouseup", touch: "touchend" },
  571. _pointerOrigin: null,
  572. onDocumentKeyUp: function (b) {
  573. -1 !== ["Tab", "Escape"].indexOf(a.eventKey(b)) && a.picker && a.picker.owner && a.picker.owner.tryHide();
  574. },
  575. onWindowResize: function (b) {
  576. a.redrawPosition();
  577. },
  578. onWindowScroll: function (b) {
  579. C && 1 !== a.checkZoomRatio() ? a.picker && a.picker.owner && a.picker.owner.tryHide() : a.redrawPosition();
  580. },
  581. onParentScroll: function (b) {
  582. a.picker && a.picker.owner && a.picker.owner.tryHide();
  583. },
  584. onDocumentMouseDown: function (b) {
  585. var d = b.composedPath()[0] || b.target || b.srcElement;
  586. if (d.frcp && d.frcp instanceof a.pub) d.frcp.showOnClick && !d.disabled && (a.picker && a.picker.owner ? a.picker.owner.tryHide() : d.frcp.show());
  587. else if (a.getData(d, "gui")) {
  588. if (a.getData(d, "control")) a.onControlPointerStart(b, d, a.getData(d, "control"), "mouse");
  589. } else a.picker && a.picker.owner && a.picker.owner.tryHide();
  590. },
  591. onPickerTouchStart: function (b) {
  592. var d = b.target || b.srcElement;
  593. if (a.getData(d, "control")) a.onControlPointerStart(b, d, a.getData(d, "control"), "touch");
  594. },
  595. onControlPointerStart: function (b, d, e, g) {
  596. var h = a.getData(d, "instance");
  597. a.preventDefault(b);
  598. var l = function (v, u) {
  599. a.attachGroupEvent("drag", v, a._pointerMoveEvent[g], a.onDocumentPointerMove(b, d, e, g, u));
  600. a.attachGroupEvent("drag", v, a._pointerEndEvent[g], a.onDocumentPointerEnd(b, d, e, g));
  601. };
  602. l(p.document, [0, 0]);
  603. if (p.parent && p.frameElement) {
  604. var m = a.checkZoomRatio(),
  605. r = p.frameElement.getBoundingClientRect();
  606. l(p.parent.window.document, C ? [-r.left * m, -r.top * m] : [-r.left, -r.top]);
  607. }
  608. l = a.getAbsPointerPos(b);
  609. m = a.getRelPointerPos(b);
  610. a._pointerOrigin = { x: l.x - m.x, y: l.y - m.y };
  611. switch (e) {
  612. case "pad":
  613. "v" === a.getSliderChannel(h) && 0 === h.channels.v && h.fromHSVA(null, null, 100, null);
  614. a.setPad(h, b, 0, 0);
  615. break;
  616. case "sld":
  617. a.setSld(h, b, 0);
  618. break;
  619. case "asld":
  620. a.setASld(h, b, 0);
  621. }
  622. h.trigger("input");
  623. },
  624. onDocumentPointerMove: function (b, d, e, g, h) {
  625. return function (l) {
  626. var m = a.getData(d, "instance");
  627. switch (e) {
  628. case "pad":
  629. a.setPad(m, l, h[0], h[1]);
  630. break;
  631. case "sld":
  632. a.setSld(m, l, h[1]);
  633. break;
  634. case "asld":
  635. a.setASld(m, l, h[1]);
  636. }
  637. m.trigger("input");
  638. };
  639. },
  640. onDocumentPointerEnd: function (b, d, e, g) {
  641. return function (h) {
  642. h = a.getData(d, "instance");
  643. a.detachGroupEvents("drag");
  644. h.trigger("input");
  645. h.trigger("change");
  646. };
  647. },
  648. setPad: function (b, d, e, g) {
  649. d = a.getAbsPointerPos(d);
  650. e = (360 / (b.width - 1)) * (e + d.x - a._pointerOrigin.x - b.padding - b.controlBorderWidth);
  651. g = 100 - (100 / (b.height - 1)) * (g + d.y - a._pointerOrigin.y - b.padding - b.controlBorderWidth);
  652. switch (a.getPadYChannel(b)) {
  653. case "s":
  654. b.fromHSVA(e, g, null, null);
  655. break;
  656. case "v":
  657. b.fromHSVA(e, null, g, null);
  658. }
  659. },
  660. setSld: function (b, d, e) {
  661. d = a.getAbsPointerPos(d);
  662. e = 100 - (100 / (b.height - 1)) * (e + d.y - a._pointerOrigin.y - b.padding - b.controlBorderWidth);
  663. switch (a.getSliderChannel(b)) {
  664. case "s":
  665. b.fromHSVA(null, e, null, null);
  666. break;
  667. case "v":
  668. b.fromHSVA(null, null, e, null);
  669. }
  670. },
  671. setASld: function (b, d, e) {
  672. d = a.getAbsPointerPos(d);
  673. e = 1 - (1 / (b.height - 1)) * (e + d.y - a._pointerOrigin.y - b.padding - b.controlBorderWidth);
  674. 1 > e && ((d = b.getFormat()), "any" !== b.format.toLowerCase() || a.isAlphaFormat(d) || b._setFormat("hex" === d ? "hexa" : "rgba"));
  675. b.fromHSVA(null, null, null, e);
  676. },
  677. createPadCanvas: function () {
  678. var b = { elm: null, draw: null },
  679. d = a.createEl("canvas"),
  680. e = d.getContext("2d");
  681. b.elm = d;
  682. b.draw = function (g, h, l) {
  683. d.width = g;
  684. d.height = h;
  685. e.clearRect(0, 0, d.width, d.height);
  686. g = e.createLinearGradient(0, 0, d.width, 0);
  687. g.addColorStop(0, "#F00");
  688. g.addColorStop(1 / 6, "#FF0");
  689. g.addColorStop(2 / 6, "#0F0");
  690. g.addColorStop(0.5, "#0FF");
  691. g.addColorStop(4 / 6, "#00F");
  692. g.addColorStop(5 / 6, "#F0F");
  693. g.addColorStop(1, "#F00");
  694. e.fillStyle = g;
  695. e.fillRect(0, 0, d.width, d.height);
  696. g = e.createLinearGradient(0, 0, 0, d.height);
  697. switch (l.toLowerCase()) {
  698. case "s":
  699. g.addColorStop(0, "rgba(255,255,255,0)");
  700. g.addColorStop(1, "rgba(255,255,255,1)");
  701. break;
  702. case "v":
  703. g.addColorStop(0, "rgba(0,0,0,0)"), g.addColorStop(1, "rgba(0,0,0,1)");
  704. }
  705. e.fillStyle = g;
  706. e.fillRect(0, 0, d.width, d.height);
  707. };
  708. return b;
  709. },
  710. createSliderGradient: function () {
  711. var b = { elm: null, draw: null },
  712. d = a.createEl("canvas"),
  713. e = d.getContext("2d");
  714. b.elm = d;
  715. b.draw = function (g, h, l, m) {
  716. d.width = g;
  717. d.height = h;
  718. e.clearRect(0, 0, d.width, d.height);
  719. g = e.createLinearGradient(0, 0, 0, d.height);
  720. g.addColorStop(0, l);
  721. g.addColorStop(1, m);
  722. e.fillStyle = g;
  723. e.fillRect(0, 0, d.width, d.height);
  724. };
  725. return b;
  726. },
  727. createASliderGradient: function () {
  728. var b = { elm: null, draw: null },
  729. d = a.createEl("canvas"),
  730. e = d.getContext("2d");
  731. b.elm = d;
  732. b.draw = function (g, h, l) {
  733. d.width = g;
  734. d.height = h;
  735. e.clearRect(0, 0, d.width, d.height);
  736. g = d.width / 2;
  737. h = a.pub.chessboardColor2;
  738. e.fillStyle = a.pub.chessboardColor1;
  739. e.fillRect(0, 0, d.width, d.height);
  740. if (0 < g) for (var m = 0; m < d.height; m += 2 * g) (e.fillStyle = h), e.fillRect(0, m, g, g), e.fillRect(g, m + g, g, g);
  741. g = e.createLinearGradient(0, 0, 0, d.height);
  742. g.addColorStop(0, l);
  743. g.addColorStop(1, "rgba(0,0,0,0)");
  744. e.fillStyle = g;
  745. e.fillRect(0, 0, d.width, d.height);
  746. };
  747. return b;
  748. },
  749. BoxShadow: (function () {
  750. var b = function (d, e, g, h, l, m) {
  751. this.hShadow = d;
  752. this.vShadow = e;
  753. this.blur = g;
  754. this.spread = h;
  755. this.color = l;
  756. this.inset = !!m;
  757. };
  758. b.prototype.toString = function () {
  759. var d = [Math.round(this.hShadow) + "px", Math.round(this.vShadow) + "px", Math.round(this.blur) + "px", Math.round(this.spread) + "px", this.color];
  760. this.inset && d.push("inset");
  761. return d.join(" ");
  762. };
  763. return b;
  764. })(),
  765. flags: { leaveValue: 1, leaveAlpha: 2, leavePreview: 4 },
  766. enumOpts: {
  767. format: "auto any hex hexa rgb rgba".split(" "),
  768. previewPosition: ["left", "right"],
  769. mode: ["hsv", "hvs", "hs", "hv"],
  770. position: ["left", "right", "top", "bottom"],
  771. alphaChannel: ["auto", !0, !1],
  772. },
  773. deprecatedOpts: {
  774. styleElement: "previewElement",
  775. onFineChange: "onInput",
  776. overwriteImportant: "forceStyle",
  777. closable: "closeButton",
  778. insetWidth: "controlBorderWidth",
  779. insetColor: "controlBorderColor",
  780. refine: null,
  781. },
  782. pub: function (b, d) {
  783. function e(c, k) {
  784. if ("string" !== typeof c) throw Error("Invalid value for option name: " + c);
  785. if (a.enumOpts.hasOwnProperty(c) && ("string" === typeof k && (k = k.toLowerCase()), -1 === a.enumOpts[c].indexOf(k)))
  786. throw Error("Option '" + c + "' has invalid value: " + k);
  787. if (a.deprecatedOpts.hasOwnProperty(c)) {
  788. var n = a.deprecatedOpts[c];
  789. if (n) c = n;
  790. else throw Error("Option '" + c + "' is DEPRECATED");
  791. }
  792. n = "set__" + c;
  793. if ("function" === typeof f[n]) return f[n](k), !0;
  794. if (c in f) return (f[c] = k), !0;
  795. throw Error("Unrecognized configuration option: " + c);
  796. }
  797. function g() {
  798. f._processParentElementsInDOM();
  799. a.picker ||
  800. ((a.picker = {
  801. owner: null,
  802. wrap: a.createEl("fr-colorpicker"),
  803. box: a.createEl("div"),
  804. boxS: a.createEl("div"),
  805. boxB: a.createEl("div"),
  806. pad: a.createEl("div"),
  807. padB: a.createEl("div"),
  808. padM: a.createEl("div"),
  809. padCanvas: a.createPadCanvas(),
  810. cross: a.createEl("div"),
  811. crossBY: a.createEl("div"),
  812. crossBX: a.createEl("div"),
  813. crossLY: a.createEl("div"),
  814. crossLX: a.createEl("div"),
  815. sld: a.createEl("div"),
  816. sldB: a.createEl("div"),
  817. sldM: a.createEl("div"),
  818. sldGrad: a.createSliderGradient(),
  819. sldPtrS: a.createEl("div"),
  820. sldPtrIB: a.createEl("div"),
  821. sldPtrMB: a.createEl("div"),
  822. sldPtrOB: a.createEl("div"),
  823. asld: a.createEl("div"),
  824. asldB: a.createEl("div"),
  825. asldM: a.createEl("div"),
  826. asldGrad: a.createASliderGradient(),
  827. asldPtrS: a.createEl("div"),
  828. asldPtrIB: a.createEl("div"),
  829. asldPtrMB: a.createEl("div"),
  830. asldPtrOB: a.createEl("div"),
  831. }),
  832. a.picker.pad.appendChild(a.picker.padCanvas.elm),
  833. a.picker.padB.appendChild(a.picker.pad),
  834. a.picker.cross.appendChild(a.picker.crossBY),
  835. a.picker.cross.appendChild(a.picker.crossBX),
  836. a.picker.cross.appendChild(a.picker.crossLY),
  837. a.picker.cross.appendChild(a.picker.crossLX),
  838. a.picker.padB.appendChild(a.picker.cross),
  839. a.picker.box.appendChild(a.picker.padB),
  840. a.picker.box.appendChild(a.picker.padM),
  841. a.picker.sld.appendChild(a.picker.sldGrad.elm),
  842. a.picker.sldB.appendChild(a.picker.sld),
  843. a.picker.sldB.appendChild(a.picker.sldPtrOB),
  844. a.picker.sldPtrOB.appendChild(a.picker.sldPtrMB),
  845. a.picker.sldPtrMB.appendChild(a.picker.sldPtrIB),
  846. a.picker.sldPtrIB.appendChild(a.picker.sldPtrS),
  847. a.picker.box.appendChild(a.picker.sldB),
  848. a.picker.box.appendChild(a.picker.sldM),
  849. a.picker.asld.appendChild(a.picker.asldGrad.elm),
  850. a.picker.asldB.appendChild(a.picker.asld),
  851. a.picker.asldB.appendChild(a.picker.asldPtrOB),
  852. a.picker.asldPtrOB.appendChild(a.picker.asldPtrMB),
  853. a.picker.asldPtrMB.appendChild(a.picker.asldPtrIB),
  854. a.picker.asldPtrIB.appendChild(a.picker.asldPtrS),
  855. a.picker.box.appendChild(a.picker.asldB),
  856. a.picker.box.appendChild(a.picker.asldM),
  857. a.picker.boxB.appendChild(a.picker.box),
  858. a.picker.wrap.appendChild(a.picker.boxS),
  859. a.picker.wrap.appendChild(a.picker.boxB),
  860. a.picker.wrap.addEventListener("touchstart", a.onPickerTouchStart, a.isPassiveEventSupported ? { passive: !1 } : !1));
  861. var c = a.picker,
  862. k = !!a.getSliderChannel(f),
  863. n = f.hasAlphaChannel(),
  864. q = a.getPickerDims(f),
  865. t = 2 * f.pointerBorderWidth + f.pointerThickness + 2 * f.crossSize,
  866. w = a.getControlPadding(f),
  867. B = Math.min(f.borderRadius, Math.round(f.padding * Math.PI)),
  868. x = a.checkZoomRatio();
  869. c.wrap.className = L;
  870. c.wrap.style.clear = "both";
  871. c.wrap.style.width = q.borderW + "px";
  872. c.wrap.style.height = q.borderH + "px";
  873. c.wrap.style.zIndex = f.zIndex;
  874. C
  875. ? x && 1 !== x
  876. ? ((c.wrap.style.position = "absolute"), (c.wrap.style.transformOrigin = "left top 0"), (c.wrap.style.transform = "scale(" + 1 / x + ")"))
  877. : ((c.wrap.style.transformOrigin = null), (c.wrap.style.transform = null))
  878. : (c.wrap.style.zoom = x && 1 !== x ? 1 / x : null);
  879. c.box.className = M;
  880. c.box.style.width = q.paddedW + "px";
  881. c.box.style.height = q.paddedH + "px";
  882. c.box.style.position = "relative";
  883. c.boxS.className = N;
  884. c.boxS.style.position = "absolute";
  885. c.boxS.style.left = "0";
  886. c.boxS.style.top = "0";
  887. c.boxS.style.width = "100%";
  888. c.boxS.style.height = "100%";
  889. a.setBorderRadius(c.boxS, B + "px");
  890. c.boxB.className = O;
  891. c.boxB.style.position = "relative";
  892. c.boxB.style.border = f.borderWidth + "px solid";
  893. c.boxB.style.borderColor = f.borderColor;
  894. c.boxB.style.background = f.backgroundColor;
  895. a.setBorderRadius(c.boxB, B + "px");
  896. c.padM.style.background = "rgba(255,0,0,.2)";
  897. c.sldM.style.background = "rgba(0,255,0,.2)";
  898. c.asldM.style.background = "rgba(0,0,255,.2)";
  899. c.padM.style.opacity = c.sldM.style.opacity = c.asldM.style.opacity = "0";
  900. c.pad.style.position = "relative";
  901. c.pad.style.width = f.width + "px";
  902. c.pad.style.height = f.height + "px";
  903. c.padCanvas.draw(f.width, f.height, a.getPadYChannel(f));
  904. c.padB.style.position = "absolute";
  905. c.padB.style.left = f.padding + "px";
  906. c.padB.style.top = f.padding + "px";
  907. c.padB.style.border = f.controlBorderWidth + "px solid";
  908. c.padB.style.borderColor = f.controlBorderColor;
  909. c.padM.style.position = "absolute";
  910. c.padM.style.left = "0px";
  911. c.padM.style.top = "0px";
  912. c.padM.style.width = f.padding + 2 * f.controlBorderWidth + f.width + w + "px";
  913. c.padM.style.height = 2 * f.controlBorderWidth + 2 * f.padding + f.height + "px";
  914. c.padM.style.cursor = "crosshair";
  915. a.setData(c.padM, { instance: f, control: "pad" });
  916. c.cross.style.position = "absolute";
  917. c.cross.style.left = c.cross.style.top = "0";
  918. c.cross.style.width = c.cross.style.height = t + "px";
  919. c.crossBY.style.position = c.crossBX.style.position = "absolute";
  920. c.crossBY.style.background = c.crossBX.style.background = f.pointerBorderColor;
  921. c.crossBY.style.width = c.crossBX.style.height = 2 * f.pointerBorderWidth + f.pointerThickness + "px";
  922. c.crossBY.style.height = c.crossBX.style.width = t + "px";
  923. c.crossBY.style.left = c.crossBX.style.top = Math.floor(t / 2) - Math.floor(f.pointerThickness / 2) - f.pointerBorderWidth + "px";
  924. c.crossBY.style.top = c.crossBX.style.left = "0";
  925. c.crossLY.style.position = c.crossLX.style.position = "absolute";
  926. c.crossLY.style.background = c.crossLX.style.background = f.pointerColor;
  927. c.crossLY.style.height = c.crossLX.style.width = t - 2 * f.pointerBorderWidth + "px";
  928. c.crossLY.style.width = c.crossLX.style.height = f.pointerThickness + "px";
  929. c.crossLY.style.left = c.crossLX.style.top = Math.floor(t / 2) - Math.floor(f.pointerThickness / 2) + "px";
  930. c.crossLY.style.top = c.crossLX.style.left = f.pointerBorderWidth + "px";
  931. c.sld.style.overflow = "hidden";
  932. c.sld.style.width = f.sliderSize + "px";
  933. c.sld.style.height = f.height + "px";
  934. c.sldGrad.draw(f.sliderSize, f.height, "#000", "#000");
  935. c.sldB.style.display = k ? "block" : "none";
  936. c.sldB.style.position = "absolute";
  937. c.sldB.style.left = f.padding + f.width + 2 * f.controlBorderWidth + 2 * w + "px";
  938. c.sldB.style.top = f.padding + "px";
  939. c.sldB.style.border = f.controlBorderWidth + "px solid";
  940. c.sldB.style.borderColor = f.controlBorderColor;
  941. c.sldM.style.display = k ? "block" : "none";
  942. c.sldM.style.position = "absolute";
  943. c.sldM.style.left = f.padding + f.width + 2 * f.controlBorderWidth + w + "px";
  944. c.sldM.style.top = "0px";
  945. c.sldM.style.width = f.sliderSize + 2 * w + 2 * f.controlBorderWidth + (n ? 0 : Math.max(0, f.padding - w)) + "px";
  946. c.sldM.style.height = 2 * f.controlBorderWidth + 2 * f.padding + f.height + "px";
  947. c.sldM.style.cursor = "default";
  948. a.setData(c.sldM, { instance: f, control: "sld" });
  949. c.sldPtrIB.style.border = c.sldPtrOB.style.border = f.pointerBorderWidth + "px solid " + f.pointerBorderColor;
  950. c.sldPtrOB.style.position = "absolute";
  951. c.sldPtrOB.style.left = -(2 * f.pointerBorderWidth + f.pointerThickness) + "px";
  952. c.sldPtrOB.style.top = "0";
  953. c.sldPtrMB.style.border = f.pointerThickness + "px solid " + f.pointerColor;
  954. c.sldPtrS.style.width = f.sliderSize + "px";
  955. c.sldPtrS.style.height = a.pub.sliderInnerSpace + "px";
  956. c.asld.style.overflow = "hidden";
  957. c.asld.style.width = f.sliderSize + "px";
  958. c.asld.style.height = f.height + "px";
  959. c.asldGrad.draw(f.sliderSize, f.height, "#000");
  960. c.asldB.style.display = n ? "block" : "none";
  961. c.asldB.style.position = "absolute";
  962. c.asldB.style.left = f.padding + f.width + 2 * f.controlBorderWidth + w + (k ? f.sliderSize + 3 * w + 2 * f.controlBorderWidth : 0) + "px";
  963. c.asldB.style.top = f.padding + "px";
  964. c.asldB.style.border = f.controlBorderWidth + "px solid";
  965. c.asldB.style.borderColor = f.controlBorderColor;
  966. c.asldM.style.display = n ? "block" : "none";
  967. c.asldM.style.position = "absolute";
  968. c.asldM.style.left = f.padding + f.width + 2 * f.controlBorderWidth + w + (k ? f.sliderSize + 2 * w + 2 * f.controlBorderWidth : 0) + "px";
  969. c.asldM.style.top = "0px";
  970. c.asldM.style.width = f.sliderSize + 2 * w + 2 * f.controlBorderWidth + Math.max(0, f.padding - w) + "px";
  971. c.asldM.style.height = 2 * f.controlBorderWidth + 2 * f.padding + f.height + "px";
  972. c.asldM.style.cursor = "default";
  973. a.setData(c.asldM, { instance: f, control: "asld" });
  974. c.asldPtrIB.style.border = c.asldPtrOB.style.border = f.pointerBorderWidth + "px solid " + f.pointerBorderColor;
  975. c.asldPtrOB.style.position = "absolute";
  976. c.asldPtrOB.style.left = -(2 * f.pointerBorderWidth + f.pointerThickness) + "px";
  977. c.asldPtrOB.style.top = "0";
  978. c.asldPtrMB.style.border = f.pointerThickness + "px solid " + f.pointerColor;
  979. c.asldPtrS.style.width = f.sliderSize + "px";
  980. c.asldPtrS.style.height = a.pub.sliderInnerSpace + "px";
  981. h();
  982. l();
  983. m();
  984. a.picker.owner && a.picker.owner !== f && a.removeClass(a.picker.owner.targetElement, a.pub.activeClassName);
  985. a.picker.owner = f;
  986. f.container === p.document.body ? a.redrawPosition() : a._drawPosition(f, 0, 0, "relative", !1);
  987. c.wrap.parentNode !== f.container && f.container.appendChild(c.wrap);
  988. a.addClass(f.targetElement, a.pub.activeClassName);
  989. }
  990. function h() {
  991. var c = a.getPadYChannel(f);
  992. c = Math.round((1 - f.channels[c] / 100) * (f.height - 1));
  993. var k = -Math.floor((2 * f.pointerBorderWidth + f.pointerThickness + 2 * f.crossSize) / 2);
  994. a.picker.cross.style.left = Math.round((f.channels.h / 360) * (f.width - 1)) + k + "px";
  995. a.picker.cross.style.top = c + k + "px";
  996. switch (a.getSliderChannel(f)) {
  997. case "s":
  998. k = a.HSV_RGB(f.channels.h, 100, f.channels.v);
  999. c = a.HSV_RGB(f.channels.h, 0, f.channels.v);
  1000. k = "rgb(" + Math.round(k[0]) + "," + Math.round(k[1]) + "," + Math.round(k[2]) + ")";
  1001. a.picker.sldGrad.draw(f.sliderSize, f.height, k, "rgb(" + Math.round(c[0]) + "," + Math.round(c[1]) + "," + Math.round(c[2]) + ")");
  1002. break;
  1003. case "v":
  1004. (c = a.HSV_RGB(f.channels.h, f.channels.s, 100)),
  1005. (k = "rgb(" + Math.round(c[0]) + "," + Math.round(c[1]) + "," + Math.round(c[2]) + ")"),
  1006. a.picker.sldGrad.draw(f.sliderSize, f.height, k, "#000");
  1007. }
  1008. a.picker.asldGrad.draw(f.sliderSize, f.height, f.toHEXString());
  1009. }
  1010. function l() {
  1011. var c = a.getSliderChannel(f);
  1012. c &&
  1013. (a.picker.sldPtrOB.style.top =
  1014. Math.round((1 - f.channels[c] / 100) * (f.height - 1)) - (2 * f.pointerBorderWidth + f.pointerThickness) - Math.floor(a.pub.sliderInnerSpace / 2) + "px");
  1015. a.picker.asldGrad.draw(f.sliderSize, f.height, f.toHEXString());
  1016. }
  1017. function m() {
  1018. a.picker.asldPtrOB.style.top =
  1019. Math.round((1 - f.channels.a) * (f.height - 1)) - (2 * f.pointerBorderWidth + f.pointerThickness) - Math.floor(a.pub.sliderInnerSpace / 2) + "px";
  1020. }
  1021. function r() {
  1022. return a.picker && a.picker.owner === f;
  1023. }
  1024. function v(c) {
  1025. "Enter" === a.eventKey(c) && (f.valueElement && f.processValueInput(f.valueElement.value), f.tryHide());
  1026. }
  1027. function u(c) {
  1028. "Enter" === a.eventKey(c) && (f.alphaElement && f.processAlphaInput(f.alphaElement.value), f.tryHide());
  1029. }
  1030. function z(c) {
  1031. a.getData(c, "internal") ||
  1032. ((c = f.valueElement.value),
  1033. f.processValueInput(f.valueElement.value),
  1034. a.triggerCallback(f, "onChange"),
  1035. f.valueElement.value !== c && a.triggerInputEvent(f.valueElement, "change", !0, !0));
  1036. }
  1037. function P(c) {
  1038. a.getData(c, "internal") ||
  1039. ((c = f.alphaElement.value),
  1040. f.processAlphaInput(f.alphaElement.value),
  1041. a.triggerCallback(f, "onChange"),
  1042. a.triggerInputEvent(f.valueElement, "change", !0, !0),
  1043. f.alphaElement.value !== c && a.triggerInputEvent(f.alphaElement, "change", !0, !0));
  1044. }
  1045. function Q(c) {
  1046. a.getData(c, "internal") || (f.valueElement && f.fromString(f.valueElement.value, a.flags.leaveValue), a.triggerCallback(f, "onInput"));
  1047. }
  1048. function R(c) {
  1049. a.getData(c, "internal") ||
  1050. (f.alphaElement && f.fromHSVA(null, null, null, parseFloat(f.alphaElement.value), a.flags.leaveAlpha),
  1051. a.triggerCallback(f, "onInput"),
  1052. a.triggerInputEvent(f.valueElement, "input", !0, !0));
  1053. }
  1054. var f = this;
  1055. d || (d = {});
  1056. this.channels = {
  1057. r: 255,
  1058. g: 255,
  1059. b: 255,
  1060. h: 0,
  1061. s: 0,
  1062. v: 100,
  1063. a: 1,
  1064. };
  1065. this.format = "auto";
  1066. this.alpha = this.value = void 0;
  1067. this.random = !1;
  1068. this.previewElement = this.alphaElement = this.valueElement = this.onInput = this.onChange = void 0;
  1069. this.previewPosition = "left";
  1070. this.previewSize = 32;
  1071. this.previewPadding = 8;
  1072. this.forceStyle = this.uppercase = this.hash = this.required = !0;
  1073. this.width = 181;
  1074. this.height = 101;
  1075. this.mode = "HSV";
  1076. this.alphaChannel = "auto";
  1077. this.position = "bottom";
  1078. this.hideOnLeave = this.showOnClick = this.smartPosition = !0;
  1079. this.sliderSize = 16;
  1080. this.crossSize = 8;
  1081. this.closeButton = !1;
  1082. this.closeText = "Close";
  1083. this.buttonColor = "rgba(0,0,0,1)";
  1084. this.buttonHeight = 18;
  1085. this.padding = 12;
  1086. this.backgroundColor = "rgba(255,255,255,1)";
  1087. this.borderWidth = 1;
  1088. this.borderColor = "rgba(187,187,187,1)";
  1089. this.borderRadius = 8;
  1090. this.controlBorderWidth = 1;
  1091. this.controlBorderColor = "rgba(187,187,187,1)";
  1092. this.shadow = !0;
  1093. this.shadowBlur = 15;
  1094. this.shadowColor = "rgba(0,0,0,0.2)";
  1095. this.pointerColor = "rgba(76,76,76,1)";
  1096. this.pointerBorderWidth = 1;
  1097. this.pointerBorderColor = "rgba(255,255,255,1)";
  1098. this.pointerThickness = 2;
  1099. this.zIndex = 1999999993;
  1100. this.container = void 0;
  1101. this.minS = 0;
  1102. this.maxS = 100;
  1103. this.minV = 0;
  1104. this.maxV = 100;
  1105. this.minA = 0;
  1106. this.maxA = 1;
  1107. this.option = function () {
  1108. if (!arguments.length) throw Error("No option specified");
  1109. if (1 === arguments.length && "string" === typeof arguments[0]) {
  1110. try {
  1111. var c = arguments[0];
  1112. if ("string" !== typeof c) throw Error("Invalid value for option name: " + c);
  1113. if (a.deprecatedOpts.hasOwnProperty(c)) {
  1114. var k = a.deprecatedOpts[c];
  1115. if (k) c = k;
  1116. else throw Error("Option '" + c + "' is DEPRECATED");
  1117. }
  1118. var n = "get__" + c;
  1119. if ("function" === typeof f[n]) var q = f[n](value);
  1120. else if (c in f) q = f[c];
  1121. else throw Error("Unrecognized configuration option: " + c);
  1122. return q;
  1123. } catch (t) {
  1124. console.error(t);
  1125. }
  1126. return !1;
  1127. }
  1128. if (2 <= arguments.length && "string" === typeof arguments[0]) {
  1129. try {
  1130. if (!e(arguments[0], arguments[1])) return !1;
  1131. } catch (t) {
  1132. return console.error(t), !1;
  1133. }
  1134. this.redraw();
  1135. this.exposeColor();
  1136. return !0;
  1137. }
  1138. if (1 === arguments.length && "object" === typeof arguments[0]) {
  1139. q = arguments[0];
  1140. c = !0;
  1141. for (n in q)
  1142. if (q.hasOwnProperty(n))
  1143. try {
  1144. e(n, q[n]) || (c = !1);
  1145. } catch (t) {
  1146. console.error(t), (c = !1);
  1147. }
  1148. this.redraw();
  1149. this.exposeColor();
  1150. return c;
  1151. }
  1152. throw Error("Invalid arguments");
  1153. };
  1154. this.channel = function (c, k) {
  1155. if ("string" !== typeof c) throw Error("Invalid value for channel name: " + c);
  1156. if (void 0 === k) return this.channels.hasOwnProperty(c.toLowerCase()) ? this.channels[c.toLowerCase()] : !1;
  1157. switch (c.toLowerCase()) {
  1158. case "r":
  1159. c = this.fromRGBA(k, null, null, null);
  1160. break;
  1161. case "g":
  1162. c = this.fromRGBA(null, k, null, null);
  1163. break;
  1164. case "b":
  1165. c = this.fromRGBA(null, null, k, null);
  1166. break;
  1167. case "h":
  1168. c = this.fromHSVA(k, null, null, null);
  1169. break;
  1170. case "s":
  1171. c = this.fromHSVA(null, k, null, null);
  1172. break;
  1173. case "v":
  1174. c = this.fromHSVA(null, null, k, null);
  1175. break;
  1176. case "a":
  1177. c = this.fromHSVA(null, null, null, k);
  1178. break;
  1179. default:
  1180. return !1;
  1181. }
  1182. return c ? (this.redraw(), !0) : !1;
  1183. };
  1184. this.trigger = function (c) {
  1185. c = a.strList(c);
  1186. for (var k = 0; k < c.length; k += 1) {
  1187. var n = c[k].toLowerCase(),
  1188. q = null;
  1189. switch (n) {
  1190. case "input":
  1191. q = "onInput";
  1192. break;
  1193. case "change":
  1194. q = "onChange";
  1195. }
  1196. q && a.triggerCallback(this, q);
  1197. a.triggerInputEvent(this.valueElement, n, !0, !0);
  1198. }
  1199. };
  1200. this.fromHSVA = function (c, k, n, q, t) {
  1201. void 0 === c && (c = null);
  1202. void 0 === k && (k = null);
  1203. void 0 === n && (n = null);
  1204. void 0 === q && (q = null);
  1205. if (null !== c) {
  1206. if (isNaN(c)) return !1;
  1207. this.channels.h = Math.max(0, Math.min(360, c));
  1208. }
  1209. if (null !== k) {
  1210. if (isNaN(k)) return !1;
  1211. this.channels.s = Math.max(0, Math.min(100, this.maxS, k), this.minS);
  1212. }
  1213. if (null !== n) {
  1214. if (isNaN(n)) return !1;
  1215. this.channels.v = Math.max(0, Math.min(100, this.maxV, n), this.minV);
  1216. }
  1217. if (null !== q) {
  1218. if (isNaN(q)) return !1;
  1219. this.channels.a = this.hasAlphaChannel() ? Math.max(0, Math.min(1, this.maxA, q), this.minA) : 1;
  1220. }
  1221. c = a.HSV_RGB(this.channels.h, this.channels.s, this.channels.v);
  1222. this.channels.r = c[0];
  1223. this.channels.g = c[1];
  1224. this.channels.b = c[2];
  1225. this.exposeColor(t);
  1226. return !0;
  1227. };
  1228. this.fromRGBA = function (c, k, n, q, t) {
  1229. void 0 === c && (c = null);
  1230. void 0 === k && (k = null);
  1231. void 0 === n && (n = null);
  1232. void 0 === q && (q = null);
  1233. if (null !== c) {
  1234. if (isNaN(c)) return !1;
  1235. c = Math.max(0, Math.min(255, c));
  1236. }
  1237. if (null !== k) {
  1238. if (isNaN(k)) return !1;
  1239. k = Math.max(0, Math.min(255, k));
  1240. }
  1241. if (null !== n) {
  1242. if (isNaN(n)) return !1;
  1243. n = Math.max(0, Math.min(255, n));
  1244. }
  1245. if (null !== q) {
  1246. if (isNaN(q)) return !1;
  1247. this.channels.a = this.hasAlphaChannel() ? Math.max(0, Math.min(1, this.maxA, q), this.minA) : 1;
  1248. }
  1249. c = a.RGB_HSV(null === c ? this.channels.r : c, null === k ? this.channels.g : k, null === n ? this.channels.b : n);
  1250. null !== c[0] && (this.channels.h = Math.max(0, Math.min(360, c[0])));
  1251. 0 !== c[2] && (this.channels.s = Math.max(0, this.minS, Math.min(100, this.maxS, c[1])));
  1252. this.channels.v = Math.max(0, this.minV, Math.min(100, this.maxV, c[2]));
  1253. c = a.HSV_RGB(this.channels.h, this.channels.s, this.channels.v);
  1254. this.channels.r = c[0];
  1255. this.channels.g = c[1];
  1256. this.channels.b = c[2];
  1257. this.exposeColor(t);
  1258. return !0;
  1259. };
  1260. this.fromHSV = function (c, k, n, q) {
  1261. return this.fromHSVA(c, k, n, null, q);
  1262. };
  1263. this.fromRGB = function (c, k, n, q) {
  1264. return this.fromRGBA(c, k, n, null, q);
  1265. };
  1266. this.fromString = function (c, k) {
  1267. if (!this.required && "" === c.trim()) return this.setPreviewElementBg(null), this.setValueElementValue(""), !0;
  1268. c = a.parseColorString(c);
  1269. if (!c) return !1;
  1270. "any" === this.format.toLowerCase() && (this._setFormat(c.format), a.isAlphaFormat(this.getFormat()) || (c.rgba[3] = 1));
  1271. this.fromRGBA(c.rgba[0], c.rgba[1], c.rgba[2], c.rgba[3], k);
  1272. return !0;
  1273. };
  1274. this.randomize = function (c, k, n, q, t, w, B, x) {
  1275. void 0 === c && (c = 0);
  1276. void 0 === k && (k = 100);
  1277. void 0 === n && (n = 0);
  1278. void 0 === q && (q = 100);
  1279. void 0 === t && (t = 0);
  1280. void 0 === w && (w = 359);
  1281. void 0 === B && (B = 1);
  1282. void 0 === x && (x = 1);
  1283. this.fromHSVA(
  1284. t + Math.floor(Math.random() * (w - t + 1)),
  1285. n + Math.floor(Math.random() * (q - n + 1)),
  1286. c + Math.floor(Math.random() * (k - c + 1)),
  1287. (100 * B + Math.floor(Math.random() * (100 * (x - B) + 1))) / 100
  1288. );
  1289. };
  1290. this.toString = function (c) {
  1291. void 0 === c && (c = this.getFormat());
  1292. switch (c.toLowerCase()) {
  1293. case "hex":
  1294. return this.toHEXString();
  1295. case "hexa":
  1296. return this.toHEXAString();
  1297. case "rgb":
  1298. return this.toRGBString();
  1299. case "rgba":
  1300. return this.toRGBAString();
  1301. }
  1302. return !1;
  1303. };
  1304. this.toHEXString = function () {
  1305. return a.hexColor(this.channels.r, this.channels.g, this.channels.b);
  1306. };
  1307. this.toHEXAString = function () {
  1308. return a.hexaColor(this.channels.r, this.channels.g, this.channels.b, this.channels.a);
  1309. };
  1310. this.toRGBString = function () {
  1311. return a.rgbColor(this.channels.r, this.channels.g, this.channels.b);
  1312. };
  1313. this.toRGBAString = function () {
  1314. return a.rgbaColor(this.channels.r, this.channels.g, this.channels.b, this.channels.a);
  1315. };
  1316. this.toGrayscale = function () {
  1317. return 0.213 * this.channels.r + 0.715 * this.channels.g + 0.072 * this.channels.b;
  1318. };
  1319. this.toCanvas = function () {
  1320. return a.genColorPreviewCanvas(this.toRGBAString()).canvas;
  1321. };
  1322. this.toDataURL = function () {
  1323. try {
  1324. return this.toCanvas().toDataURL();
  1325. } catch (c) {
  1326. return a.base64Data;
  1327. }
  1328. };
  1329. this.toBackground = function () {
  1330. return a.pub.background(this.toRGBAString());
  1331. };
  1332. this.isLight = function () {
  1333. return 127.5 < this.toGrayscale();
  1334. };
  1335. this.hide = function () {
  1336. r() &&
  1337. (a.removeClass(f.targetElement, a.pub.activeClassName),
  1338. a.picker.wrap && a.picker.wrap.parentNode && a.picker.wrap.parentNode.removeChild(a.picker.wrap),
  1339. delete a.picker.owner);
  1340. };
  1341. this.show = function () {
  1342. g();
  1343. };
  1344. this.redraw = function () {
  1345. r() && g();
  1346. };
  1347. this.getFormat = function () {
  1348. return this._currentFormat;
  1349. };
  1350. this._setFormat = function (c) {
  1351. this._currentFormat = c.toLowerCase();
  1352. };
  1353. this.hasAlphaChannel = function () {
  1354. return "auto" === this.alphaChannel
  1355. ? "any" === this.format.toLowerCase() || a.isAlphaFormat(this.getFormat()) || void 0 !== this.alpha || void 0 !== this.alphaElement
  1356. : this.alphaChannel;
  1357. };
  1358. this.processValueInput = function (c) {
  1359. this.fromString(c) || this.exposeColor();
  1360. };
  1361. this.processAlphaInput = function (c) {
  1362. this.fromHSVA(null, null, null, parseFloat(c)) || this.exposeColor();
  1363. };
  1364. this.exposeColor = function (c) {
  1365. var k = this.toString(),
  1366. n = this.getFormat();
  1367. a.setDataAttr(this.targetElement, "current-color", k);
  1368. if (!(c & a.flags.leaveValue) && this.valueElement) {
  1369. if ("hex" === n || "hexa" === n) this.uppercase || (k = k.toLowerCase()), this.hash || (k = k.replace(/^#/, ""));
  1370. this.setValueElementValue(k);
  1371. }
  1372. c & a.flags.leaveAlpha || !this.alphaElement || this.setAlphaElementValue(Math.round(100 * this.channels.a) / 100);
  1373. c & a.flags.leavePreview ||
  1374. !this.previewElement ||
  1375. (a.isTextInput(this.previewElement) || (a.isButton(this.previewElement) && a.isButtonEmpty(this.previewElement)), this.setPreviewElementBg(this.toRGBAString()));
  1376. r() && (h(), l(), m());
  1377. };
  1378. this.setPreviewElementBg = function (c) {
  1379. if (this.previewElement) {
  1380. var k = null,
  1381. n = null;
  1382. if (a.isTextInput(this.previewElement) || (a.isButton(this.previewElement) && !a.isButtonEmpty(this.previewElement)))
  1383. (k = this.previewPosition), (n = this.previewSize);
  1384. var q = null,
  1385. t = [];
  1386. if (c) {
  1387. t.push({
  1388. image: a.genColorPreviewGradient(c, k, n ? n - a.pub.previewSeparator.length : null),
  1389. position: "left top",
  1390. size: "auto",
  1391. repeat: k ? "repeat-y" : "repeat",
  1392. origin: "padding-box",
  1393. });
  1394. c = a.genColorPreviewCanvas("rgba(0,0,0,0)", k ? { left: "right", right: "left" }[k] : null, n, !0);
  1395. try {
  1396. q = c.canvas.toDataURL();
  1397. } catch (S) {
  1398. q = a.base64Data;
  1399. }
  1400. t.push({
  1401. image: "url('" + q + "')",
  1402. position: (k || "left") + " top",
  1403. size: c.width + "px " + c.height + "px",
  1404. repeat: k ? "repeat-y" : "repeat",
  1405. origin: "padding-box",
  1406. });
  1407. } else
  1408. t.push({
  1409. image: "none",
  1410. position: "left top",
  1411. size: "auto",
  1412. repeat: "no-repeat",
  1413. origin: "padding-box",
  1414. });
  1415. q = [];
  1416. c = [];
  1417. n = [];
  1418. for (var w = [], B = [], x = 0; x < t.length; x += 1) q.push(t[x].image), c.push(t[x].position), n.push(t[x].size), w.push(t[x].repeat), B.push(t[x].origin);
  1419. t = {
  1420. "background-image": q.join(", "),
  1421. "background-position": c.join(", "),
  1422. "background-size": n.join(", "),
  1423. "background-repeat": w.join(", "),
  1424. "background-origin": B.join(", "),
  1425. };
  1426. a.setStyle(this.previewElement, t, this.forceStyle);
  1427. t = { left: null, right: null };
  1428. k && (t[k] = this.previewSize + this.previewPadding + "px");
  1429. t = { "padding-left": t.left, "padding-right": t.right };
  1430. a.setStyle(this.previewElement, t, this.forceStyle, !0);
  1431. }
  1432. };
  1433. this.setValueElementValue = function (c) {
  1434. this.valueElement && ("input" === a.nodeName(this.valueElement) ? (this.valueElement.value = c) : (this.valueElement.innerHTML = E.createHTML(c)));
  1435. };
  1436. this.setAlphaElementValue = function (c) {
  1437. this.alphaElement && ("input" === a.nodeName(this.alphaElement) ? (this.alphaElement.value = c) : (this.alphaElement.innerHTML = E.createHTML(c)));
  1438. };
  1439. this._processParentElementsInDOM = function () {
  1440. if (!this._parentElementsProcessed) {
  1441. this._parentElementsProcessed = !0;
  1442. var c = this.targetElement;
  1443. do {
  1444. var k = a.getCompStyle(c);
  1445. c instanceof ShadowRoot && (this.fixed = !0);
  1446. k.position && "fixed" === k.position.toLowerCase() && (this.fixed = !0);
  1447. c === this.targetElement || a.getData(c, "hasScrollListener") || (c.addEventListener("scroll", a.onParentScroll, !1), a.setData(c, "hasScrollListener", !0));
  1448. } while ((c = c.parentNode) && "body" !== a.nodeName(c));
  1449. }
  1450. };
  1451. this.tryHide = function () {
  1452. this.hideOnLeave && this.hide();
  1453. };
  1454. if (a.pub.options)
  1455. for (var A in a.pub.options)
  1456. if (a.pub.options.hasOwnProperty(A))
  1457. try {
  1458. e(A, a.pub.options[A]);
  1459. } catch (c) {
  1460. console.error(c);
  1461. }
  1462. var D = [];
  1463. d.preset && ("string" === typeof d.preset ? (D = d.preset.split(/\s+/)) : Array.isArray(d.preset) ? (D = d.preset.slice()) : console.warn("Unrecognized value"));
  1464. -1 === D.indexOf("default") && D.push("default");
  1465. for (var J = D.length - 1; 0 <= J; --J) {
  1466. var I = D[J];
  1467. if (I && a.pub.presets.hasOwnProperty(I))
  1468. for (A in a.pub.presets[I])
  1469. if (a.pub.presets[I].hasOwnProperty(A))
  1470. try {
  1471. e(A, a.pub.presets[I][A]);
  1472. } catch (c) {
  1473. console.error(c);
  1474. }
  1475. }
  1476. D = ["preset"];
  1477. for (A in d)
  1478. if (d.hasOwnProperty(A) && -1 === D.indexOf(A))
  1479. try {
  1480. e(A, d[A]);
  1481. } catch (c) {
  1482. console.error(c);
  1483. }
  1484. this.container = void 0 === this.container ? p.document.body : a.node(this.container);
  1485. if (!this.container) throw Error("No container element");
  1486. this.targetElement = a.node(b);
  1487. if (!this.targetElement) {
  1488. if ("string" === typeof b && /^[a-zA-Z][\w:.-]*$/.test(b)) throw Error("Need CSS selector.");
  1489. throw Error("No target element");
  1490. }
  1491. if (this.targetElement.frcp && this.targetElement.frcp instanceof a.pub) throw Error("Redundant Fr-Color-picker");
  1492. this.targetElement.frcp = this;
  1493. a.addClass(this.targetElement, a.pub.className);
  1494. a.instances.push(this);
  1495. a.isButton(this.targetElement) &&
  1496. ("button" !== this.targetElement.type.toLowerCase() && (this.targetElement.type = "button"),
  1497. a.isButtonEmpty(this.targetElement) &&
  1498. (a.removeChildren(this.targetElement),
  1499. this.targetElement.appendChild(p.document.createTextNode("\u00a0")),
  1500. (b = a.getCompStyle(this.targetElement)),
  1501. (parseFloat(b["min-width"]) || 0) < this.previewSize && a.setStyle(this.targetElement, { "min-width": this.previewSize + "px" }, this.forceStyle)));
  1502. void 0 === this.valueElement
  1503. ? a.isTextInput(this.targetElement) && (this.valueElement = this.targetElement)
  1504. : null !== this.valueElement && (this.valueElement = a.node(this.valueElement));
  1505. this.alphaElement && (this.alphaElement = a.node(this.alphaElement));
  1506. void 0 === this.previewElement ? (this.previewElement = this.targetElement) : null !== this.previewElement && (this.previewElement = a.node(this.previewElement));
  1507. this.valueElement &&
  1508. a.isTextInput(this.valueElement) &&
  1509. ((b = this.valueElement.oninput),
  1510. (this.valueElement.oninput = null),
  1511. this.valueElement.addEventListener("keydown", v, !1),
  1512. this.valueElement.addEventListener("change", z, !1),
  1513. this.valueElement.addEventListener("input", Q, !1),
  1514. b && this.valueElement.addEventListener("input", b, !1),
  1515. this.valueElement.setAttribute("autocomplete", "off"),
  1516. this.valueElement.setAttribute("autocorrect", "off"),
  1517. this.valueElement.setAttribute("autocapitalize", "off"),
  1518. this.valueElement.setAttribute("spellcheck", !1));
  1519. this.alphaElement &&
  1520. a.isTextInput(this.alphaElement) &&
  1521. (this.alphaElement.addEventListener("keydown", u, !1),
  1522. this.alphaElement.addEventListener("change", P, !1),
  1523. this.alphaElement.addEventListener("input", R, !1),
  1524. this.alphaElement.setAttribute("autocomplete", "off"),
  1525. this.alphaElement.setAttribute("autocorrect", "off"),
  1526. this.alphaElement.setAttribute("autocapitalize", "off"),
  1527. this.alphaElement.setAttribute("spellcheck", !1));
  1528. b = "FFFFFF";
  1529. void 0 !== this.value ? (b = this.value) : this.valueElement && void 0 !== this.valueElement.value && (b = this.valueElement.value);
  1530. d = void 0;
  1531. void 0 !== this.alpha ? (d = "" + this.alpha) : this.alphaElement && void 0 !== this.alphaElement.value && (d = this.alphaElement.value);
  1532. this._currentFormat = null;
  1533. -1 < ["auto", "any"].indexOf(this.format.toLowerCase())
  1534. ? (this._currentFormat = (A = a.parseColorString(b)) ? A.format : "hex")
  1535. : (this._currentFormat = this.format.toLowerCase());
  1536. this.processValueInput(b);
  1537. void 0 !== d && this.processAlphaInput(d);
  1538. this.random && this.randomize.apply(this, Array.isArray(this.random) ? this.random : []);
  1539. },
  1540. };
  1541. a.pub.className = G;
  1542. a.pub.activeClassName = H;
  1543. a.pub.looseJSON = !0;
  1544. a.pub.presets = {};
  1545. a.pub.presets["default"] = {};
  1546. a.pub.sliderInnerSpace = 3;
  1547. a.pub.chessboardSize = 8;
  1548. a.pub.chessboardColor1 = "#666666";
  1549. a.pub.chessboardColor2 = "#999999";
  1550. a.pub.previewSeparator = [];
  1551. a.pub.init = function () {
  1552. if (!a.initialized)
  1553. for (
  1554. p.document.addEventListener("mousedown", a.onDocumentMouseDown, !1),
  1555. p.document.addEventListener("keyup", a.onDocumentKeyUp, !1),
  1556. p.addEventListener("resize", a.onWindowResize, !1),
  1557. p.addEventListener("scroll", a.onWindowScroll, !1),
  1558. a.initialized = !0;
  1559. a.readyQueue.length;
  1560.  
  1561. )
  1562. a.readyQueue.shift()();
  1563. };
  1564. a.pub.ready = function (b) {
  1565. if ("function" !== typeof b) return !1;
  1566. a.initialized ? b() : a.readyQueue.push(b);
  1567. return !0;
  1568. };
  1569. a.pub.trigger = function (b) {
  1570. var d = function () {
  1571. a.triggerGlobal(b);
  1572. };
  1573. a.initialized ? d() : a.pub.ready(d);
  1574. };
  1575. a.pub.hide = function () {
  1576. a.picker && a.picker.owner && a.picker.owner.hide();
  1577. };
  1578. a.pub.background = function (b) {
  1579. var d = [];
  1580. d.push(a.genColorPreviewGradient(b));
  1581. b = a.genColorPreviewCanvas();
  1582. try {
  1583. d.push(["url('" + b.canvas.toDataURL() + "')", "left top repeat"].join(" "));
  1584. } catch (e) {
  1585. d.push(["url('" + a.base64Data + "')", "left top repeat"].join(" "));
  1586. }
  1587. return d.join(", ");
  1588. };
  1589. a.pub.options = {};
  1590. a.pub.lookupClass = G;
  1591. a.pub.installByClassName = function () {
  1592. return !1;
  1593. };
  1594. a.register();
  1595. return a.pub;
  1596. })();
  1597. "undefined" === typeof p.FRColorPicker && (p.FRColorPicker = p.frColorPicker = F);
  1598. return F;
  1599. },
  1600. { createHTML: p => p }
  1601. );

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址