svgedit/dist/editor/system/extensions/ext-helloworld/ext-helloworld.js

10 lines
2.6 KiB
JavaScript

System.register([],(function(e,r){"use strict";return{execute:function(){function asyncGeneratorStep(e,r,t,n,o,a,i){try{var u=e[a](i),l=u.value}catch(e){return void t(e)}u.done?r(l):Promise.resolve(l).then(n,o)}function _slicedToArray(e,r){return function _arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function _iterableToArrayLimit(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return t}(e,r)||function _unsupportedIterableToArray(e,r){if(!e)return;if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _arrayLikeToArray(e,r)}(e,r)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}
/**
* @file ext-helloworld.js
*
* @license MIT
*
* @copyright 2010 Alexis Deveria
*
*/()}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}e("default",{name:"helloworld",init:function init(e){var t=this;return function _asyncToGenerator(e){return function(){var r=this,t=arguments;return new Promise((function(n,o){var a=e.apply(r,t);function _next(e){asyncGeneratorStep(a,n,o,_next,_throw,"next",e)}function _throw(e){asyncGeneratorStep(a,n,o,_next,_throw,"throw",e)}_next(void 0)}))}}(regeneratorRuntime.mark((function _callee(){var n,o,a,i,u;return regeneratorRuntime.wrap((function _callee$(l){for(;;)switch(l.prev=l.next){case 0:return n=e.$,e.importLocale,o=t,l.next=4,r.import("./locale/".concat(o.curPrefs.lang,".js"));case 4:return a=l.sent,i=a.default,u=o.canvas,l.abrupt("return",{name:i.name,svgicons:"helloworld-icon.xml",buttons:[{id:"hello_world",icon:"helloworld.png",type:"mode",title:i.buttons[0].title,events:{click:function click(){u.setMode("hello_world")}}}],mouseDown:function mouseDown(){if("hello_world"===u.getMode())return{started:!0}},mouseUp:function mouseUp(e){if("hello_world"===u.getMode()){var r=u.getZoom(),t=e.mouse_x/r,o=e.mouse_y/r,a=i.text;[["x",t],["y",o]].forEach((function(e){var r=_slicedToArray(e,2),t=r[0],n=r[1];a=a.replace("{"+t+"}",n)})),n.alert(a)}}});case 8:case"end":return l.stop()}}),_callee)})))()}})}}}));