From 68c3f1e90ce5fa3eeeb6098964cc2d71ec5018ab Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 29 Sep 2021 13:07:34 +0800 Subject: [PATCH] MDL-70658 mod_bigbluebuttonbn: Use core/event_dispatcher --- .../amd/build/event_dispatcher.min.js | 2 - .../amd/build/event_dispatcher.min.js.map | 1 - mod/bigbluebuttonbn/amd/build/events.min.js | 2 +- .../amd/build/events.min.js.map | 2 +- .../amd/src/event_dispatcher.js | 82 ------------------- mod/bigbluebuttonbn/amd/src/events.js | 4 +- 6 files changed, 3 insertions(+), 90 deletions(-) delete mode 100644 mod/bigbluebuttonbn/amd/build/event_dispatcher.min.js delete mode 100644 mod/bigbluebuttonbn/amd/build/event_dispatcher.min.js.map delete mode 100644 mod/bigbluebuttonbn/amd/src/event_dispatcher.js diff --git a/mod/bigbluebuttonbn/amd/build/event_dispatcher.min.js b/mod/bigbluebuttonbn/amd/build/event_dispatcher.min.js deleted file mode 100644 index 9b7d489a34a..00000000000 --- a/mod/bigbluebuttonbn/amd/build/event_dispatcher.min.js +++ /dev/null @@ -1,2 +0,0 @@ -define ("mod_bigbluebuttonbn/event_dispatcher",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.dispatchEvent=void 0;a.dispatchEvent=function dispatchEvent(a){var b=1.\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.\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"],"file":"event_dispatcher.min.js"} \ No newline at end of file diff --git a/mod/bigbluebuttonbn/amd/build/events.min.js b/mod/bigbluebuttonbn/amd/build/events.min.js index fb8798c4c01..dfc3cafcc20 100644 --- a/mod/bigbluebuttonbn/amd/build/events.min.js +++ b/mod/bigbluebuttonbn/amd/build/events.min.js @@ -1,2 +1,2 @@ -define ("mod_bigbluebuttonbn/events",["exports","./event_dispatcher"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.notifyCurrentSessionEnded=a.notifySessionEnded=a.eventTypes=void 0;var c={sessionEnded:"mod_bigbluebuttonbn/sessionEnded",currentSessionEnded:"mod_bigbluebuttonbn/currentSessionEnded"};a.eventTypes=c;a.notifySessionEnded=function notifySessionEnded(a,d){return(0,b.dispatchEvent)(c.sessionEnded,{bbbId:a,groupId:d})};a.notifyCurrentSessionEnded=function notifyCurrentSessionEnded(a){return(0,b.dispatchEvent)(c.currentSessionEnded,{},a)}}); +define ("mod_bigbluebuttonbn/events",["exports","core/event_dispatcher"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.notifyCurrentSessionEnded=a.notifySessionEnded=a.eventTypes=void 0;var c={sessionEnded:"mod_bigbluebuttonbn/sessionEnded",currentSessionEnded:"mod_bigbluebuttonbn/currentSessionEnded"};a.eventTypes=c;a.notifySessionEnded=function notifySessionEnded(a,d){return(0,b.dispatchEvent)(c.sessionEnded,{bbbId:a,groupId:d})};a.notifyCurrentSessionEnded=function notifyCurrentSessionEnded(a){return(0,b.dispatchEvent)(c.currentSessionEnded,{},a)}}); //# sourceMappingURL=events.min.js.map diff --git a/mod/bigbluebuttonbn/amd/build/events.min.js.map b/mod/bigbluebuttonbn/amd/build/events.min.js.map index 019aa8f3f49..bbf9c6de396 100644 --- a/mod/bigbluebuttonbn/amd/build/events.min.js.map +++ b/mod/bigbluebuttonbn/amd/build/events.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/events.js"],"names":["eventTypes","sessionEnded","currentSessionEnded","notifySessionEnded","bbbId","groupId","notifyCurrentSessionEnded","container"],"mappings":"uNA2BO,GAAMA,CAAAA,CAAU,CAAG,CAUtBC,YAAY,CAAE,kCAVQ,CAmBtBC,mBAAmB,CAAE,yCAnBC,CAAnB,C,oCA8B2B,QAArBC,CAAAA,kBAAqB,CAACC,CAAD,CAAQC,CAAR,QAAoB,oBAAcL,CAAU,CAACC,YAAzB,CAAuC,CACzFG,KAAK,CAALA,CADyF,CAEzFC,OAAO,CAAPA,CAFyF,CAAvC,CAApB,C,6BAYO,QAA5BC,CAAAA,yBAA4B,CAAAC,CAAS,QAAI,oBAClDP,CAAU,CAACE,mBADuC,CAElD,EAFkD,CAGlDK,CAHkD,CAAJ,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\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 * Events for the mod_bigbluebuttonbn plugin.\n *\n * @module mod_bigbluebuttonbn/events\n * @copyright 2021 Blindside Networks Inc\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n// TODO For master this can be changed to `core/event_dispatcher` and the local copy removed.\n// For 3.11 and earlier this line should stay.\nimport {dispatchEvent} from './event_dispatcher';\n\nexport const eventTypes = {\n /**\n * Fired when a session has been ended.\n *\n * @event mod_bigbluebuttonbn/sessionEnded\n * @type CustomEvent\n * @property {object} detail\n * @property {number} detail.bbbId\n * @property {number} detail.groupId\n */\n sessionEnded: 'mod_bigbluebuttonbn/sessionEnded',\n\n /**\n * Fired when the current session has been ended.\n *\n * @event mod_bigbluebuttonbn/currentSessionEnded\n * @type CustomEvent\n * @property {object} detail\n */\n currentSessionEnded: 'mod_bigbluebuttonbn/currentSessionEnded',\n};\n\n/**\n * Trigger the sessionEnded event.\n *\n * @param {number} bbbId\n * @param {number} groupId\n * @returns {CustomEvent}\n * @fires event:mod_bigbluebuttonbn/sessionEnded\n */\nexport const notifySessionEnded = (bbbId, groupId) => dispatchEvent(eventTypes.sessionEnded, {\n bbbId,\n groupId,\n});\n\n/**\n * Trigger the currentSessionEnded event.\n *\n * @param {Element} container\n * @returns {CustomEvent}\n * @fires event:mod_bigbluebuttonbn/currentSessionEnded\n */\nexport const notifyCurrentSessionEnded = container => dispatchEvent(\n eventTypes.currentSessionEnded,\n {},\n container\n);\n"],"file":"events.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/events.js"],"names":["eventTypes","sessionEnded","currentSessionEnded","notifySessionEnded","bbbId","groupId","notifyCurrentSessionEnded","container"],"mappings":"0NAyBO,GAAMA,CAAAA,CAAU,CAAG,CAUtBC,YAAY,CAAE,kCAVQ,CAmBtBC,mBAAmB,CAAE,yCAnBC,CAAnB,C,oCA8B2B,QAArBC,CAAAA,kBAAqB,CAACC,CAAD,CAAQC,CAAR,QAAoB,oBAAcL,CAAU,CAACC,YAAzB,CAAuC,CACzFG,KAAK,CAALA,CADyF,CAEzFC,OAAO,CAAPA,CAFyF,CAAvC,CAApB,C,6BAYO,QAA5BC,CAAAA,yBAA4B,CAAAC,CAAS,QAAI,oBAClDP,CAAU,CAACE,mBADuC,CAElD,EAFkD,CAGlDK,CAHkD,CAAJ,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\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 * Events for the mod_bigbluebuttonbn plugin.\n *\n * @module mod_bigbluebuttonbn/events\n * @copyright 2021 Blindside Networks Inc\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {dispatchEvent} from 'core/event_dispatcher';\n\nexport const eventTypes = {\n /**\n * Fired when a session has been ended.\n *\n * @event mod_bigbluebuttonbn/sessionEnded\n * @type CustomEvent\n * @property {object} detail\n * @property {number} detail.bbbId\n * @property {number} detail.groupId\n */\n sessionEnded: 'mod_bigbluebuttonbn/sessionEnded',\n\n /**\n * Fired when the current session has been ended.\n *\n * @event mod_bigbluebuttonbn/currentSessionEnded\n * @type CustomEvent\n * @property {object} detail\n */\n currentSessionEnded: 'mod_bigbluebuttonbn/currentSessionEnded',\n};\n\n/**\n * Trigger the sessionEnded event.\n *\n * @param {number} bbbId\n * @param {number} groupId\n * @returns {CustomEvent}\n * @fires event:mod_bigbluebuttonbn/sessionEnded\n */\nexport const notifySessionEnded = (bbbId, groupId) => dispatchEvent(eventTypes.sessionEnded, {\n bbbId,\n groupId,\n});\n\n/**\n * Trigger the currentSessionEnded event.\n *\n * @param {Element} container\n * @returns {CustomEvent}\n * @fires event:mod_bigbluebuttonbn/currentSessionEnded\n */\nexport const notifyCurrentSessionEnded = container => dispatchEvent(\n eventTypes.currentSessionEnded,\n {},\n container\n);\n"],"file":"events.min.js"} \ No newline at end of file diff --git a/mod/bigbluebuttonbn/amd/src/event_dispatcher.js b/mod/bigbluebuttonbn/amd/src/event_dispatcher.js deleted file mode 100644 index 92667d3e9fd..00000000000 --- a/mod/bigbluebuttonbn/amd/src/event_dispatcher.js +++ /dev/null @@ -1,82 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ // -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * An Event dispatcher used to dispatch Native JS CustomEvent objects with custom default properties. - * - * @module core/event_dispatcher - * @copyright 2021 Andrew Nicols - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @since 4.0 - */ - -/** - * Dispatch an event as a CustomEvent on the specified container. - * By default events are bubbled, and cancelable. - * - * The eventName should typically by sourced using a constant. See the supplied examples. - * - * Note: This function uses native events. Any additional details are passed to the function in event.detail. - * - * This function mimics the behaviour of EventTarget.dispatchEvent but bubbles by default. - * - * @method dispatchEvent - * @param {String} eventName The name of the event - * @param {Object} detail Any additional details to pass into the eveent - * @param {HTMLElement} container The point at which to dispatch the event - * @param {Object} options - * @param {Boolean} options.bubbles Whether to bubble up the DOM - * @param {Boolean} options.cancelable Whether preventDefault() can be called - * @param {Boolean} options.composed Whether the event can bubble across the ShadowDOM bounadry - * @returns {CustomEvent} - * - * @example Using a native CustomEvent to indicate that some example data was displayed. - * // mod/example/amd/src/events.js - * - * import {dispatchEvent} from 'core/event_dispatcher'; - * - * export const eventTypes = { - * exampleDataDisplayed: 'mod_example/exampleDataDisplayed', - * }; - * - * export const notifyExampleDisplayed = someArgument => dispatchEvent(eventTypes.exampleDataDisplayed, { - * someArgument, - * }, document, { - * cancelable: false, - * }); - */ -export const dispatchEvent = ( - eventName, - detail = {}, - container = document, - { - bubbles = true, - cancelable = false, - composed = false, - } = {} -) => { - const customEvent = new CustomEvent( - eventName, - { - bubbles, - cancelable, - composed, - detail, - } - ); - - container.dispatchEvent(customEvent); - - return customEvent; -}; diff --git a/mod/bigbluebuttonbn/amd/src/events.js b/mod/bigbluebuttonbn/amd/src/events.js index a370bb10d20..1d2a3661d0d 100644 --- a/mod/bigbluebuttonbn/amd/src/events.js +++ b/mod/bigbluebuttonbn/amd/src/events.js @@ -21,9 +21,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -// TODO For master this can be changed to `core/event_dispatcher` and the local copy removed. -// For 3.11 and earlier this line should stay. -import {dispatchEvent} from './event_dispatcher'; +import {dispatchEvent} from 'core/event_dispatcher'; export const eventTypes = { /**