From dd0d788380419a89a310a3972b28d7cc08f584f9 Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Tue, 28 Jun 2016 17:18:03 +0300
Subject: [PATCH] Lightbox Non-JS, init and translation fixes (#743)

Add a heading for the lightbox facet list, init lightbox_facets js only if available and translate 'more' properly in JS.
---
 .../src/VuFind/Controller/AbstractSearch.php    |  3 +++
 themes/bootstrap3/templates/layout/layout.phtml |  7 +++++--
 .../templates/search/facet-list.phtml           | 17 ++++++++++-------
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/module/VuFind/src/VuFind/Controller/AbstractSearch.php b/module/VuFind/src/VuFind/Controller/AbstractSearch.php
index b0a7da3c531..922987af7a0 100644
--- a/module/VuFind/src/VuFind/Controller/AbstractSearch.php
+++ b/module/VuFind/src/VuFind/Controller/AbstractSearch.php
@@ -735,12 +735,15 @@ class AbstractSearch extends AbstractBase
             $this->params()->fromQuery('facetop', 'AND') == 'OR'
         );
         $list = $facets[$facet]['data']['list'];
+        $params->activateAllFacets();
+        $facetLabel = $params->getFacetLabel($facet);
 
         $view = $this->createViewModel(
             [
                 'data' => $list,
                 'exclude' => $this->params()->fromQuery('facetexclude', 0),
                 'facet' => $facet,
+                'facetLabel' => $facetLabel,
                 'operator' => $this->params()->fromQuery('facetop', 'AND'),
                 'page' => $page,
                 'results' => $results,
diff --git a/themes/bootstrap3/templates/layout/layout.phtml b/themes/bootstrap3/templates/layout/layout.phtml
index d21b224333a..dc37ae8fc8c 100644
--- a/themes/bootstrap3/templates/layout/layout.phtml
+++ b/themes/bootstrap3/templates/layout/layout.phtml
@@ -45,8 +45,11 @@
             'libphonenumber_tooshort' => 'libphonenumber_tooshort',
             'libphonenumber_tooshortidd' => 'libphonenumber_tooshortidd',
             'loading' => 'Loading',
-            'sms_success' => 'sms_success',
-            'number_thousands_separator' => ['number_thousands_separator', null, ',']
+            'more' => 'more',
+            'number_thousands_separator' => [
+                'number_thousands_separator', null, ','
+            ],
+            'sms_success' => 'sms_success'
           )
         );
         // Add libphonenumber.js strings
diff --git a/themes/bootstrap3/templates/search/facet-list.phtml b/themes/bootstrap3/templates/search/facet-list.phtml
index cb070b85ad5..97c859d65d3 100644
--- a/themes/bootstrap3/templates/search/facet-list.phtml
+++ b/themes/bootstrap3/templates/search/facet-list.phtml
@@ -7,15 +7,18 @@
   }
   $urlBase = $this->url($facetLightbox) . $results->getUrlQuery()->getParams() . '&amp;facet=' . urlencode($this->facet) . '&amp;facetexclude=' . $this->exclude . '&amp;facetop=' . $this->operator;
 ?>
+<h2><?=$this->transEsc($this->facetLabel) ?></h2>
 <? if (count($this->sortOptions) > 1): ?>
-  <label><?=$this->translate('Sort') ?></label>
-  <div class="btn-group">
-    <? foreach ($this->sortOptions as $key=>$sort): ?>
-      <a href="<?=$urlBase . '&amp;facetpage=1&amp;facetsort=' . urlencode($key) ?>" class="btn btn-default js-facet-sort<? if($this->sort == $key): ?> active<? endif; ?>" data-sort="<?=$key ?>" data-lightbox-ignore><?=$this->translate($sort) ?></a>
-    <? endforeach; ?>
+  <div class="full-facet-sort-options">
+    <label><?=$this->translate('Sort') ?></label>
+    <div class="btn-group">
+      <? foreach ($this->sortOptions as $key=>$sort): ?>
+        <a href="<?=$urlBase . '&amp;facetpage=1&amp;facetsort=' . urlencode($key) ?>" class="btn btn-default js-facet-sort<? if($this->sort == $key): ?> active<? endif; ?>" data-sort="<?=$key ?>" data-lightbox-ignore><?=$this->translate($sort) ?></a>
+      <? endforeach; ?>
+    </div>
   </div>
 <? endif; ?>
-<div class="lightbox-scroll">
+<div class="lightbox-scroll full-facets">
   <? foreach ($this->sortOptions as $key=>$sort): ?>
     <? $active = $this->sort == $key; ?>
     <div class="full-facet-list list-group<? if(!$active): ?> hidden<? endif; ?>" id="facet-list-<?=$this->escapeHtmlAttr($key) ?>">
@@ -69,4 +72,4 @@
   <? endforeach; ?>
 </div>
 <button class="btn btn-default lightbox-only" data-dismiss="modal"><?=$this->translate('close') ?></button>
-<?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, 'VuFind.lightbox_facets.setup();', 'SET'); ?>
+<?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, '(typeof VuFind.lightbox_facets !== "undefined") && VuFind.lightbox_facets.setup();', 'SET'); ?>
-- 
GitLab