}
function browse() {
- CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
- $this->_tabs = array('campaign' => ts('Campaigns'),
+ $this->_tabs = array(
+ 'campaign' => ts('Campaigns'),
'survey' => ts('Surveys'),
'petition' => ts('Petitions'),
);
$subPageType = CRM_Utils_Request::retrieve('type', 'String', $this);
if ($subPageType) {
+ if (!isset($this->_tabs[$subPageType])) {
+ CRM_Utils_System::permissionDenied();
+ }
//load the data in tabs.
$this->{'browse' . ucfirst($subPageType)}();
+ $this->assign('subPageType', ucfirst($subPageType));
}
else {
//build the tabs.
$this->buildTabs();
}
- $this->assign('subPageType', $subPageType);
//give focus to proper tab.
- $selectedTabIndex = array_search(strtolower(CRM_Utils_Array::value('subPage', $_GET, 'campaign')),
- array_keys($this->_tabs)
- );
- if (!$selectedTabIndex) {
- $selectedTabIndex = array_search('campaign', array_keys($this->_tabs));
- }
- $this->assign('selectedTabIndex', $selectedTabIndex);
+ $selectedTabIndex = strtolower(CRM_Utils_Array::value('subPage', $_GET, 'campaign'));
+ $this->assign('selectedTab', $selectedTabIndex);
}
function run() {
function buildTabs() {
$allTabs = array();
foreach ($this->_tabs as $name => $title) {
- $allTabs[] = array(
- 'id' => $name,
+ $allTabs[$name] = array(
'title' => $title,
- 'url' => CRM_Utils_System::url('civicrm/campaign', "reset=1&type=$name&snippet=1"),
+ 'valid' => TRUE,
+ 'active' => TRUE,
+ 'link' => CRM_Utils_System::url('civicrm/campaign', "reset=1&type=$name"),
);
}
-
- $this->assign('allTabs', $allTabs);
+ $this->assign('tabHeader', $allTabs);
}
}
continue;
}
- $urlParams = "type={$name}&snippet=1";
+ $urlParams = "type={$name}";
if ($this->_surveyId) {
$urlParams .= "&sid={$this->_surveyId}";
}
if ($this->_interviewerId) {
$urlParams .= "&cid={$this->_interviewerId}";
}
- $allTabs[] = array(
- 'id' => $name,
+ $allTabs[$name] = array(
'title' => $title,
- 'url' => CRM_Utils_System::url('civicrm/campaign/vote',
- $urlParams
- ),
+ 'valid' => TRUE,
+ 'active' => TRUE,
+ 'link' => CRM_Utils_System::url('civicrm/campaign/vote', $urlParams),
);
}
- $this->assign('allTabs', empty($allTabs) ? FALSE : $allTabs);
+ $this->assign('tabHeader', empty($allTabs) ? FALSE : $allTabs);
}
}
position: relative;
padding: 0px 14px 0 5px;
background: url("../i/TreePlus.gif") no-repeat right 1px;
- border-left: none;
+ white-space: nowrap;
z-index: 2;
}
+--------------------------------------------------------------------+
*}
-{include file="CRM/common/TabHeader.tpl"}
+{include file="CRM/common/TabHeader.tpl" cache=true}
*}
{* CiviCampaign DashBoard (launch page) *}
-{* build the campaign selector *}
-{if $subPageType eq 'campaign'}
- {* load the campaign search and selector here *}
- {include file="CRM/Campaign/Form/Search/Campaign.tpl"}
-
-{* build the survey selector *}
-{elseif $subPageType eq 'survey'}
-
- {* load the survey search and selector here *}
- {include file="CRM/Campaign/Form/Search/Survey.tpl"}
-
-{* build normal page *}
-{elseif $subPageType eq 'petition'}
-
- {* load the petition search and selector here *}
- {include file="CRM/Campaign/Form/Search/Petition.tpl"}
-
-{* build normal page *}
+{if !empty($subPageType)}
+ {* load campaign/survey/petition tab *}
+ {include file="CRM/Campaign/Form/Search/$subPageType.tpl"}
{else}
-
- {* enclosed all tabs and its content in a block *}
- <div class="crm-block crm-content-block crm-campaign-page">
-
- <div id="mainTabContainer" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
- <ul class="crm-campaign-tabs-list">
- {foreach from=$allTabs key=tabName item=tabValue}
- <li id="tab_{$tabValue.id}" class="crm-tab-button ui-corner-bottom">
- <a href="{$tabValue.url}" title="{$tabValue.title}"><span></span>{$tabValue.title}</a>
- </li>
- {/foreach}
- </ul>
- </div>
-
-
-{literal}
-<script type="text/javascript">
-
-//explicitly stop spinner
-function stopSpinner( ) {
- cj('li.crm-tab-button').each(function(){ cj(this).find('span').text(' ');})
-}
-
-cj(document).ready( function( ) {
- {/literal}
- var spinnerImage = '<img src="{$config->resourceBase}i/loading.gif" style="width:10px;height:10px"/>';
- {literal}
-
- var selectedTabIndex = {/literal}{$selectedTabIndex}{literal};
- cj("#mainTabContainer").tabs( {
- active: selectedTabIndex,
- spinner: spinnerImage,
- cache: true,
- load: stopSpinner
- });
-});
-
-</script>
-{/literal}
-<div class="clear"></div>
-</div> {* crm-content-block ends here *}
+ {include file="CRM/common/TabHeader.tpl" cache=true}
+ <div class="clear"></div>
{/if}
{elseif $subPageType eq 'reserve'}
{* build the ajax search and voters reserve interface here *}
{include file='CRM/Campaign/Form/Gotv.tpl'}
-{elseif $allTabs}
- {* build normal page *}
- <div id="mainTabContainer" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
- <ul class="crm-vote-tabs-list">
- {foreach from=$allTabs key=tabName item=tabValue}
- <li id="tab_{$tabValue.id}" class="crm-tab-button ui-corner-bottom">
- <a href="{$tabValue.url}" title="{$tabValue.title}"><span></span>{$tabValue.title}</a>
- </li>
- {/foreach}
- </ul>
- </div>
- <div class="spacer"></div>
-
-{literal}
-<script type="text/javascript">
-
-//explicitly stop spinner
-function stopSpinner( ) {
- cj('li.crm-tab-button').each(function(){ cj(this).find('span').text(' ');})
-}
-
-cj(document).ready( function( ) {
- {/literal}
- var spinnerImage = '<img src="{$config->resourceBase}i/loading.gif" style="width:10px;height:10px"/>';
- {literal}
-
- var selectedTabIndex = {/literal}{$selectedTabIndex}{literal};
- cj("#mainTabContainer").tabs( {
- active: selectedTabIndex,
- spinner: spinnerImage,
- cache: false,
- load: stopSpinner
- });
-});
-
-</script>
-{/literal}
+{elseif $tabHeader}
+ {include file="CRM/common/TabHeader.tpl" cache=false}
{else}
<div class="messages status no-popup">
<div class="icon inform-icon"></div>
</ul>
<div class="clear"></div>
</div>
-{include file="CRM/common/TabHeader.tpl"}
+{include file="CRM/common/TabHeader.tpl" cache=true}
{literal}
<script>
</div>
{/if}
-{include file="CRM/common/TabHeader.tpl"}
+{include file="CRM/common/TabHeader.tpl" cache=true}
{literal}
<script>
})
.on('tabsbeforeload',
function(e, ui) {
+ console.log(ui.panel.data())
// Use civicrm ajax wrappers rather than the default $.load
- if (!ui.tab.data("loaded")) {
+ if (!ui.panel.data("civicrmCrmSnippet")) {
CRM.loadPage($('a', ui.tab).attr('href'), {
target: ui.panel
})
}
- ui.tab.data("loaded", true);
+ {/literal}{if empty($cache)}
+ else ui.panel.crmSnippet("refresh");
+ {/if}{literal}
e.preventDefault();
})
.tabs(tabSettings);