Merge pull request #5298 from colemanw/CRM-16019-b
[civicrm-core.git] / templates / CRM / common / TabHeader.tpl
index e528d7df07a5782814614ac9a841b381292d90c3..78e2cdac3324bcd02db1920f281fd53ad576e45f 100644 (file)
@@ -1,8 +1,8 @@
 {*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  +--------------------------------------------------------------------+
 *}
 
-{* enclosed all tabs and its content in a block *}
 {* include wysiwyg related files*}
 {include file="CRM/common/wysiwyg.tpl" includeWysiwygEditor=true}
 
+{* enclose all tabs and its content in a block *}
 <div class="crm-block crm-content-block">
-  {if $tabHeader and count($tabHeader) gt 1}
+  {if $tabHeader and count($tabHeader)}
     <div id="mainTabContainer">
     <ul>
        {foreach from=$tabHeader key=tabName item=tabValue}
-          <li id="tab_{$tabName}" class="crm-tab-button ui-corner-all {if !$tabValue.valid}disabled{/if}">
-          {if $tabValue.link and $tabValue.active}
-             <a href="{$tabValue.link}" title="{$tabValue.title}{if !$tabValue.valid} ({ts}disabled{/ts}){/if}">{$tabValue.title}</a>
+          <li id="tab_{$tabName}" class="crm-tab-button ui-corner-all{if !$tabValue.valid} disabled{/if}{if isset($tabValue.class)} {$tabValue.class}{/if}" {$tabValue.extra}>
+          {if $tabValue.active}
+             <a href="{if !empty($tabValue.template)}#panel_{$tabName}{else}{$tabValue.link}{/if}" title="{$tabValue.title}{if !$tabValue.valid} ({ts}disabled{/ts}){/if}">{$tabValue.title}{if isset($tabValue.count)} <em>{$tabValue.count}</em>{/if}</a>
           {else}
              <span {if !$tabValue.valid} title="{ts}disabled{/ts}"{/if}>{$tabValue.title}</span>
           {/if}
           </li>
        {/foreach}
     </ul>
+      {foreach from=$tabHeader key=tabName item=tabValue}
+        {if !empty($tabValue.template)}
+          <div id="#panel_{$tabName}">
+            {include file=$tabValue.template}
+          </div>
+        {/if}
+      {/foreach}
     </div>
   {/if}
   <div class="clear"></div>
 </div> {* crm-content-block ends here *}
-
-<script type="text/javascript">
-{literal}
-  cj(function($) {
-    var tabSettings = {};
-    {/literal}{if $selectedTab}
-    var selectedTab = "{$selectedTab}";
-    tabSettings.active = $('#tab_' + selectedTab).prevAll().length;
-    {/if}{literal}
-    $("#mainTabContainer")
-      .on('tabsbeforeactivate',
-        function(e, ui) {
-          // Warn of unsaved changes - requires formNavigate.tpl to be included in each tab
-          if (!global_formNavigate) {
-            var message = '{/literal}{ts escape="js" 1='%1'}Your changes in the <em>%1</em> tab have not been saved.{/ts}{literal}';
-            CRM.alert(ts(message, {1: ui.oldTab.text()}), '{/literal}{ts escape="js"}Unsaved Changes{/ts}{literal}', 'warning');
-            global_formNavigate = true;
-          }
-        })
-      .on('tabsbeforeload',
-        function(e, ui) {
-          // Use civicrm ajax wrappers rather than the default $.load
-          if (!ui.tab.data("loaded")) {
-            CRM.loadPage($('a', ui.tab).attr('href'), {
-              target: ui.panel
-            })
-          }
-          ui.tab.data("loaded", true);
-          e.preventDefault();
-        })
-      .tabs(tabSettings);
-});
-{/literal}
-</script>
-