Merge branch 'MDL-84324-main' of https://github.com/roland04/moodle

This commit is contained in:
Jun Pataleta 2025-02-26 07:13:31 +08:00
commit 5461afb6f4
No known key found for this signature in database
GPG key ID: F83510526D99E2C7
12 changed files with 47 additions and 27 deletions

View file

@ -11,6 +11,6 @@ define("core/first",["jquery"],(function(_jquery){var obj;
* @copyright 2015 Damyon Wiese <damyon@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 2.9
*/(0,(_jquery=(obj=_jquery)&&obj.__esModule?obj:{default:obj}).default)(document).bind("ajaxStart",(function(){M.util.js_pending("jq")})).bind("ajaxStop",(function(){M.util.js_complete("jq")}))}));
*/(0,(_jquery=(obj=_jquery)&&obj.__esModule?obj:{default:obj}).default)(document).bind("ajaxStart",(function(){M.util.js_pending("jq")})).bind("ajaxStop",(function(){M.util.js_complete("jq")})),window.jQuery=_jquery.default}));
//# sourceMappingURL=first.min.js.map

View file

@ -1 +1 @@
{"version":3,"file":"first.min.js","sources":["../src/first.js"],"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 * This is an empty module, that is required before all other modules.\n * Because every module is returned from a request for any other module, this\n * forces the loading of all modules with a single request.\n *\n * This function also sets up the listeners for ajax requests so we can tell\n * if any requests are still in progress.\n *\n * @module core/first\n * @copyright 2015 Damyon Wiese <damyon@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 2.9\n */\n\nimport $ from 'jquery';\n\n$(document)\n.bind(\"ajaxStart\", function() {\n M.util.js_pending('jq');\n})\n.bind(\"ajaxStop\", function() {\n M.util.js_complete('jq');\n});\n"],"names":["document","bind","M","util","js_pending","js_complete"],"mappings":";;;;;;;;;;;;;2EA+BEA,UACDC,KAAK,aAAa,WACfC,EAAEC,KAAKC,WAAW,SAErBH,KAAK,YAAY,WACdC,EAAEC,KAAKE,YAAY"}
{"version":3,"file":"first.min.js","sources":["../src/first.js"],"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 * This is an empty module, that is required before all other modules.\n * Because every module is returned from a request for any other module, this\n * forces the loading of all modules with a single request.\n *\n * This function also sets up the listeners for ajax requests so we can tell\n * if any requests are still in progress.\n *\n * @module core/first\n * @copyright 2015 Damyon Wiese <damyon@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 2.9\n */\n\nimport $ from 'jquery';\n\n$(document)\n.bind(\"ajaxStart\", function() {\n M.util.js_pending('jq');\n})\n.bind(\"ajaxStop\", function() {\n M.util.js_complete('jq');\n});\n\n// TODO: MDL-84465 Final deprecation in 6.0.\n// Attach jQuery to the window object for Bootstrap backwards compatibility.\n// Bootstrap 5 is designed to be used without jQuery, but its still possible to use our components with jQuery.\n// If Bootstrap detects jQuery in the window object itll add all of our components in jQuerys plugin system.\nwindow.jQuery = $;\n"],"names":["document","bind","M","util","js_pending","js_complete","window","jQuery","$"],"mappings":";;;;;;;;;;;;;2EA+BEA,UACDC,KAAK,aAAa,WACfC,EAAEC,KAAKC,WAAW,SAErBH,KAAK,YAAY,WACdC,EAAEC,KAAKE,YAAY,SAOvBC,OAAOC,OAASC"}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -36,3 +36,9 @@ $(document)
.bind("ajaxStop", function() {
M.util.js_complete('jq');
});
// TODO: MDL-84465 Final deprecation in 6.0.
// Attach jQuery to the window object for Bootstrap backwards compatibility.
// Bootstrap 5 is designed to be used without jQuery, but its still possible to use our components with jQuery.
// If Bootstrap detects jQuery in the window object itll add all of our components in jQuerys plugin system.
window.jQuery = $;

View file

