Skip to content

Commit

Permalink
MDL-70990 core_form: Standardise event name usage
Browse files Browse the repository at this point in the history
The `types` object introduced in Moodle 3.11 has been replaced with the
`eventTypes` object which is used consistently across all CustomEvent
definitinos.

Likewise the trigger functions have been renamed from
`triggerUploadStarted` to `notifyUploadStarted` and from
`triggerUploadCompleted` to `notifyUploadCompleted`.

Backwards compatability is maintained.
  • Loading branch information
andrewnicols committed May 26, 2021
1 parent 919db49 commit a1ccefe
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 67 deletions.
12 changes: 6 additions & 6 deletions course/dndupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ M.course_dndupload = {
this.originalUnloadEvent = window.onbeforeunload;
// Trigger form upload start events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadStarted(section.get('id'));
FormEvent.notifyUploadStarted(section.get('id'));
});
}
if (xhr.readyState == 4) {
Expand Down Expand Up @@ -796,7 +796,7 @@ M.course_dndupload = {
}
// Trigger form upload complete events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(section.get('id'));
FormEvent.notifyUploadCompleted(section.get('id'));
});
}
};
Expand Down Expand Up @@ -1031,7 +1031,7 @@ M.course_dndupload = {
this.originalUnloadEvent = window.onbeforeunload;
// Trigger form upload start events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadStarted(section.get('id'));
FormEvent.notifyUploadStarted(section.get('id'));
});
}
if (xhr.readyState == 4) {
Expand All @@ -1052,21 +1052,21 @@ M.course_dndupload = {
resel.parent.removeChild(resel.li);
// Trigger form upload complete events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(section.get('id'));
FormEvent.notifyUploadCompleted(section.get('id'));
});
new M.core.alert({message: result.error});
}
}
} else {
// Trigger form upload complete events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(section.get('id'));
FormEvent.notifyUploadCompleted(section.get('id'));
});
new M.core.alert({message: M.util.get_string('servererror', 'moodle')});
}
// Trigger form upload complete events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(section.get('id'));
FormEvent.notifyUploadCompleted(section.get('id'));
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi

// Trigger form upload start events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadStarted(self.editor.get('id'));
FormEvent.notifyUploadStarted(self.editor.get('id'));
});

var options = host.get('filepickeroptions').image,
Expand Down Expand Up @@ -419,7 +419,7 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
}
// Trigger form upload complete events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(self.editor.get('id'));
FormEvent.notifyUploadCompleted(self.editor.get('id'));
});
throw new M.core.ajaxException(result);
}
Expand Down Expand Up @@ -450,7 +450,7 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
Y.use('moodle-core-notification-alert', function() {
// Trigger form upload complete events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(self.editor.get('id'));
FormEvent.notifyUploadCompleted(self.editor.get('id'));
});
new M.core.alert({message: M.util.get_string('servererror', 'moodle')});
});
Expand All @@ -460,7 +460,7 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
}
// Trigger form upload complete events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(self.editor.get('id'));
FormEvent.notifyUploadCompleted(self.editor.get('id'));
});
}
};
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi

// Trigger form upload start events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadStarted(self.editor.get('id'));
FormEvent.notifyUploadStarted(self.editor.get('id'));
});

var options = host.get('filepickeroptions').image,
Expand Down Expand Up @@ -419,7 +419,7 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
}
// Trigger form upload complete events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(self.editor.get('id'));
FormEvent.notifyUploadCompleted(self.editor.get('id'));
});
throw new M.core.ajaxException(result);
}
Expand Down Expand Up @@ -450,7 +450,7 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
Y.use('moodle-core-notification-alert', function() {
// Trigger form upload complete events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(self.editor.get('id'));
FormEvent.notifyUploadCompleted(self.editor.get('id'));
});
new M.core.alert({message: M.util.get_string('servererror', 'moodle')});
});
Expand All @@ -460,7 +460,7 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
}
// Trigger form upload complete events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(self.editor.get('id'));
FormEvent.notifyUploadCompleted(self.editor.get('id'));
});
}
};
Expand Down
8 changes: 4 additions & 4 deletions lib/editor/atto/plugins/image/yui/src/button/js/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi

// Trigger form upload start events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadStarted(self.editor.get('id'));
FormEvent.notifyUploadStarted(self.editor.get('id'));
});

var options = host.get('filepickeroptions').image,
Expand Down Expand Up @@ -417,7 +417,7 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
}
// Trigger form upload complete events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(self.editor.get('id'));
FormEvent.notifyUploadCompleted(self.editor.get('id'));
});
throw new M.core.ajaxException(result);
}
Expand Down Expand Up @@ -448,7 +448,7 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
Y.use('moodle-core-notification-alert', function() {
// Trigger form upload complete events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(self.editor.get('id'));
FormEvent.notifyUploadCompleted(self.editor.get('id'));
});
new M.core.alert({message: M.util.get_string('servererror', 'moodle')});
});
Expand All @@ -458,7 +458,7 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
}
// Trigger form upload complete events.
require(['core_form/events'], function(FormEvent) {
FormEvent.triggerUploadCompleted(self.editor.get('id'));
FormEvent.notifyUploadCompleted(self.editor.get('id'));
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion lib/form/amd/build/events.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a1ccefe

Please sign in to comment.