diff --git a/lib/amd/build/event.min.js b/lib/amd/build/event.min.js index 54c25236296..1d56d250c5e 100644 --- a/lib/amd/build/event.min.js +++ b/lib/amd/build/event.min.js @@ -1,2 +1,2 @@ -define ("core/event",["exports","core_editor/events","core_filters/events","core_form/events","jquery","core/yui"],function(a,b,c,d,e,f){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;e=g(e);f=g(f);function g(a){return a&&a.__esModule?a:{default:a}}var h=function(){var a=e.default.Deferred();f.default.use("event","moodle-core-event",function(){a.resolve(window.M.core.event)});return a.promise()},i=function(a,b,c,d){return function(){window.console.warn("The core/event::".concat(a,"() function has been moved to ").concat(b,"::").concat(c,". ")+"Please update your code to use the new module.");return d.apply(void 0,arguments)}},j={Events:{FORM_FIELD_VALIDATION:"core_form-field-validation"},getLegacyEvents:h,notifyEditorContentRestored:i("notifyEditorContentRestored","core_editor/events","notifyEditorContentRestored",b.notifyEditorContentRestored),notifyFilterContentUpdated:i("notifyFilterContentUpdated","core_filters/events","notifyFilterContentUpdated",c.notifyFilterContentUpdated),notifyFormSubmitAjax:i("notifyFormSubmitAjax","core_form/events","notifyFormSubmittedByJavascript",d.notifyFormSubmittedByJavascript)};a.default=j;return a.default}); +define ("core/event",["exports","core_editor/events","core_filters/events","core_form/events","jquery","core/yui"],function(a,b,c,d,e,f){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;e=g(e);f=g(f);function g(a){return a&&a.__esModule?a:{default:a}}var h=function(){var a=e.default.Deferred();window.console.warn("The getLegacyEvents function has been deprecated. Please update your code to use native events.");f.default.use("event","moodle-core-event",function(){a.resolve(window.M.core.event)});return a.promise()},i=function(a,b,c,d){return function(){window.console.warn("The core/event::".concat(a,"() function has been moved to ").concat(b,"::").concat(c,". ")+"Please update your code to use the new module.");return d.apply(void 0,arguments)}},j={Events:{FORM_FIELD_VALIDATION:"core_form-field-validation"},getLegacyEvents:h,notifyEditorContentRestored:i("notifyEditorContentRestored","core_editor/events","notifyEditorContentRestored",b.notifyEditorContentRestored),notifyFilterContentUpdated:i("notifyFilterContentUpdated","core_filters/events","notifyFilterContentUpdated",c.notifyFilterContentUpdated),notifyFormSubmitAjax:i("notifyFormSubmitAjax","core_form/events","notifyFormSubmittedByJavascript",d.notifyFormSubmittedByJavascript)};a.default=j;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 b4ef534c8f1..ed46fc9d436 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":["getLegacyEvents","result","$","Deferred","Y","use","resolve","window","M","core","event","promise","getRenamedLegacyFunction","oldFunctionName","newModule","newFunctionName","newFunctionRef","console","warn","Events","FORM_FIELD_VALIDATION","notifyEditorContentRestored","notifyFilterContentUpdated","notifyFormSubmitAjax","notifyFormSubmittedByJavascript"],"mappings":"wNA6BA,OACA,O,sDAaMA,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,CAWKC,CAAwB,CAAG,SAACC,CAAD,CAAkBC,CAAlB,CAA6BC,CAA7B,CAA8CC,CAA9C,QAAiE,WAAa,CAC3GT,MAAM,CAACU,OAAP,CAAeC,IAAf,CACI,0BAAmBL,CAAnB,0CAAmEC,CAAnE,cAAiFC,CAAjF,uDADJ,EAKA,MAAOC,CAAAA,CAAc,MAAd,kBACV,CAPgC,C,GASlB,CACXG,MAAM,CArCK,CACXC,qBAAqB,CAAE,4BADZ,CAoCA,CAEXpB,eAAe,CAAfA,CAFW,CAIXqB,2BAA2B,CAAET,CAAwB,CACjD,6BADiD,CAEjD,oBAFiD,CAGjD,6BAHiD,CAIjDS,6BAJiD,CAJ1C,CAWXC,0BAA0B,CAAEV,CAAwB,CAChD,4BADgD,CAEhD,qBAFgD,CAGhD,4BAHgD,CAIhDU,4BAJgD,CAXzC,CAkBXC,oBAAoB,CAAEX,CAAwB,CAC1C,sBAD0C,CAE1C,kBAF0C,CAG1C,iCAH0C,CAI1CY,iCAJ0C,CAlBnC,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 * Global registry of core events that can be triggered/listened for.\n *\n * @module core/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 */\n\nimport {notifyEditorContentRestored} from 'core_editor/events';\nimport {notifyFilterContentUpdated} from 'core_filters/events';\nimport {notifyFormSubmittedByJavascript} from 'core_form/events';\n\n// These are only imported for legacy.\nimport $ from 'jquery';\nimport Y from 'core/yui';\n\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 * Get a curried function to warn that a function has been moved and renamed\n *\n * @param {String} oldFunctionName\n * @param {String} newModule\n * @param {String} newFunctionName\n * @param {Function} newFunctionRef\n * @returns {Function}\n */\nconst getRenamedLegacyFunction = (oldFunctionName, newModule, newFunctionName, newFunctionRef) => (...args) => {\n window.console.warn(\n `The core/event::${oldFunctionName}() function has been moved to ${newModule}::${newFunctionName}. ` +\n `Please update your code to use the new module.`\n );\n\n return newFunctionRef(...args);\n};\n\nexport default {\n Events,\n getLegacyEvents,\n\n notifyEditorContentRestored: getRenamedLegacyFunction(\n 'notifyEditorContentRestored',\n 'core_editor/events',\n 'notifyEditorContentRestored',\n notifyEditorContentRestored\n ),\n\n notifyFilterContentUpdated: getRenamedLegacyFunction(\n 'notifyFilterContentUpdated',\n 'core_filters/events',\n 'notifyFilterContentUpdated',\n notifyFilterContentUpdated\n ),\n\n notifyFormSubmitAjax: getRenamedLegacyFunction(\n 'notifyFormSubmitAjax',\n 'core_form/events',\n 'notifyFormSubmittedByJavascript',\n notifyFormSubmittedByJavascript\n ),\n};\n"],"file":"event.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/event.js"],"names":["getLegacyEvents","result","$","Deferred","window","console","warn","Y","use","resolve","M","core","event","promise","getRenamedLegacyFunction","oldFunctionName","newModule","newFunctionName","newFunctionRef","Events","FORM_FIELD_VALIDATION","notifyEditorContentRestored","notifyFilterContentUpdated","notifyFormSubmitAjax","notifyFormSubmittedByJavascript"],"mappings":"wNA6BA,OACA,O,sDAeMA,CAAAA,CAAe,CAAG,UAAM,CAC1B,GAAMC,CAAAA,CAAM,CAAGC,UAAEC,QAAF,EAAf,CACAC,MAAM,CAACC,OAAP,CAAeC,IAAf,CAAoB,iGAApB,EAEAC,UAAEC,GAAF,CAAM,OAAN,CAAe,mBAAf,CAAoC,UAAW,CAC3CP,CAAM,CAACQ,OAAP,CAAeL,MAAM,CAACM,CAAP,CAASC,IAAT,CAAcC,KAA7B,CACH,CAFD,EAGA,MAAOX,CAAAA,CAAM,CAACY,OAAP,EACV,C,CAWKC,CAAwB,CAAG,SAACC,CAAD,CAAkBC,CAAlB,CAA6BC,CAA7B,CAA8CC,CAA9C,QAAiE,WAAa,CAC3Gd,MAAM,CAACC,OAAP,CAAeC,IAAf,CACI,0BAAmBS,CAAnB,0CAAmEC,CAAnE,cAAiFC,CAAjF,uDADJ,EAKA,MAAOC,CAAAA,CAAc,MAAd,kBACV,CAPgC,C,GASlB,CACXC,MAAM,CAxCK,CACXC,qBAAqB,CAAE,4BADZ,CAuCA,CAEXpB,eAAe,CAAfA,CAFW,CAIXqB,2BAA2B,CAAEP,CAAwB,CACjD,6BADiD,CAEjD,oBAFiD,CAGjD,6BAHiD,CAIjDO,6BAJiD,CAJ1C,CAWXC,0BAA0B,CAAER,CAAwB,CAChD,4BADgD,CAEhD,qBAFgD,CAGhD,4BAHgD,CAIhDQ,4BAJgD,CAXzC,CAkBXC,oBAAoB,CAAET,CAAwB,CAC1C,sBAD0C,CAE1C,kBAF0C,CAG1C,iCAH0C,CAI1CU,iCAJ0C,CAlBnC,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 * Global registry of core events that can be triggered/listened for.\n *\n * @module core/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 */\n\nimport {notifyEditorContentRestored} from 'core_editor/events';\nimport {notifyFilterContentUpdated} from 'core_filters/events';\nimport {notifyFormSubmittedByJavascript} from 'core_form/events';\n\n// These are only imported for legacy.\nimport $ from 'jquery';\nimport Y from 'core/yui';\n\n// These are AMD only events - no backwards compatibility for new things.\n// Note: No new events should be created here.\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 * @deprecated\n */\nconst getLegacyEvents = () => {\n const result = $.Deferred();\n window.console.warn(\"The getLegacyEvents function has been deprecated. Please update your code to use native events.\");\n\n Y.use('event', 'moodle-core-event', function() {\n result.resolve(window.M.core.event);\n });\n return result.promise();\n};\n\n/**\n * Get a curried function to warn that a function has been moved and renamed\n *\n * @param {String} oldFunctionName\n * @param {String} newModule\n * @param {String} newFunctionName\n * @param {Function} newFunctionRef\n * @returns {Function}\n */\nconst getRenamedLegacyFunction = (oldFunctionName, newModule, newFunctionName, newFunctionRef) => (...args) => {\n window.console.warn(\n `The core/event::${oldFunctionName}() function has been moved to ${newModule}::${newFunctionName}. ` +\n `Please update your code to use the new module.`\n );\n\n return newFunctionRef(...args);\n};\n\nexport default {\n Events,\n getLegacyEvents,\n\n notifyEditorContentRestored: getRenamedLegacyFunction(\n 'notifyEditorContentRestored',\n 'core_editor/events',\n 'notifyEditorContentRestored',\n notifyEditorContentRestored\n ),\n\n notifyFilterContentUpdated: getRenamedLegacyFunction(\n 'notifyFilterContentUpdated',\n 'core_filters/events',\n 'notifyFilterContentUpdated',\n notifyFilterContentUpdated\n ),\n\n notifyFormSubmitAjax: getRenamedLegacyFunction(\n 'notifyFormSubmitAjax',\n 'core_form/events',\n 'notifyFormSubmittedByJavascript',\n notifyFormSubmittedByJavascript\n ),\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 36257ae30eb..efdc274588e 100644 --- a/lib/amd/src/event.js +++ b/lib/amd/src/event.js @@ -31,6 +31,7 @@ import $ from 'jquery'; import Y from 'core/yui'; // These are AMD only events - no backwards compatibility for new things. +// Note: No new events should be created here. const Events = { FORM_FIELD_VALIDATION: "core_form-field-validation" }; @@ -40,9 +41,12 @@ const Events = { * * @method getLegacyEvents * @return {Promise} + * @deprecated */ const getLegacyEvents = () => { const result = $.Deferred(); + window.console.warn("The getLegacyEvents function has been deprecated. Please update your code to use native events."); + Y.use('event', 'moodle-core-event', function() { result.resolve(window.M.core.event); }); diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 5a83a037388..36f1a5776d4 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -19,6 +19,7 @@ information provided here is intended especially for developers. - The FORM_SUBMIT_AJAX event has been replaced with a new native event in the `core_form/events` AMD module eventTypes.formSubmittedByJavascript. * The block template now includues a block-instanceid data attribute. +* The core/event::getLegacyEvents() function has been deprecated and should no longer be used. === 3.11 === * PHPUnit has been upgraded to 9.5 (see MDL-71036 for details).