CRM-13997 CRM-13863 - Use CRM.loadPage for contact tabs
authorColeman Watts <coleman@civicrm.org>
Sat, 28 Dec 2013 19:58:12 +0000 (11:58 -0800)
committerColeman Watts <coleman@civicrm.org>
Mon, 6 Jan 2014 19:11:39 +0000 (11:11 -0800)
CRM/Contact/Page/View/Summary.php
templates/CRM/Contact/Page/View/Summary.js
templates/CRM/Contact/Page/View/Summary.tpl
templates/CRM/Tag/Form/Tag.tpl
templates/CRM/common/TabHeader.js

index 668bcc10cbf20aa9c914a7e7bdc92f808b5d8915..d561d123e31a5cfe98e82a197a88a9cccb02cbb8 100644 (file)
@@ -137,7 +137,11 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
       ->addScriptFile('civicrm', 'templates/CRM/Contact/Page/View/Summary.js')
       ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
       ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header')
-      ->addSetting(array('summaryPrint' => array('mode' => $this->_print)));
+      ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js')
+      ->addSetting(array(
+        'summaryPrint' => array('mode' => $this->_print),
+        'tabSettings' => array('active' => CRM_Utils_Request::retrieve('selectedChild', 'String', $this, FALSE, 'summary')),
+      ));
     $this->assign('summaryPrint', $this->_print);
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
@@ -316,9 +320,9 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
 
         //appending isTest to url for test soft credit CRM-3891.
         //FIXME: hack ajax url.
-        $q = "reset=1&snippet=1&force=1&cid={$this->_contactId}";
+        $q = "reset=1&force=1&cid={$this->_contactId}";
         if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) {
-          $q = $q . "&isTest=1";
+          $q .= "&isTest=1";
         }
         $allTabs[] = array(
           'id' => $i,
@@ -351,7 +355,7 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
           'id' => $k,
           'url' => CRM_Utils_System::url(
             "civicrm/contact/view/$k",
-            "reset=1&snippet=1&cid={$this->_contactId}"
+            "reset=1&cid={$this->_contactId}"
           ),
           'title' => $v,
           'weight' => $weight,
@@ -373,7 +377,7 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
       $id = "custom_{$group['id']}";
       $allTabs[] = array(
         'id' => $id,
-        'url' => CRM_Utils_System::url($group['path'], $group['query'] . "&snippet=1&selectedChild=$id"),
+        'url' => CRM_Utils_System::url($group['path'], $group['query'] . "&selectedChild=$id"),
         'title' => $group['title'],
         'weight' => $weight,
         'count' => CRM_Contact_BAO_Contact::getCountComponent($id, $this->_contactId, $group['table_name']),
@@ -389,9 +393,6 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
 
     $this->assign('allTabs', $allTabs);
 
-    $selectedChild = CRM_Utils_Request::retrieve('selectedChild', 'String', $this, FALSE, 'summary');
-    $this->assign('selectedChild', $selectedChild);
-
     // hook for contact summary
     // ignored but needed to prevent warnings
     $contentPlacement = CRM_Utils_Hook::SUMMARY_BELOW;
index 8c8bbc4b1a153a6c2927e4540d43398784ae9736..edf04537ae577d2a9eb7b9e7d2b61fd97cac706a 100644 (file)
@@ -90,7 +90,7 @@
       }
       // Update changelog tab and contact footer
       if (response.changeLog.count) {
-        $("#tab_log a em").html(response.changeLog.count);
+        CRM.updateTabCount('#tab_log', response.changeLog.count);
       }
       $("#crm-record-log").replaceWith(response.changeLog.markup);
       // Refresh tab contents - Advanced logging
       $('#tab_log a').click();
       return false;
     });
+    $().crmAccordions();
   });
 })(cj);
index 0225cb63728ed7a4369792611eb3af17e9d3e5ab..13291abbd66eecfacc4a34641a8bc5873e52f351 100644 (file)
   {/if}
 
   <div class="crm-block crm-content-block crm-contact-page crm-inline-edit-container">
-    <div id="mainTabContainer" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
+    <div id="mainTabContainer">
       <ul class="crm-contact-tabs-list">
         <li id="tab_summary" class="crm-tab-button">
           <a href="#contact-summary" title="{ts}Summary{/ts}">
     </div>
     <div class="clear"></div>
   </div><!-- /.crm-content-block -->
-
-  <script type="text/javascript">
-    {literal}
-    cj(function($) {
-      //explicitly stop spinner
-      function stopSpinner( ) {
-        $('li.crm-tab-button span').text(' ');
-      }
-      {/literal}
-      var selectedTab = '{if !empty($selectedChild)}{$selectedChild}{else}summary{/if}';
-      var tabIndex = $('#tab_' + selectedTab).prevAll().length;
-      var spinnerImage = '<img src="{$config->resourceBase}i/loading.gif" style="width:10px;height:10px"/>';
-      {literal}
-      $("#mainTabContainer").tabs({ active: tabIndex, spinner: spinnerImage, cache: true, load: stopSpinner});
-      $(".crm-tab-button").addClass("ui-corner-bottom");
-      $().crmAccordions();
-
-      $('body').click(function() {
-        cj('#crm-contact-actions-list').hide();
-      });
-    });
-    {/literal}
-  </script>
 {/if}
 
 {* CRM-10560 *}
index 4a8e70fef0d7d228fb7e019cf196603af41fd31d..3132cabb2e5947693df1b14b242564dedc065427 100644 (file)
     });
 
     CRM.updateContactSummaryTags = function() {
-      var tags = [], $tab = $('#tab_tag');
+      var tags = [];
       $('.tag-section .token-input-token-facebook p, #tagtree input:checkbox:checked+label').each(function() {
         tags.push($(this).text());
       });
       // showing count of tags in summary tab
-      $('a em', $tab).html('' + tags.length);
-      $tab
-        .removeClass($tab.attr('class').match(/(crm-count-\d+)/)[0])
-        .addClass('crm-count-' + tags.length);
+      CRM.updateTabCount('#tab_tag', tags.length);
       // update summary tab
       $("#tags").html(tags.join(', '));
     };
index a39b1b2d4c7f68f87edcc2124f00bc144216a48d..948bced38f77352ecb5d16c0efb1c0b2855e012a 100644 (file)
@@ -21,3 +21,11 @@ cj(function($) {
     })
     .tabs(tabSettings);
 });
+(function($) {
+  CRM.updateTabCount = function(tab, count) {
+    $(tab)
+      .removeClass($(tab).attr('class').match(/(crm-count-\d+)/)[0])
+      .addClass('crm-count-' + count)
+      .find('a em').html('' + count);
+  }
+})(cj);