Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const globalSearch = doc.querySelector('.ibexa-global-search');
const { getJsonFromResponse } = ibexa.helpers.request;
const { showErrorNotification } = ibexa.helpers.notification;
const { isShortcutWithLetter } = ibexa.helpers.system;
const { minQueryLength, resultLimit } = ibexa.adminUiConfig.suggestions;

if (!globalSearch) {
Expand Down Expand Up @@ -142,7 +143,13 @@
removeClickOutsideEventListener();
removeKeyboardEventListener();
};
const focusSearch = (event) => {
if (isShortcutWithLetter(event, '/')) {
globalSearchInput.focus();
}
};

globalSearchInput.addEventListener('keyup', handleTyping, false);
clearBtn.addEventListener('click', hideAutocomplete, false);
doc.addEventListener('keydown', focusSearch, false);
})(window, document, window.ibexa, window.Routing, window.Translator);
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,6 @@
isPastePressed,
isPrintPressed,
isSelectAllPressed,
isShortcutWithLetter,
});
})(window, window.document, window.ibexa);
10 changes: 10 additions & 0 deletions src/bundle/Resources/public/scss/_global-search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,14 @@
}
}
}

&__shortcut {
display: inline-block;
line-height: calculateRem(21px);
font-size: $ibexa-text-font-size-medium;
padding: 0 calculateRem(4px);
background-color: $ibexa-color-light-300;
border-radius: calculateRem(4px);
font-weight: 400;
}
}
5 changes: 5 additions & 0 deletions src/bundle/Resources/translations/ibexa_search.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<target state="new">View all results</target>
<note>key: autocomplete.view_all_results</note>
</trans-unit>
<trans-unit id="75d6d16d28be17ef015b223c19696f17e99f2be3" resname="global_search.focus.hint">
<source>Search</source>
<target state="new">Search</target>
<note>key: global_search.focus.hint</note>
</trans-unit>
<trans-unit id="7100bfb6741e032fcfcc681f3eceef78650e4672" resname="header.search">
<source>Search...</source>
<target state="new">Search...</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
{% trans_default_domain 'ibexa_search' %}

<div class="ibexa-global-search">
{% set is_mac = 'Mac OS X' in app.request.headers.get('user-agent') %}
{% set shortcut = is_mac ? '⌘ + /' : 'Ctrl + /' %}
{% set shortcut_title = 'global_search.focus.hint'|trans|desc('Search') ~ ' <span class="ibexa-global-search__shortcut">' ~ shortcut ~ '</span>' %}

{{ form_start(form, { attr: { class: 'form-inline', id: 'ibexa-global-search-form' }}) }}
{{ form_widget(form.query, {
attr: {
class: 'ibexa-global-search__input',
placeholder: 'header.search'|trans|desc('Search...'),
autocomplete: "off"
autocomplete: "off",
title: shortcut_title,
'data-tooltip-use-html': true,
'data-tooltip-trigger': 'hover',
}
}) }}
{{ form_end(form) }}
Expand Down