CRM-15705 - Fix menu closing
[civicrm-core.git] / templates / CRM / common / navigation.js.tpl
index 05c8c53d0c3a8e54bcfda052343156f7f0a21b1d..553e248b9d9d8fcb1d7a430230177f668eaa50a2 100644 (file)
@@ -1,6 +1,6 @@
 {*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -32,7 +32,7 @@
             <input type="text" class="form-text" id="sort_name_navigation" placeholder="{ts}Find Contacts{/ts}" name="sort_name" style="width: 12em;" />
             <input type="text" id="sort_contact_id" style="display: none" />
             <input type="hidden" name="hidden_location" value="1" />
-            <input type="hidden" name="qfKey" value="{crmKey name='CRM_Contact_Controller_Search' addSequence=1}" />
+            <input type="hidden" name="qfKey" value="" />
             <div style="height:1px; overflow:hidden;"><input type="submit" value="{ts}Go{/ts}" name="_qf_Advanced_refresh" class="crm-form-submit default" /></div>
           </div>
         </form>
@@ -80,6 +80,9 @@
     $("#crm-nav-menu-container").html(menuMarkup).css({'padding-bottom': '10px'});
   }
 {/literal}{/if}{literal}
+  // CRM-15493 get the current qfKey
+  $("input[name=qfKey]", "#quickSearch").val($('#civicrm-navigation-menu').data('qfkey'));
+
 $('#civicrm-menu').ready(function() {
   $('#root-menu-div .outerbox').css({'margin-top': '6px'});
   $('#root-menu-div .menu-ul li').css({'padding-bottom': '2px', 'margin-top': '2px'});
@@ -110,7 +113,7 @@ $('#civicrm-menu').ready(function() {
       },
       focus: function (event, ui){
         return false;
-      }, 
+      },
       select: function (event, ui) {
         document.location = CRM.url('civicrm/contact/view', {reset: 1, cid: ui.item.value});
         return false;
@@ -123,18 +126,21 @@ $('#civicrm-menu').ready(function() {
     .keydown(function() {
       $.Menu.closeAll();
     });
-  $('.crm-hidemenu').click(function() {
-    $.Menu.closeAll();
+  $('.crm-hidemenu').click(function(e) {
     $('#civicrm-menu').slideUp();
     if ($('#crm-notification-container').length) {
-      var alert = CRM.alert({/literal}'<a href="#" id="crm-restore-menu">{ts escape='js'}Restore Menu{/ts}</a>', "{ts escape='js'}CiviCRM Menu Hidden{/ts}"{literal});
-      $('#crm-restore-menu').button({icons: {primary: 'ui-icon-arrowreturnthick-1-w'}}).click(function(e) {
-        e.preventDefault();
-        alert.close();
-        $('#civicrm-menu').slideDown();
-      });
+      var alert = CRM.alert({/literal}'<a href="#" id="crm-restore-menu" style="text-align: center; margin-top: -8px;">{ts escape='js'}Restore CiviCRM Menu{/ts}</a>'{literal}, '', 'none', {expires: 10000});
+      $('#crm-restore-menu')
+        .button({icons: {primary: 'ui-icon-arrowreturnthick-1-w'}})
+        .click(function(e) {
+          e.preventDefault();
+          alert.close();
+          $('#civicrm-menu').slideDown();
+        })
+        .parent().css('text-align', 'center').find('.ui-button-text').css({'padding-top': '4px', 'padding-bottom': '4px'})
+      ;
     }
-    return false;
+    e.preventDefault();
   });
   $('.crm-quickSearchField').click(function() {
     var label = $(this).text();
@@ -154,6 +160,8 @@ $('#civicrm-menu').ready(function() {
       return false;
     }
   });
+  // Close menu after selecting an item
+  $('#root-menu-div').on('click', 'a', $.Menu.closeAll);
 });
 $('#civicrm-menu').menuBar({arrowSrc: CRM.config.resourceBase + 'packages/jquery/css/images/arrow.png'});
 })(CRM.$);{/literal}