From b8e865c7952a954a485d7fbebf29d3aa90edc9cc Mon Sep 17 00:00:00 2001 From: Robert Lange <robert.lange@uni-leipzig.de> Date: Fri, 10 Jan 2020 15:13:47 +0100 Subject: [PATCH] refs #16706 [fid_adlr] fix favorites in themes * remove redundant saved favorites from detail view for core template of ** SolrDefault ** SolrAI ** SolarMarc * show saved list when loaded on mobile too * favorites / star icon: replace awesome font icon by iconmoon in result list * override vufind js method to display filled star icon when item has been saved to favorites / personal list * hide favorites / saved lists on result view * also hidden on detail for mobile (vufind default behaviour) --- themes/fid_adlr/js/check_save_statuses_adlr.js | 16 ++++++++++++++++ themes/fid_adlr/scss/compiled.scss | 7 +++++++ .../RecordDriver/DefaultRecord/core.phtml | 4 ---- .../RecordDriver/DefaultRecord/result-list.phtml | 2 +- .../templates/RecordDriver/SolrAI/core.phtml | 4 ---- .../RecordDriver/SolrAI/result-list.phtml | 2 +- .../templates/RecordDriver/SolrMarc/core.phtml | 4 ---- themes/fid_adlr/templates/record/view.phtml | 1 + themes/fid_adlr/templates/search/results.phtml | 1 + 9 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 themes/fid_adlr/js/check_save_statuses_adlr.js diff --git a/themes/fid_adlr/js/check_save_statuses_adlr.js b/themes/fid_adlr/js/check_save_statuses_adlr.js new file mode 100644 index 00000000000..91091bc2a9d --- /dev/null +++ b/themes/fid_adlr/js/check_save_statuses_adlr.js @@ -0,0 +1,16 @@ +function displaySaveStatus(itemLists, $item) { + if (itemLists.length > 0) { + // If we got lists back, display them! + var html = '<ul>' + itemLists.map(function convertToLi(l) { + return '<li><a href="' + l.list_url + '">' + htmlEncode(l.list_title) + '</a></li>'; + }).join('') + '</ul>'; + $item.find('.savedLists').addClass('loaded'); + $item.find('.js-load').replaceWith(html); + $item.find('.icon-star').removeClass('icon-star').addClass('icon-star-filled'); + } else { + // If we got nothing back, remove the pending status: + $item.find('.js-load').remove(); + } + // No matter what, clear the flag that we have a pending save: + $item.removeClass('js-save-pending'); +} diff --git a/themes/fid_adlr/scss/compiled.scss b/themes/fid_adlr/scss/compiled.scss index d5be0a89d28..1444a811f45 100644 --- a/themes/fid_adlr/scss/compiled.scss +++ b/themes/fid_adlr/scss/compiled.scss @@ -1707,9 +1707,16 @@ input.searchForm_lookfor { } .result-links { + .save-record, #toolbar-menu { color: $violet; } + + // #16706 dont show loaded favorites in result list + .savedLists.loaded { + display: none; + } + // move favorites and other icons to the right text-align: right; diff --git a/themes/fid_adlr/templates/RecordDriver/DefaultRecord/core.phtml b/themes/fid_adlr/templates/RecordDriver/DefaultRecord/core.phtml index 62a57b7e884..a57af5b8dcd 100644 --- a/themes/fid_adlr/templates/RecordDriver/DefaultRecord/core.phtml +++ b/themes/fid_adlr/templates/RecordDriver/DefaultRecord/core.phtml @@ -81,10 +81,6 @@ <?php elseif ($block = $this->permission()->getAlternateContent('feature.Favorites')): ?> <?=$block?> <?php endif; ?> - <?php /* Saved lists */ ?> - <div class="savedLists alert alert-info hidden"> - <strong><?=$this->transEsc("Saved in")?>:</strong> - </div> <?php endif; ?> </div> </div> diff --git a/themes/fid_adlr/templates/RecordDriver/DefaultRecord/result-list.phtml b/themes/fid_adlr/templates/RecordDriver/DefaultRecord/result-list.phtml index 12ae7ab2823..c13841cdad3 100644 --- a/themes/fid_adlr/templates/RecordDriver/DefaultRecord/result-list.phtml +++ b/themes/fid_adlr/templates/RecordDriver/DefaultRecord/result-list.phtml @@ -189,7 +189,7 @@ $i = 0; <?php if ($this->permission()->allowDisplay('feature.Favorites')): ?> <?php /* Add to favorites; finc: keep Icon inside link - CK */ ?> <a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Save')?>" data-lightbox class="save-record result-link-label" data-id="<?=$this->escapeHtmlAttr($this->driver->getUniqueId())?>" title="<?=$this->transEsc('Add to favorites')?>"> - <i class="fa fa-fw fa-star-o fa-2x" aria-hidden="true"></i> <span class="hidden-xs hidden-sm"><?/* =$this->transEsc('Add to favorites') */?></span> + <i class="icon icon-star icon-1.5x" aria-hidden="true"></i> <span class="hidden-xs hidden-sm"><?/* =$this->transEsc('Add to favorites') */?></span> </a><br/> <?php elseif ($block = $this->permission()->getAlternateContent('feature.Favorites')): ?> <?=$block?> diff --git a/themes/fid_adlr/templates/RecordDriver/SolrAI/core.phtml b/themes/fid_adlr/templates/RecordDriver/SolrAI/core.phtml index e651e7d0605..2037a043c58 100644 --- a/themes/fid_adlr/templates/RecordDriver/SolrAI/core.phtml +++ b/themes/fid_adlr/templates/RecordDriver/SolrAI/core.phtml @@ -84,10 +84,6 @@ <?php elseif ($block = $this->permission()->getAlternateContent('feature.Favorites')): ?> <?=$block?> <?php endif; ?> - <?php /* Saved lists */ ?> - <div class="savedLists alert alert-info hidden"> - <strong><?=$this->transEsc("Saved in")?>:</strong> - </div> <?php endif; ?> </div> </div> diff --git a/themes/fid_adlr/templates/RecordDriver/SolrAI/result-list.phtml b/themes/fid_adlr/templates/RecordDriver/SolrAI/result-list.phtml index 2f2b27d7b45..fc9ca125b07 100644 --- a/themes/fid_adlr/templates/RecordDriver/SolrAI/result-list.phtml +++ b/themes/fid_adlr/templates/RecordDriver/SolrAI/result-list.phtml @@ -159,7 +159,7 @@ if ($cover): <?php /* Add to favorites; finc: keep Icon inside link - CK */ ?> <a href="<?=$this->recordLink()->getActionUrl($this->driver, 'Save')?>" data-lightbox class="save-record result-link-label" data-id="<?=$this->escapeHtmlAttr($this->driver->getUniqueId())?>" title="<?=$this->transEsc('Add to favorites')?>"> - <i class="result-link-icon fa fa-fw fa-star-o fa-2x" aria-hidden="true"></i> <?/* =$this->transEsc('Add to favorites') */?> + <i class="result-link-icon icon icon-star icon-1.5x" aria-hidden="true"></i> <?/* =$this->transEsc('Add to favorites') */?> </a><br/> <?php elseif ($block = $this->permission()->getAlternateContent('feature.Favorites')): ?> <?=$block?> diff --git a/themes/fid_adlr/templates/RecordDriver/SolrMarc/core.phtml b/themes/fid_adlr/templates/RecordDriver/SolrMarc/core.phtml index e2e43d8b62e..2d2eb4cacad 100644 --- a/themes/fid_adlr/templates/RecordDriver/SolrMarc/core.phtml +++ b/themes/fid_adlr/templates/RecordDriver/SolrMarc/core.phtml @@ -83,10 +83,6 @@ <?php elseif ($block = $this->permission()->getAlternateContent('feature.Favorites')): ?> <?=$block?> <?php endif; ?> - <?php /* Saved lists */ ?> - <div class="savedLists alert alert-info hidden"> - <strong><?=$this->transEsc("Saved in")?>:</strong> - </div> <?php endif; ?> </div> </div> diff --git a/themes/fid_adlr/templates/record/view.phtml b/themes/fid_adlr/templates/record/view.phtml index bde5f9e3857..e256d75a228 100644 --- a/themes/fid_adlr/templates/record/view.phtml +++ b/themes/fid_adlr/templates/record/view.phtml @@ -3,6 +3,7 @@ // Set up standard record scripts: $this->headScript()->appendFile("record.js"); $this->headScript()->appendFile("check_save_statuses.js"); +$this->headScript()->appendFile("check_save_statuses_adlr.js"); // Activate Syndetics Plus if necessary: if ($this->syndeticsPlus()->isActive()) { $this->headScript()->appendFile($this->syndeticsPlus()->getScript()); diff --git a/themes/fid_adlr/templates/search/results.phtml b/themes/fid_adlr/templates/search/results.phtml index 780ef91a514..0973736e4bf 100644 --- a/themes/fid_adlr/templates/search/results.phtml +++ b/themes/fid_adlr/templates/search/results.phtml @@ -48,6 +48,7 @@ if ($this->params->getOptions()->getListViewOption() != "full") { $this->headScript()->appendFile("vendor/hunt.min.js"); $this->headScript()->appendFile("check_item_statuses.js"); $this->headScript()->appendFile("check_save_statuses.js"); +$this->headScript()->appendFile("check_save_statuses_adlr.js"); ?> <?php /* finc: we need search-results-col to pull content to full width, also used in print styles! - CK */?> -- GitLab