added simple math and charts modules

This commit is contained in:
2024-12-10 23:53:23 +01:00
parent 62a5f3c97c
commit 688ff42752
196 changed files with 20285 additions and 8 deletions

View File

@@ -0,0 +1,46 @@
/**
* @file
* Charts API.
*/
((Drupal) => {
Drupal.Charts = Drupal.Charts || {};
Drupal.Charts.Configs = Drupal.Charts.Configs || [];
/**
* @typedef {class} Drupal.Charts.Contents
*/
Drupal.Charts.Contents = class {
constructor() {
const chartsElements = document.querySelectorAll('[data-chart]');
chartsElements.forEach(function (el) {
const id = el.getAttribute('id');
Drupal.Charts.Configs[id] = JSON.parse(el.getAttribute('data-chart'));
Drupal.Charts.Configs[id].drupalChartDivElement = el;
Drupal.Charts.Configs[id].drupalChartDivId = id;
});
}
initialize(id) {
const event = new CustomEvent('drupalChartsConfigsInitialization', {
detail: Drupal.Charts.Configs[id]
});
Drupal.Charts.Configs[id].drupalChartDivElement.dispatchEvent(event);
}
static update(id, data) {
if (Drupal.Charts.Configs.hasOwnProperty(id)) {
Drupal.Charts.Configs[id] = data;
}
}
getData(id) {
if (Drupal.Charts.Configs.hasOwnProperty(id)) {
this.initialize(id);
return Drupal.Charts.Configs[id];
}
return {};
}
};
})(Drupal);

View File

@@ -0,0 +1,45 @@
/**
* DO NOT EDIT THIS FILE.
* See the following change record for more information,
* https://www.drupal.org/node/2815083
* @preserve
**/
(Drupal => {
Drupal.Charts = Drupal.Charts || {};
Drupal.Charts.Configs = Drupal.Charts.Configs || [];
Drupal.Charts.Contents = class {
constructor() {
const charts_elements = document.querySelectorAll('[data-chart]');
charts_elements.forEach(function (el) {
const id = el.getAttribute('id');
Drupal.Charts.Configs[id] = JSON.parse(el.getAttribute('data-chart'));
Drupal.Charts.Configs[id].drupalChartDivElement = el;
Drupal.Charts.Configs[id].drupalChartDivId = id;
});
}
initialize(id) {
const event = new CustomEvent('drupalChartsConfigsInitialization', {
detail: Drupal.Charts.Configs[id]
});
Drupal.Charts.Configs[id].drupalChartDivElement.dispatchEvent(event);
}
static update(id, data) {
if (Drupal.Charts.Configs.hasOwnProperty(id)) {
Drupal.Charts.Configs[id] = data;
}
}
getData(id) {
if (Drupal.Charts.Configs.hasOwnProperty(id)) {
this.initialize(id);
return Drupal.Charts.Configs[id];
}
return {};
}
};
})(Drupal);