@ -31,6 +31,7 @@ define([
'core/aria',
'core_form/changechecker',
'core/popper2',
'theme_boost/bootstrap/dom/event-handler',
], function(
$,
log,
@ -40,7 +41,8 @@ define([
LoadingIcon,
Aria,
FormChangeChecker,
Popper
Popper,
EventHandler,
) {
// Private functions and variables.
/** @var {Object} KEYS - List of keycode constants. */
@ -1083,6 +1085,16 @@ define([
});
}
}
// Add a Bootstrap keydown handler to close the suggestions list preventing the whole Dropdown close.
EventHandler.on(document, 'keydown.bs.dropdown.data-api', '.dropdown-menu', (event) => {
const pendingPromise = addPendingJSPromise('addNavigation-' + state.inputId + '-' + event.key);
if (event.key === "Escape" && inputElement.attr('aria-expanded') === "true") {
event.stopImmediatePropagation();
return pendingPromise.resolve(closeSuggestions(state));
}
return pendingPromise.resolve();
});
};
/**

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,4 +1,4 @@
define("theme_boost/loader",["exports","./aria","./index","core/pending","./bootstrap/util/sanitizer","./pending"],(function(_exports,Aria,Bootstrap,_pending,_sanitizer,_pending2){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}
define("theme_boost/loader",["exports","./aria","./index","core/pending","./bootstrap/util/sanitizer","./pending","./bootstrap/dom/event-handler"],(function(_exports,Aria,Bootstrap,_pending,_sanitizer,_pending2,_eventHandler){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}
/**
* Template renderer for Moodle. Load and render Moodle templates with Mustache.
*
@ -6,6 +6,6 @@ define("theme_boost/loader",["exports","./aria","./index","core/pending","./boot
* @copyright 2015 Damyon Wiese <damyon@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 2.9
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.Bootstrap=void 0,Aria=_interopRequireWildcard(Aria),Bootstrap=_interopRequireWildcard(Bootstrap),_exports.Bootstrap=Bootstrap,_pending=_interopRequireDefault(_pending),_pending2=_interopRequireDefault(_pending2);const pendingPromise=new _pending.default("theme_boost/loader:init");(0,_pending2.default)(),Aria.init(),(()=>{[...document.querySelectorAll('a[data-bs-toggle="tab"]')].map((tabTriggerEl=>tabTriggerEl.addEventListener("shown.bs.tab",(e=>{var hash=e.target.getAttribute("href");history.replaceState?history.replaceState(null,null,hash):location.hash=hash}))));const hash=window.location.hash;if(hash){const tab=document.querySelector('[role="tablist"] [href="'+hash+'"]');tab&&tab.click()}})(),(()=>{const popoverTriggerList=document.querySelectorAll('[data-bs-toggle="popover"]'),popoverConfig={container:"body",trigger:"focus",allowList:Object.assign(_sanitizer.DefaultAllowlist,{table:[],thead:[],tbody:[],tr:[],th:[],td:[]})};[...popoverTriggerList].map((popoverTriggerEl=>new Bootstrap.Popover(popoverTriggerEl,popoverConfig))),document.addEventListener("core/modal:bodyRendered",(e=>{[...e.target.querySelectorAll('[data-bs-toggle="popover"]')].map((popoverTriggerEl=>new Bootstrap.Popover(popoverTriggerEl,popoverConfig)))})),document.addEventListener("keydown",(e=>{const popoverTrigger=e.target.closest('[data-bs-toggle="popover"]');"Escape"===e.key&&popoverTrigger&&Bootstrap.Popover.getInstance(popoverTrigger).hide(),"Enter"===e.key&&popoverTrigger&&Bootstrap.Popover.getInstance(popoverTrigger).show()})),document.addEventListener("click",(e=>{const popoverTrigger=e.target.closest('[data-bs-toggle="popover"]');if(!popoverTrigger)return;const popover=Bootstrap.Popover.getInstance(popoverTrigger);popover._isShown()||popover.show()}))})(),[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map((tooltipTriggerEl=>new Bootstrap.Tooltip(tooltipTriggerEl))),pendingPromise.resolve()}));
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.Bootstrap=void 0,Aria=_interopRequireWildcard(Aria),Bootstrap=_interopRequireWildcard(Bootstrap),_exports.Bootstrap=Bootstrap,_pending=_interopRequireDefault(_pending),_pending2=_interopRequireDefault(_pending2),_eventHandler=_interopRequireDefault(_eventHandler);const pendingPromise=new _pending.default("theme_boost/loader:init");(0,_pending2.default)(),Aria.init(),(()=>{[...document.querySelectorAll('a[data-bs-toggle="tab"]')].map((tabTriggerEl=>tabTriggerEl.addEventListener("shown.bs.tab",(e=>{var hash=e.target.getAttribute("href");history.replaceState?history.replaceState(null,null,hash):location.hash=hash}))));const hash=window.location.hash;if(hash){const tab=document.querySelector('[role="tablist"] [href="'+hash+'"]');tab&&tab.click()}})(),(()=>{const popoverTriggerList=document.querySelectorAll('[data-bs-toggle="popover"]'),popoverConfig={container:"body",trigger:"focus",allowList:Object.assign(_sanitizer.DefaultAllowlist,{table:[],thead:[],tbody:[],tr:[],th:[],td:[]})};[...popoverTriggerList].map((popoverTriggerEl=>new Bootstrap.Popover(popoverTriggerEl,popoverConfig))),document.addEventListener("core/modal:bodyRendered",(e=>{[...e.target.querySelectorAll('[data-bs-toggle="popover"]')].map((popoverTriggerEl=>new Bootstrap.Popover(popoverTriggerEl,popoverConfig)))})),document.addEventListener("keydown",(e=>{const popoverTrigger=e.target.closest('[data-bs-toggle="popover"]');"Escape"===e.key&&popoverTrigger&&Bootstrap.Popover.getInstance(popoverTrigger).hide(),"Enter"===e.key&&popoverTrigger&&Bootstrap.Popover.getInstance(popoverTrigger).show()})),document.addEventListener("click",(e=>{const popoverTrigger=e.target.closest('[data-bs-toggle="popover"]');if(!popoverTrigger)return;const popover=Bootstrap.Popover.getInstance(popoverTrigger);popover._isShown()||popover.show()}))})(),[...document.querySelectorAll('[data-bs-toggle="tooltip"]')].map((tooltipTriggerEl=>new Bootstrap.Tooltip(tooltipTriggerEl))),_eventHandler.default.off(document,"keydown.bs.dropdown.data-api",".dropdown-menu",Bootstrap.Dropdown.dataApiKeydownHandler),_eventHandler.default.on(document.body,"keydown.bs.dropdown.data-api",".dropdown-menu",Bootstrap.Dropdown.dataApiKeydownHandler),pendingPromise.resolve()}));
//# sourceMappingURL=loader.min.js.map

File diff suppressed because one or more lines are too long

View file

@ -227,23 +227,6 @@ const dropdownFix = () => {
});
}
});
// Prevent closing the dropdown when the autocomplete suggestions are visible.
document.addEventListener('hide.bs.dropdown', (e) => {
const dropdown = e.target.closest('.dropdown');
if (!dropdown) {
return;
}
const autocompleteSuggestions = document.querySelector('.form-autocomplete-suggestions:not([aria-hidden="true"])');
if (autocompleteSuggestions) {
// Dropdown should not be hidden while the autocomplete suggestions are visible inside.
e.preventDefault();
// Return the focus to the autocomplete input.
const autocompleteElement = autocompleteSuggestions.closest('[data-fieldtype="autocomplete"]');
const autocompleteInput = autocompleteElement.querySelector('.form-autocomplete-input input');
setTimeout(()=> autocompleteInput.focus(), 1000);
}
});
};
/**

View file

@ -27,6 +27,7 @@ import * as Bootstrap from './index';
import Pending from 'core/pending';
import {DefaultAllowlist} from './bootstrap/util/sanitizer';
import setupBootstrapPendingChecks from './pending';
import EventHandler from './bootstrap/dom/event-handler';
/**
* Rember the last visited tabs.
@ -100,6 +101,21 @@ const enableTooltips = () => {
[...tooltipTriggerList].map(tooltipTriggerEl => new Bootstrap.Tooltip(tooltipTriggerEl));
};
/**
* Realocate Bootstrap events to the body element.
*
* Bootstrap 5 has a unique event handling mechanism that attaches all event handlers at the document level
* during the capture phase, rather than the usual bubbling phase. As a result, original Bootstrap events
* cannot be stopped or prevented, since the document is the first node executed in the capture phase.
* For certain advanced UI elements, such as form autocomplete, it is important to capture key-down events before
* Bootstrap's handlers to prevent unintended closures of elements. Therefore, we need to change the Bootstrap handler
* so that it operates one level lower, specifically at the body level.
*/
const realocateBootstrapEvents = () => {
EventHandler.off(document, 'keydown.bs.dropdown.data-api', '.dropdown-menu', Bootstrap.Dropdown.dataApiKeydownHandler);
EventHandler.on(document.body, 'keydown.bs.dropdown.data-api', '.dropdown-menu', Bootstrap.Dropdown.dataApiKeydownHandler);
};
const pendingPromise = new Pending('theme_boost/loader:init');
// Add pending promise event listeners to relevant Bootstrap custom events.
@ -117,6 +133,9 @@ enablePopovers();
// Enable all tooltips.
enableTooltips();
// Realocate Bootstrap events to the body element.
realocateBootstrapEvents();
pendingPromise.resolve();
export {