MDL-70033 course: Update download content event handling for Classic
authorMichael Hawkins <michaelh@moodle.com>
Tue, 27 Oct 2020 10:51:28 +0000 (18:51 +0800)
committerMichael Hawkins <michaelh@moodle.com>
Tue, 3 Nov 2020 03:53:57 +0000 (11:53 +0800)
course/amd/build/downloadcontent.min.js
course/amd/build/downloadcontent.min.js.map
course/amd/src/downloadcontent.js
course/classes/output/content_export_link.php

index 8e99320..901c7c8 100644 (file)
Binary files a/course/amd/build/downloadcontent.min.js and b/course/amd/build/downloadcontent.min.js differ
index 29cc63d..b6c5863 100644 (file)
Binary files a/course/amd/build/downloadcontent.min.js.map and b/course/amd/build/downloadcontent.min.js.map differ
index 67a6d83..2c5899a 100644 (file)
@@ -27,6 +27,7 @@ import CustomEvents from 'core/custom_interaction_events';
 import * as ModalFactory from 'core/modal_factory';
 import jQuery from 'jquery';
 import Pending from 'core/pending';
+import {enter, space} from 'core/key_codes';
 
 /**
  * Set up listener to trigger the download course content modal.
@@ -36,12 +37,11 @@ import Pending from 'core/pending';
 export const init = () => {
     const pendingPromise = new Pending();
 
-    document.addEventListener('click', (e) => {
-        const downloadModalTrigger = e.target.closest('[data-downloadcourse]');
-
-        if (downloadModalTrigger) {
+    // Add event listeners for click and enter/space keys.
+    jQuery('[data-downloadcourse]').on('click keydown', (e) => {
+        if (e.type === 'click' || e.which === enter || e.which === space) {
             e.preventDefault();
-            displayDownloadConfirmation(downloadModalTrigger);
+            displayDownloadConfirmation(e.currentTarget);
         }
     });
 
index 6b3deea..cfa667a 100644 (file)
@@ -53,6 +53,7 @@ class content_export_link {
             'data-download-button-text' => get_string('download'),
             'data-download-link' => $downloadlink->out(false),
             'data-download-title' => get_string('downloadcoursecontent', 'course'),
+            'data-overrides-tree-activation-key-handler' => 1,
         ];
 
         return $downloadattr;