mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-77167 javascript: Remove deprecation layer for YUI Events
The deprecation layer was introduced with MDL-70990. Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
This commit is contained in:
parent
fd487cd3f2
commit
c3df4078e8
5
.upgradenotes/MDL-77167-2024062111140275.yml
Normal file
5
.upgradenotes/MDL-77167-2024062111140275.yml
Normal file
@ -0,0 +1,5 @@
|
||||
issueNumber: MDL-77167
|
||||
notes:
|
||||
core:
|
||||
- message: Remove deprecation layer for YUI Events. The deprecation layer was introduced with MDL-70990 and MDL-72291.
|
||||
type: removed
|
2
blocks/amd/build/events.min.js
vendored
2
blocks/amd/build/events.min.js
vendored
@ -15,6 +15,6 @@ define("core_block/events",["exports","core/event_dispatcher"],(function(_export
|
||||
* window.console.log(e.detail.instanceId); // The instanceId of the block that was updated.
|
||||
* });
|
||||
*/
|
||||
const eventTypes={blockContentUpdated:"core_block/contentUpdated"};_exports.eventTypes=eventTypes;_exports.notifyBlockContentUpdated=element=>(0,_event_dispatcher.dispatchEvent)(eventTypes.blockContentUpdated,{instanceId:element.dataset.instanceId},element);let legacyEventsRegistered=!1;legacyEventsRegistered||(Y.use("event","moodle-core-event",(Y=>{document.addEventListener(eventTypes.blockContentUpdated,(e=>{Y.Global.fire(M.core.event.BLOCK_CONTENT_UPDATED,{instanceid:e.detail.instanceId})}))})),legacyEventsRegistered=!0)}));
|
||||
const eventTypes={blockContentUpdated:"core_block/contentUpdated"};_exports.eventTypes=eventTypes;_exports.notifyBlockContentUpdated=element=>(0,_event_dispatcher.dispatchEvent)(eventTypes.blockContentUpdated,{instanceId:element.dataset.instanceId},element)}));
|
||||
|
||||
//# sourceMappingURL=events.min.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"events.min.js","sources":["../src/events.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Javascript events for the `core_block` subsystem.\n *\n * @module core_block/events\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 * @example <caption>Example of listening to a block event.</caption>\n * import {eventTypes as blockEventTypes} from 'core_block/events';\n *\n * document.addEventListener(blockEventTypes.blockContentUpdated, e => {\n * window.console.log(e.target); // The HTMLElement relating to the block whose content was updated.\n * window.console.log(e.detail.instanceId); // The instanceId of the block that was updated.\n * });\n */\n\nimport {dispatchEvent} from 'core/event_dispatcher';\n\n/**\n * Events for `core_block`.\n *\n * @constant\n * @property {String} blockContentUpdated See {@link event:blockContentUpdated}\n */\nexport const eventTypes = {\n /**\n * An event triggered when the content of a block has changed.\n *\n * @event blockContentUpdated\n * @type {CustomEvent}\n * @property {HTMLElement} target The block element that was updated\n * @property {object} detail\n * @property {number} detail.instanceId The block instance id\n */\n blockContentUpdated: 'core_block/contentUpdated',\n};\n\n/**\n * Trigger an event to indicate that the content of a block was updated.\n *\n * @method notifyBlockContentUpdated\n * @param {HTMLElement} element The HTMLElement containing the updated block.\n * @returns {CustomEvent}\n * @fires blockContentUpdated\n */\nexport const notifyBlockContentUpdated = element => dispatchEvent(\n eventTypes.blockContentUpdated,\n {\n instanceId: element.dataset.instanceId,\n },\n element\n);\n\nlet legacyEventsRegistered = false;\nif (!legacyEventsRegistered) {\n // The following event triggers are legacy and will be removed in the future.\n // The following approach provides a backwards-compatability layer for the new events.\n // Code should be updated to make use of native events.\n\n Y.use('event', 'moodle-core-event', Y => {\n // Provide a backwards-compatability layer for YUI Events.\n document.addEventListener(eventTypes.blockContentUpdated, e => {\n // Trigger the legacy YUI event.\n Y.Global.fire(M.core.event.BLOCK_CONTENT_UPDATED, {instanceid: e.detail.instanceId});\n });\n });\n\n legacyEventsRegistered = true;\n}\n"],"names":["eventTypes","blockContentUpdated","element","instanceId","dataset","legacyEventsRegistered","Y","use","document","addEventListener","e","Global","fire","M","core","event","BLOCK_CONTENT_UPDATED","instanceid","detail"],"mappings":";;;;;;;;;;;;;;;;;MAuCaA,WAAa,CAUtBC,oBAAqB,+FAWgBC,UAAW,mCAChDF,WAAWC,oBACX,CACIE,WAAYD,QAAQE,QAAQD,YAEhCD,aAGAG,wBAAyB,EACxBA,yBAKDC,EAAEC,IAAI,QAAS,qBAAqBD,IAEhCE,SAASC,iBAAiBT,WAAWC,qBAAqBS,IAEtDJ,EAAEK,OAAOC,KAAKC,EAAEC,KAAKC,MAAMC,sBAAuB,CAACC,WAAYP,EAAEQ,OAAOf,mBAIhFE,wBAAyB"}
|
||||
{"version":3,"file":"events.min.js","sources":["../src/events.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Javascript events for the `core_block` subsystem.\n *\n * @module core_block/events\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 * @example <caption>Example of listening to a block event.</caption>\n * import {eventTypes as blockEventTypes} from 'core_block/events';\n *\n * document.addEventListener(blockEventTypes.blockContentUpdated, e => {\n * window.console.log(e.target); // The HTMLElement relating to the block whose content was updated.\n * window.console.log(e.detail.instanceId); // The instanceId of the block that was updated.\n * });\n */\n\nimport {dispatchEvent} from 'core/event_dispatcher';\n\n/**\n * Events for `core_block`.\n *\n * @constant\n * @property {String} blockContentUpdated See {@link event:blockContentUpdated}\n */\nexport const eventTypes = {\n /**\n * An event triggered when the content of a block has changed.\n *\n * @event blockContentUpdated\n * @type {CustomEvent}\n * @property {HTMLElement} target The block element that was updated\n * @property {object} detail\n * @property {number} detail.instanceId The block instance id\n */\n blockContentUpdated: 'core_block/contentUpdated',\n};\n\n/**\n * Trigger an event to indicate that the content of a block was updated.\n *\n * @method notifyBlockContentUpdated\n * @param {HTMLElement} element The HTMLElement containing the updated block.\n * @returns {CustomEvent}\n * @fires blockContentUpdated\n */\nexport const notifyBlockContentUpdated = element => dispatchEvent(\n eventTypes.blockContentUpdated,\n {\n instanceId: element.dataset.instanceId,\n },\n element\n);\n"],"names":["eventTypes","blockContentUpdated","element","instanceId","dataset"],"mappings":";;;;;;;;;;;;;;;;;MAuCaA,WAAa,CAUtBC,oBAAqB,+FAWgBC,UAAW,mCAChDF,WAAWC,oBACX,CACIE,WAAYD,QAAQE,QAAQD,YAEhCD"}
|
@ -65,20 +65,3 @@ export const notifyBlockContentUpdated = element => dispatchEvent(
|
||||
},
|
||||
element
|
||||
);
|
||||
|
||||
let legacyEventsRegistered = false;
|
||||
if (!legacyEventsRegistered) {
|
||||
// The following event triggers are legacy and will be removed in the future.
|
||||
// The following approach provides a backwards-compatability layer for the new events.
|
||||
// Code should be updated to make use of native events.
|
||||
|
||||
Y.use('event', 'moodle-core-event', Y => {
|
||||
// Provide a backwards-compatability layer for YUI Events.
|
||||
document.addEventListener(eventTypes.blockContentUpdated, e => {
|
||||
// Trigger the legacy YUI event.
|
||||
Y.Global.fire(M.core.event.BLOCK_CONTENT_UPDATED, {instanceid: e.detail.instanceId});
|
||||
});
|
||||
});
|
||||
|
||||
legacyEventsRegistered = true;
|
||||
}
|
||||
|
5
filter/amd/build/events.min.js
vendored
5
filter/amd/build/events.min.js
vendored
@ -1,4 +1,4 @@
|
||||
define("core_filters/events",["exports","core/event_dispatcher","core/normalise","jquery"],(function(_exports,_event_dispatcher,_normalise,_jquery){var obj;
|
||||
define("core_filters/events",["exports","core/event_dispatcher","core/normalise"],(function(_exports,_event_dispatcher,_normalise){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.notifyFilterContentUpdated=_exports.notifyFilterContentRenderingComplete=_exports.eventTypes=void 0;
|
||||
/**
|
||||
* Javascript events for the `core_filters` subsystem.
|
||||
*
|
||||
@ -13,6 +13,7 @@ define("core_filters/events",["exports","core/event_dispatcher","core/normalise"
|
||||
* document.addEventListener(filterEventTypes.filterContentUpdated, e => {
|
||||
* window.console.log(e.detail.nodes); // A list of the HTMLElements whose content was updated
|
||||
* });
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.notifyFilterContentUpdated=_exports.notifyFilterContentRenderingComplete=_exports.eventTypes=void 0,_jquery=(obj=_jquery)&&obj.__esModule?obj:{default:obj};const eventTypes={filterContentUpdated:"core_filters/contentUpdated",filterContentRenderingComplete:"core_filters/contentRenderingComplete"};_exports.eventTypes=eventTypes;_exports.notifyFilterContentUpdated=nodes=>(nodes=(0,_normalise.getList)(nodes),(0,_event_dispatcher.dispatchEvent)(eventTypes.filterContentUpdated,{nodes:nodes}));_exports.notifyFilterContentRenderingComplete=nodes=>(0,_event_dispatcher.dispatchEvent)(eventTypes.filterContentRenderingComplete,{nodes:nodes});let legacyEventsRegistered=!1;legacyEventsRegistered||(Y.use("event","moodle-core-event",(()=>{document.addEventListener(eventTypes.filterContentUpdated,(e=>{(0,_jquery.default)(document).trigger(M.core.event.FILTER_CONTENT_UPDATED,[(0,_jquery.default)(e.detail.nodes)]),Y.fire(M.core.event.FILTER_CONTENT_UPDATED,{nodes:new Y.NodeList(e.detail.nodes)})}))})),legacyEventsRegistered=!0)}));
|
||||
*/
|
||||
const eventTypes={filterContentUpdated:"core_filters/contentUpdated",filterContentRenderingComplete:"core_filters/contentRenderingComplete"};_exports.eventTypes=eventTypes;_exports.notifyFilterContentUpdated=nodes=>(nodes=(0,_normalise.getList)(nodes),(0,_event_dispatcher.dispatchEvent)(eventTypes.filterContentUpdated,{nodes:nodes}));_exports.notifyFilterContentRenderingComplete=nodes=>(0,_event_dispatcher.dispatchEvent)(eventTypes.filterContentRenderingComplete,{nodes:nodes})}));
|
||||
|
||||
//# sourceMappingURL=events.min.js.map
|
File diff suppressed because one or more lines are too long
@ -30,7 +30,6 @@
|
||||
|
||||
import {dispatchEvent} from 'core/event_dispatcher';
|
||||
import {getList as normalistNodeList} from 'core/normalise';
|
||||
import jQuery from 'jquery';
|
||||
|
||||
/**
|
||||
* Events for the `core_filters` subsystem.
|
||||
@ -90,23 +89,3 @@ export const notifyFilterContentUpdated = nodes => {
|
||||
export const notifyFilterContentRenderingComplete = nodes => {
|
||||
return dispatchEvent(eventTypes.filterContentRenderingComplete, {nodes});
|
||||
};
|
||||
|
||||
let legacyEventsRegistered = false;
|
||||
if (!legacyEventsRegistered) {
|
||||
// The following event triggers are legacy and will be removed in the future.
|
||||
// The following approach provides a backwards-compatability layer for the new events.
|
||||
// Code should be updated to make use of native events.
|
||||
|
||||
Y.use('event', 'moodle-core-event', () => {
|
||||
// Provide a backwards-compatability layer for YUI Events.
|
||||
document.addEventListener(eventTypes.filterContentUpdated, e => {
|
||||
// Trigger the legacy jQuery event.
|
||||
jQuery(document).trigger(M.core.event.FILTER_CONTENT_UPDATED, [jQuery(e.detail.nodes)]);
|
||||
|
||||
// Trigger the legacy YUI event.
|
||||
Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: new Y.NodeList(e.detail.nodes)});
|
||||
});
|
||||
});
|
||||
|
||||
legacyEventsRegistered = true;
|
||||
}
|
||||
|
5
lib/amd/build/event.min.js
vendored
5
lib/amd/build/event.min.js
vendored
@ -1,4 +1,4 @@
|
||||
define("core/event",["exports","core_editor/events","core_filters/events","core_form/events","jquery","core/yui"],(function(_exports,_events,_events2,_events3,_jquery,_yui){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}
|
||||
define("core/event",["exports","core_editor/events","core_filters/events","core_form/events"],(function(_exports,_events,_events2,_events3){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;
|
||||
/**
|
||||
* Global registry of core events that can be triggered/listened for.
|
||||
*
|
||||
@ -6,6 +6,7 @@ define("core/event",["exports","core_editor/events","core_filters/events","core_
|
||||
* @copyright 2015 Damyon Wiese <damyon@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since 3.0
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_jquery=_interopRequireDefault(_jquery),_yui=_interopRequireDefault(_yui);const getRenamedLegacyFunction=(oldFunctionName,newModule,newFunctionName,newFunctionRef)=>function(){return window.console.warn("The core/event::".concat(oldFunctionName,"() function has been moved to ").concat(newModule,"::").concat(newFunctionName,". ")+"Please update your code to use the new module."),newFunctionRef(...arguments)};var _default={Events:{FORM_FIELD_VALIDATION:"core_form-field-validation"},getLegacyEvents:()=>{const result=_jquery.default.Deferred();return window.console.warn("The getLegacyEvents function has been deprecated. Please update your code to use native events."),_yui.default.use("event","moodle-core-event",(function(){result.resolve(window.M.core.event)})),result.promise()},notifyEditorContentRestored:getRenamedLegacyFunction("notifyEditorContentRestored","core_editor/events","notifyEditorContentRestored",_events.notifyEditorContentRestored),notifyFilterContentUpdated:getRenamedLegacyFunction("notifyFilterContentUpdated","core_filters/events","notifyFilterContentUpdated",_events2.notifyFilterContentUpdated),notifyFormSubmitAjax:getRenamedLegacyFunction("notifyFormSubmitAjax","core_form/events","notifyFormSubmittedByJavascript",_events3.notifyFormSubmittedByJavascript)};return _exports.default=_default,_exports.default}));
|
||||
*/
|
||||
const getRenamedLegacyFunction=(oldFunctionName,newModule,newFunctionName,newFunctionRef)=>function(){return window.console.warn("The core/event::".concat(oldFunctionName,"() function has been moved to ").concat(newModule,"::").concat(newFunctionName,". ")+"Please update your code to use the new module."),newFunctionRef(...arguments)};var _default={Events:{FORM_FIELD_VALIDATION:"core_form-field-validation"},notifyEditorContentRestored:getRenamedLegacyFunction("notifyEditorContentRestored","core_editor/events","notifyEditorContentRestored",_events.notifyEditorContentRestored),notifyFilterContentUpdated:getRenamedLegacyFunction("notifyFilterContentUpdated","core_filters/events","notifyFilterContentUpdated",_events2.notifyFilterContentUpdated),notifyFormSubmitAjax:getRenamedLegacyFunction("notifyFormSubmitAjax","core_form/events","notifyFormSubmittedByJavascript",_events3.notifyFormSubmittedByJavascript)};return _exports.default=_default,_exports.default}));
|
||||
|
||||
//# sourceMappingURL=event.min.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"event.min.js","sources":["../src/event.js"],"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 * Global registry of core events that can be triggered/listened for.\n *\n * @module core/event\n * @copyright 2015 Damyon Wiese <damyon@moodle.com>\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"],"names":["getRenamedLegacyFunction","oldFunctionName","newModule","newFunctionName","newFunctionRef","window","console","warn","Events","FORM_FIELD_VALIDATION","getLegacyEvents","result","$","Deferred","use","resolve","M","core","event","promise","notifyEditorContentRestored","notifyFilterContentUpdated","notifyFormSubmitAjax","notifyFormSubmittedByJavascript"],"mappings":";;;;;;;;qKAgEMA,yBAA2B,CAACC,gBAAiBC,UAAWC,gBAAiBC,iBAAmB,kBAC9FC,OAAOC,QAAQC,KACX,0BAAmBN,yDAAgDC,uBAAcC,wEAI9EC,2CAGI,CACXI,OAxCW,CACXC,sBAAuB,8BAwCvBC,gBA9BoB,WACdC,OAASC,gBAAEC,kBACjBR,OAAOC,QAAQC,KAAK,gHAElBO,IAAI,QAAS,qBAAqB,WAChCH,OAAOI,QAAQV,OAAOW,EAAEC,KAAKC,UAE1BP,OAAOQ,WAyBdC,4BAA6BpB,yBACzB,8BACA,qBACA,8BACAoB,qCAGJC,2BAA4BrB,yBACxB,6BACA,sBACA,6BACAqB,qCAGJC,qBAAsBtB,yBAClB,uBACA,mBACA,kCACAuB"}
|
||||
{"version":3,"file":"event.min.js","sources":["../src/event.js"],"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 * Global registry of core events that can be triggered/listened for.\n *\n * @module core/event\n * @copyright 2015 Damyon Wiese <damyon@moodle.com>\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 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 * 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 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"],"names":["getRenamedLegacyFunction","oldFunctionName","newModule","newFunctionName","newFunctionRef","window","console","warn","Events","FORM_FIELD_VALIDATION","notifyEditorContentRestored","notifyFilterContentUpdated","notifyFormSubmitAjax","notifyFormSubmittedByJavascript"],"mappings":";;;;;;;;;MA2CMA,yBAA2B,CAACC,gBAAiBC,UAAWC,gBAAiBC,iBAAmB,kBAC9FC,OAAOC,QAAQC,KACX,0BAAmBN,yDAAgDC,uBAAcC,wEAI9EC,2CAGI,CACXI,OAvBW,CACXC,sBAAuB,8BAuBvBC,4BAA6BV,yBACzB,8BACA,qBACA,8BACAU,qCAGJC,2BAA4BX,yBACxB,6BACA,sBACA,6BACAW,qCAGJC,qBAAsBZ,yBAClB,uBACA,mBACA,kCACAa"}
|
@ -26,33 +26,12 @@ import {notifyEditorContentRestored} from 'core_editor/events';
|
||||
import {notifyFilterContentUpdated} from 'core_filters/events';
|
||||
import {notifyFormSubmittedByJavascript} from 'core_form/events';
|
||||
|
||||
// These are only imported for legacy.
|
||||
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"
|
||||
};
|
||||
|
||||
/**
|
||||
* Load the legacy YUI module which defines events in M.core.event and return it.
|
||||
*
|
||||
* @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);
|
||||
});
|
||||
return result.promise();
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a curried function to warn that a function has been moved and renamed
|
||||
*
|
||||
@ -73,8 +52,6 @@ const getRenamedLegacyFunction = (oldFunctionName, newModule, newFunctionName, n
|
||||
|
||||
export default {
|
||||
Events,
|
||||
getLegacyEvents,
|
||||
|
||||
notifyEditorContentRestored: getRenamedLegacyFunction(
|
||||
'notifyEditorContentRestored',
|
||||
'core_editor/events',
|
||||
|
5
lib/editor/amd/build/events.min.js
vendored
5
lib/editor/amd/build/events.min.js
vendored
@ -1,4 +1,4 @@
|
||||
define("core_editor/events",["exports","core/event_dispatcher","jquery","core/yui"],(function(_exports,_event_dispatcher,_jquery,_yui){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}
|
||||
define("core_editor/events",["exports","core/event_dispatcher"],(function(_exports,_event_dispatcher){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.notifyEditorContentRestored=_exports.eventTypes=void 0;
|
||||
/**
|
||||
* Javascript events for the `core_editor` subsystem.
|
||||
*
|
||||
@ -6,6 +6,7 @@ define("core_editor/events",["exports","core/event_dispatcher","jquery","core/yu
|
||||
* @copyright 2021 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since 4.0
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.notifyEditorContentRestored=_exports.eventTypes=void 0,_jquery=_interopRequireDefault(_jquery),_yui=_interopRequireDefault(_yui);const eventTypes={editorContentRestored:"core_editor/contentRestored"};_exports.eventTypes=eventTypes;_exports.notifyEditorContentRestored=editor=>(editor||window.console.warn("The HTMLElement representing the editor that was modified should be provided to notifyEditorContentRestored."),(0,_event_dispatcher.dispatchEvent)(eventTypes.editorContentRestored,{},editor||document));let legacyEventsRegistered=!1;legacyEventsRegistered||(_yui.default.use("event","moodle-core-event",(()=>{document.addEventListener(eventTypes.editorContentRestored,(()=>{(0,_jquery.default)(document).trigger(M.core.event.EDITOR_CONTENT_RESTORED),_yui.default.fire(M.core.event.EDITOR_CONTENT_RESTORED)}))})),legacyEventsRegistered=!0)}));
|
||||
*/
|
||||
const eventTypes={editorContentRestored:"core_editor/contentRestored"};_exports.eventTypes=eventTypes;_exports.notifyEditorContentRestored=editor=>(editor||window.console.warn("The HTMLElement representing the editor that was modified should be provided to notifyEditorContentRestored."),(0,_event_dispatcher.dispatchEvent)(eventTypes.editorContentRestored,{},editor||document))}));
|
||||
|
||||
//# sourceMappingURL=events.min.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"events.min.js","sources":["../src/events.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Javascript events for the `core_editor` subsystem.\n *\n * @module core_editor/events\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\nimport {dispatchEvent} from 'core/event_dispatcher';\nimport jQuery from 'jquery';\nimport Y from 'core/yui';\n\n/**\n * Events for the `core_editor` subsystem.\n *\n * @constant\n * @property {String} editorContentRestored See {@link event:editorContentRestored}\n */\nexport const eventTypes = {\n /**\n * An event triggered when an editor restores auto-saved content.\n *\n * @event editorContentRestored\n */\n editorContentRestored: 'core_editor/contentRestored',\n};\n\n/**\n * Trigger an event to indicate that editor content was restored.\n *\n * @method notifyEditorContentRestored\n * @param {HTMLElement|null} editor The element that was modified\n * @returns {CustomEvent}\n * @fires editorContentRestored\n */\nexport const notifyEditorContentRestored = editor => {\n if (!editor) {\n window.console.warn(\n `The HTMLElement representing the editor that was modified should be provided to notifyEditorContentRestored.`\n );\n }\n return dispatchEvent(\n eventTypes.editorContentRestored,\n {},\n editor || document\n );\n};\n\nlet legacyEventsRegistered = false;\nif (!legacyEventsRegistered) {\n // The following event triggers are legacy and will be removed in the future.\n // The following approach provides a backwards-compatability layer for the new events.\n // Code should be updated to make use of native events.\n\n Y.use('event', 'moodle-core-event', () => {\n // Provide a backwards-compatability layer for YUI Events.\n document.addEventListener(eventTypes.editorContentRestored, () => {\n // Trigger a legacy AMD event.\n jQuery(document).trigger(M.core.event.EDITOR_CONTENT_RESTORED);\n\n // Trigger a legacy YUI event.\n Y.fire(M.core.event.EDITOR_CONTENT_RESTORED);\n });\n });\n\n legacyEventsRegistered = true;\n}\n"],"names":["eventTypes","editorContentRestored","editor","window","console","warn","document","legacyEventsRegistered","use","addEventListener","trigger","M","core","event","EDITOR_CONTENT_RESTORED","fire"],"mappings":";;;;;;;;6MAiCaA,WAAa,CAMtBC,sBAAuB,mGAWgBC,SAClCA,QACDC,OAAOC,QAAQC,sHAIZ,mCACHL,WAAWC,sBACX,GACAC,QAAUI,eAIdC,wBAAyB,EACxBA,sCAKCC,IAAI,QAAS,qBAAqB,KAEhCF,SAASG,iBAAiBT,WAAWC,uBAAuB,yBAEjDK,UAAUI,QAAQC,EAAEC,KAAKC,MAAMC,sCAGpCC,KAAKJ,EAAEC,KAAKC,MAAMC,+BAI5BP,wBAAyB"}
|
||||
{"version":3,"file":"events.min.js","sources":["../src/events.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Javascript events for the `core_editor` subsystem.\n *\n * @module core_editor/events\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\nimport {dispatchEvent} from 'core/event_dispatcher';\n\n/**\n * Events for the `core_editor` subsystem.\n *\n * @constant\n * @property {String} editorContentRestored See {@link event:editorContentRestored}\n */\nexport const eventTypes = {\n /**\n * An event triggered when an editor restores auto-saved content.\n *\n * @event editorContentRestored\n */\n editorContentRestored: 'core_editor/contentRestored',\n};\n\n/**\n * Trigger an event to indicate that editor content was restored.\n *\n * @method notifyEditorContentRestored\n * @param {HTMLElement|null} editor The element that was modified\n * @returns {CustomEvent}\n * @fires editorContentRestored\n */\nexport const notifyEditorContentRestored = editor => {\n if (!editor) {\n window.console.warn(\n `The HTMLElement representing the editor that was modified should be provided to notifyEditorContentRestored.`\n );\n }\n return dispatchEvent(\n eventTypes.editorContentRestored,\n {},\n editor || document\n );\n};\n"],"names":["eventTypes","editorContentRestored","editor","window","console","warn","document"],"mappings":";;;;;;;;;MA+BaA,WAAa,CAMtBC,sBAAuB,mGAWgBC,SAClCA,QACDC,OAAOC,QAAQC,sHAIZ,mCACHL,WAAWC,sBACX,GACAC,QAAUI"}
|
@ -22,8 +22,6 @@
|
||||
*/
|
||||
|
||||
import {dispatchEvent} from 'core/event_dispatcher';
|
||||
import jQuery from 'jquery';
|
||||
import Y from 'core/yui';
|
||||
|
||||
/**
|
||||
* Events for the `core_editor` subsystem.
|
||||
@ -60,23 +58,3 @@ export const notifyEditorContentRestored = editor => {
|
||||
editor || document
|
||||
);
|
||||
};
|
||||
|
||||
let legacyEventsRegistered = false;
|
||||
if (!legacyEventsRegistered) {
|
||||
// The following event triggers are legacy and will be removed in the future.
|
||||
// The following approach provides a backwards-compatability layer for the new events.
|
||||
// Code should be updated to make use of native events.
|
||||
|
||||
Y.use('event', 'moodle-core-event', () => {
|
||||
// Provide a backwards-compatability layer for YUI Events.
|
||||
document.addEventListener(eventTypes.editorContentRestored, () => {
|
||||
// Trigger a legacy AMD event.
|
||||
jQuery(document).trigger(M.core.event.EDITOR_CONTENT_RESTORED);
|
||||
|
||||
// Trigger a legacy YUI event.
|
||||
Y.fire(M.core.event.EDITOR_CONTENT_RESTORED);
|
||||
});
|
||||
});
|
||||
|
||||
legacyEventsRegistered = true;
|
||||
}
|
||||
|
5
lib/form/amd/build/events.min.js
vendored
5
lib/form/amd/build/events.min.js
vendored
@ -1,4 +1,4 @@
|
||||
define("core_form/events",["exports","core/str","core/event_dispatcher","jquery","core/yui"],(function(_exports,_str,_event_dispatcher,_jquery,_yui){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}
|
||||
define("core_form/events",["exports","core/str","core/event_dispatcher"],(function(_exports,_str,_event_dispatcher){
|
||||
/**
|
||||
* Javascript events for the `core_form` subsystem.
|
||||
*
|
||||
@ -14,6 +14,7 @@ define("core_form/events",["exports","core/str","core/event_dispatcher","jquery"
|
||||
* window.console.log(e.target); // The form that was submitted.
|
||||
* window.console.log(e.detail.skipValidation); // Whether form validation was skipped.
|
||||
* });
|
||||
*/let changesMadeString;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.types=_exports.triggerUploadStarted=_exports.triggerUploadCompleted=_exports.notifyUploadStarted=_exports.notifyUploadCompleted=_exports.notifyUploadChanged=_exports.notifyFormSubmittedByJavascript=_exports.notifyFormError=_exports.notifyFieldValidationFailure=_exports.notifyFieldStructureChanged=_exports.eventTypes=void 0,_jquery=_interopRequireDefault(_jquery),_yui=_interopRequireDefault(_yui);const changesMadeCheck=e=>{e&&(e.returnValue=changesMadeString)},eventTypes={formError:"core_form/error",formSubmittedByJavascript:"core_form/submittedByJavascript",formFieldValidationFailed:"core_form/fieldValidationFailed",uploadStarted:"core_form/uploadStarted",uploadCompleted:"core_form/uploadCompleted",uploadChanged:"core_form/uploadChanged",fieldStructureChanged:"core_form/fieldStructureChanged"};_exports.eventTypes=eventTypes;_exports.notifyFormError=field=>(0,_event_dispatcher.dispatchEvent)(eventTypes.formError,{},field);_exports.notifyFormSubmittedByJavascript=function(form){let skipValidation=arguments.length>1&&void 0!==arguments[1]&&arguments[1],fallbackHandled=arguments.length>2&&void 0!==arguments[2]&&arguments[2];skipValidation&&(window.skipClientValidation=!0);const customEvent=(0,_event_dispatcher.dispatchEvent)(eventTypes.formSubmittedByJavascript,{skipValidation:skipValidation,fallbackHandled:fallbackHandled},form);return skipValidation&&(window.skipClientValidation=!1),customEvent};_exports.notifyFieldValidationFailure=(field,message)=>(0,_event_dispatcher.dispatchEvent)(eventTypes.formFieldValidationFailed,{message:message},field,{cancelable:!0});const notifyUploadStarted=async elementId=>(changesMadeString=await(0,_str.getString)("changesmadereallygoaway","moodle"),window.addEventListener("beforeunload",changesMadeCheck),(0,_event_dispatcher.dispatchEvent)(eventTypes.uploadStarted,{},document.getElementById(elementId),{bubbles:!0,cancellable:!1}));_exports.notifyUploadStarted=notifyUploadStarted;const notifyUploadCompleted=elementId=>(window.removeEventListener("beforeunload",changesMadeCheck),(0,_event_dispatcher.dispatchEvent)(eventTypes.uploadCompleted,{},document.getElementById(elementId),{bubbles:!0,cancellable:!1}));_exports.notifyUploadCompleted=notifyUploadCompleted;const triggerUploadStarted=notifyUploadStarted;_exports.triggerUploadStarted=triggerUploadStarted;const triggerUploadCompleted=notifyUploadCompleted;_exports.triggerUploadCompleted=triggerUploadCompleted;_exports.types={uploadStarted:"core_form/uploadStarted",uploadCompleted:"core_form/uploadCompleted"};let legacyEventsRegistered=!1;legacyEventsRegistered||(_yui.default.use("event","moodle-core-event",(()=>{document.addEventListener(eventTypes.formError,(e=>{const element=_yui.default.one(e.target),formElement=_yui.default.one(e.target.closest("form"));_yui.default.Global.fire(M.core.globalEvents.FORM_ERROR,{formid:formElement.generateID(),elementid:element.generateID()})})),document.addEventListener(eventTypes.formSubmittedByJavascript,(e=>{if(e.detail.fallbackHandled)return;e.skipValidation&&(window.skipClientValidation=!0);const form=_yui.default.one(e.target);form.fire(M.core.event.FORM_SUBMIT_AJAX,{currentTarget:form,fallbackHandled:!0}),e.skipValidation&&(window.skipClientValidation=!1)}))})),document.addEventListener(eventTypes.formFieldValidationFailed,(e=>{const legacyEvent=_jquery.default.Event("core_form-field-validation");(0,_jquery.default)(e.target).trigger(legacyEvent,e.detail.message)})),legacyEventsRegistered=!0);_exports.notifyUploadChanged=elementId=>(0,_event_dispatcher.dispatchEvent)(eventTypes.uploadChanged,{},document.getElementById(elementId),{bubbles:!0,cancellable:!1});_exports.notifyFieldStructureChanged=elementId=>(0,_event_dispatcher.dispatchEvent)(eventTypes.fieldStructureChanged,{},document.getElementById(elementId),{bubbles:!0,cancellable:!1})}));
|
||||
*/
|
||||
let changesMadeString;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.types=_exports.triggerUploadStarted=_exports.triggerUploadCompleted=_exports.notifyUploadStarted=_exports.notifyUploadCompleted=_exports.notifyUploadChanged=_exports.notifyFormSubmittedByJavascript=_exports.notifyFormError=_exports.notifyFieldValidationFailure=_exports.notifyFieldStructureChanged=_exports.eventTypes=void 0;const changesMadeCheck=e=>{e&&(e.returnValue=changesMadeString)},eventTypes={formError:"core_form/error",formSubmittedByJavascript:"core_form/submittedByJavascript",formFieldValidationFailed:"core_form/fieldValidationFailed",uploadStarted:"core_form/uploadStarted",uploadCompleted:"core_form/uploadCompleted",uploadChanged:"core_form/uploadChanged",fieldStructureChanged:"core_form/fieldStructureChanged"};_exports.eventTypes=eventTypes;_exports.notifyFormError=field=>(0,_event_dispatcher.dispatchEvent)(eventTypes.formError,{},field);_exports.notifyFormSubmittedByJavascript=function(form){let skipValidation=arguments.length>1&&void 0!==arguments[1]&&arguments[1],fallbackHandled=arguments.length>2&&void 0!==arguments[2]&&arguments[2];skipValidation&&(window.skipClientValidation=!0);const customEvent=(0,_event_dispatcher.dispatchEvent)(eventTypes.formSubmittedByJavascript,{skipValidation:skipValidation,fallbackHandled:fallbackHandled},form);return skipValidation&&(window.skipClientValidation=!1),customEvent};_exports.notifyFieldValidationFailure=(field,message)=>(0,_event_dispatcher.dispatchEvent)(eventTypes.formFieldValidationFailed,{message:message},field,{cancelable:!0});const notifyUploadStarted=async elementId=>(changesMadeString=await(0,_str.getString)("changesmadereallygoaway","moodle"),window.addEventListener("beforeunload",changesMadeCheck),(0,_event_dispatcher.dispatchEvent)(eventTypes.uploadStarted,{},document.getElementById(elementId),{bubbles:!0,cancellable:!1}));_exports.notifyUploadStarted=notifyUploadStarted;const notifyUploadCompleted=elementId=>(window.removeEventListener("beforeunload",changesMadeCheck),(0,_event_dispatcher.dispatchEvent)(eventTypes.uploadCompleted,{},document.getElementById(elementId),{bubbles:!0,cancellable:!1}));_exports.notifyUploadCompleted=notifyUploadCompleted;const triggerUploadStarted=notifyUploadStarted;_exports.triggerUploadStarted=triggerUploadStarted;const triggerUploadCompleted=notifyUploadCompleted;_exports.triggerUploadCompleted=triggerUploadCompleted;_exports.types={uploadStarted:"core_form/uploadStarted",uploadCompleted:"core_form/uploadCompleted"};_exports.notifyUploadChanged=elementId=>(0,_event_dispatcher.dispatchEvent)(eventTypes.uploadChanged,{},document.getElementById(elementId),{bubbles:!0,cancellable:!1});_exports.notifyFieldStructureChanged=elementId=>(0,_event_dispatcher.dispatchEvent)(eventTypes.fieldStructureChanged,{},document.getElementById(elementId),{bubbles:!0,cancellable:!1})}));
|
||||
|
||||
//# sourceMappingURL=events.min.js.map
|
File diff suppressed because one or more lines are too long
@ -125,10 +125,6 @@ export const eventTypes = {
|
||||
fieldStructureChanged: 'core_form/fieldStructureChanged',
|
||||
};
|
||||
|
||||
// These are only imported for legacy.
|
||||
import jQuery from 'jquery';
|
||||
import Y from 'core/yui';
|
||||
|
||||
/**
|
||||
* Trigger an event to indicate that a form field contained an error.
|
||||
*
|
||||
@ -269,67 +265,6 @@ export const types = {
|
||||
uploadCompleted: 'core_form/uploadCompleted',
|
||||
};
|
||||
|
||||
let legacyEventsRegistered = false;
|
||||
if (!legacyEventsRegistered) {
|
||||
// The following event triggers are legacy and will be removed in the future.
|
||||
// The following approach provides a backwards-compatability layer for the new events.
|
||||
// Code should be updated to make use of native events.
|
||||
Y.use('event', 'moodle-core-event', () => {
|
||||
|
||||
// Watch for the new native formError event, and trigger the legacy YUI event.
|
||||
document.addEventListener(eventTypes.formError, e => {
|
||||
const element = Y.one(e.target);
|
||||
const formElement = Y.one(e.target.closest('form'));
|
||||
|
||||
Y.Global.fire(
|
||||
M.core.globalEvents.FORM_ERROR,
|
||||
{
|
||||
formid: formElement.generateID(),
|
||||
elementid: element.generateID(),
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Watch for the new native formSubmittedByJavascript event, and trigger the legacy YUI event.
|
||||
document.addEventListener(eventTypes.formSubmittedByJavascript, e => {
|
||||
if (e.detail.fallbackHandled) {
|
||||
// This event was originally generated by a YUI event.
|
||||
// Do not generate another as this will recurse.
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.skipValidation) {
|
||||
window.skipClientValidation = true;
|
||||
}
|
||||
|
||||
// Trigger the legacy YUI event.
|
||||
const form = Y.one(e.target);
|
||||
form.fire(
|
||||
M.core.event.FORM_SUBMIT_AJAX,
|
||||
{
|
||||
currentTarget: form,
|
||||
fallbackHandled: true,
|
||||
}
|
||||
);
|
||||
|
||||
if (e.skipValidation) {
|
||||
window.skipClientValidation = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Watch for the new native formFieldValidationFailed event, and trigger the legacy jQuery event.
|
||||
document.addEventListener(eventTypes.formFieldValidationFailed, e => {
|
||||
// Note: The "core_form-field-validation" event is hard-coded in core/event.
|
||||
// This is not included to prevent cyclic module dependencies.
|
||||
const legacyEvent = jQuery.Event("core_form-field-validation");
|
||||
|
||||
jQuery(e.target).trigger(legacyEvent, e.detail.message);
|
||||
});
|
||||
|
||||
legacyEventsRegistered = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger an event to notify the file upload field has been changed.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user