Skip to content
Snippets Groups Projects
Commit 35b8ef9e authored by Nia Kathoni's avatar Nia Kathoni Committed by Daniel Cothran
Browse files

Issue #3495124: Rename charts.es6.js to charts.js for 5.1.x

parent 3e1b3566
No related branches found
No related tags found
3 merge requests!124Resolve #3495124 "Rename charts.es6.js to",!113fixed the issue,!75Resolve #3391197 "Enable support for"
Pipeline #378718 passed with warnings
/**
* @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);
/** /**
* DO NOT EDIT THIS FILE. * @file
* See the following change record for more information, * Charts API.
* https://www.drupal.org/node/2815083 */
* @preserve ((Drupal) => {
**/
(Drupal => {
Drupal.Charts = Drupal.Charts || {}; Drupal.Charts = Drupal.Charts || {};
Drupal.Charts.Configs = Drupal.Charts.Configs || []; Drupal.Charts.Configs = Drupal.Charts.Configs || [];
/**
* @typedef {class} Drupal.Charts.Contents
*/
Drupal.Charts.Contents = class { Drupal.Charts.Contents = class {
constructor() { constructor() {
const charts_elements = document.querySelectorAll('[data-chart]'); const chartsElements = document.querySelectorAll('[data-chart]');
charts_elements.forEach(function (el) { chartsElements.forEach(function (el) {
const id = el.getAttribute('id'); const id = el.getAttribute('id');
Drupal.Charts.Configs[id] = JSON.parse(el.getAttribute('data-chart')); Drupal.Charts.Configs[id] = JSON.parse(el.getAttribute('data-chart'));
Drupal.Charts.Configs[id].drupalChartDivElement = el; Drupal.Charts.Configs[id].drupalChartDivElement = el;
...@@ -21,7 +24,8 @@ ...@@ -21,7 +24,8 @@
initialize(id) { initialize(id) {
const event = new CustomEvent('drupalChartsConfigsInitialization', { const event = new CustomEvent('drupalChartsConfigsInitialization', {
detail: Drupal.Charts.Configs[id] detail: Drupal.Charts.Configs[id],
bubbles: true,
}); });
Drupal.Charts.Configs[id].drupalChartDivElement.dispatchEvent(event); Drupal.Charts.Configs[id].drupalChartDivElement.dispatchEvent(event);
} }
...@@ -37,9 +41,7 @@ ...@@ -37,9 +41,7 @@
this.initialize(id); this.initialize(id);
return Drupal.Charts.Configs[id]; return Drupal.Charts.Configs[id];
} }
return {}; return {};
} }
}; };
})(Drupal); })(Drupal);
(function () { (function (Drupal) {
'use strict'; 'use strict';
Drupal.charts_api_example = Drupal.charts_api_example || {}; Drupal.charts_api_example = Drupal.charts_api_example || {};
// PLEASE NOTE: this example is structured to work for Highcharts, but you // PLEASE NOTE: this example is structured to work for Highcharts, but you
// do the same thing for any of the charting libraries. // do the same thing for any of the charting libraries.
...@@ -7,10 +9,11 @@ ...@@ -7,10 +9,11 @@
return 'The value for <b>' + this.x + return 'The value for <b>' + this.x +
'</b> is <b>' + this.y + '</b>'; '</b> is <b>' + this.y + '</b>';
}; };
Drupal.behaviors.chartsApiExampleCharts = { Drupal.behaviors.chartsApiExampleCharts = {
attach: function (context, settings) { attach: function (context, settings) {
let chartcontainer = document.getElementById('exampleidjs'); let chartContainer = document.getElementById('example-id-js');
chartcontainer.addEventListener('drupalChartsConfigsInitialization', function (e) { chartContainer.addEventListener('drupalChartsConfigsInitialization', function (e) {
let data = e.detail; let data = e.detail;
const id = data.drupalChartDivId; const id = data.drupalChartDivId;
// Change the background of the chart to green. // Change the background of the chart to green.
...@@ -21,4 +24,4 @@ ...@@ -21,4 +24,4 @@
}); });
} }
}; };
}()); }(Drupal));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment