diff options
Diffstat (limited to 'core/misc/drupalSettingsLoader.js')
-rw-r--r-- | core/misc/drupalSettingsLoader.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/misc/drupalSettingsLoader.js b/core/misc/drupalSettingsLoader.js new file mode 100644 index 00000000000..ab3911dea88 --- /dev/null +++ b/core/misc/drupalSettingsLoader.js @@ -0,0 +1,24 @@ +/** + * @file + * Parse inline JSON and initialize the drupalSettings global object. + */ + +(function () { + + "use strict"; + + var settingsElement = document.querySelector('script[type="application/json"][data-drupal-selector="drupal-settings-json"]'); + + /** + * Variable generated by Drupal with all the configuration created from PHP. + * + * @global + * + * @type {object} + */ + window.drupalSettings = {}; + + if (settingsElement !== null) { + window.drupalSettings = JSON.parse(settingsElement.textContent); + } +})(); |