1 YUI.add('moodle-core-formchangechecker', function (Y, NAME) {
4 * A utility to check for form changes before navigating away from a page.
6 * @module moodle-core-formchangechecker
10 * A utility to check for form changes before navigating away from a page.
12 * Please note that this YUI module has been deprecated in favour of the core_form/changechecker AMD module.
14 * @class M.core.formchangechecker
19 'The moodle-core-formchangechecker has been deprecated ' +
20 'and replaced with core_form/changechecker. ' +
21 'Please update your code to make use of the new module.'
24 require(['core_form/changechecker'], function(ChangeChecker) {
25 ChangeChecker.startWatching();
28 // The following are provided to prevent race conditions.
29 // Because the AMD module is loaded asynchronously after the YUI module is loaded, there is a possibility that the
30 // calling code may call the YUI function calls before the AMD module has finished loading.
31 // These will be removed in future and are automatically overwritten by the legacy helper provided as part of the new
32 // changechecker AMD module.
33 // eslint-disable-next-line camelcase
34 M.core_formchangechecker = M.core_formchangechecker || {
35 init: function(config) {
36 require(['core_form/changechecker'], function(ChangeChecker) {
37 ChangeChecker.watchFormById(config.formid);
42 * Set the form changed state to true
44 // eslint-disable-next-line camelcase
45 set_form_changed: function() {
46 require(['core_form/changechecker'], function(ChangeChecker) {
47 ChangeChecker.markAllFormsAsDirty();
52 * Set the form submitted state to true
54 // eslint-disable-next-line camelcase
55 set_form_submitted: function() {
56 require(['core_form/changechecker'], function(ChangeChecker) {
57 ChangeChecker.markAllFormsSubmitted();
62 * Reset the form state
64 // eslint-disable-next-line camelcase
65 reset_form_dirty_state: function() {
66 require(['core_form/changechecker'], function(ChangeChecker) {
67 ChangeChecker.resetAllFormDirtyStates();
73 }, '@VERSION@', {"requires": ["base", "event-focus", "moodle-core-event"]});