diff --git a/module/DependentWorks b/module/DependentWorks index 88f18ff91..b5042fac9 160000 --- a/module/DependentWorks +++ b/module/DependentWorks @@ -1 +1 @@ -Subproject commit 88f18ff91409d915f4ea785a15ca476586e1ad31 +Subproject commit b5042fac94ffeba153b4ff3596fd886562b1dd6a diff --git a/themes/belugax/templates/layout/layout.phtml b/themes/belugax/templates/layout/layout.phtml index 34bb2cce2..0724778dd 100755 --- a/themes/belugax/templates/layout/layout.phtml +++ b/themes/belugax/templates/layout/layout.phtml @@ -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') : '{}'; ?> layout()->rtl) { @@ -113,10 +117,11 @@ $translations = $this->jsTranslations()->getJSON(); $dsb = DEFAULT_SEARCH_BACKEND; $setupJS = <<headScript()->appendScript($setupJS); ?> headScript()?> diff --git a/themes/belugax/templates/search/searchbox.phtml b/themes/belugax/templates/search/searchbox.phtml index 650d11bb4..ef54d160d 100755 --- a/themes/belugax/templates/search/searchbox.phtml +++ b/themes/belugax/templates/search/searchbox.phtml @@ -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); diff --git a/themes/belugax_hcu/js/missing.js b/themes/belugax_hcu/js/missing.js index 25d49aa66..873780d35 100644 --- a/themes/belugax_hcu/js/missing.js +++ b/themes/belugax_hcu/js/missing.js @@ -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(); + }); +} diff --git a/themes/belugax_hcu/templates/layout/layout.phtml b/themes/belugax_hcu/templates/layout/layout.phtml index 654d3d4c3..623e74366 100755 --- a/themes/belugax_hcu/templates/layout/layout.phtml +++ b/themes/belugax_hcu/templates/layout/layout.phtml @@ -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') : '{}'; ?> layout()->rtl) { @@ -114,10 +118,11 @@ $translations = $this->jsTranslations()->getJSON(); $dsb = DEFAULT_SEARCH_BACKEND; $setupJS = <<headScript()->appendScript($setupJS); ?> headScript()?> diff --git a/themes/belugax_hcu/templates/search/searchbox.phtml b/themes/belugax_hcu/templates/search/searchbox.phtml index 44ffaf5cc..2419fa387 100755 --- a/themes/belugax_hcu/templates/search/searchbox.phtml +++ b/themes/belugax_hcu/templates/search/searchbox.phtml @@ -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) {