X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=js%2Fcrm.menubar.js;h=c75e38c5e5ba0f1e711433ebc4a747846d0f277d;hb=a9d11b7c6a89aa7d28872f02efa19b3d095c4660;hp=d28f0983498f6a908f41c5b3839575871977f3ba;hpb=5bbbc7fe1543094478ecc72fc60389db843371d7;p=civicrm-core.git diff --git a/js/crm.menubar.js b/js/crm.menubar.js index d28f098349..c75e38c5e5 100644 --- a/js/crm.menubar.js +++ b/js/crm.menubar.js @@ -314,6 +314,12 @@ }); }, focus: function (event, ui) { + // This is when an item is 'focussed' by keyboard up/down or mouse hover. + // It is not the same as actually having focus, i.e. it is not :focus + var lis = $(event.currentTarget).find('li[data-cid="' + ui.item.value + '"]'); + lis.children('div').addClass('ui-state-active'); + lis.siblings().children('div').removeClass('ui-state-active'); + // Returning false leaves the user-entered text as it was. return false; }, select: function (event, ui) { @@ -336,7 +342,34 @@ CRM.menubar.open('QuickSearch'); } } - }); + }) + .autocomplete( "instance" )._renderItem = function( ul, item ) { + var uiMenuItemWrapper = $("
"); + if (item.value == 0) { + // "No results" + uiMenuItemWrapper.text(item.label); + } + else { + uiMenuItemWrapper.append($('') + .attr('href', CRM.url('civicrm/contact/view', {reset: 1, cid: item.value})) + .css({ display: 'block' }) + .text(item.label) + .click(function(e) { + if (e.ctrlKey || e.shiftKey || e.altKey) { + // Special-clicking lets you open several tabs. + e.stopPropagation(); + } + else { + // Fall back to original behaviour. + e.preventDefault(); + } + })); + } + + return $( "
  • " ) + .append(uiMenuItemWrapper) + .appendTo( ul ); + }; $('#crm-qsearch > a').keyup(function(e) { if ($(e.target).is(this)) { $('#crm-qsearch-input').focus();