whisper.cat/weboasis/js/jscolor.min.js

1 line
28 KiB
JavaScript
Raw Normal View History

2023-10-05 23:28:32 +11:00
"use strict";window.jscolor||(window.jscolor=function(){var d={register:function(){d.attachDOMReadyEvent(d.init),d.attachEvent(document,"mousedown",d.onDocumentMouseDown),d.attachEvent(document,"touchstart",d.onDocumentTouchStart),d.attachEvent(window,"resize",d.onWindowResize)},init:function(){d.jscolor.lookupClass&&d.jscolor.installByClassName(d.jscolor.lookupClass)},tryInstallOnElements:function(a,b){for(var c=new RegExp("(^|\\s)("+b+")(\\s*(\\{[^}]*\\})|\\s|$)","i"),e=0;e<a.length;e+=1)if(!(void 0!==a[e].type&&"color"==a[e].type.toLowerCase()&&d.isColorAttrSupported)){var f;if(!a[e].jscolor&&a[e].className&&(f=a[e].className.match(c))){var g=a[e],h=null,j=d.getDataAttr(g,"jscolor");null===j?f[4]&&(h=f[4]):h=j;var k={};if(h)try{k=new Function("return ("+h+")")()}catch(a){d.warn("Error parsing jscolor options: "+a+":\n"+h)}g.jscolor=new d.jscolor(g,k)}}},isColorAttrSupported:function(){var a=document.createElement("input");return!!(a.setAttribute&&(a.setAttribute("type","color"),"color"==a.type.toLowerCase()))}(),isCanvasSupported:function(){var a=document.createElement("canvas");return!!(a.getContext&&a.getContext("2d"))}(),fetchElement:function(a){return"string"==typeof a?document.getElementById(a):a},isElementType:function(a,b){return a.nodeName.toLowerCase()===b.toLowerCase()},getDataAttr:function(a,b){var c=a.getAttribute("data-"+b);return null===c?null:c},attachEvent:function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)},detachEvent:function(a,b,c){a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent&&a.detachEvent("on"+b,c)},_attachedGroupEvents:{},attachGroupEvent:function(a,b,c,e){d._attachedGroupEvents.hasOwnProperty(a)||(d._attachedGroupEvents[a]=[]),d._attachedGroupEvents[a].push([b,c,e]),d.attachEvent(b,c,e)},detachGroupEvents:function(a){if(d._attachedGroupEvents.hasOwnProperty(a)){for(var b,c=0;c<d._attachedGroupEvents[a].length;c+=1)b=d._attachedGroupEvents[a][c],d.detachEvent(b[0],b[1],b[2]);delete d._attachedGroupEvents[a]}},attachDOMReadyEvent:function(a){var b=!1,c=function(){b||(b=!0,a())};if("complete"===document.readyState)return void setTimeout(c,1);if(document.addEventListener)document.addEventListener("DOMContentLoaded",c,!1),window.addEventListener("load",c,!1);else if(document.attachEvent&&(document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&(document.detachEvent("onreadystatechange",arguments.callee),c())}),window.attachEvent("onload",c),document.documentElement.doScroll&&window==window.top)){var d=function(){if(document.body)try{document.documentElement.doScroll("left"),c()}catch(a){setTimeout(d,1)}};d()}},warn:function(a){window.console&&window.console.warn&&window.console.warn(a)},preventDefault:function(a){a.preventDefault&&a.preventDefault(),a.returnValue=!1},captureTarget:function(a){a.setCapture&&(d._capturedTarget=a,d._capturedTarget.setCapture())},releaseTarget:function(){d._capturedTarget&&(d._capturedTarget.releaseCapture(),d._capturedTarget=null)},fireEvent:function(a,b){if(a)if(document.createEvent){var c=document.createEvent("HTMLEvents");c.initEvent(b,!0,!0),a.dispatchEvent(c)}else if(document.createEventObject){var c=document.createEventObject();a.fireEvent("on"+b,c)}else a["on"+b]&&a["on"+b]()},classNameToList:function(a){return a.replace(/^\s+|\s+$/g,"").split(/\s+/)},hasClass:function(a,b){return!!b&&-1!=(" "+a.className.replace(/\s+/g," ")+" ").indexOf(" "+b+" ")},setClass:function(a,b){for(var c=d.classNameToList(b),e=0;e<c.length;e+=1)d.hasClass(a,c[e])||(a.className+=(a.className?" ":"")+c[e])},unsetClass:function(a,b){for(var c,e=d.classNameToList(b),f=0;f<e.length;f+=1)c=new RegExp("^\\s*"+e[f]+"\\s*|\\s*"+e[f]+"\\s*$|\\s+"+e[f]+"(\\s+)","g"),a.className=a.className.replace(c,"$1")},getStyle:function(a){return window.getComputedStyle?window.getComputedStyle(a):a.currentStyle},setStyle:function(){var a=document.createElement("div"),b=function(b){for(var c=0;c<b.length;c+=1)if(b[c]in a.style)return b[c]},c={borderRadius:b(["borderRadius","MozBorderRadius","webkitBorderRadiu