CRM-12337 - Encapsulate menu within a script
[civicrm-core.git] / templates / CRM / common / Navigation.tpl
index 3a0e5083d6713c3425bc64391f09d14caaa18939..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">
         </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);
@@ -119,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 () {
@@ -136,9 +136,10 @@ cj(function( ) {
   // 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'});
   }
 
@@ -150,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}