pdfdraw/js/libs/iro-transparency-plugin-1.0.2.min.js
2020-11-25 15:38:38 +01:00

9 lines
No EOL
6.9 KiB
JavaScript

/*!
* iro-transparency-plugin v1.0.2
* Adds comprehensive transparency support to iro.js
* 2019 James Daniel
* Licensed under MPL 2.0
* github.com/jaames/iro-transparency-plugin
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("iroTransparencyPlugin",[],e):"object"==typeof exports?exports.iroTransparencyPlugin=e():t.iroTransparencyPlugin=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function c(t){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}r.r(e);var l=function(t,e){var r=t.h,n=t.Slider,l=t.Handle,u=e.resolveUrl;return function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),i(this,c(e).apply(this,arguments))}var s,f,h;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&a(t,e)}(e,n),s=e,(f=[{key:"render",value:function(t){var e=t.width,n=t.sliderHeight,o=t.borderWidth,i=t.handleRadius;n=n||2*t.padding+2*i+2*o,this.width=e,this.height=n;var c=n/2,a=e-2*c,s=t.color.hslString,f=t.color.hsva.a;return r("svg",{class:"iro__slider iro__slider--transparency",width:e,height:n,style:{marginTop:t.sliderMargin,overflow:"visible",display:"block"}},r("defs",null,r("linearGradient",{id:"gradient_".concat(this.uid)},r("stop",{offset:"0%","stop-color":s,"stop-opacity":"0"}),r("stop",{offset:"100%","stop-color":s,"stop-opacity":"1"})),r("pattern",{id:"grid_".concat(this.uid),width:"8",height:"8",patternUnits:"userSpaceOnUse"},r("rect",{class:"iro__slider__grid",x:"0",y:"0",width:"4",height:"4",fill:"#fff"}),r("rect",{class:"iro__slider__grid iro__slider__grid--alt",x:"4",y:"0",width:"4",height:"4",fill:"#ccc"}),r("rect",{class:"iro__slider__grid",x:"4",y:"4",width:"4",height:"4",fill:"#fff"}),r("rect",{class:"iro__slider__grid iro__slider__grid--alt",x:"0",y:"4",width:"4",height:"4",fill:"#ccc"})),r("pattern",{id:"fill_".concat(this.uid),width:"100%",height:"100%"},r("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:"url(".concat(u("#grid_"+this.uid),")")}),r("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:"url(".concat(u("#gradient_"+this.uid),")")}))),r("rect",{class:"iro__slider__value",rx:c,ry:c,x:o/2,y:o/2,width:e-o,height:n-o,"stroke-width":o,stroke:t.borderColor,fill:"url(".concat(u("#fill_"+this.uid),")")}),r(l,{r:i,url:t.handleSvg,origin:t.handleOrigin,x:c+f*a,y:n/2}))}},{key:"handleInput",value:function(t,e,r,n){this.props.onInput(n,{a:this.getValueFromPoint(t,e,r)/100})}}])&&o(s.prototype,f),h&&o(s,h),e}()};function u(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.forEach(function(e){f(t,e,r[e])})}return t}function f(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}e.default=function(t,e){var r=l(t.ui,t.util),n=t.util,o=(n.parseHexInt,n.parseUnit,n.intToHex);t.ColorPicker.addHook("init:after",function(){this.props.transparency&&this.layout.push({component:r,options:{}})});var i=t.Color.prototype.set;t.Color.prototype.set=function(t){var e="object"===h(t);e&&"r"in t&&"g"in t&&"b"in t&&"a"in t?this.rgba=t:e&&"h"in t&&"s"in t&&"v"in t&&"a"in t?this.hsva=t:e&&"h"in t&&"s"in t&&"l"in t&&"a"in t?this.hsla=t:i.call(this,t)},Object.defineProperties(t.Color.prototype,{hsva:{get:function(){var t=this._value;return{h:t.h,s:t.s,v:t.v,a:t.a}},set:function(t){this.hsv=t}},alpha:{get:function(){return this._value.a},set:function(t){this.hsv=s({},this.hsv,{a:t})}},rgba:{get:function(){return s({},this.rgb,{a:this.alpha})},set:function(t){var e=t.a,r=u(t,["a"]);this.rgb=r,this.alpha=e}},hsla:{get:function(){return s({},this.hsl,{a:this.alpha})},set:function(t){var e=t.a,r=u(t,["a"]);this.hsl=r,this.alpha=e}},hex8String:{get:function(){var t=this.rgba,e=t.r,r=t.g,n=t.b,i=t.a;return"#".concat(o(e)).concat(o(r)).concat(o(n)).concat(o(Math.floor(255*i)))},set:function(t){this.hexString=t}},rgbaString:{get:function(){var t=this.rgba,e=t.r,r=t.g,n=t.b,o=t.a;return"rgba(".concat(e,", ").concat(r,", ").concat(n,", ").concat(o,")")},set:function(t){this.rgbString=t}},hslaString:{get:function(){var t=this.hsla,e=t.h,r=t.s,n=t.l,o=t.a;return"hsla(".concat(e,", ").concat(r,"%, ").concat(n,"%, ").concat(o,")")},set:function(t){this.hslString=t}}}),t.ui.TransparencySlider=r,t.transparencyPlugin={version:"1.0.2"}}}]).default});
//# sourceMappingURL=iro-transparency-plugin.min.js.map