Initial Drupal 11 with DDEV setup
This commit is contained in:
34
web/core/misc/drupal.init.js
Normal file
34
web/core/misc/drupal.init.js
Normal file
@ -0,0 +1,34 @@
|
||||
// Allow other JavaScript libraries to use $.
|
||||
if (window.jQuery) {
|
||||
jQuery.noConflict();
|
||||
}
|
||||
|
||||
// Class indicating that JS is enabled; used for styling purpose.
|
||||
document.documentElement.className += ' js';
|
||||
|
||||
// JavaScript should be made compatible with libraries other than jQuery by
|
||||
// wrapping it in an anonymous closure.
|
||||
(function (Drupal, drupalSettings) {
|
||||
/**
|
||||
* Calls callback when document ready.
|
||||
*
|
||||
* @param {function} callback
|
||||
* The function to be called on document ready.
|
||||
*/
|
||||
const domReady = (callback) => {
|
||||
const listener = () => {
|
||||
callback();
|
||||
document.removeEventListener('DOMContentLoaded', listener);
|
||||
};
|
||||
if (document.readyState !== 'loading') {
|
||||
setTimeout(callback, 0);
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', listener);
|
||||
}
|
||||
};
|
||||
|
||||
// Attach all behaviors.
|
||||
domReady(() => {
|
||||
Drupal.attachBehaviors(document, drupalSettings);
|
||||
});
|
||||
})(Drupal, window.drupalSettings);
|
||||
Reference in New Issue
Block a user