Skip to content

Commit

Permalink
Merge branch 'hcu-9' of github.com:qcovery/core into hcu-9
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-stoehr committed Oct 5, 2023
2 parents a2aab91 + bf9d636 commit fd1430c
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 11 deletions.
2 changes: 1 addition & 1 deletion module/DependentWorks
13 changes: 9 additions & 4 deletions themes/belugax/templates/layout/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
'rel' => 'search'
]
);
// We need to generate the icons early, because they may add some stylesheets;
// if we render them after the headLink / headStyle calls, some dependencies
// may not load correctly. Thus, we render early, but use this later.
$icons = !isset($this->renderingError) ? $this->render('js-icons.phtml') : '{}';
?>
<!-- RTL styling -->
<? if ($this->layout()->rtl) {
Expand Down Expand Up @@ -113,10 +117,11 @@
$translations = $this->jsTranslations()->getJSON();
$dsb = DEFAULT_SEARCH_BACKEND;
$setupJS = <<<JS
VuFind.path = '{$root}';
VuFind.defaultSearchBackend = '{$dsb}';
VuFind.addTranslations({$translations});
JS;
VuFind.path = '{$root}';
VuFind.defaultSearchBackend = '{$dsb}';
VuFind.addTranslations({$translations});
VuFind.addIcons({$icons});
JS;
$this->headScript()->appendScript($setupJS);
?>
<?=$this->headScript()?>
Expand Down
2 changes: 1 addition & 1 deletion themes/belugax/templates/search/searchbox.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$searchType = $this->searchType;

if ($this->lookfor == '') {
if ($_GET['lookfor']) {
if (!empty($_GET['lookfor'])) {
$this->lookfor = $_GET['lookfor'];
foreach($keywords as $identifier => $type) {
$this->lookfor = str_replace($type.":",$identifier." ",$this->lookfor);
Expand Down
48 changes: 48 additions & 0 deletions themes/belugax_hcu/js/missing.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,51 @@ function lessFacets(id) {
$('#more-' + id).removeClass('hidden');
return false;
}

function setupAutocomplete() {
// If .autocomplete class is missing, autocomplete is disabled and we should bail out.
var searchbox = $('#searchForm_lookfor.autocomplete');
if (searchbox.length < 1) {
return;
}
// Search autocomplete
searchbox.autocomplete({
rtl: $(document.body).hasClass("rtl"),
maxResults: 10,
loadingString: VuFind.translate('loading') + '...',
handler: function vufindACHandler(input, cb) {
var query = input.val();
var searcher = extractClassParams(input);
var hiddenFilters = [];
$('#searchForm').find('input[name="hiddenFilters[]"]').each(function hiddenFiltersEach() {
hiddenFilters.push($(this).val());
});
$.fn.autocomplete.ajax({
url: VuFind.path + '/AJAX/JSON',
data: {
q: query,
method: 'getACSuggestions',
searcher: searcher.searcher,
type: searcher.type ? searcher.type : $('#searchForm_type').val(),
hiddenFilters: hiddenFilters
},
dataType: 'json',
success: function autocompleteJSON(json) {
if (json.data.suggestions.length > 0) {
var datums = [];
for (var j = 0; j < json.data.suggestions.length; j++) {
datums.push(json.data.suggestions[j]);
}
cb(datums);
} else {
cb([]);
}
}
});
}
});
// Update autocomplete on type change
$('#searchForm_type').change(function searchTypeChange() {
searchbox.autocomplete().clearCache();
});
}
13 changes: 9 additions & 4 deletions themes/belugax_hcu/templates/layout/layout.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
'rel' => 'search'
]
);
// We need to generate the icons early, because they may add some stylesheets;
// if we render them after the headLink / headStyle calls, some dependencies
// may not load correctly. Thus, we render early, but use this later.
$icons = !isset($this->renderingError) ? $this->render('js-icons.phtml') : '{}';
?>
<!-- RTL styling -->
<? if ($this->layout()->rtl) {
Expand Down Expand Up @@ -114,10 +118,11 @@
$translations = $this->jsTranslations()->getJSON();
$dsb = DEFAULT_SEARCH_BACKEND;
$setupJS = <<<JS
VuFind.path = '{$root}';
VuFind.defaultSearchBackend = '{$dsb}';
VuFind.addTranslations({$translations});
JS;
VuFind.path = '{$root}';
VuFind.defaultSearchBackend = '{$dsb}';
VuFind.addTranslations({$translations});
VuFind.addIcons({$icons});
JS;
$this->headScript()->appendScript($setupJS);
?>
<?=$this->headScript()?>
Expand Down
2 changes: 1 addition & 1 deletion themes/belugax_hcu/templates/search/searchbox.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$searchType = $this->searchType;

if ($this->lookfor === '') {
if ($_GET['lookfor']) {
if (!empty($_GET['lookfor'])) {
$this->lookfor = $_GET['lookfor'];
if (isset($keywords) && is_array($keywords)) {
foreach ($keywords as $identifier => $type) {
Expand Down

0 comments on commit fd1430c

Please sign in to comment.