From da8658e49afa3bea3240e5a2fcd86eb807f6737d Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 24 Feb 2021 09:35:38 +0800 Subject: [PATCH] MDL-70990 core: Rewrite core/event as ES6 --- lib/amd/build/event.min.js | 2 +- lib/amd/build/event.min.js.map | 2 +- lib/amd/src/event.js | 160 +++++++++++++++++---------------- lib/upgrade.txt | 1 + 4 files changed, 84 insertions(+), 81 deletions(-) diff --git a/lib/amd/build/event.min.js b/lib/amd/build/event.min.js index 3541d3199fb..5fbbc30bbc1 100644 --- a/lib/amd/build/event.min.js +++ b/lib/amd/build/event.min.js @@ -1,2 +1,2 @@ -define ("core/event",["jquery","core/yui"],function(a,b){return{Events:{FORM_FIELD_VALIDATION:"core_form-field-validation"},getLegacyEvents:function getLegacyEvents(){var c=a.Deferred();b.use("event","moodle-core-event",function(){c.resolve(window.M.core.event)});return c.promise()},notifyFilterContentUpdated:function notifyFilterContentUpdated(c){c=a(c);b.use("event","moodle-core-event",function(b){a(document).trigger(M.core.event.FILTER_CONTENT_UPDATED,[c]);var d=new b.NodeList(c.get());b.fire(M.core.event.FILTER_CONTENT_UPDATED,{nodes:d})})},notifyFormSubmitAjax:function notifyFormSubmitAjax(c,d){d=d||!1;b.use("event","moodle-core-event",function(b){if(d){window.skipClientValidation=!0}a(c).trigger(M.core.event.FORM_SUBMIT_AJAX);b.one(c).fire(M.core.event.FORM_SUBMIT_AJAX,{currentTarget:b.one(c)});if(d){window.skipClientValidation=!1}})},notifyEditorContentRestored:function notifyEditorContentRestored(){b.use("event","moodle-core-event",function(b){a(document).trigger(M.core.event.EDITOR_CONTENT_RESTORED);b.fire(M.core.event.EDITOR_CONTENT_RESTORED)})}}}); +define ("core/event",["exports","jquery","core/yui"],function(a,b,c){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=d(b);c=d(c);function d(a){return a&&a.__esModule?a:{default:a}}var e=function(){var a=b.default.Deferred();c.default.use("event","moodle-core-event",function(){a.resolve(window.M.core.event)});return a.promise()},f=function(a){a=(0,b.default)(a);c.default.use("event","moodle-core-event",function(c){(0,b.default)(document).trigger(M.core.event.FILTER_CONTENT_UPDATED,[a]);var d=new c.NodeList(a.get());c.fire(M.core.event.FILTER_CONTENT_UPDATED,{nodes:d})})},g=function(a,d){d=d||!1;c.default.use("event","moodle-core-event",function(c){if(d){window.skipClientValidation=!0}(0,b.default)(a).trigger(M.core.event.FORM_SUBMIT_AJAX);c.one(a).fire(M.core.event.FORM_SUBMIT_AJAX,{currentTarget:c.one(a)});if(d){window.skipClientValidation=!1}})},h=function(){c.default.use("event","moodle-core-event",function(a){(0,b.default)(document).trigger(M.core.event.EDITOR_CONTENT_RESTORED);a.fire(M.core.event.EDITOR_CONTENT_RESTORED)})};a.default={Events:{FORM_FIELD_VALIDATION:"core_form-field-validation"},getLegacyEvents:e,notifyFilterContentUpdated:f,notifyFormSubmitAjax:g,notifyEditorContentRestored:h};return a.default}); //# sourceMappingURL=event.min.js.map diff --git a/lib/amd/build/event.min.js.map b/lib/amd/build/event.min.js.map index 38e1a2d518d..f2c79d4e88e 100644 --- a/lib/amd/build/event.min.js.map +++ b/lib/amd/build/event.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/event.js"],"names":["define","$","Y","Events","FORM_FIELD_VALIDATION","getLegacyEvents","result","Deferred","use","resolve","window","M","core","event","promise","notifyFilterContentUpdated","nodes","document","trigger","FILTER_CONTENT_UPDATED","yuiNodes","NodeList","get","fire","notifyFormSubmitAjax","form","skipValidation","skipClientValidation","FORM_SUBMIT_AJAX","one","currentTarget","notifyEditorContentRestored","EDITOR_CONTENT_RESTORED"],"mappings":"AAyBAA,OAAM,cAAC,CAAC,QAAD,CAAW,UAAX,CAAD,CACC,SAASC,CAAT,CAAYC,CAAZ,CAAe,CAElB,MAAuC,CAKnCC,MAAM,CAAE,CACJC,qBAAqB,CAAE,4BADnB,CAL2B,CAenCC,eAAe,CAAE,0BAAW,CACxB,GAAIC,CAAAA,CAAM,CAAGL,CAAC,CAACM,QAAF,EAAb,CACAL,CAAC,CAACM,GAAF,CAAM,OAAN,CAAe,mBAAf,CAAoC,UAAW,CAC3CF,CAAM,CAACG,OAAP,CAAeC,MAAM,CAACC,CAAP,CAASC,IAAT,CAAcC,KAA7B,CACH,CAFD,EAGA,MAAOP,CAAAA,CAAM,CAACQ,OAAP,EACV,CArBkC,CA6BnCC,0BAA0B,CAAE,oCAASC,CAAT,CAAgB,CACxCA,CAAK,CAAGf,CAAC,CAACe,CAAD,CAAT,CACAd,CAAC,CAACM,GAAF,CAAM,OAAN,CAAe,mBAAf,CAAoC,SAASN,CAAT,CAAY,CAE5CD,CAAC,CAACgB,QAAD,CAAD,CAAYC,OAAZ,CAAoBP,CAAC,CAACC,IAAF,CAAOC,KAAP,CAAaM,sBAAjC,CAAyD,CAACH,CAAD,CAAzD,EAGA,GAAII,CAAAA,CAAQ,CAAG,GAAIlB,CAAAA,CAAC,CAACmB,QAAN,CAAeL,CAAK,CAACM,GAAN,EAAf,CAAf,CAGApB,CAAC,CAACqB,IAAF,CAAOZ,CAAC,CAACC,IAAF,CAAOC,KAAP,CAAaM,sBAApB,CAA4C,CAACH,KAAK,CAAEI,CAAR,CAA5C,CACH,CATD,CAUH,CAzCkC,CAkDnCI,oBAAoB,CAAE,8BAASC,CAAT,CAAeC,CAAf,CAA+B,CAGjDA,CAAc,CAAGA,CAAc,IAA/B,CAEAxB,CAAC,CAACM,GAAF,CAAM,OAAN,CAAe,mBAAf,CAAoC,SAASN,CAAT,CAAY,CAC5C,GAAIwB,CAAJ,CAAoB,CAChBhB,MAAM,CAACiB,oBAAP,GACH,CAED1B,CAAC,CAACwB,CAAD,CAAD,CAAQP,OAAR,CAAgBP,CAAC,CAACC,IAAF,CAAOC,KAAP,CAAae,gBAA7B,EAGA1B,CAAC,CAAC2B,GAAF,CAAMJ,CAAN,EAAYF,IAAZ,CAAiBZ,CAAC,CAACC,IAAF,CAAOC,KAAP,CAAae,gBAA9B,CAAgD,CAACE,aAAa,CAAE5B,CAAC,CAAC2B,GAAF,CAAMJ,CAAN,CAAhB,CAAhD,EAEA,GAAIC,CAAJ,CAAoB,CAChBhB,MAAM,CAACiB,oBAAP,GACH,CACJ,CAbD,CAcH,CArEkC,CA6EnCI,2BAA2B,CAAE,sCAAW,CACpC7B,CAAC,CAACM,GAAF,CAAM,OAAN,CAAe,mBAAf,CAAoC,SAASN,CAAT,CAAY,CAE5CD,CAAC,CAACgB,QAAD,CAAD,CAAYC,OAAZ,CAAoBP,CAAC,CAACC,IAAF,CAAOC,KAAP,CAAamB,uBAAjC,EAGA9B,CAAC,CAACqB,IAAF,CAAOZ,CAAC,CAACC,IAAF,CAAOC,KAAP,CAAamB,uBAApB,CACH,CAND,CAOH,CArFkC,CAuF1C,CA1FK,CAAN","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 * Global registry of core events that can be triggered/listened for.\n *\n * @module core/event\n * @package core\n * @class event\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 3.0\n */\ndefine(['jquery', 'core/yui'],\n function($, Y) {\n\n return /** @alias module:core/event */ {\n\n\n // Public variables and functions.\n // These are AMD only events - no backwards compatibility for new things.\n Events: {\n FORM_FIELD_VALIDATION: \"core_form-field-validation\"\n },\n\n /**\n * Load the legacy YUI module which defines events in M.core.event and return it.\n *\n * @method getLegacyEvents\n * @return {Promise}\n */\n getLegacyEvents: function() {\n var result = $.Deferred();\n Y.use('event', 'moodle-core-event', function() {\n result.resolve(window.M.core.event);\n });\n return result.promise();\n },\n\n /**\n * Trigger an event using both JQuery and YUI\n *\n * @method notifyFilterContentUpdated\n * @param {string|JQuery} nodes - Selector or list of elements that were inserted.\n */\n notifyFilterContentUpdated: function(nodes) {\n nodes = $(nodes);\n Y.use('event', 'moodle-core-event', function(Y) {\n // Trigger it the JQuery way.\n $(document).trigger(M.core.event.FILTER_CONTENT_UPDATED, [nodes]);\n\n // Create a YUI NodeList from our JQuery Object.\n var yuiNodes = new Y.NodeList(nodes.get());\n\n // And again for YUI.\n Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: yuiNodes});\n });\n },\n\n /**\n * Trigger an event using both JQuery and YUI\n *\n * @method notifyFormSubmittedAjax\n * @param {DOMElement} form\n * @param {boolean} skipValidation Submit the form without validation. E.g. \"Cancel\".\n */\n notifyFormSubmitAjax: function(form, skipValidation) {\n\n // Argument is optional.\n skipValidation = skipValidation || false;\n\n Y.use('event', 'moodle-core-event', function(Y) {\n if (skipValidation) {\n window.skipClientValidation = true;\n }\n // Trigger it the JQuery way.\n $(form).trigger(M.core.event.FORM_SUBMIT_AJAX);\n\n // And again for YUI.\n Y.one(form).fire(M.core.event.FORM_SUBMIT_AJAX, {currentTarget: Y.one(form)});\n\n if (skipValidation) {\n window.skipClientValidation = false;\n }\n });\n },\n\n /**\n * Trigger an event using both JQuery and YUI\n * This event alerts the world that the editor has restored some content.\n *\n * @method notifyEditorContentRestored\n */\n notifyEditorContentRestored: function() {\n Y.use('event', 'moodle-core-event', function(Y) {\n // Trigger it the JQuery way.\n $(document).trigger(M.core.event.EDITOR_CONTENT_RESTORED);\n\n // And again for YUI.\n Y.fire(M.core.event.EDITOR_CONTENT_RESTORED);\n });\n },\n };\n});\n"],"file":"event.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/event.js"],"names":["getLegacyEvents","result","$","Deferred","Y","use","resolve","window","M","core","event","promise","notifyFilterContentUpdated","nodes","document","trigger","FILTER_CONTENT_UPDATED","yuiNodes","NodeList","get","fire","notifyFormSubmitAjax","form","skipValidation","skipClientValidation","FORM_SUBMIT_AJAX","one","currentTarget","notifyEditorContentRestored","EDITOR_CONTENT_RESTORED","Events","FORM_FIELD_VALIDATION"],"mappings":"oJAwBA,OACA,O,sDAcMA,CAAAA,CAAe,CAAG,UAAM,CAC1B,GAAMC,CAAAA,CAAM,CAAGC,UAAEC,QAAF,EAAf,CACAC,UAAEC,GAAF,CAAM,OAAN,CAAe,mBAAf,CAAoC,UAAW,CAC3CJ,CAAM,CAACK,OAAP,CAAeC,MAAM,CAACC,CAAP,CAASC,IAAT,CAAcC,KAA7B,CACH,CAFD,EAGA,MAAOT,CAAAA,CAAM,CAACU,OAAP,EACV,C,CAQKC,CAA0B,CAAG,SAAAC,CAAK,CAAI,CACxCA,CAAK,CAAG,cAAEA,CAAF,CAAR,CACAT,UAAEC,GAAF,CAAM,OAAN,CAAe,mBAAf,CAAoC,SAASD,CAAT,CAAY,CAE5C,cAAEU,QAAF,EAAYC,OAAZ,CAAoBP,CAAC,CAACC,IAAF,CAAOC,KAAP,CAAaM,sBAAjC,CAAyD,CAACH,CAAD,CAAzD,EAGA,GAAII,CAAAA,CAAQ,CAAG,GAAIb,CAAAA,CAAC,CAACc,QAAN,CAAeL,CAAK,CAACM,GAAN,EAAf,CAAf,CAGAf,CAAC,CAACgB,IAAF,CAAOZ,CAAC,CAACC,IAAF,CAAOC,KAAP,CAAaM,sBAApB,CAA4C,CAACH,KAAK,CAAEI,CAAR,CAA5C,CACH,CATD,CAUH,C,CASKI,CAAoB,CAAG,SAACC,CAAD,CAAOC,CAAP,CAA0B,CAEnDA,CAAc,CAAGA,CAAc,IAA/B,CAEAnB,UAAEC,GAAF,CAAM,OAAN,CAAe,mBAAf,CAAoC,SAASD,CAAT,CAAY,CAC5C,GAAImB,CAAJ,CAAoB,CAChBhB,MAAM,CAACiB,oBAAP,GACH,CAED,cAAEF,CAAF,EAAQP,OAAR,CAAgBP,CAAC,CAACC,IAAF,CAAOC,KAAP,CAAae,gBAA7B,EAGArB,CAAC,CAACsB,GAAF,CAAMJ,CAAN,EAAYF,IAAZ,CAAiBZ,CAAC,CAACC,IAAF,CAAOC,KAAP,CAAae,gBAA9B,CAAgD,CAACE,aAAa,CAAEvB,CAAC,CAACsB,GAAF,CAAMJ,CAAN,CAAhB,CAAhD,EAEA,GAAIC,CAAJ,CAAoB,CAChBhB,MAAM,CAACiB,oBAAP,GACH,CACJ,CAbD,CAcH,C,CAQKI,CAA2B,CAAG,UAAM,CACtCxB,UAAEC,GAAF,CAAM,OAAN,CAAe,mBAAf,CAAoC,SAASD,CAAT,CAAY,CAE5C,cAAEU,QAAF,EAAYC,OAAZ,CAAoBP,CAAC,CAACC,IAAF,CAAOC,KAAP,CAAamB,uBAAjC,EAGAzB,CAAC,CAACgB,IAAF,CAAOZ,CAAC,CAACC,IAAF,CAAOC,KAAP,CAAamB,uBAApB,CACH,CAND,CAOH,C,WAEc,CACXC,MAAM,CAlFK,CACXC,qBAAqB,CAAE,4BADZ,CAiFA,CAEX/B,eAAe,CAAfA,CAFW,CAGXY,0BAA0B,CAA1BA,CAHW,CAIXS,oBAAoB,CAApBA,CAJW,CAKXO,2BAA2B,CAA3BA,CALW,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 .\n\n/**\n * Global registry of core events that can be triggered/listened for.\n *\n * @module core/event\n * @package core\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 3.0\n */\n\nimport $ from 'jquery';\nimport Y from 'core/yui';\n\n// Public variables and functions.\n// These are AMD only events - no backwards compatibility for new things.\nconst Events = {\n FORM_FIELD_VALIDATION: \"core_form-field-validation\"\n};\n\n/**\n * Load the legacy YUI module which defines events in M.core.event and return it.\n *\n * @method getLegacyEvents\n * @return {Promise}\n */\nconst getLegacyEvents = () => {\n const result = $.Deferred();\n Y.use('event', 'moodle-core-event', function() {\n result.resolve(window.M.core.event);\n });\n return result.promise();\n};\n\n/**\n * Trigger an event using both JQuery and YUI\n *\n * @method notifyFilterContentUpdated\n * @param {string|JQuery} nodes - Selector or list of elements that were inserted.\n */\nconst notifyFilterContentUpdated = nodes => {\n nodes = $(nodes);\n Y.use('event', 'moodle-core-event', function(Y) {\n // Trigger it the JQuery way.\n $(document).trigger(M.core.event.FILTER_CONTENT_UPDATED, [nodes]);\n\n // Create a YUI NodeList from our JQuery Object.\n var yuiNodes = new Y.NodeList(nodes.get());\n\n // And again for YUI.\n Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: yuiNodes});\n });\n};\n\n/**\n * Trigger an event using both JQuery and YUI\n *\n * @method notifyFormSubmittedAjax\n * @param {DOMElement} form\n * @param {boolean} skipValidation Submit the form without validation. E.g. \"Cancel\".\n */\nconst notifyFormSubmitAjax = (form, skipValidation) => {\n // Argument is optional.\n skipValidation = skipValidation || false;\n\n Y.use('event', 'moodle-core-event', function(Y) {\n if (skipValidation) {\n window.skipClientValidation = true;\n }\n // Trigger it the JQuery way.\n $(form).trigger(M.core.event.FORM_SUBMIT_AJAX);\n\n // And again for YUI.\n Y.one(form).fire(M.core.event.FORM_SUBMIT_AJAX, {currentTarget: Y.one(form)});\n\n if (skipValidation) {\n window.skipClientValidation = false;\n }\n });\n};\n\n/**\n * Trigger an event using both JQuery and YUI\n * This event alerts the world that the editor has restored some content.\n *\n * @method notifyEditorContentRestored\n */\nconst notifyEditorContentRestored = () => {\n Y.use('event', 'moodle-core-event', function(Y) {\n // Trigger it the JQuery way.\n $(document).trigger(M.core.event.EDITOR_CONTENT_RESTORED);\n\n // And again for YUI.\n Y.fire(M.core.event.EDITOR_CONTENT_RESTORED);\n });\n};\n\nexport default {\n Events,\n getLegacyEvents,\n notifyFilterContentUpdated,\n notifyFormSubmitAjax,\n notifyEditorContentRestored,\n};\n"],"file":"event.min.js"} \ No newline at end of file diff --git a/lib/amd/src/event.js b/lib/amd/src/event.js index a5d80e51410..5f15d725a79 100644 --- a/lib/amd/src/event.js +++ b/lib/amd/src/event.js @@ -18,99 +18,101 @@ * * @module core/event * @package core - * @class event * @copyright 2015 Damyon Wiese * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @since 3.0 */ -define(['jquery', 'core/yui'], - function($, Y) { - return /** @alias module:core/event */ { +import $ from 'jquery'; +import Y from 'core/yui'; +// Public variables and functions. +// These are AMD only events - no backwards compatibility for new things. +const Events = { + FORM_FIELD_VALIDATION: "core_form-field-validation" +}; - // Public variables and functions. - // These are AMD only events - no backwards compatibility for new things. - Events: { - FORM_FIELD_VALIDATION: "core_form-field-validation" - }, +/** + * Load the legacy YUI module which defines events in M.core.event and return it. + * + * @method getLegacyEvents + * @return {Promise} + */ +const getLegacyEvents = () => { + const result = $.Deferred(); + Y.use('event', 'moodle-core-event', function() { + result.resolve(window.M.core.event); + }); + return result.promise(); +}; - /** - * Load the legacy YUI module which defines events in M.core.event and return it. - * - * @method getLegacyEvents - * @return {Promise} - */ - getLegacyEvents: function() { - var result = $.Deferred(); - Y.use('event', 'moodle-core-event', function() { - result.resolve(window.M.core.event); - }); - return result.promise(); - }, +/** + * Trigger an event using both JQuery and YUI + * + * @method notifyFilterContentUpdated + * @param {string|JQuery} nodes - Selector or list of elements that were inserted. + */ +const notifyFilterContentUpdated = nodes => { + nodes = $(nodes); + Y.use('event', 'moodle-core-event', function(Y) { + // Trigger it the JQuery way. + $(document).trigger(M.core.event.FILTER_CONTENT_UPDATED, [nodes]); - /** - * Trigger an event using both JQuery and YUI - * - * @method notifyFilterContentUpdated - * @param {string|JQuery} nodes - Selector or list of elements that were inserted. - */ - notifyFilterContentUpdated: function(nodes) { - nodes = $(nodes); - Y.use('event', 'moodle-core-event', function(Y) { - // Trigger it the JQuery way. - $(document).trigger(M.core.event.FILTER_CONTENT_UPDATED, [nodes]); + // Create a YUI NodeList from our JQuery Object. + var yuiNodes = new Y.NodeList(nodes.get()); - // Create a YUI NodeList from our JQuery Object. - var yuiNodes = new Y.NodeList(nodes.get()); + // And again for YUI. + Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: yuiNodes}); + }); +}; - // And again for YUI. - Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: yuiNodes}); - }); - }, +/** + * Trigger an event using both JQuery and YUI + * + * @method notifyFormSubmittedAjax + * @param {DOMElement} form + * @param {boolean} skipValidation Submit the form without validation. E.g. "Cancel". + */ +const notifyFormSubmitAjax = (form, skipValidation) => { + // Argument is optional. + skipValidation = skipValidation || false; - /** - * Trigger an event using both JQuery and YUI - * - * @method notifyFormSubmittedAjax - * @param {DOMElement} form - * @param {boolean} skipValidation Submit the form without validation. E.g. "Cancel". - */ - notifyFormSubmitAjax: function(form, skipValidation) { + Y.use('event', 'moodle-core-event', function(Y) { + if (skipValidation) { + window.skipClientValidation = true; + } + // Trigger it the JQuery way. + $(form).trigger(M.core.event.FORM_SUBMIT_AJAX); - // Argument is optional. - skipValidation = skipValidation || false; + // And again for YUI. + Y.one(form).fire(M.core.event.FORM_SUBMIT_AJAX, {currentTarget: Y.one(form)}); - Y.use('event', 'moodle-core-event', function(Y) { - if (skipValidation) { - window.skipClientValidation = true; - } - // Trigger it the JQuery way. - $(form).trigger(M.core.event.FORM_SUBMIT_AJAX); + if (skipValidation) { + window.skipClientValidation = false; + } + }); +}; - // And again for YUI. - Y.one(form).fire(M.core.event.FORM_SUBMIT_AJAX, {currentTarget: Y.one(form)}); +/** + * Trigger an event using both JQuery and YUI + * This event alerts the world that the editor has restored some content. + * + * @method notifyEditorContentRestored + */ +const notifyEditorContentRestored = () => { + Y.use('event', 'moodle-core-event', function(Y) { + // Trigger it the JQuery way. + $(document).trigger(M.core.event.EDITOR_CONTENT_RESTORED); - if (skipValidation) { - window.skipClientValidation = false; - } - }); - }, + // And again for YUI. + Y.fire(M.core.event.EDITOR_CONTENT_RESTORED); + }); +}; - /** - * Trigger an event using both JQuery and YUI - * This event alerts the world that the editor has restored some content. - * - * @method notifyEditorContentRestored - */ - notifyEditorContentRestored: function() { - Y.use('event', 'moodle-core-event', function(Y) { - // Trigger it the JQuery way. - $(document).trigger(M.core.event.EDITOR_CONTENT_RESTORED); - - // And again for YUI. - Y.fire(M.core.event.EDITOR_CONTENT_RESTORED); - }); - }, - }; -}); +export default { + Events, + getLegacyEvents, + notifyFilterContentUpdated, + notifyFormSubmitAjax, + notifyEditorContentRestored, +}; diff --git a/lib/upgrade.txt b/lib/upgrade.txt index df17134a6ab..1bd865575d3 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -6,6 +6,7 @@ information provided here is intended especially for developers. will be called. The following behaviour will be the new standard for nodes added via callbacks: - Module nodes added will be appended to the end and will appear within the hamburger option. - Course nodes added will also be appended and appear within the 'More' option/page. +* The core/event events have been renamed and now fire native events, in addition to the legacy YUI and jQuery events. === 3.11 === * PHPUnit has been upgraded to 9.5 (see MDL-71036 for details).