From 66ec3e603c1483e9d684082473d5621b49275fe8 Mon Sep 17 00:00:00 2001 From: scottshipman Date: Mon, 9 Jul 2018 11:40:06 -0400 Subject: [PATCH 1/2] fix js errors causing client and source issues --- Assets/js/global-revenue.js | 3 +++ Assets/js/source-revenue.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Assets/js/global-revenue.js b/Assets/js/global-revenue.js index 35a9447..e9cdf95 100644 --- a/Assets/js/global-revenue.js +++ b/Assets/js/global-revenue.js @@ -196,5 +196,8 @@ Mautic.loadGlobalRevenueWidget = function (globalWidgetHeight) { mQuery(document).ready(function () { + if (typeof globalWidgetHeight == 'undefined'){ + let globalWidgetHeight = '445'; + } Mautic.loadGlobalRevenueWidget(globalWidgetHeight); }); diff --git a/Assets/js/source-revenue.js b/Assets/js/source-revenue.js index 8d9ce91..b6a19d2 100644 --- a/Assets/js/source-revenue.js +++ b/Assets/js/source-revenue.js @@ -205,6 +205,9 @@ mQuery.getCssOnce = function (url, callback) { }; mQuery(document).ready(function () { + if (typeof detailWidgetHeight == 'undefined'){ + let detailWidgetHeight = '445'; + } Mautic.loadSourceRevenueWidget(detailWidgetHeight); }); From f11610d722e3672be4f46658185cd9ebd4647e94 Mon Sep 17 00:00:00 2001 From: scottshipman Date: Mon, 9 Jul 2018 12:33:38 -0400 Subject: [PATCH 2/2] use includeScripts method to load js, and set widget height as elem data prop --- Assets/js/global-revenue.js | 12 ++---------- Assets/js/source-revenue.js | 11 ++--------- Views/Widgets/revenue.html.php | 11 ++++------- Views/Widgets/sourceRevenue.html.php | 16 ++++++++-------- 4 files changed, 16 insertions(+), 34 deletions(-) diff --git a/Assets/js/global-revenue.js b/Assets/js/global-revenue.js index e9cdf95..835b851 100644 --- a/Assets/js/global-revenue.js +++ b/Assets/js/global-revenue.js @@ -1,4 +1,4 @@ -Mautic.loadGlobalRevenueWidget = function (globalWidgetHeight) { +Mautic.loadGlobalRevenueWidget = function () { var $globaltarget = mQuery('#global-revenue'); if ($globaltarget.length) { mQuery('#global-revenue:not(.table-initialized):first').addClass('table-initialized').each(function () { @@ -15,7 +15,7 @@ Mautic.loadGlobalRevenueWidget = function (globalWidgetHeight) { cache: true, dataType: 'json', success: function (response) { - var rowCount = Math.floor((globalWidgetHeight - 220) / 40); + var rowCount = Math.floor(($globaltarget.data('height') - 220) / 40); mQuery('#global-revenue').DataTable({ language: { emptyTable: 'No results found for this date range and filters.' @@ -193,11 +193,3 @@ Mautic.loadGlobalRevenueWidget = function (globalWidgetHeight) { } callback(); }; - - -mQuery(document).ready(function () { - if (typeof globalWidgetHeight == 'undefined'){ - let globalWidgetHeight = '445'; - } - Mautic.loadGlobalRevenueWidget(globalWidgetHeight); -}); diff --git a/Assets/js/source-revenue.js b/Assets/js/source-revenue.js index b6a19d2..a7bba55 100644 --- a/Assets/js/source-revenue.js +++ b/Assets/js/source-revenue.js @@ -1,4 +1,4 @@ -Mautic.loadSourceRevenueWidget = function (detailWidgetHeight) { +Mautic.loadSourceRevenueWidget = function () { var $sourcetarget = mQuery('#source-revenue'); if($sourcetarget.length) { mQuery('#source-revenue:first:not(.table-initialized)').addClass('table-initialized').each(function () { @@ -15,7 +15,7 @@ Mautic.loadSourceRevenueWidget = function (detailWidgetHeight) { cache: true, dataType: 'json', success: function (response) { - var rowCount = Math.floor((detailWidgetHeight - 220) / 40); + var rowCount = Math.floor(($sourcetarget.data('height') - 220) / 40); mQuery('#source-revenue').DataTable({ language: { emptyTable: "No results found for this date range and filters." @@ -204,11 +204,4 @@ mQuery.getCssOnce = function (url, callback) { callback(); }; -mQuery(document).ready(function () { - if (typeof detailWidgetHeight == 'undefined'){ - let detailWidgetHeight = '445'; - } - Mautic.loadSourceRevenueWidget(detailWidgetHeight); -}); - diff --git a/Views/Widgets/revenue.html.php b/Views/Widgets/revenue.html.php index f295088..967091b 100644 --- a/Views/Widgets/revenue.html.php +++ b/Views/Widgets/revenue.html.php @@ -10,9 +10,10 @@ */ ?> - includeScript('plugins/MauticContactLedgerBundle/Assets/js/global-revenue.js', 'loadGlobalRevenueWidget'); + $params = $data['params']; ?> @@ -22,14 +23,10 @@
- +
- - \ No newline at end of file + \ No newline at end of file diff --git a/Views/Widgets/sourceRevenue.html.php b/Views/Widgets/sourceRevenue.html.php index 4b00f13..54406be 100644 --- a/Views/Widgets/sourceRevenue.html.php +++ b/Views/Widgets/sourceRevenue.html.php @@ -9,8 +9,8 @@ * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ ?> - includeScript('plugins/MauticContactLedgerBundle/Assets/js/source-revenue.js', 'loadSourceRevenueWidget'); $params = $data['params']; ?> @@ -20,17 +20,17 @@
-
- +
+
+ +
+
+
- +