From 4165b7e5246d4d169c6faa16621bedbb84c1f431 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 28 Dec 2013 11:22:18 -0800 Subject: [PATCH] CRM-13997 CRM-13863 - Decouple TabHeader markup from scripts --- CRM/Campaign/Form/Survey/TabHeader.php | 7 +++- CRM/Campaign/Page/DashBoard.php | 9 +++-- CRM/Campaign/Page/Vote.php | 9 +++-- .../Form/ContributionPage/TabHeader.php | 6 ++- CRM/Event/Form/ManageEvent/TabHeader.php | 7 +++- templates/CRM/Campaign/Form/Survey/Main.tpl | 4 +- templates/CRM/Campaign/Form/Survey/Tab.tpl | 2 +- templates/CRM/Campaign/Page/DashBoard.tpl | 2 +- templates/CRM/Campaign/Page/Vote.tpl | 2 +- .../Contribute/Form/ContributionPage/Tab.tpl | 2 +- templates/CRM/Event/Form/ManageEvent/Tab.tpl | 2 +- templates/CRM/UF/Page/Group.tpl | 9 ++--- templates/CRM/common/TabHeader.js | 23 +++++++++++ templates/CRM/common/TabHeader.tpl | 38 ------------------- 14 files changed, 59 insertions(+), 63 deletions(-) create mode 100644 templates/CRM/common/TabHeader.js diff --git a/CRM/Campaign/Form/Survey/TabHeader.php b/CRM/Campaign/Form/Survey/TabHeader.php index 779eb4e9be..77378a7893 100644 --- a/CRM/Campaign/Form/Survey/TabHeader.php +++ b/CRM/Campaign/Form/Survey/TabHeader.php @@ -45,8 +45,11 @@ class CRM_Campaign_Form_Survey_TabHeader { $form->set('tabHeader', $tabs); } $form->assign_by_ref('tabHeader', $tabs); - $selectedTab = self::getCurrentTab($tabs); - $form->assign_by_ref('selectedTab', $selectedTab); + CRM_Core_Resources::singleton() + ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js') + ->addSetting(array('tabSettings' => array( + 'active' => self::getCurrentTab($tabs), + ))); return $tabs; } diff --git a/CRM/Campaign/Page/DashBoard.php b/CRM/Campaign/Page/DashBoard.php index e0ac0c32c5..a30603468b 100644 --- a/CRM/Campaign/Page/DashBoard.php +++ b/CRM/Campaign/Page/DashBoard.php @@ -439,10 +439,11 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { //build the tabs. $this->buildTabs(); } - - //give focus to proper tab. - $selectedTabIndex = strtolower(CRM_Utils_Array::value('subPage', $_GET, 'campaign')); - $this->assign('selectedTab', $selectedTabIndex); + CRM_Core_Resources::singleton() + ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js') + ->addSetting(array('tabSettings' => array( + 'active' => strtolower(CRM_Utils_Array::value('subPage', $_GET, 'campaign')), + ))); } function run() { diff --git a/CRM/Campaign/Page/Vote.php b/CRM/Campaign/Page/Vote.php index 143692d663..ed788a0e79 100644 --- a/CRM/Campaign/Page/Vote.php +++ b/CRM/Campaign/Page/Vote.php @@ -86,10 +86,11 @@ class CRM_Campaign_Page_Vote extends CRM_Core_Page { } $this->assign('subPageType', $subPageType); - //give focus to proper tab. - $this->assign('selectedTabIndex', array_search(CRM_Utils_Array::value('subPage', $_GET, 'reserve'), - array_keys($this->_tabs) - )); + CRM_Core_Resources::singleton() + ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js') + ->addSetting(array('tabSettings' => array( + 'active' => strtolower(CRM_Utils_Array::value('subPage', $_GET, 'reserve')), + ))); } function run() { diff --git a/CRM/Contribute/Form/ContributionPage/TabHeader.php b/CRM/Contribute/Form/ContributionPage/TabHeader.php index 9385bb9994..12dfd39bea 100644 --- a/CRM/Contribute/Form/ContributionPage/TabHeader.php +++ b/CRM/Contribute/Form/ContributionPage/TabHeader.php @@ -44,7 +44,11 @@ class CRM_Contribute_Form_ContributionPage_TabHeader { $form->set('tabHeader', $tabs); } $form->assign_by_ref('tabHeader', $tabs); - $form->assign('selectedTab', self::getCurrentTab($tabs)); + CRM_Core_Resources::singleton() + ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js') + ->addSetting(array('tabSettings' => array( + 'active' => self::getCurrentTab($tabs), + ))); return $tabs; } diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index 7c071baf42..92756352fe 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -45,8 +45,11 @@ class CRM_Event_Form_ManageEvent_TabHeader { $form->set('tabHeader', $tabs); } $form->assign_by_ref('tabHeader', $tabs); - $selectedTab = self::getCurrentTab($tabs); - $form->assign_by_ref('selectedTab', $selectedTab); + CRM_Core_Resources::singleton() + ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js') + ->addSetting(array('tabSettings' => array( + 'active' => self::getCurrentTab($tabs), + ))); return $tabs; } diff --git a/templates/CRM/Campaign/Form/Survey/Main.tpl b/templates/CRM/Campaign/Form/Survey/Main.tpl index c34b849876..66362f0f44 100644 --- a/templates/CRM/Campaign/Form/Survey/Main.tpl +++ b/templates/CRM/Campaign/Form/Survey/Main.tpl @@ -107,8 +107,8 @@ }); {/literal} - -{include file="CRM/common/customData.tpl"} +{* editor has already been included in TabHeader.tpl so set flag true *} +{include file="CRM/common/customData.tpl" includeWysiwygEditor=true} {literal} - -- 2.25.1