From 58ca2c89b232677021a2a741eb94526d6b33c15a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 5 Nov 2014 11:11:55 -0500 Subject: [PATCH] CRM-15524 - Modify contribution dashboard js to work as header script --- templates/CRM/Contribute/Page/DashBoard.js | 39 +++++++++++++--------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/templates/CRM/Contribute/Page/DashBoard.js b/templates/CRM/Contribute/Page/DashBoard.js index 653a6ceb09..0d9d0f209b 100644 --- a/templates/CRM/Contribute/Page/DashBoard.js +++ b/templates/CRM/Contribute/Page/DashBoard.js @@ -21,24 +21,31 @@ } }; - $('#crm-container').on('crmLoad', function (e) { - if ($(e.target).is('#crm-main-content-wrapper, #crm-container')) { - $('#chart_view, #table_view').click(function () { - if ($(this).hasClass('ui-state-default')) { - $('.ui-tabs-selected', '#mainTabContainer').removeClass('ui-state-active ui-tabs-selected').addClass('ui-state-default'); - $(this).removeClass('ui-state-default').addClass('ui-state-active ui-tabs-selected'); - load[this.id](); - } - }); - - // Initialize chart or table based on url hash - if (window.location.hash === '#table_layout') { - $('#table_view').click(); - } - else { - load.chart_view(); + function refresh() { + $('#chart_view, #table_view').click(function () { + if ($(this).hasClass('ui-state-default')) { + $('.ui-tabs-selected', '#mainTabContainer').removeClass('ui-state-active ui-tabs-selected').addClass('ui-state-default'); + $(this).removeClass('ui-state-default').addClass('ui-state-active ui-tabs-selected'); + load[this.id](); } + }); + + // Initialize chart or table based on url hash + if (window.location.hash === '#table_layout') { + $('#table_view').click(); } + else { + load.chart_view(); + } + } + + $(function () { + $('#crm-main-content-wrapper').on('crmLoad', function (e) { + if ($(e.target).is(this)) { + refresh(); + } + }); + refresh(); }); })(CRM.$); -- 2.25.1