Merge branch 'MDL-72013-master-int' of git://github.com/andrewnicols/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2021-10-21 09:25:58 +02:00
commit 6863a92722
141 changed files with 504 additions and 303 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
{"version":3,"sources":["../../../src/local/repository/dynamic_tabs.js"],"names":["getContent","tab","jsondata","Ajax","call","methodname","args"],"mappings":"qKAuBA,uDASO,GAAMA,CAAAA,CAAU,CAAG,SAACC,CAAD,CAAMC,CAAN,CAAmB,CAMzC,MAAOC,WAAKC,IAAL,CAAU,CALD,CACZC,UAAU,CAAE,+BADA,CAEZC,IAAI,CAAE,CAACL,GAAG,CAAEA,CAAN,CAAWC,QAAQ,CAAEA,CAArB,CAFM,CAKC,CAAV,EAAqB,CAArB,CACV,CAPM,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n* Module to handle dynamic tabs AJAX requests\n*\n* @module core/local/repository/dynamic_tabs\n* @copyright 2021 David Matamoros <davidmc@moodle.com>\n* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n*/\n\nimport Ajax from 'core/ajax';\n\n/**\n* Return tab content\n*\n* @param {String} tab\n* @param {String} jsondata\n* @return {Promise}\n*/\nexport const getContent = (tab, jsondata) => {\n const request = {\n methodname: 'core_dynamic_tabs_get_content',\n args: {tab: tab, jsondata: jsondata}\n };\n\n return Ajax.call([request])[0];\n};\n"],"file":"dynamic_tabs.min.js"}
{"version":3,"sources":["../../../src/local/repository/dynamic_tabs.js"],"names":["getContent","tab","jsondata","Ajax","call","methodname","args"],"mappings":"qKAuBA,uDASO,GAAMA,CAAAA,CAAU,CAAG,SAACC,CAAD,CAAMC,CAAN,CAAmB,CAMzC,MAAOC,WAAKC,IAAL,CAAU,CALD,CACZC,UAAU,CAAE,+BADA,CAEZC,IAAI,CAAE,CAACL,GAAG,CAAEA,CAAN,CAAWC,QAAQ,CAAEA,CAArB,CAFM,CAKC,CAAV,EAAqB,CAArB,CACV,CAPM,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Module to handle dynamic tabs AJAX requests\n *\n * @module core/local/repository/dynamic_tabs\n * @copyright 2021 David Matamoros <davidmc@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\n\n/**\n * Return tab content\n *\n * @param {String} tab\n * @param {String} jsondata\n * @return {Promise}\n */\nexport const getContent = (tab, jsondata) => {\n const request = {\n methodname: 'core_dynamic_tabs_get_content',\n args: {tab: tab, jsondata: jsondata}\n };\n\n return Ajax.call([request])[0];\n};\n"],"file":"dynamic_tabs.min.js"}

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
{"version":3,"sources":["../src/utils.js"],"names":["throttle","func","wait","onCooldown","runAgain","run","args","apply","setTimeout","recurse","debounce","timeout","clearTimeout"],"mappings":"mJAoCwB,QAAXA,CAAAA,QAAW,CAACC,CAAD,CAAOC,CAAP,CAAgB,IAChCC,CAAAA,CAAU,GADsB,CAEhCC,CAAQ,CAAG,IAFqB,CAG9BC,CAAG,CAAG,UAAkB,4BAANC,CAAM,uBAANA,CAAM,iBAC1B,GAAiB,IAAb,GAAAF,CAAJ,CAAuB,CAEnBA,CAAQ,GACX,CAHD,IAGO,CAGHA,CAAQ,GACX,CAED,GAAID,CAAJ,CAAgB,CAEZ,MACH,CAEDF,CAAI,CAACM,KAAL,CAAW,IAAX,CAAiBD,CAAjB,EACAH,CAAU,GAAV,CAEAK,UAAU,CAAC,UAAM,CACb,GAAMC,CAAAA,CAAO,CAAGL,CAAhB,CACAD,CAAU,GAAV,CACAC,CAAQ,CAAG,IAAX,CAEA,GAAIK,CAAJ,CAAa,CACTJ,CAAG,CAACC,CAAD,CACN,CACJ,CARS,CAQPJ,CARO,CASb,CA9BmC,CAgCpC,MAAOG,CAAAA,CACV,C,YAYuB,QAAXK,CAAAA,QAAW,CAACT,CAAD,CAAOC,CAAP,CAAgB,CACpC,GAAIS,CAAAA,CAAO,CAAG,IAAd,CACA,MAAO,WAAkB,mCAANL,CAAM,uBAANA,CAAM,iBACrBM,YAAY,CAACD,CAAD,CAAZ,CACAA,CAAO,CAAGH,UAAU,CAAC,UAAM,CACvBP,CAAI,CAACM,KAAL,CAAW,CAAX,CAAiBD,CAAjB,CACH,CAFmB,CAEjBJ,CAFiB,CAGvB,CACJ,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Utility functions.\n *\n * @module core/utils\n * @copyright 2019 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n /**\n * Create a wrapper function to throttle the execution of the given\n * function to at most once every specified period.\n *\n * If the function is attempted to be executed while it's in cooldown\n * (during the wait period) then it'll immediately execute again as\n * soon as the cooldown is over.\n *\n * @method\n * @param {Function} func The function to throttle\n * @param {Number} wait The number of milliseconds to wait between executions\n * @return {Function}\n */\nexport const throttle = (func, wait) => {\n let onCooldown = false;\n let runAgain = null;\n const run = function(...args) {\n if (runAgain === null) {\n // This is the first time the function has been called.\n runAgain = false;\n } else {\n // This function has been called a second time during the wait period\n // so re-run it once the wait period is over.\n runAgain = true;\n }\n\n if (onCooldown) {\n // Function has already run for this wait period.\n return;\n }\n\n func.apply(this, args);\n onCooldown = true;\n\n setTimeout(() => {\n const recurse = runAgain;\n onCooldown = false;\n runAgain = null;\n\n if (recurse) {\n run(args);\n }\n }, wait);\n };\n\n return run;\n};\n\n/**\n * Create a wrapper function to debounce the execution of the given\n * function. Each attempt to execute the function will reset the cooldown\n * period.\n *\n * @method\n * @param {Function} func The function to debounce\n * @param {Number} wait The number of milliseconds to wait after the final attempt to execute\n * @return {Function}\n */\nexport const debounce = (func, wait) => {\n let timeout = null;\n return function(...args) {\n clearTimeout(timeout);\n timeout = setTimeout(() => {\n func.apply(this, args);\n }, wait);\n };\n};\n"],"file":"utils.min.js"}
{"version":3,"sources":["../src/utils.js"],"names":["throttle","func","wait","onCooldown","runAgain","run","args","apply","setTimeout","recurse","debounce","timeout","clearTimeout"],"mappings":"mJAqCwB,QAAXA,CAAAA,QAAW,CAACC,CAAD,CAAOC,CAAP,CAAgB,IAChCC,CAAAA,CAAU,GADsB,CAEhCC,CAAQ,CAAG,IAFqB,CAG9BC,CAAG,CAAG,UAAkB,4BAANC,CAAM,uBAANA,CAAM,iBAC1B,GAAiB,IAAb,GAAAF,CAAJ,CAAuB,CAEnBA,CAAQ,GACX,CAHD,IAGO,CAGHA,CAAQ,GACX,CAED,GAAID,CAAJ,CAAgB,CAEZ,MACH,CAEDF,CAAI,CAACM,KAAL,CAAW,IAAX,CAAiBD,CAAjB,EACAH,CAAU,GAAV,CAEAK,UAAU,CAAC,UAAM,CACb,GAAMC,CAAAA,CAAO,CAAGL,CAAhB,CACAD,CAAU,GAAV,CACAC,CAAQ,CAAG,IAAX,CAEA,GAAIK,CAAJ,CAAa,CACTJ,CAAG,CAACC,CAAD,CACN,CACJ,CARS,CAQPJ,CARO,CASb,CA9BmC,CAgCpC,MAAOG,CAAAA,CACV,C,YAYuB,QAAXK,CAAAA,QAAW,CAACT,CAAD,CAAOC,CAAP,CAAgB,CACpC,GAAIS,CAAAA,CAAO,CAAG,IAAd,CACA,MAAO,WAAkB,mCAANL,CAAM,uBAANA,CAAM,iBACrBM,YAAY,CAACD,CAAD,CAAZ,CACAA,CAAO,CAAGH,UAAU,CAAC,UAAM,CACvBP,CAAI,CAACM,KAAL,CAAW,CAAX,CAAiBD,CAAjB,CACH,CAFmB,CAEjBJ,CAFiB,CAGvB,CACJ,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Utility functions.\n *\n * @module core/utils\n * @copyright 2019 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n /**\n * Create a wrapper function to throttle the execution of the given\n *\n * function to at most once every specified period.\n *\n * If the function is attempted to be executed while it's in cooldown\n * (during the wait period) then it'll immediately execute again as\n * soon as the cooldown is over.\n *\n * @method\n * @param {Function} func The function to throttle\n * @param {Number} wait The number of milliseconds to wait between executions\n * @return {Function}\n */\nexport const throttle = (func, wait) => {\n let onCooldown = false;\n let runAgain = null;\n const run = function(...args) {\n if (runAgain === null) {\n // This is the first time the function has been called.\n runAgain = false;\n } else {\n // This function has been called a second time during the wait period\n // so re-run it once the wait period is over.\n runAgain = true;\n }\n\n if (onCooldown) {\n // Function has already run for this wait period.\n return;\n }\n\n func.apply(this, args);\n onCooldown = true;\n\n setTimeout(() => {\n const recurse = runAgain;\n onCooldown = false;\n runAgain = null;\n\n if (recurse) {\n run(args);\n }\n }, wait);\n };\n\n return run;\n};\n\n/**\n * Create a wrapper function to debounce the execution of the given\n * function. Each attempt to execute the function will reset the cooldown\n * period.\n *\n * @method\n * @param {Function} func The function to debounce\n * @param {Number} wait The number of milliseconds to wait after the final attempt to execute\n * @return {Function}\n */\nexport const debounce = (func, wait) => {\n let timeout = null;\n return function(...args) {\n clearTimeout(timeout);\n timeout = setTimeout(() => {\n func.apply(this, args);\n }, wait);\n };\n};\n"],"file":"utils.min.js"}

