mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 12:45:04 +01:00
MDL-70658 mod_bigbluebuttonbn: Use core/event_dispatcher
This commit is contained in:
parent
65212c538b
commit
68c3f1e90c
@ -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<arguments.length&&arguments[1]!==void 0?arguments[1]:{},c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:document,d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:{},e=d.bubbles,f=void 0===e?!0:e,g=d.cancelable,h=void 0===g?!1:g,i=d.composed,j=void 0===i?!1:i,k=new CustomEvent(a,{bubbles:f,cancelable:h,composed:j,detail:b});c.dispatchEvent(k);return k}});
|
||||
//# sourceMappingURL=event_dispatcher.min.js.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../src/event_dispatcher.js"],"names":["dispatchEvent","eventName","detail","container","document","bubbles","cancelable","composed","customEvent","CustomEvent"],"mappings":"4KA0D6B,QAAhBA,CAAAA,aAAgB,CACzBC,CADyB,CASxB,IAPDC,CAAAA,CAOC,wDAPQ,EAOR,CANDC,CAMC,wDANWC,QAMX,0DADG,EACH,KAJGC,OAIH,CAJGA,CAIH,qBAHGC,UAGH,CAHGA,CAGH,qBAFGC,QAEH,CAFGA,CAEH,iBACKC,CAAW,CAAG,GAAIC,CAAAA,WAAJ,CAChBR,CADgB,CAEhB,CACII,OAAO,CAAPA,CADJ,CAEIC,UAAU,CAAVA,CAFJ,CAGIC,QAAQ,CAARA,CAHJ,CAIIL,MAAM,CAANA,CAJJ,CAFgB,CADnB,CAWDC,CAAS,CAACH,aAAV,CAAwBQ,CAAxB,EAEA,MAAOA,CAAAA,CACV,C","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 <http://www.gnu.org/licenses/>.\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 <andrew@nicols.co.uk>\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 <caption>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"],"file":"event_dispatcher.min.js"}
|
2
mod/bigbluebuttonbn/amd/build/events.min.js
vendored
2
mod/bigbluebuttonbn/amd/build/events.min.js
vendored
@ -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
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.\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"}
|
||||
{"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 <http://www.gnu.org/licenses/>.\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"}
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* An Event dispatcher used to dispatch Native JS CustomEvent objects with custom default properties.
|
||||
*
|
||||
* @module core/event_dispatcher
|
||||
* @copyright 2021 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @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 <caption>Using a native CustomEvent to indicate that some example data was displayed.</caption>
|
||||
* // 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;
|
||||
};
|
@ -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 = {
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user