CRM-12337 - Encapsulate menu within a script
[civicrm-core.git] / templates / CRM / common / Navigation.tpl
index 824c70ba2f606586c01bdbff6b7fad0685e35b7c..0fc7fe06c331413e57c1f2f190803066e2e6b983 100644 (file)
@@ -1,6 +1,6 @@
 {*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -23,8 +23,8 @@
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
 *}
-<div id="menu-container" style="display:none;">
-    <ul id="civicrm-menu">
+{capture assign=menuMarkup}
+  <ul id="civicrm-menu">
       {if call_user_func(array('CRM_Core_Permission','giveMeAllACLs'))}
         <li id="crm-qsearch" class="menumain crm-link-home">
             <form action="{crmURL p='civicrm/contact/search/advanced' h=0 }" name="search_block" id="id_search_block" method="post">
@@ -38,7 +38,7 @@
             </form>
           <ul>
             <li><label class="crm-quickSearchField"><input type="radio" checked="" data-tablename="cc" checked="checked" value="" name="quickSearchField">{ts}Name/Email{/ts}</label></li>
-            <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="id" name="quickSearchField">{ts}CiviCRM ID{/ts}</label></li>
+            <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="contact_id" name="quickSearchField">{ts}CiviCRM ID{/ts}</label></li>
             <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="external_identifier" name="quickSearchField">{ts}External ID{/ts}</label></li>
             <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="first_name" name="quickSearchField">{ts}First Name{/ts}</label></li>
             <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="last_name" name="quickSearchField">{ts}Last Name{/ts}</label></li>
         </li>
       {/if}
       {$navigation}
-    </ul>
-</div>
-
+    </ul>{/capture}
 {literal}
 <script type="text/javascript">
+(function($) {
+  var menuMarkup = {/literal}{$menuMarkup|@json_encode}{literal};
 cj(function( ) {
   cj("#civicrm-menu >li").each(function(i){
     cj(this).attr("tabIndex",i+2);
@@ -70,9 +70,8 @@ cj(function( ) {
       minChars: 1,
       matchContains: true,
       delay: 400,
-      max: CRM.config.search_autocomplete_count,
+      max: {/literal}{crmSetting name="search_autocomplete_count" group="Search Preferences"}{literal},
       extraParams:{
-        limit: CRM.config.search_autocomplete_count,
         fieldName:function () {
           return  cj('input[name=quickSearchField]:checked').val();
         },
@@ -120,8 +119,8 @@ cj(function( ) {
   });
 });
 
-{/literal}{if $config->userFramework neq 'Joomla'}{literal}
-  cj('body').prepend( cj("#menu-container").html() );
+{/literal}{if $config->userFramework neq 'Joomla' and $config->userFrameworkFrontend ne 1}{literal}
+  cj('body').prepend(menuMarkup);
 
   //Track Scrolling
   cj(window).scroll( function () {
@@ -133,16 +132,17 @@ cj(function( ) {
   if ( cj('#edit-shortcuts').length > 0 ) {
      cj('#civicrm-menu').css({ 'width': '97%' });
   }
-{/literal}{else}{* Special menu hacks for Joomla *}{literal}
+{/literal}{elseif $config->userFrameworkFrontend ne 1}{* Special menu hacks for Joomla *}{literal}
   // below div is present in older version of joomla 2.5.x
   var elementExists = cj('div#toolbar-box div.m').length;
   if ( elementExists > 0 ) {
-    cj('div#toolbar-box div.m').html(cj("#menu-container").html());
+    cj('div#toolbar-box div.m').html(menuMarkup);
   }
   else {
+    // Fixme
     cj("#menu-container").show().css({'padding-bottom': '10px'});
   }
-  
+
   cj('#civicrm-menu').ready(function() {
     cj('#root-menu-div .outerbox').css({ 'margin-top': '6px'});
     cj('#root-menu-div .outerbox').first().css({ 'margin-top': '20px'});
@@ -151,5 +151,6 @@ cj(function( ) {
   });
   {/literal}{/if}{literal}
   cj('#civicrm-menu').menu( {arrowSrc: CRM.config.resourceBase + 'packages/jquery/css/images/arrow.png'} );
+})(cj);
 </script>
 {/literal}