mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-78006 course: register activity chooser listeners just once.
This commit is contained in:
parent
4e632b7251
commit
97f5badba5
2
course/amd/build/activitychooser.min.js
vendored
2
course/amd/build/activitychooser.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -44,6 +44,8 @@ const ACTIVITIESRESOURCESREC = 5;
|
||||
const ACTIVITY = 0;
|
||||
const RESOURCE = 1;
|
||||
|
||||
let initialized = false;
|
||||
|
||||
/**
|
||||
* Set up the activity chooser.
|
||||
*
|
||||
@ -67,6 +69,12 @@ export const init = (courseId, chooserConfig) => {
|
||||
* @param {Object} chooserConfig Any PHP config settings that we may need to reference
|
||||
*/
|
||||
const registerListenerEvents = (courseId, chooserConfig) => {
|
||||
|
||||
// Ensure we only add our listeners once.
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
const events = [
|
||||
'click',
|
||||
CustomEvents.events.activate,
|
||||
@ -170,6 +178,8 @@ const registerListenerEvents = (courseId, chooserConfig) => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
initialized = true;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user