UNPKG

3.73 kBPlain TextView Raw
1{"code":"function defineName$__(cls,name){\n\tObject.defineProperty(cls,\"name\",{value:name,configurable:true});\n};;\nfunction extend$__(target,ext){\n\t// @ts-ignore\n\tconst descriptors = Object.getOwnPropertyDescriptors(ext);\n\tdelete descriptors.constructor;\n\tif(target.extend__ instanceof Function){\n\t\ttarget.extend__(descriptors,ext);\n\t} else {\n\t\t// @ts-ignore\n\t\tObject.defineProperties(target,descriptors);\n\t}\n\treturn target;\n};\n\n/*body*/\nimport {Event,CustomEvent,Element} from '../dom/core';\n\nexport function use_events_selection(){\n\t\n\tglobalThis.imba.uses_events_selection = true;\n\treturn true;\n};\n\nlet selHandler;\nlet handledSym = Symbol();\n\nfunction activateSelectionHandler(){\n\t\n\tif (!(selHandler)) {\n\t\t\n\t\tselHandler = function(e) {\n\t\t\t\n\t\t\tif (e[handledSym]) { return };\n\t\t\te[handledSym] = true;\n\t\t\t\n\t\t\tlet target = globalThis.document.activeElement;\n\t\t\tif (target && target.matches('input,textarea')) {\n\t\t\t\t\n\t\t\t\tlet custom = new CustomEvent('selection',{\n\t\t\t\t\tdetail: {\n\t\t\t\t\t\tstart: target.selectionStart,\n\t\t\t\t\t\tend: target.selectionEnd\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn target.dispatchEvent(custom);\n\t\t\t};\n\t\t};\n\t\treturn globalThis.document.addEventListener('selectionchange',selHandler);\n\t};\n};\n\nclass ΩElement {\n\t\n\ton$selection(mods,context,handler,o){\n\t\t\n\t\tactivateSelectionHandler();\n\t\tthis.addEventListener('selection',handler,o);\n\t\treturn handler;\n\t}\n\tstatic {\n\t\tdefineName$__(this,'Element');}\n};\nextend$__(Element.prototype,ΩElement.prototype);\n;\n","map":{"version":3,"file":"selection.js","sourceRoot":"","sources":["/Users/abdellah/workspace/scrimba/imba/packages/imba/src/imba/events/selection.imba"],"sourcesContent":["import {Event,CustomEvent,Element} from '../dom/core'\n\nexport def use_events_selection\n\tglobal.imba.uses_events_selection = yes\n\tyes\n\nlet selHandler\nlet handledSym = Symbol!\n\ndef activateSelectionHandler\n\tunless selHandler\n\t\tselHandler = do(e)\n\t\t\treturn if e[handledSym]\n\t\t\te[handledSym] = yes\n\n\t\t\tlet target = global.document.activeElement\n\t\t\tif target and target.matches('input,textarea')\n\t\t\t\tlet custom = new CustomEvent('selection',{\n\t\t\t\t\tdetail: {\n\t\t\t\t\t\tstart: target.selectionStart\n\t\t\t\t\t\tend: target.selectionEnd\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\ttarget.dispatchEvent(custom)\n\t\tglobal.document.addEventListener('selectionchange',selHandler)\n\nextend class Element\n\tdef on$selection mods, context, handler,o\n\t\tactivateSelectionHandler()\n\t\tself.addEventListener('selection',handler,o)\n\t\treturn handler"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,OAAO,OAAO,aAAa;;AAErD,MAAM,CAAC,QAAG,CAAC,oBAAoB,EAAA;;CAC9B,UAAM,CAAC,IAAI,CAAC,qBAAqB,GAAG,IAAG;CACvC,OAAA,IAAG;CAAA;;IAEA,UAAU;IACV,UAAU,GAAG,MAAM,EAAC;;AAExB,QAAG,CAAC,wBAAwB,EAAA;;CAC3B,EAAM,IAAC,UAAU,GAAA;;EAChB,UAAU,GAAG,QAAE,CAAC,CAAC,EAAC;;GACV,EAAE,EAAC,CAAC,CAAA,UAAW,CAAC,EAAvB,EAAA,MAAM;GACN,CAAC,CAAA,UAAW,CAAC,GAAG,IAAG;;OAEf,MAAM,GAAG,UAAM,CAAC,QAAQ,CAAC,aAAa;GAC1C,EAAE,EAAC,MAAM,CAAC,EAAG,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAA;;QACzC,MAAM,GAAG,GAAG,CAAC,WAAW,CAAC,WAAW,CAAC;KACxC,MAAM,EAAE;MACP,KAAK,EAAE,MAAM,CAAC,cAAc;MAC5B,GAAG,EAAE,MAAM,CAAC,Y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