{"version":3,"file":"event_dispatcher.min.js","sources":["https:\/\/inclusivemediatraining.eu\/lib\/amd\/src\/event_dispatcher.js"],"sourcesContent":["\/\/ This file is part of Moodle - http:\/\/moodle.org\/ \/\/\n\/\/ Moodle is free software: you can redistribute it and\/or modify\n\/\/ it under the terms of the GNU General Public License as published by\n\/\/ the Free Software Foundation, either version 3 of the License, or\n\/\/ (at your option) any later version.\n\/\/\n\/\/ Moodle is distributed in the hope that it will be useful,\n\/\/ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\/\/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\/\/ GNU General Public License for more details.\n\/\/\n\/\/ You should have received a copy of the GNU General Public License\n\/\/ along with Moodle. If not, see .\n\n\/**\n * An Event dispatcher used to dispatch Native JS CustomEvent objects with custom default properties.\n *\n * @module core\/event_dispatcher\n * @copyright 2021 Andrew Nicols \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n * @since 4.0\n *\/\n\n\/**\n * Dispatch an event as a CustomEvent on the specified container.\n * By default events are bubbled, and cancelable.\n *\n * The eventName should typically by sourced using a constant. See the supplied examples.\n *\n * Note: This function uses native events. Any additional details are passed to the function in event.detail.\n *\n * This function mimics the behaviour of EventTarget.dispatchEvent but bubbles by default.\n *\n * @method dispatchEvent\n * @param {String} eventName The name of the event\n * @param {Object} detail Any additional details to pass into the eveent\n * @param {HTMLElement} container The point at which to dispatch the event\n * @param {Object} options\n * @param {Boolean} options.bubbles Whether to bubble up the DOM\n * @param {Boolean} options.cancelable Whether preventDefault() can be called\n * @param {Boolean} options.composed Whether the event can bubble across the ShadowDOM bounadry\n * @returns {CustomEvent}\n *\n * @example Using a native CustomEvent to indicate that some example data was displayed.<\/caption>\n * \/\/ mod\/example\/amd\/src\/events.js\n *\n * import {dispatchEvent} from 'core\/event_dispatcher';\n *\n * export const eventTypes = {\n * exampleDataDisplayed: 'mod_example\/exampleDataDisplayed',\n * };\n *\n * export const notifyExampleDisplayed = someArgument => dispatchEvent(eventTypes.exampleDataDisplayed, {\n * someArgument,\n * }, document, {\n * cancelable: false,\n * });\n *\/\nexport const dispatchEvent = (\n eventName,\n detail = {},\n container = document,\n {\n bubbles = true,\n cancelable = false,\n composed = false,\n } = {}\n) => {\n const customEvent = new CustomEvent(\n eventName,\n {\n bubbles,\n cancelable,\n composed,\n detail,\n }\n );\n\n container.dispatchEvent(customEvent);\n\n return customEvent;\n};\n"],"names":["eventName","detail","container","document","bubbles","cancelable","composed","customEvent","CustomEvent","dispatchEvent"],"mappings":"4KA0D6B,SACzBA,eACAC,8DAAS,GACTC,iEAAYC,UACZC,QACIA,SAAU,EADdC,WAEIA,YAAa,EAFjBC,SAGIA,UAAW,0DACX,SAEEC,YAAc,IAAIC,YACpBR,UACA,CACII,QAAAA,QACAC,WAAAA,WACAC,SAAAA,SACAL,OAAAA,gBAIRC,UAAUO,cAAcF,aAEjBA"}