Merge branch 'MDL-70033-310-2' of git://github.com/mickhawkins/moodle into MOODLE_310_STABLE

This commit is contained in:
Jun Pataleta
2020-11-03 12:01:33 +08:00
7 changed files with 43 additions and 40 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core_course/downloadcontent",["exports","core/config","core/custom_interaction_events","core/modal_factory","jquery","core/pending"],function(a,b,c,d,e,f){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=i(b);c=i(c);d=h(d);e=i(e);f=i(f);function g(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;g=function(){return a};return a}function h(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=g();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function i(a){return a&&a.__esModule?a:{default:a}}var j=function(){var a=new f.default;document.addEventListener("click",function(a){var b=a.target.closest("[data-downloadcourse]");if(b){a.preventDefault();k(b)}});a.resolve()};a.init=j;var k=function(a){d.create({title:a.dataset.downloadTitle,type:d.types.SAVE_CANCEL,body:"<p>".concat(a.dataset.downloadBody,"</p>"),buttons:{save:a.dataset.downloadButtonText},templateContext:{classes:"downloadcoursecontentmodal"}}).then(function(b){b.show();var d=document.querySelector(".modal .downloadcoursecontentmodal [data-action=\"save\"]"),f=document.querySelector(".modal .downloadcoursecontentmodal [data-action=\"cancel\"]"),g=document.querySelector(".modal[data-region=\"modal-container\"]");(0,e.default)(d).on(c.default.events.activate,function(c){return l(c,a,b)});(0,e.default)(f).on(c.default.events.activate,function(){b.destroy()});if(g.querySelector(".downloadcoursecontentmodal")){(0,e.default)(g).on(c.default.events.activate,function(){b.destroy()})}})},l=function(a,c,d){a.preventDefault();var e=document.createElement("form");e.action=c.dataset.downloadLink;e.method="POST";e.target="_blank";var f=document.createElement("input");f.name="sesskey";f.value=b.default.sesskey;e.appendChild(f);e.style.display="none";document.body.appendChild(e);e.submit();document.body.removeChild(e);d.destroy()}});
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core_course/downloadcontent",["exports","core/config","core/custom_interaction_events","core/modal_factory","jquery","core/pending","core/key_codes"],function(a,b,c,d,e,f,g){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=j(b);c=j(c);d=i(d);e=j(e);f=j(f);function h(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;h=function(){return a};return a}function i(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=h();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function j(a){return a&&a.__esModule?a:{default:a}}var k=function(){var a=new f.default;(0,e.default)("[data-downloadcourse]").on("click keydown",function(a){if("click"===a.type||a.which===g.enter||a.which===g.space){a.preventDefault();l(a.currentTarget)}});a.resolve()};a.init=k;var l=function(a){d.create({title:a.dataset.downloadTitle,type:d.types.SAVE_CANCEL,body:"<p>".concat(a.dataset.downloadBody,"</p>"),buttons:{save:a.dataset.downloadButtonText},templateContext:{classes:"downloadcoursecontentmodal"}}).then(function(b){b.show();var d=document.querySelector(".modal .downloadcoursecontentmodal [data-action=\"save\"]"),f=document.querySelector(".modal .downloadcoursecontentmodal [data-action=\"cancel\"]"),g=document.querySelector(".modal[data-region=\"modal-container\"]");(0,e.default)(d).on(c.default.events.activate,function(c){return m(c,a,b)});(0,e.default)(f).on(c.default.events.activate,function(){b.destroy()});if(g.querySelector(".downloadcoursecontentmodal")){(0,e.default)(g).on(c.default.events.activate,function(){b.destroy()})}})},m=function(a,c,d){a.preventDefault();var e=document.createElement("form");e.action=c.dataset.downloadLink;e.method="POST";e.target="_blank";var f=document.createElement("input");f.name="sesskey";f.value=b.default.sesskey;e.appendChild(f);e.style.display="none";document.body.appendChild(e);e.submit();document.body.removeChild(e);d.destroy()}});
//# sourceMappingURL=downloadcontent.min.js.map
File diff suppressed because one or more lines are too long
+5 -5
View 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);
}
});
@@ -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;
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+33 -31
View File
@@ -351,7 +351,6 @@ define(['jquery'], function($) {
* @method handleKeyDown
* @param {Object} item is the jquery id of the parent item of the group.
* @param {Event} e The event.
* @return {Boolean}
*/
// This function should be simplified. In the meantime..
// eslint-disable-next-line complexity
@@ -360,7 +359,7 @@ define(['jquery'], function($) {
if ((e.altKey || e.ctrlKey || e.metaKey) || (e.shiftKey && e.keyCode != this.keys.tab)) {
// Do nothing.
return true;
return;
}
switch (e.keyCode) {
@@ -368,21 +367,24 @@ define(['jquery'], function($) {
// Jump to first item in tree.
this.getVisibleItems().first().focus();
e.stopPropagation();
return false;
e.preventDefault();
return;
}
case this.keys.end: {
// Jump to last visible item.
this.getVisibleItems().last().focus();
e.stopPropagation();
return false;
e.preventDefault();
return;
}
case this.keys.enter: {
var links = item.children('a').length ? item.children('a') : item.children().not(SELECTORS.GROUP).find('a');
if (links.length) {
// See if we have a callback.
if (typeof this.enterCallback === 'function') {
if (links.first().data('overrides-tree-activation-key-handler')) {
// If the link overrides handling of activation keys, let it do so.
links.first().triggerHandler(e);
} else if (typeof this.enterCallback === 'function') {
// Use callback if there is one.
this.enterCallback(item);
} else {
window.location.href = links.first().attr('href');
@@ -391,16 +393,22 @@ define(['jquery'], function($) {
this.toggleGroup(item, true);
}
e.stopPropagation();
return false;
e.preventDefault();
return;
}
case this.keys.space: {
if (this.isGroupItem(item)) {
this.toggleGroup(item, true);
} else if (item.children('a').length) {
var firstLink = item.children('a').first();
if (firstLink.data('overrides-tree-activation-key-handler')) {
firstLink.triggerHandler(e);
}
}
e.stopPropagation();
return false;
e.preventDefault();
return;
}
case this.keys.left: {
var focusParent = function(tree) {
@@ -422,8 +430,8 @@ define(['jquery'], function($) {
focusParent(this);
}
e.stopPropagation();
return false;
e.preventDefault();
return;
}
case this.keys.right: {
// If this is a group item then expand it and focus the first child item
@@ -437,8 +445,8 @@ define(['jquery'], function($) {
}
}
e.stopPropagation();
return false;
e.preventDefault();
return;
}
case this.keys.up: {
@@ -448,8 +456,8 @@ define(['jquery'], function($) {
prev.focus();
}
e.stopPropagation();
return false;
e.preventDefault();
return;
}
case this.keys.down: {
@@ -459,17 +467,16 @@ define(['jquery'], function($) {
next.focus();
}
e.stopPropagation();
return false;
e.preventDefault();
return;
}
case this.keys.asterisk: {
// Expand all groups.
this.expandAllGroups();
e.stopPropagation();
return false;
e.preventDefault();
return;
}
}
return true;
};
/**
@@ -478,7 +485,6 @@ define(['jquery'], function($) {
* @method handleClick
* @param {Object} item The jquery id of the parent item of the group.
* @param {Event} e The event.
* @return {Boolean}
*/
Tree.prototype.handleClick = function(item, e) {
@@ -502,14 +508,10 @@ define(['jquery'], function($) {
* @method handleFocus
* @param {Object} item The jquery id of the parent item of the group.
* @param {Event} e The event.
* @return {Boolean}
*/
Tree.prototype.handleFocus = function(item, e) {
Tree.prototype.handleFocus = function(item) {
this.setActiveItem(item);
e.stopPropagation();
return true;
};
/**
@@ -529,8 +531,8 @@ define(['jquery'], function($) {
keydown: function(e) {
return thisObj.handleKeyDown($(this), e);
},
focus: function(e) {
return thisObj.handleFocus($(this), e);
focus: function() {
return thisObj.handleFocus($(this));
},
}, SELECTORS.ITEM);
};