View file

@ -73,7 +73,7 @@ const registerListenerEvents = (pageType, pageLayout, addBlockUrl) => {
* Method that creates the 'add block' modal.
*
* @method buildAddBlockModal
* @return {Promise} The modal promise (modal's body will be rendered later).
* @returns {Promise} The modal promise (modal's body will be rendered later).
*/
const buildAddBlockModal = () => {
return ModalFactory.create({

View file

@ -184,7 +184,6 @@ define([
* Make the config config.
*
* @protected
* @param {module:core/chart_axis} axis The axis.
* @return {Object} The axis config.
*/
Output.prototype._makeConfig = function() {

View file

@ -47,10 +47,10 @@ const reactiveDebuggers = {};
class Debug extends Reactive {
/**
* Set the initial state.
*
* @param {object} stateData the initial state data.
*/
* Set the initial state.
*
* @param {object} stateData the initial state data.
*/
setInitialState(stateData) {
super.setInitialState(stateData);
log.debug(`Debug module "M.reactive" loaded.`);
@ -206,7 +206,7 @@ class DebugInstance {
*
* Quick access to the instance setReadOnly method.
*
* @param {bool} value: the new read only value
* @param {bool} value the new read only value
*/
set readOnly(value) {
this.instance.stateManager.setReadOnly(value);
@ -215,7 +215,7 @@ class DebugInstance {
/**
* Get the read only value
*
* @return {bool}
* @returns {bool}
*/
get readOnly() {
return this.instance.stateManager.readonly;
@ -224,7 +224,7 @@ class DebugInstance {
/**
* Return the current state object.
*
* @return {object}
* @returns {object}
*/
get state() {
return this.instance.state;
@ -246,7 +246,7 @@ class DebugInstance {
/**
* Get the current highligh value.
*
* @return {bool}
* @returns {bool}
*/
get highlight() {
return this.instance._reactiveDebugData.highlighted;
@ -255,7 +255,7 @@ class DebugInstance {
/**
* List all the components registered in this instance.
*
* @return {array}
* @returns {array}
*/
get components() {
return [...this.instance.components];
@ -264,7 +264,7 @@ class DebugInstance {
/**
* List all the state changes evenet pending to dispatch.
*
* @return {array}
* @returns {array}
*/
get changes() {
const result = [];
@ -283,8 +283,7 @@ class DebugInstance {
* goes wrong. However, course editor can directly display a notification.
*
* @method dispatch
* @param {string} actionName the action name (usually the mutation name)
* @param {*} param any number of params the mutation needs.
* @param {*} args
*/
async dispatch(...args) {
this.instance.dispatch(...args);
@ -293,7 +292,7 @@ class DebugInstance {
/**
* Return all the HTML elements registered in the instance components.
*
* @return {array}
* @returns {array}
*/
get elements() {
const result = [];
@ -306,7 +305,7 @@ class DebugInstance {
/**
* Return a plain copy of the state data.
*
* @return {object}
* @returns {object}
*/
get stateData() {
return JSON.parse(JSON.stringify(this.state));

View file

@ -274,7 +274,8 @@ class DebugInstanceSubpanel extends BaseComponent {
/**
* Wtacher method to refresh the log panel.
*
* @param {object} detail of the change
* @param {object} args
* @param {HTMLElement} args.element
*/
_refreshLog({element}) {
const list = element?.lastChanges ?? [];

View file

@ -137,24 +137,24 @@ export default class {
}
/**
* Set the initial state.
*
* @param {object} stateData the initial state data.
*/
* Set the initial state.
*
* @param {object} stateData the initial state data.
*/
setInitialState(stateData) {
this.pendingState.resolve();
this.stateManager.setInitialState(stateData);
}
/**
* Add individual functions to the mutations.
*
* Note new mutations will be added to the existing ones. To replace the full mutation
* object with a new one, use setMutations method.
*
* @method addMutations
* @param {Object} newFunctions an object with new mutation functions.
*/
* Add individual functions to the mutations.
*
* Note new mutations will be added to the existing ones. To replace the full mutation
* object with a new one, use setMutations method.
*
* @method addMutations
* @param {Object} newFunctions an object with new mutation functions.
*/
addMutations(newFunctions) {
// Mutations can provide an init method to do some setup in the statemanager.
if (newFunctions.init !== undefined) {
@ -183,10 +183,10 @@ export default class {
}
/**
* Return the current state.
*
* @return {object}
*/
* Return the current state.
*
* @return {object}
*/
get state() {
return this.stateManager.state;
}
@ -206,42 +206,42 @@ export default class {
}
/**
* Return the initial state promise.
*
* Typically, components do not require to use this promise because registerComponent
* will trigger their stateReady method automatically. But it could be useful for complex
* components that require to combine state, template and string loadings.
*
* @method getState
* @return {Promise}
*/
* Return the initial state promise.
*
* Typically, components do not require to use this promise because registerComponent
* will trigger their stateReady method automatically. But it could be useful for complex
* components that require to combine state, template and string loadings.
*
* @method getState
* @return {Promise}
*/
getInitialStatePromise() {
return this.stateManager.getInitialPromise();
}
/**
* Register a new component.
*
* Component can provide some optional functions to the reactive module:
* - getWatchers: returns an array of watchers
* - stateReady: a method to call when the initial state is loaded
*
* It can also provide some optional attributes:
* - name: the component name (default value: "Unkown component") to customize debug messages.
*
* The method will also use dispatchRegistrationSuccess and dispatchRegistrationFail. Those
* are BaseComponent methods to inform parent components of the registration status.
* Components should not override those methods.
*
* @method registerComponent
* @param {object} component the new component
* @property {string} [component.name] the component name to display in warnings and errors.
* @property {Function} [component.dispatchRegistrationSuccess] method to notify registration success
* @property {Function} [component.dispatchRegistrationFail] method to notify registration fail
* @property {Function} [component.getWatchers] getter of the component watchers
* @property {Function} [component.stateReady] method to call when the state is ready
* @return {object} the registered component
*/
* Register a new component.
*
* Component can provide some optional functions to the reactive module:
* - getWatchers: returns an array of watchers
* - stateReady: a method to call when the initial state is loaded
*
* It can also provide some optional attributes:
* - name: the component name (default value: "Unkown component") to customize debug messages.
*
* The method will also use dispatchRegistrationSuccess and dispatchRegistrationFail. Those
* are BaseComponent methods to inform parent components of the registration status.
* Components should not override those methods.
*
* @method registerComponent
* @param {object} component the new component
* @param {string} [component.name] the component name to display in warnings and errors.
* @param {Function} [component.dispatchRegistrationSuccess] method to notify registration success
* @param {Function} [component.dispatchRegistrationFail] method to notify registration fail
* @param {Function} [component.getWatchers] getter of the component watchers
* @param {Function} [component.stateReady] method to call when the state is ready
* @return {object} the registered component
*/
registerComponent(component) {
// Component name is an optional attribute to customize debug messages.
@ -360,16 +360,16 @@ export default class {
}
/**
* Dispatch a change in the state.
*
* This method is the only way for components to alter the state. Watchers will receive a
* read only state to prevent illegal changes. If some user action require a state change, the
* component should dispatch a mutation to trigger all the necessary logic to alter the state.
*
* @method dispatch
* @param {string} actionName the action name (usually the mutation name)
* @param {*} param any number of params the mutation needs.
*/
* Dispatch a change in the state.
*
* This method is the only way for components to alter the state. Watchers will receive a
* read only state to prevent illegal changes. If some user action require a state change, the
* component should dispatch a mutation to trigger all the necessary logic to alter the state.
*
* @method dispatch
* @param {string} actionName the action name (usually the mutation name)
* @param {mixed} params any number of params the mutation needs.
*/
async dispatch(actionName, ...params) {
if (typeof actionName !== 'string') {
throw new Error(`Dispatch action name must be a string`);

View file

@ -14,22 +14,22 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Module to handle dynamic tabs AJAX requests
*
* @module core/local/repository/dynamic_tabs
* @copyright 2021 David Matamoros <davidmc@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* Module to handle dynamic tabs AJAX requests
*
* @module core/local/repository/dynamic_tabs
* @copyright 2021 David Matamoros <davidmc@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import Ajax from 'core/ajax';
/**
* Return tab content
*
* @param {String} tab
* @param {String} jsondata
* @return {Promise}
*/
* Return tab content
*
* @param {String} tab
* @param {String} jsondata
* @return {Promise}
*/
export const getContent = (tab, jsondata) => {
const request = {
methodname: 'core_dynamic_tabs_get_content',

View file

@ -123,7 +123,8 @@ function($, log, autoScroll, str, ModalFactory, ModalEvents, Notification) {
* Allow to create non-passive touchstart listeners and prevent page scrolling when dragging
* From: https://stackoverflow.com/a/48098097
*
* @type {Object}
* @param {string} eventname
* @returns {object}
*/
var registerNotPassiveListeners = function(eventname) {
return {
@ -149,13 +150,13 @@ function($, log, autoScroll, str, ModalFactory, ModalEvents, Notification) {
*
* @param {(String|jQuery|Element)} root JQuery/DOM element representing sortable list (i.e. <ul>, <tbody>) or CSS selector
* @param {Object} config Parameters for the list. See defaultParameters above for examples.
* @property {(String|jQuery|Element)} config.targetListSelector target lists, by default same as root
* @property {String} config.moveHandlerSelector CSS selector for a drag handle. By default '[data-drag-type=move]'
* @property {String} config.targetListSelector CSS selector for target lists. By default the same as root
* @property {(Boolean|Function)} config.isHorizontal Set to true if the list is horizontal
* (can also be a callback with list as an argument)
* @property {Boolean} config.autoScroll Engages autoscroll module for automatic vertical scrolling of the
* whole page, by default true
* @param {(String|jQuery|Element)} config.targetListSelector target lists, by default same as root
* @param {String} config.moveHandlerSelector CSS selector for a drag handle. By default '[data-drag-type=move]'
* @param {String} config.listSelector CSS selector for target lists. By default the same as root
* @param {(Boolean|Function)} config.isHorizontal Set to true if the list is horizontal (can also be a callback
* with list as an argument)
* @param {Boolean} config.autoScroll Engages autoscroll module for automatic vertical scrolling of the whole page,
* by default true
*/
var SortableList = function(root, config) {

View file

@ -22,18 +22,19 @@
*/
/**
* Create a wrapper function to throttle the execution of the given
* function to at most once every specified period.
*
* If the function is attempted to be executed while it's in cooldown
* (during the wait period) then it'll immediately execute again as
* soon as the cooldown is over.
*
* @method
* @param {Function} func The function to throttle
* @param {Number} wait The number of milliseconds to wait between executions
* @return {Function}
*/
* Create a wrapper function to throttle the execution of the given
*
* function to at most once every specified period.
*
* If the function is attempted to be executed while it's in cooldown
* (during the wait period) then it'll immediately execute again as
* soon as the cooldown is over.
*
* @method
* @param {Function} func The function to throttle
* @param {Number} wait The number of milliseconds to wait between executions
* @return {Function}
*/
export const throttle = (func, wait) => {
let onCooldown = false;
let runAgain = null;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -16,7 +16,13 @@
/**
* Display an embedded form, it is only loaded and reloaded inside its container
*
* Example:
*
* @module core_form/dynamicform
* @copyright 2019 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* See also https://docs.moodle.org/dev/Modal_and_AJAX_forms
*
* @example
* import DynamicForm from 'core_form/dynamicform';
*
* const dynamicForm = new DynamicForm(document.querySelector('#mycontainer', 'pluginname\\form\\formname');
@ -27,11 +33,6 @@
* });
* dynamicForm.load();
*
* See also https://docs.moodle.org/dev/Modal_and_AJAX_forms
*
* @module core_form/dynamicform
* @copyright 2019 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import * as FormChangeChecker from 'core_form/changechecker';
@ -160,7 +161,8 @@ export default class DynamicForm {
/**
* Add listener for an event
*
* Example:
* @param {array} args
* @example:
* const dynamicForm = new DynamicForm(...);
* dynamicForm.addEventListener(dynamicForm.events.FORM_SUBMITTED, e => {
* e.preventDefault();
@ -285,8 +287,9 @@ export default class DynamicForm {
/**
* Update form contents
*
* @param {string} html
* @param {string} js
* @param {object} param
* @param {string} param.html
* @param {string} param.js
* @returns {Promise}
*/
updateForm({html, js}) {

View file

@ -87,13 +87,13 @@ export default class ModalForm {
* Shows the required form inside a modal dialogue
*
* @param {Object} config parameters for the form and modal dialogue:
* @property {String} config.formClass PHP class name that handles the form (should extend \core_form\modal )
* @property {Object} config.modalConfig modal config - title, type, etc.
* @paramy {String} config.formClass PHP class name that handles the form (should extend \core_form\modal )
* @paramy {Object} config.modalConfig modal config - title, type, etc.
* Default: {removeOnClose: true, type: ModalFactory.types.SAVE_CANCEL}
* @property {Object} config.args Arguments for the initial form rendering (for example, id of the edited entity)
* @property {String} config.saveButtonText the text to display on the Modal "Save" button (optional)
* @property {String} config.saveButtonClasses additional CSS classes for the Modal "Save" button
* @property {HTMLElement} config.returnFocus element to return focus to after the dialogue is closed
* @paramy {Object} config.args Arguments for the initial form rendering (for example, id of the edited entity)
* @paramy {String} config.saveButtonText the text to display on the Modal "Save" button (optional)
* @paramy {String} config.saveButtonClasses additional CSS classes for the Modal "Save" button
* @paramy {HTMLElement} config.returnFocus element to return focus to after the dialogue is closed
*/
constructor(config) {
this.modal = null;
@ -207,7 +207,8 @@ export default class ModalForm {
/**
* Add listener for an event
*
* Example:
* @param {array} args
* @example:
* const modalForm = new ModalForm(...);
* dynamicForm.addEventListener(modalForm.events.FORM_SUBMITTED, e => {
* window.console.log(e.detail);