From b40894910c009269e1b95372e73c5697d4f7febb Mon Sep 17 00:00:00 2001 From: Chris Hallberg <crhallberg@gmail.com> Date: Tue, 24 Sep 2013 15:44:26 -0400 Subject: [PATCH] Blueprint advanced facets front. --- themes/blueprint/css/styles.css | 4 ++++ themes/blueprint/js/common.js | 22 +++++++++++++++++++ .../templates/Recommend/SideFacets.phtml | 6 ++--- .../blueprint/templates/layout/layout.phtml | 7 +++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/themes/blueprint/css/styles.css b/themes/blueprint/css/styles.css index 2f0b1a9b02b..f6d9298cc14 100644 --- a/themes/blueprint/css/styles.css +++ b/themes/blueprint/css/styles.css @@ -530,6 +530,10 @@ dl.narrowList a { padding:0.2em 0.4em; background-color: #eee; } +dd input[type="checkbox"] { + margin:0 4px 0 0; + vertical-align:text-bottom; +} /* Icon Classes */ diff --git a/themes/blueprint/js/common.js b/themes/blueprint/js/common.js index 07209f28afc..575594db7c5 100644 --- a/themes/blueprint/js/common.js +++ b/themes/blueprint/js/common.js @@ -277,6 +277,25 @@ function extractSource(element) return x.length == 0 ? 'VuFind' : x; } +// Advanced facets +function updateOrFacets(url, op) { + window.location.assign(url); + var list = $(op).parents('dl'); + var header = $(list).find('dt'); + list.html(header[0].outerHTML+'<div class="info">'+vufindString.loading+'...</div>'); +} +function setupOrFacets() { + var facets = $('.facetOR'); + for(var i=0;i<facets.length;i++) { + $facet = $(facets[i]); + if($facet.hasClass('applied')) { + $facet.prepend('<input type="checkbox" checked onChange="updateOrFacets($(this).parent().attr(\'href\'), this)"/>'); + } else { + $facet.before('<input type="checkbox" onChange="updateOrFacets($(this).next(\'a\').attr(\'href\'), this)"/>'); + } + } +} + $(document).ready(function(){ // initialize autocomplete initAutocomplete(); @@ -351,4 +370,7 @@ $(document).ready(function(){ //ContextHelp contextHelp.init(); contextHelp.contextHelpSys.load(); + + // Advanced facets + setupOrFacets(); }); \ No newline at end of file diff --git a/themes/blueprint/templates/Recommend/SideFacets.phtml b/themes/blueprint/templates/Recommend/SideFacets.phtml index 2755db07470..ac4573f3ee8 100644 --- a/themes/blueprint/templates/Recommend/SideFacets.phtml +++ b/themes/blueprint/templates/Recommend/SideFacets.phtml @@ -63,12 +63,12 @@ <dl class="narrowList navmenu offscreen" id="narrowGroupHidden_<?=$this->escapeHtml($title)?>"> <? endif; ?> <? if ($thisFacet['isApplied']): ?> - <dd><?=$this->escapeHtml($thisFacet['displayText'])?> <img src="<?=$this->imageLink('silk/tick.png')?>" alt="Selected"/></dd> + <dd class="facet<?=$thisFacet['operator'] ?> applied"<? if($thisFacet['operator'] == 'OR'): ?> href="<?=$this->currentPath().$results->getUrlQuery()->removeFacet($title, $thisFacet['value'], true, $thisFacet['operator']) ?>"<? endif ?>><?=$this->escapeHtml($thisFacet['displayText'])?> <img src="<?=$this->imageLink('silk/tick.png')?>" alt="Selected"/></dd> <? else: ?> <dd> - <a href="<?=$this->currentPath().$results->getUrlQuery()->addFacet($title, $thisFacet['value'], $thisFacet['operator'])?>"><?=$this->escapeHtml($thisFacet['displayText'])?></a> (<?=$this->escapeHtml($thisFacet['count'])?>) + <a class="facet<?=$thisFacet['operator'] ?>" href="<?=$this->currentPath().$results->getUrlQuery()->addFacet($title, $thisFacet['value'], $thisFacet['operator'])?>"><?=$this->escapeHtml($thisFacet['displayText'])?></a> (<?=$this->escapeHtml($thisFacet['count'])?>) <? if ($allowExclude): ?> - <a href="<?=$this->currentPath().$results->getUrlQuery()->addFacet($title, $thisFacet['value'], 'NOT')?>"><?=$this->transEsc('exclude_facet')?></a> + <a href="<?=$this->currentPath().$results->getUrlQuery()->addFacet($title, $thisFacet['value'], 'NOT')?>" title="<?=$this->transEsc('exclude_facet')?>"><img src="<?=$this->imageLink('fugue/cross-small.png')?>" alt="Delete"/></a> <? endif; ?> </dd> <? endif; ?> diff --git a/themes/blueprint/templates/layout/layout.phtml b/themes/blueprint/templates/layout/layout.phtml index 49e14aa65a0..b280e799f55 100644 --- a/themes/blueprint/templates/layout/layout.phtml +++ b/themes/blueprint/templates/layout/layout.phtml @@ -26,7 +26,12 @@ <? // Set global path for Javascript code: $this->headScript()->prependScript("path = '" . rtrim($this->url('home'), '/') . "';"); - + + $this->jsTranslations()->addStrings( + array( + 'loading'=>'Loading' + ) + ); // Deal with cart stuff: if (!isset($this->renderingError)) { $cart = $this->cart(); -- GitLab