From 4bda52e75445b3bb009ffc5acff761d6349ccefa Mon Sep 17 00:00:00 2001 From: Chris Hallberg <crhallberg@gmail.com> Date: Thu, 12 Mar 2015 12:36:54 -0400 Subject: [PATCH] OR facets again block rapid clicking behaviour. --- themes/bootstrap3/js/common.js | 23 +--- .../templates/Recommend/SideFacets.phtml | 130 +++++++++--------- 2 files changed, 72 insertions(+), 81 deletions(-) diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js index e03e7ed1042..b382da12620 100644 --- a/themes/bootstrap3/js/common.js +++ b/themes/bootstrap3/js/common.js @@ -54,7 +54,7 @@ function deparam(url) { var pairs = url.substring(url.indexOf('?') + 1).split('&'); for (var i = 0; i < pairs.length; i++) { var pair = pairs[i].split('='); - var name = decodeURIComponent(pair[0].replace(/\+/g, ' ')); + var name = decodeURIComponent(pair[0]); if(name.length == 0) { continue; } @@ -63,9 +63,9 @@ function deparam(url) { if(!request[name]) { request[name] = []; } - request[name].push(decodeURIComponent(pair[1].replace(/\+/g, ' '))); + request[name].push(decodeURIComponent(pair[1])); } else { - request[name] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); + request[name] = decodeURIComponent(pair[1]); } } return request; @@ -81,18 +81,6 @@ function lessFacets(id) { $('#more-'+id).removeClass('hidden'); } -// Advanced facets -function updateOrFacets(url, op) { - window.location.assign(url); - var list = $(op).parents('ul'); - var header = $(list).find('li.nav-header'); - list.html(header[0].outerHTML+'<div class="alert alert-info">'+vufindString.loading+'...</div>'); -} -function setupOrFacets() { - $('.facetOR').find('.icon-check').replaceWith('<input type="checkbox" checked onChange="updateOrFacets($(this).parent().parent().attr(\'href\'), this)"/>'); - $('.facetOR').find('.icon-check-empty').replaceWith('<input type="checkbox" onChange="updateOrFacets($(this).parent().attr(\'href\'), this)"/> '); -} - // Lightbox /* * This function adds jQuery events to elements in the lightbox @@ -386,7 +374,10 @@ $(document).ready(function() { } // Advanced facets - setupOrFacets(); + $('.facetOR').click(function() { + $(this).closest('.collapse').html('<div class="list-group-item">'+vufindString.loading+'...</div>'); + window.location.assign($(this).attr('href')); + }); $('[name=bulkActionForm]').submit(function() { return bulkActionSubmit($(this)); diff --git a/themes/bootstrap3/templates/Recommend/SideFacets.phtml b/themes/bootstrap3/templates/Recommend/SideFacets.phtml index 9e79b957efa..77f5344431b 100644 --- a/themes/bootstrap3/templates/Recommend/SideFacets.phtml +++ b/themes/bootstrap3/templates/Recommend/SideFacets.phtml @@ -118,86 +118,86 @@ JS; <?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?> <? endif; ?> <? else: ?> - <? if (in_array($title, $hierarchicalFacets)): ?> - <? $this->headScript()->appendFile('vendor/jsTree/jstree.min.js'); ?> - <? $this->headScript()->appendFile('facets.js'); ?> - <? $sort = isset($hierarchicalFacetSortOptions[$title]) ? $hierarchicalFacetSortOptions[$title] : ''; ?> - <? if (!in_array($title, $collapsedFacets)): ?> - <? - $script = <<<JS + <? if (in_array($title, $hierarchicalFacets)): ?> + <? $this->headScript()->appendFile('vendor/jsTree/jstree.min.js'); ?> + <? $this->headScript()->appendFile('facets.js'); ?> + <? $sort = isset($hierarchicalFacetSortOptions[$title]) ? $hierarchicalFacetSortOptions[$title] : ''; ?> + <? if (!in_array($title, $collapsedFacets)): ?> + <? + $script = <<<JS $(document).ready(function() { initFacetTree($('#facet_{$this->escapeHtml($title)}'), true); }); JS; - ?> - <?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?> - <? else: ?> - <? - $script = <<<JS + ?> + <?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?> + <? else: ?> + <? + $script = <<<JS $('#side-collapse-{$this->escapeHtmlAttr($title)}').on('show.bs.collapse', function() { initFacetTree($('#facet_{$this->escapeHtml($title)}'), true); }); JS; - ?> - <?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?> - <? endif; ?> - <li id="facet_<?=$this->escapeHtml($title)?>" class="jstree-facet" - data-facet="<?=$this->escapeHtmlAttr($title)?>" - data-path="<?=$this->currentPath()?>" - data-exclude="<?=$allowExclude?>" - data-operator="<?=$this->recommend->getFacetOperator($title)?>" - data-exclude-title="<?=$this->transEsc('exclude_facet')?>" - data-sort="<?=isset($hierarchicalFacetSortOptions[$title]) ? $hierarchicalFacetSortOptions[$title] : ''?>"> - </li> - <noscript> - <? endif; ?> - <? foreach ($cluster['list'] as $i=>$thisFacet): ?> - <? - if(strlen($thisFacet['displayText']) == 0) { - $thisFacet['displayText'] = "-"; - } - ?> - <? $moreClass = 'narrowGroupHidden-'.$this->escapeHtmlAttr($title).' hidden'; ?> - <? if ($i == 6): ?> - <a id="more-narrowGroupHidden-<?=$this->escapeHtmlAttr($title)?>" class="list-group-item" href="javascript:moreFacets('narrowGroupHidden-<?=$title ?>')"><?=$this->transEsc('more')?> ...</a> + ?> + <?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?> + <? endif; ?> + <li id="facet_<?=$this->escapeHtml($title)?>" class="jstree-facet" + data-facet="<?=$this->escapeHtmlAttr($title)?>" + data-path="<?=$this->currentPath()?>" + data-exclude="<?=$allowExclude?>" + data-operator="<?=$this->recommend->getFacetOperator($title)?>" + data-exclude-title="<?=$this->transEsc('exclude_facet')?>" + data-sort="<?=isset($hierarchicalFacetSortOptions[$title]) ? $hierarchicalFacetSortOptions[$title] : ''?>"> + </li> + <noscript> <? endif; ?> - <? if ($thisFacet['isApplied']): ?> - <a class="list-group-item active<? if ($i>5): ?><?=$moreClass ?><?endif ?><? if ($thisFacet['operator'] == 'OR'): ?> facetOR applied<? endif ?>" href="<?=$this->currentPath().$results->getUrlQuery()->removeFacet($title, $thisFacet['value'], true, $thisFacet['operator']) ?>"> - <? if ($thisFacet['operator'] == 'OR'): ?> - <i class="fa fa-check-square-o"></i> + <? foreach ($cluster['list'] as $i=>$thisFacet): ?> + <? + if(strlen($thisFacet['displayText']) == 0) { + $thisFacet['displayText'] = "-"; + } + ?> + <? $moreClass = 'narrowGroupHidden-'.$this->escapeHtmlAttr($title).' hidden'; ?> + <? if ($i == 6): ?> + <a id="more-narrowGroupHidden-<?=$this->escapeHtmlAttr($title)?>" class="list-group-item" href="javascript:moreFacets('narrowGroupHidden-<?=$title ?>')"><?=$this->transEsc('more')?> ...</a> + <? endif; ?> + <? if ($thisFacet['isApplied']): ?> + <a class="list-group-item active<? if ($i>5): ?><?=$moreClass ?><?endif ?><? if ($thisFacet['operator'] == 'OR'): ?> facetOR applied<? endif ?>" href="<?=$this->currentPath().$results->getUrlQuery()->removeFacet($title, $thisFacet['value'], true, $thisFacet['operator']) ?>"> + <? if ($thisFacet['operator'] == 'OR'): ?> + <i class="fa fa-check-square-o"></i> + <? else: ?> + <span class="pull-right"><i class="fa fa-check"></i></span> + <? endif; ?> + <?=$this->escapeHtml($thisFacet['displayText'])?> + </a> + <? else: ?> + <? $addURL = $this->currentPath().$results->getUrlQuery()->addFacet($title, $thisFacet['value'], $thisFacet['operator']); ?> + <? if ($allowExclude): ?> + <li class="list-group-item facet<?=$thisFacet['operator'] ?><? if ($i>5): ?> <?=$moreClass ?><?endif ?>"> <? else: ?> - <span class="pull-right"><i class="fa fa-check"></i></span> + <a href="<?=$addURL ?>" class="list-group-item facet<?=$thisFacet['operator'] ?><? if ($i>5): ?> <?=$moreClass ?><?endif ?>"> <? endif; ?> - <?=$this->escapeHtml($thisFacet['displayText'])?> - </a> - <? else: ?> - <? $addURL = $this->currentPath().$results->getUrlQuery()->addFacet($title, $thisFacet['value'], $thisFacet['operator']); ?> - <? if ($allowExclude): ?> - <li class="list-group-item facet<?=$thisFacet['operator'] ?><? if ($i>5): ?> <?=$moreClass ?><?endif ?>"> - <? else: ?> - <a href="<?=$addURL ?>" class="list-group-item facet<?=$thisFacet['operator'] ?><? if ($i>5): ?> <?=$moreClass ?><?endif ?>"> - <? endif; ?> - <span class="badge"> - <?=$this->localizedNumber($thisFacet['count'])?> + <span class="badge"> + <?=$this->localizedNumber($thisFacet['count'])?> + <? if ($allowExclude): ?> + <a href="<?=$this->currentPath().$results->getUrlQuery()->addFacet($title, $thisFacet['value'], 'NOT') ?>" title="<?=$this->transEsc('exclude_facet') ?>"><i class="fa fa-times"></i></a> + <? endif; ?> + </span> <? if ($allowExclude): ?> - <a href="<?=$this->currentPath().$results->getUrlQuery()->addFacet($title, $thisFacet['value'], 'NOT') ?>" title="<?=$this->transEsc('exclude_facet') ?>"><i class="fa fa-times"></i></a> + <a href="<?=$addURL ?>"> <? endif; ?> - </span> - <? if ($allowExclude): ?> - <a href="<?=$addURL ?>"> - <? endif; ?> - <? if($thisFacet['operator'] == 'OR'): ?> - <i class="fa fa-square-o"></i> - <? endif; ?> - <?=$this->escapeHtml($thisFacet['displayText'])?> - <? if ($allowExclude): ?> + <? if($thisFacet['operator'] == 'OR'): ?> + <i class="fa fa-square-o"></i> + <? endif; ?> + <?=$this->escapeHtml($thisFacet['displayText'])?> + <? if ($allowExclude): ?> + </a> + </li> + <? else: ?> </a> - </li> - <? else: ?> - </a> + <? endif; ?> <? endif; ?> - <? endif; ?> - <? endforeach; ?> + <? endforeach; ?> <? if ($i > 5): ?><a class="list-group-item <?=$moreClass ?>" href="javascript:lessFacets('narrowGroupHidden-<?=$title ?>')"><?=$this->transEsc('less')?> ...</a><? endif; ?> <? endif; ?> <? if (in_array($title, $hierarchicalFacets)): ?> -- GitLab