11 lines
2.8 KiB
JavaScript
11 lines
2.8 KiB
JavaScript
|
System.register([],(function(e,t){"use strict";return{execute:function(){function asyncGeneratorStep(e,t,r,n,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,o)}
|
||
|
/**
|
||
|
* @file ext-eyedropper.js
|
||
|
*
|
||
|
* @license MIT
|
||
|
*
|
||
|
* @copyright 2010 Jeff Schiller
|
||
|
*
|
||
|
*/
|
||
|
e("default",{name:"eyedropper",init:function init(e){var r=this;return function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function _next(e){asyncGeneratorStep(i,n,o,_next,_throw,"next",e)}function _throw(e){asyncGeneratorStep(i,n,o,_next,_throw,"throw",e)}_next(void 0)}))}}(regeneratorRuntime.mark((function _callee(){var n,o,i,a,s,c,l,u,p,d;return regeneratorRuntime.wrap((function _callee$(y){for(;;)switch(y.prev=y.next){case 0:return p=function _getStyle(e){if("eyedropper"!==c.getMode()){var t=a("#tool_eyedropper"),r=null;e.multiselected||!e.elems[0]||["svg","g","use"].includes(e.elems[0].nodeName)?t.addClass("disabled"):(r=e.elems[0],t.removeClass("disabled"),u.fillPaint=r.getAttribute("fill")||"black",u.fillOpacity=r.getAttribute("fill-opacity")||1,u.strokePaint=r.getAttribute("stroke"),u.strokeOpacity=r.getAttribute("stroke-opacity")||1,u.strokeWidth=r.getAttribute("stroke-width"),u.strokeDashArray=r.getAttribute("stroke-dasharray"),u.strokeLinecap=r.getAttribute("stroke-linecap"),u.strokeLinejoin=r.getAttribute("stroke-linejoin"),u.opacity=r.getAttribute("opacity")||1)}},n=r,y.next=4,t.import("./locale/".concat(n.curPrefs.lang,".js"));case 4:return o=y.sent,i=o.default,a=e.$,s=e.ChangeElementCommand,c=n.canvas,l=function addToHistory(e){c.undoMgr.addCommandToHistory(e)},u={fillPaint:"red",fillOpacity:1,strokePaint:"black",strokeOpacity:1,strokeWidth:5,strokeDashArray:null,opacity:1,strokeLinecap:"butt",strokeLinejoin:"miter"},d=[{id:"tool_eyedropper",icon:"eyedropper.png",type:"mode",events:{click:function click(){c.setMode("eyedropper")}}}],y.abrupt("return",{name:i.name,svgicons:"eyedropper-icon.xml",buttons:i.buttons.map((function(e,t){return Object.assign(d[t],e)})),selectedChanged:p,elementChanged:p,mouseDown:function mouseDown(e){if("eyedropper"===c.getMode()){var t=e.event.target;if(!["svg","g","use"].includes(t.nodeName)){var r={},n=function change(e,t,n){r[t]=e.getAttribute(t),e.setAttribute(t,n)};u.fillPaint&&n(t,"fill",u.fillPaint),u.fillOpacity&&n(t,"fill-opacity",u.fillOpacity),u.strokePaint&&n(t,"stroke",u.strokePaint),u.strokeOpacity&&n(t,"stroke-opacity",u.strokeOpacity),u.strokeWidth&&n(t,"stroke-width",u.strokeWidth),u.strokeDashArray&&n(t,"stroke-dasharray",u.strokeDashArray),u.opacity&&n(t,"opacity",u.opacity),u.strokeLinecap&&n(t,"stroke-linecap",u.strokeLinecap),u.strokeLinejoin&&n(t,"stroke-linejoin",u.strokeLinejoin),l(new s(t,r))}}}});case 9:case"end":return y.stop()}}),_callee)})))()}})}}}));
|