Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2021-12-03 12:38:01 +0300
committerGitHub <noreply@github.com>2021-12-03 12:38:01 +0300
commitad6f19a072a575a629fb90c4a7f5f25edcbd283c (patch)
tree54a7a5ae00d07e7feb0d19a68eab134ae0d8245c /plugins/CoreHome/javascripts
parent25a58955bac36a9804388281bcfaf02cdf43b2d0 (diff)
Ensure javascript of a datatable only initializes itself (#18386)
* Ensure javascript of a datatable only initializes itself * apply review feedback * use css max-width instead of js calculation * improve js code * updates expected screenshots * updates submodule
Diffstat (limited to 'plugins/CoreHome/javascripts')
-rw-r--r--plugins/CoreHome/javascripts/dataTable.js31
1 files changed, 10 insertions, 21 deletions
diff --git a/plugins/CoreHome/javascripts/dataTable.js b/plugins/CoreHome/javascripts/dataTable.js
index 35b73de875..1453f257b9 100644
--- a/plugins/CoreHome/javascripts/dataTable.js
+++ b/plugins/CoreHome/javascripts/dataTable.js
@@ -39,8 +39,9 @@ function DataTable(element) {
DataTable._footerIconHandlers = {};
-DataTable.initNewDataTables = function () {
- $('div.dataTable').each(function () {
+DataTable.initNewDataTables = function (reportId) {
+ var selector = typeof reportId === 'string' ? '[data-report='+JSON.stringify(reportId)+']' : 'div.dataTable';
+ $(selector).each(function () {
if (!$(this).attr('id')) {
var tableType = $(this).attr('data-table-type') || 'DataTable',
klass = require('piwik/UI')[tableType] || require(tableType);
@@ -376,7 +377,7 @@ $.extend(DataTable.prototype, UIControl.prototype, {
self.handleSearchBox(domElem);
self.handleColumnDocumentation(domElem);
self.handleRowActions(domElem);
- self.handleCellTooltips(domElem);
+ self.handleCellTooltips(domElem);
self.handleRelatedReports(domElem);
self.handleTriggeredEvents(domElem);
self.handleColumnHighlighting(domElem);
@@ -425,14 +426,6 @@ $.extend(DataTable.prototype, UIControl.prototype, {
$domElem.width('');
parentDataTable.width('');
- var $table = $('table.dataTable', domElem);
- if ($table.closest('.reportsByDimensionView').length) {
- var requiredTableWidth = $table.width() - 40; // 40 is padding on card content
- if (domElem.width() > requiredTableWidth) {
- domElem.css('max-width', requiredTableWidth + 'px');
- }
- }
-
var tableWidth = getTableWidth(domElem);
if (tableWidth <= maxTableWidth) {
@@ -445,9 +438,9 @@ $.extend(DataTable.prototype, UIControl.prototype, {
if (dataTableInCard && dataTableInCard.length) {
// makes sure card has the same width
- dataTableInCard.width(maxTableWidth);
+ dataTableInCard.css('max-width', maxTableWidth);
} else {
- $domElem.width(maxTableWidth);
+ $domElem.css('max-width', maxTableWidth);
}
if (parentDataTable && parentDataTable.length) {
@@ -455,9 +448,9 @@ $.extend(DataTable.prototype, UIControl.prototype, {
// applied in getLabelWidth() since they will have the same size.
if (dataTableInCard.length) {
- dataTableInCard.width(maxTableWidth);
+ dataTableInCard.css('max-width', maxTableWidth);
} else {
- parentDataTable.width(maxTableWidth);
+ parentDataTable.css('max-width', maxTableWidth);
}
}
}
@@ -1963,17 +1956,13 @@ $.extend(DataTable.prototype, UIControl.prototype, {
// ensure the tooltips of parent elements are hidden when the action tooltip is shown
// otherwise it can happen that tooltips for subtable rows are shown as well.
open: function() {
- var tooltip = $(this).parents().filter(function() {
- return jQuery.hasData(this) && $(this).data('ui-tooltip');
- }).tooltip('instance');
+ var tooltip = $(this).parents('[piwik-widget]').tooltip('instance');
if (tooltip) {
tooltip.disable();
}
},
close: function() {
- var tooltip = $(this).parents().filter(function() {
- return jQuery.hasData(this) && $(this).data('ui-tooltip');
- }).tooltip('instance');
+ var tooltip = $(this).parents('[piwik-widget]').tooltip('instance');
if (tooltip) {
tooltip.enable();
}