mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
22 lines
15 KiB
JavaScript
22 lines
15 KiB
JavaScript
|
/*!
|
||
|
* Huebee PACKAGED v2.1.0
|
||
|
* 1-click color picker
|
||
|
* MIT license
|
||
|
* https://huebee.buzz
|
||
|
* Copyright 2020 Metafizzy
|
||
|
*/
|
||
|
(function(t,e){if(typeof define=="function"&&define.amd){define("ev-emitter/ev-emitter",e)}else if(typeof module=="object"&&module.exports){module.exports=e()}else{t.EvEmitter=e()}})(typeof window!="undefined"?window:this,function(){"use strict";function t(){}var e=t.prototype;e.on=function(t,e){if(!t||!e){return}var i=this._events=this._events||{};var n=i[t]=i[t]||[];if(n.indexOf(e)==-1){n.push(e)}return this};e.once=function(t,e){if(!t||!e){return}this.on(t,e);var i=this._onceEvents=this._onceEvents||{};var n=i[t]=i[t]||{};n[e]=true;return this};e.off=function(t,e){var i=this._events&&this._events[t];if(!i||!i.length){return}var n=i.indexOf(e);if(n!=-1){i.splice(n,1)}return this};e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(!i||!i.length){return}i=i.slice(0);e=e||[];var n=this._onceEvents&&this._onceEvents[t];for(var o=0;o<i.length;o++){var s=i[o];var r=n&&n[s];if(r){this.off(t,s);delete n[s]}s.apply(this,e)}return this};e.allOff=function(){delete this._events;delete this._onceEvents};return t});
|
||
|
/*!
|
||
|
* Unipointer v2.3.0
|
||
|
* base class for doing one thing with pointer event
|
||
|
* MIT license
|
||
|
*/
|
||
|
(function(e,i){if(typeof define=="function"&&define.amd){define("unipointer/unipointer",["ev-emitter/ev-emitter"],function(t){return i(e,t)})}else if(typeof module=="object"&&module.exports){module.exports=i(e,require("ev-emitter"))}else{e.Unipointer=i(e,e.EvEmitter)}})(window,function t(o,e){"use strict";function i(){}function n(){}var s=n.prototype=Object.create(e.prototype);s.bindStartEvent=function(t){this._bindStartEvent(t,true)};s.unbindStartEvent=function(t){this._bindStartEvent(t,false)};s._bindStartEvent=function(t,e){e=e===undefined?true:e;var i=e?"addEventListener":"removeEventListener";var n="mousedown";if(o.PointerEvent){n="pointerdown"}else if("ontouchstart"in o){n="touchstart"}t[i](n,this)};s.handleEvent=function(t){var e="on"+t.type;if(this[e]){this[e](t)}};s.getTouch=function(t){for(var e=0;e<t.length;e++){var i=t[e];if(i.identifier==this.pointerIdentifier){return i}}};s.onmousedown=function(t){var e=t.button;if(e&&(e!==0&&e!==1)){return}this._pointerDown(t,t)};s.ontouchstart=function(t){this._pointerDown(t,t.changedTouches[0])};s.onpointerdown=function(t){this._pointerDown(t,t)};s._pointerDown=function(t,e){if(t.button||this.isPointerDown){return}this.isPointerDown=true;this.pointerIdentifier=e.pointerId!==undefined?e.pointerId:e.identifier;this.pointerDown(t,e)};s.pointerDown=function(t,e){this._bindPostStartEvents(t);this.emitEvent("pointerDown",[t,e])};var r={mousedown:["mousemove","mouseup"],touchstart:["touchmove","touchend","touchcancel"],pointerdown:["pointermove","pointerup","pointercancel"]};s._bindPostStartEvents=function(t){if(!t){return}var e=r[t.type];e.forEach(function(t){o.addEventListener(t,this)},this);this._boundPointerEvents=e};s._unbindPostStartEvents=function(){if(!this._boundPointerEvents){return}this._boundPointerEvents.forEach(function(t){o.removeEventListener(t,this)},this);delete this._boundPointerEvents};s.onmousemove=function(t){this._pointerMove(t,t)};s.onpointermove=function(t){if(t.pointerId==this.pointerIdentifier){this._pointerMove(t,t)}};s.ontouchmove=function(t){var e=this.getTouch(t.changedTouches);if(e){this._pointerMove(t,e)}};s._pointerMove=function(t,e){this.pointerMove(t,e)};s.pointerMove=function(t,e){this.emitEvent("pointerMove",[t,e])};s.onmouseup=function(t){this._pointerUp(t,t)};s.onpointerup=function(t){if(t.pointerId==this.pointerIdentifier){this._pointerUp(t,t)}};s.ontouchend=function(t){var e=this.getTouch(t.changedTouches);if(e){this._pointerUp(t,e)}};s._pointerUp=function(t,e){this._pointerDone();this.pointerUp(t,e)};s.pointerUp=function(t,e){this.emitEvent("pointerUp",[t,e])};s._pointerDone=function(){this._pointerReset();this._unbindPostStartEvents();this.pointerDone()};s._pointerReset=function(){this.isPointerDown=false;delete this.pointerIdentifier};s.pointerDone=i;s.onpointercancel=function(t){if(t.pointerId==this.pointerIdentifier){this._pointerCancel(t,t)}};s.ontouchcancel=function(t){var e=this.getTouch(t.changedTouches);if(e){this._pointerCancel(t,e)}};s._pointerCancel=function(t,e){this._pointerDone();this.pointerCancel(t,e)};s.pointerCancel=function(t,e){this.emitEvent("pointerCancel",[t,e])};n.getPointerPoint=function(t){return{x:t.pageX,y:t.pageY}};return n});
|
||
|
/*!
|
||
|
* Huebee v2.1.0
|
||
|
* 1-click color picker
|
||
|
* MIT license
|
||
|
* https://huebee.buzz
|
||
|
* Copyright 2020 Metafizzy
|
||
|
*/
|
||
|
(function(i,n){if(typeof define=="function"&&define.amd){define(["ev-emitter/ev-emitter","unipointer/unipointer"],function(t,e){return n(i,t,e)})}else if(typeof module=="object"&&module.exports){module.exports=n(i,require("ev-emitter"),require("unipointer"))}else{i.Huebee=n(i,i.EvEmitter,i.Unipointer)}})(window,function t(e,i,n){function s(t,e){t=C(t);if(!t){throw new Error("Bad element for Huebee: "+t)}this.anchor=t;this.options={};this.option(s.defaults);this.option(e);this.create()}s.defaults={hues:12,hue0:0,shades:5,saturations:3,notation:"shortHex",setText:true,setBGColor:true};var o=s.prototype=Object.create(i.prototype);o.option=function(t){this.options=b(this.options,t)};var r=0;var a={};o.create=function(){var t=this.guid=++r;this.anchor.huebeeGUID=t;a[t]=this;this.setBGElems=this.getSetElems(this.options.setBGColor);this.setTextElems=this.getSetElems(this.options.setText);this.outsideCloseIt=this.outsideClose.bind(this);this.onDocKeydown=this.docKeydown.bind(this);this.closeIt=this.close.bind(this);this.openIt=this.open.bind(this);this.onElemTransitionend=this.elemTransitionend.bind(this);this.isInputAnchor=this.anchor.nodeName=="INPUT";if(!this.options.staticOpen){this.anchor.addEventListener("click",this.openIt);this.anchor.addEventListener("focus",this.openIt)}if(this.isInputAnchor){this.anchor.addEventListener("input",this.inputInput.bind(this))}var e=this.element=document.createElement("div");e.className="huebee ";e.className+=this.options.staticOpen?"is-static-open ":"is-hidden ";e.className+=this.options.className||"";var i=this.container=document.createElement("div");i.className="huebee__container";function n(t){if(t.target==i){t.preventDefault()}}i.addEventListener("mousedown",n);i.addEventListener("touchstart",n);this.createCanvas();this.cursor=document.createElement("div");this.cursor.className="huebee__cursor is-hidden";i.appendChild(this.cursor);this.createCloseButton();e.appendChild(i);if(!this.options.staticOpen){var o=getComputedStyle(this.anchor.parentNode);if(o.position!="relative"&&o.position!="absolute"){this.anchor.parentNode.style.position="relative"}}var s=this.getCustomLength();this.satY=s?Math.ceil(s/this.options.hues)+1:0;this.updateColors();this.setAnchorColor();if(this.options.staticOpen){this.open()}};o.getSetElems=function(t){if(t===true){return[this.anchor]}else if(typeof t=="string"){return document.querySelectorAll(t)}};o.getCustomLength=function(){var t=this.options.customColors;return t&&t.length||0};o.createCanvas=function(){var t=this.canvas=document.createElement("canvas");t.className="huebee__canvas";this.ctx=t.getContext("2d");var e=this.canvasPointer=new n;e._bindStartEvent(t);e.on("pointerDown",this.canvasPointerDown.bind(this));e.on("pointerMove",this.canvasPointerMove.bind(this));this.container.appendChild(t)};var h="http://www.w3.org/2000/svg";o.createCloseButton=function(){if(this.options.staticOpen){return}var t=document.createElementNS(h,"svg");t.setAttribute("class","huebee__close-button");t.setAttribute("viewBox","0 0 24 24");t.setAttribute("width","24");t.setAttribute("height","24");var e=document.createElementNS(h,"path");e.setAttribute("d","M 7,7 L 17,17 M 17,7 L 7,17");e.setAttribute("class","huebee__close-button__x");t.appendChild(e);t.addEventListener("click",this.closeIt);this.container.appendChild(t)};o.updateColors=function(){this.swatches={};this.colorGrid={};this.updateColorModer();var t=this.options.shades;var e=this.options.saturations;var o=this.options.hues;if(this.getCustomLength()){var s=0;this.options.customColors.forEach(function(t){var e=s%o;var i=Math.floor(s/o);var n=E(t);if(n){this.addSwatch(n,e,i);s++}}.bind(this))}var i;for(i=0;i<e;i++){var n=1-i/e;var r=t*i+this.satY;this.updateSaturationGrid(i,n,r)}var a=this.getGrayCount();for(i=0;i<a;i++){var h=1-i/(t+1);var u=this.colorModer(0,0,h);var c=E(u);this.addSwatch(c,o+1,i)}};o.getGrayCount=function(){return this.options.shades?this.options.shades+2:0};o.updateSaturationGrid=function(t,e,i){var n=this.options.shades;var o=this.options.hues;var s=this.options.hue0;for(var r=0;r<n;r++){for(v
|