CRM-13997 CRM-13863 - Decouple TabHeader markup from scripts
[civicrm-core.git] / templates / CRM / common / TabHeader.js
CommitLineData
4165b7e5
CW
1// https://civicrm.org/licensing
2cj(function($) {
3 var tabSettings = CRM.tabSettings || {};
4 tabSettings.active = tabSettings.active ? $('#tab_' + tabSettings.active).prevAll().length : 0;
5 $("#mainTabContainer")
6 .on('tabsbeforeactivate', function(e, ui) {
7 // Warn of unsaved changes - requires formNavigate.tpl to be included in each tab
8 if (!global_formNavigate) {
9 CRM.alert(ts('Your changes in the <em>%1</em> tab have not been saved.', {1: ui.oldTab.text()}), ts('Unsaved Changes'), 'warning');
10 global_formNavigate = true;
11 }
12 })
13 .on('tabsbeforeload', function(e, ui) {
14 // Use civicrm ajax wrappers rather than the default $.load
15 if (!ui.panel.data("civicrmCrmSnippet")) {
16 CRM.loadPage($('a', ui.tab).attr('href'), {
17 target: ui.panel
18 })
19 }
20 e.preventDefault();
21 })
22 .tabs(tabSettings);
23});