diff --git a/module/VuFind/src/VuFind/Controller/AjaxController.php b/module/VuFind/src/VuFind/Controller/AjaxController.php index 5c6a41c3c4f..33484cbd2a4 100644 --- a/module/VuFind/src/VuFind/Controller/AjaxController.php +++ b/module/VuFind/src/VuFind/Controller/AjaxController.php @@ -1334,4 +1334,26 @@ protected function getResultsManager() { return $this->getServiceLocator()->get('VuFind\SearchResultsPluginManager'); } + + /** + * Return all facet values for the total expansion module + * + * @return \Zend\Http\Response + */ + public function getAllFacetValuesAjax() { + $query = $this->getRequest()->getQuery(); + if(empty($query['facetFields'])) { + return $this->output($this->translate('Empty field'), self::STATUS_ERROR); + } + $sm = $this->getSearchManager(); + $params = $sm->setSearchClassId('Solr')->getParams(); + $params->initFromRequest($this->getRequest()->getQuery()); + foreach ($this->params()->fromQuery('hf', array()) as $hf) { + $params->getOptions()->addHiddenFilter($hf); + } + $results = $sm->setSearchClassId('Solr')->getResults($params); + $facets = $results->getFullFieldFacets($query['facetFields'], true, -1, 'count'); + + return $this->output($facets, self::STATUS_OK); + } } diff --git a/themes/blueprint/js/check_all_facets.js b/themes/blueprint/js/check_all_facets.js new file mode 100644 index 00000000000..2e9ee6bc5d8 --- /dev/null +++ b/themes/blueprint/js/check_all_facets.js @@ -0,0 +1,29 @@ +function loadAllFacets() { + var expandedFacets = ['authorStr','topic']; + var facet_length = facet_limit ?> | 0; + for(var j=0;jgetUrlQuery()->getParams()) ?>&method=getAllFacetValues&facetFields[]=' + encodeURIComponent(expandedFacets[j]); + $.getJSON(url, function (data) { + for(var i in data.data) { + var allFacets = { + 'label': data.data[i].data.label, + 'list' : data.data[i].data.list.slice(facet_length) + }; + if(allFacets.list.length > 0) { + var html = ''; + $(html).insertAfter('#narrowGroupHidden_'+allFacets.label); + $('#narrowGroupHidden_'+allFacets.label).append('
transEsc('all')?> ...
') + } + } + }); + } +} + +$(document).ready(function() { + loadAllFacets(); +}); \ No newline at end of file diff --git a/themes/blueprint/js/common.js b/themes/blueprint/js/common.js index 7b9a9f1473a..937cd11c064 100644 --- a/themes/blueprint/js/common.js +++ b/themes/blueprint/js/common.js @@ -36,6 +36,12 @@ function moreFacets(name) { function lessFacets(name) { $("#more"+name).show(); $("#narrowGroupHidden_"+name).addClass("offscreen"); + $("#allGroupHidden_"+name).addClass("offscreen"); +} + +function allFacets(name) { + $("#more"+name).hide(); + $("#allGroupHidden_"+name).removeClass("offscreen"); } function filterAll(element, formId) { diff --git a/themes/blueprint/templates/search/results.phtml b/themes/blueprint/templates/search/results.phtml index 5db2662f51a..d54f4316143 100644 --- a/themes/blueprint/templates/search/results.phtml +++ b/themes/blueprint/templates/search/results.phtml @@ -33,6 +33,7 @@ // Load Javascript dependencies into header: $this->headScript()->appendFile("check_item_statuses.js"); $this->headScript()->appendFile("check_save_statuses.js"); + $this->headScript()->appendFile("check_all_facets.js"); ?>
results->getResultTotal()) > 0): // only display these at very top if we have results ?> @@ -125,4 +126,3 @@
-