From 91a8c4ae117722a8ac7fa710528e001330aa1efb Mon Sep 17 00:00:00 2001 From: Dorian Merz <merz@ub.uni-leipzig.de> Date: Wed, 12 Jun 2019 13:08:32 +0200 Subject: [PATCH] refs #15362 [fid_bbi] back to result list * adds back link on details view * adds jump marks in result list * jumps back to correct position * avoid hyphenation ** set hyphens: none for all elements ** avoids ugly line breaks in details table co-authored by: Claas Kazzer <kazzer@ub.uni-leipzig.de> --- fid_bbi/languages/de.ini | 1 + fid_bbi/languages/en.ini | 1 + .../src/fid_bbi/View/Helper/Root/Factory.php | 14 +++++ .../fid_bbi/View/Helper/Root/SearchMemory.php | 60 +++++++++++++++++++ themes/fid_bbi/scss/compiled.scss | 21 ++++++- themes/fid_bbi/templates/record/view.phtml | 3 + .../fid_bbi/templates/search/list-list.phtml | 1 + themes/fid_bbi/theme.config.php | 1 + 8 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 module/fid_bbi/src/fid_bbi/View/Helper/Root/SearchMemory.php diff --git a/fid_bbi/languages/de.ini b/fid_bbi/languages/de.ini index 74455d3c42c..d3602757f6f 100644 --- a/fid_bbi/languages/de.ini +++ b/fid_bbi/languages/de.ini @@ -2251,3 +2251,4 @@ AAAAA= "keine der angegebenen Bibliotheken" BBI Welcome = Sehr geehrte Nutzerin, sehr geehrter Nutzer, wir freuen uns, dass Sie unsere Dienste ab sofort nutzen möchten. Ein Mitarbeiter des Fachinformationsdienstes wird sich mit Ihnen in Verbindung setzen. Nach erfolgter Registrierung können Sie die erweiterten Funktionalitäten des Portals nutzen. Für Rückfragen stehen wir Ihnen unter der Mailadresse info@fid-bbi.de jederzeit zur Verfügung. +back_to_result_list = "Zurück zur Suche" \ No newline at end of file diff --git a/fid_bbi/languages/en.ini b/fid_bbi/languages/en.ini index bd679f1863f..abe35292ecc 100644 --- a/fid_bbi/languages/en.ini +++ b/fid_bbi/languages/en.ini @@ -2184,3 +2184,4 @@ AAAAA= "None of the Specified Libraries" BBI Welcome = Sehr geehrte Nutzerin, sehr geehrter Nutzer, wir freuen uns, dass Sie unsere Dienste ab sofort nutzen möchten. Ein Mitarbeiter des Fachinformationsdienstes wird sich mit Ihnen in Verbindung setzen. Nach erfolgter Registrierung können Sie die erweiterten Funktionalitäten des Portals nutzen. Für Rückfragen stehen wir Ihnen unter der Mailadresse info@fid-bbi.de jederzeit zur Verfügung. +back_to_result_list = "Back to Search" \ No newline at end of file diff --git a/module/fid_bbi/src/fid_bbi/View/Helper/Root/Factory.php b/module/fid_bbi/src/fid_bbi/View/Helper/Root/Factory.php index a004040538a..8b96f55de72 100644 --- a/module/fid_bbi/src/fid_bbi/View/Helper/Root/Factory.php +++ b/module/fid_bbi/src/fid_bbi/View/Helper/Root/Factory.php @@ -65,4 +65,18 @@ class Factory return $return; } + + /** + * Construct the Record helper. + * + * @param ContainerInterface $container Service manager. + * + * @return SearchMemory + */ + public static function getSearchMemory(ContainerInterface $container) + { + return new SearchMemory( + $container->get('VuFind\Search\Memory') + ); + } } diff --git a/module/fid_bbi/src/fid_bbi/View/Helper/Root/SearchMemory.php b/module/fid_bbi/src/fid_bbi/View/Helper/Root/SearchMemory.php new file mode 100644 index 00000000000..537ec2f77e4 --- /dev/null +++ b/module/fid_bbi/src/fid_bbi/View/Helper/Root/SearchMemory.php @@ -0,0 +1,60 @@ +<?php +/** + * View helper for remembering recent user searches/parameters. + * + * PHP version 7 + * + * Copyright (C) Villanova University 2010. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * @category VuFind + * @package View_Helpers + * @author Dorian Merz <merz@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ +namespace fid_bbi\View\Helper\Root; + +/** + * View helper for remembering recent user searches/parameters. + * + * @category VuFind + * @package View_Helpers + * @author Dorian Merz <merz@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ +class SearchMemory extends \VuFind\View\Helper\Root\SearchMemory +{ + /** + * If a previous search is recorded in the session, return a link to it; + * otherwise, return a blank string. + * + * @param string $link Text to use as body of link + * @param string $prefix Text to place in front of link + * @param string $suffix Text to place after link + * + * @return string + */ + public function getAnchoredSearchLink($label, $anchor) + { + $last = $this->memory->retrieveSearch(); + if (!empty($last)) { + $escaper = $this->getView()->plugin('escapeHtml'); + return '<a href="' . $escaper($last.'#'.$anchor) . '">' . $label . '</a>'; + } + return ''; + } +} diff --git a/themes/fid_bbi/scss/compiled.scss b/themes/fid_bbi/scss/compiled.scss index fb1c705927f..1fa8a65020c 100644 --- a/themes/fid_bbi/scss/compiled.scss +++ b/themes/fid_bbi/scss/compiled.scss @@ -4,7 +4,7 @@ // General body { - hyphens: auto; + hyphens: none; // Padding to make sure header with "keep filters" doesn't overlap breadcrumbs padding-top: 120px; } @@ -386,4 +386,23 @@ footer { color: $brand-primary-light; } } +} + +// Add jump-save padding to result IDs +[id*='jump'] { + content: ''; + display: block; + height: 120px; + margin-top: -120px; + visibility: hidden; + + @media screen and (max-width: $screen-xs-max) { + height: $navbar-height-xs; + margin-top: -$navbar-height-xs; + } + + @media screen and (min-width: $screen-sm-min) and (max-width: $screen-sm-max) { + height: $navbar-height-sm; + margin-top: -$navbar-height-sm; + } } \ No newline at end of file diff --git a/themes/fid_bbi/templates/record/view.phtml b/themes/fid_bbi/templates/record/view.phtml index cd9edc4d693..f48b6a92553 100644 --- a/themes/fid_bbi/templates/record/view.phtml +++ b/themes/fid_bbi/templates/record/view.phtml @@ -19,6 +19,9 @@ $this->layout()->breadcrumbs = '<li>' . $this->searchMemory()->getLastSearchLink $this->layout()->title = $this->driver->getShortTitle(); ?> +<?php if (isset($this->scrollData) && isset($this->scrollData['currentPosition'])): ?> + <?=$this->searchMemory()->getAnchoredSearchLink($this->transEsc('back_to_result_list'),'jump'.$this->scrollData['currentPosition'])?> +<?php endif; ?> <?php if (isset($this->scrollData) && ($this->scrollData['previousRecord'] || $this->scrollData['nextRecord'])): ?> <?php /* Pager is identical to pager in collection - view! diff --git a/themes/fid_bbi/templates/search/list-list.phtml b/themes/fid_bbi/templates/search/list-list.phtml index fc7f1367725..b5b87b28afd 100644 --- a/themes/fid_bbi/templates/search/list-list.phtml +++ b/themes/fid_bbi/templates/search/list-list.phtml @@ -3,6 +3,7 @@ <?php $i = $this->indexStart; ?> <?php foreach ($this->results->getResults() as $current): ?> <?php $recordNumber = $this->results->getStartRecord() + $i - $this->indexStart; ?> + <span id="jump<?=$recordNumber?>"></span> <div id="result<?=$i++ ?>" class="result<?=$current->supportsAjaxStatus()?' ajaxItem':''?>"> <?php if (isset($this->showCheckboxes) && $this->showCheckboxes): ?> <?=$this->record($current)->getCheckbox('', 'search-cart-form', $recordNumber)?> diff --git a/themes/fid_bbi/theme.config.php b/themes/fid_bbi/theme.config.php index 1c983fd3140..5c5b31ecd37 100644 --- a/themes/fid_bbi/theme.config.php +++ b/themes/fid_bbi/theme.config.php @@ -8,6 +8,7 @@ return [ 'fid_bbi\View\Helper\Root\Factory::getRecord', 'VuFind\View\Helper\Root\RecordDataFormatter' => 'fid_bbi\View\Helper\Root\RecordDataFormatterFactory', + 'VuFind\View\Helper\Root\SearchMemory' => 'fid_bbi\View\Helper\Root\Factory::getSearchMemory' ), ), ]; -- GitLab