Skip to content
Snippets Groups Projects
Commit 9e9d047b authored by Alexander Purr's avatar Alexander Purr Committed by Robert Lange
Browse files

refs #22511 [fid_adlr] usability date range slider

* adapt finc changes of this ticket
parent b6ceb6f8
No related merge requests found
<!-- fid_adlr: Recommend - SideFacets - range-slider --> <!-- fid_adlr: Recommend - SideFacets - range-slider -->
<?php /* compare with bootstrap3 */?> <?php /* compare with finc */?>
<?php
/** finc: usability date range slider #22511:
* set boundary values for daterange input and slider
* min & max values of handles and inputs are defined by search results
* if date range filter is applied additionaly: lowest and highest record years can be within filter values
*/
foreach ($cluster['list'] as $facet) {
$years[] = $facet['value'];
}
$facetmin = min($years);
$facetmax = max($years);
$low = $facetmin;
$min = !empty($this->facet['values'][0]) ? $this->facet['values'][0] : $facetmin;
$high = $facetmax;
$max = !empty($this->facet['values'][1]) ? $this->facet['values'][1] : $facetmax;
?>
<?php /* finc changes div into li for compatibility with facet list structure */ ?>
<li class="facet"> <li class="facet">
<?php /* finc adds landmarks for active facets */ ?>
<?php if (!empty($this->facet['values'][0])): ?>
<?php $this->sideFacet()->setAppliedFacet($this->transEsc('Skip to facet', ['%%filter_name%%' => $this->transEsc('Year of Publication')]), $this->escapeHtmlAttr($this->title) . 'from')?>
<?php elseif (!empty($this->facet['values'][1])): ?>
<?php $this->sideFacet()->setAppliedFacet($this->transEsc('Skip to facet', ['%%filter_name%%' => $this->transEsc('Year of Publication')]), $this->escapeHtmlAttr($this->title) . 'to')?>
<?php endif; ?>
<?php /* finc adds landmarks for active facets - END */ ?>
<form class="facet-range-form" name="<?=$this->escapeHtmlAttr($this->title)?>Filter" id="<?=$this->escapeHtmlAttr($this->title)?>Filter"> <form class="facet-range-form" name="<?=$this->escapeHtmlAttr($this->title)?>Filter" id="<?=$this->escapeHtmlAttr($this->title)?>Filter">
<?=$results->getUrlQuery()->asHiddenFields(['page' => "/./", 'filter' => "/^{$this->title}:.*/"])?> <?=$results->getUrlQuery()->asHiddenFields(['page' => "/./", 'filter' => "/^{$this->title}:.*/"])?>
<input type="hidden" name="<?=$this->escapeHtmlAttr($this->facet['type'])?>range[]" value="<?=$this->escapeHtmlAttr($this->title)?>"/> <input type="hidden" name="<?=$this->escapeHtmlAttr($this->facet['type'])?>range[]" value="<?=$this->escapeHtmlAttr($this->title)?>"/>
...@@ -9,24 +33,26 @@ ...@@ -9,24 +33,26 @@
<div class="slider-container"><input type="text" class="hidden" id="<?=$this->escapeHtmlAttr($this->title)?><?=$this->escapeHtml($this->facet['type'])?>Slider" aria-label="<?=$this->transEsc('Range-from-to')?>"/></div> <div class="slider-container"><input type="text" class="hidden" id="<?=$this->escapeHtmlAttr($this->title)?><?=$this->escapeHtml($this->facet['type'])?>Slider" aria-label="<?=$this->transEsc('Range-from-to')?>"/></div>
<?php endif; ?> <?php endif; ?>
<div class="date-fields"> <div class="date-fields">
<?php /* finc adds 'max="'.(date('Y')+1).' to prevent dates beyond the year + 1 to be entered; maxlength was causing w3c issues */ ?> <?php /* finc: usability date range slider #22511:
<?php $extraInputAttribs = ($this->facet['type'] == 'date') ? 'max="'.(date('Y')+1).'" ' : ''; ?> prefill min & max attributes by possible date range (given by search results or chosen date range filter)
*/ ?>
<?php $extraInputAttribs = ($this->facet['type'] == 'date') ? " min=\"{$min}\" max=\"{$max}\" " : ''; ?>
<div class="date-from"> <div class="date-from">
<?php /* finc adds label ids */ ?> <?php /* finc adds label ids */ ?>
<label id="from-label" for="<?=$this->escapeHtmlAttr($this->title)?>from"> <label id="from-label" for="<?=$this->escapeHtmlAttr($this->title)?>from">
<?php /* fid_adlr: modify result list; remove colon #15967 */ ?> <?php /* fid_adlr: modify result list; remove colon #15967 */ ?>
<?=$this->transEsc('date_from')?> <?=$this->transEsc('date_from')?>
</label> </label>
<?php /* finc changes this to number for consistency with adv search */ ?> <?php /* finc: usability date range slider #22135, #22511: change input type and value */ ?>
<input type="number" class="form-control" name="<?=$this->escapeHtmlAttr($this->title)?>from" id="<?=$this->escapeHtmlAttr($this->title)?>from" value="<?=isset($this->facet['values'][0]) ? $this->escapeHtmlAttr($this->facet['values'][0]) : ''?>" <?=$extraInputAttribs?>/> <input type="number" class="form-control" name="<?=$this->escapeHtmlAttr($this->title)?>from" id="<?=$this->escapeHtmlAttr($this->title)?>from" value="<?=!empty($this->facet['values'][0]) ? $this->escapeHtmlAttr($low) : ''?>" <?=$extraInputAttribs?>/>
</div> </div>
<div class="date-to"> <div class="date-to">
<label id="to-label" for="<?=$this->escapeHtmlAttr($this->title)?>to"> <label id="to-label" for="<?=$this->escapeHtmlAttr($this->title)?>to">
<?php /* fid_adlr: modify result list; remove colon #15967 */ ?> <?php /* fid_adlr: modify result list; remove colon #15967 */ ?>
<?=$this->transEsc('date_to')?> <?=$this->transEsc('date_to')?>
</label> </label>
<?php /* finc changes this to number for consistency with adv search */ ?> <?php /* finc: usability date range slider #22135, #22511: change input type and value input */ ?>
<input type="number" class="form-control" name="<?=$this->escapeHtmlAttr($this->title)?>to" id="<?=$this->escapeHtmlAttr($this->title)?>to" value="<?=isset($this->facet['values'][1]) ? $this->escapeHtmlAttr($this->facet['values'][1]) : ''?>" <?=$extraInputAttribs?>/> <input type="number" class="form-control" name="<?=$this->escapeHtmlAttr($this->title)?>to" id="<?=$this->escapeHtmlAttr($this->title)?>to" value="<?=!empty($this->facet['values'][1]) ? $this->escapeHtmlAttr($high) : ''?>" <?=$extraInputAttribs?>/>
</div> </div>
</div> </div>
<input class="btn btn-default" type="submit" value="<?=$this->transEsc('Set')?>"/> <input class="btn btn-default" type="submit" value="<?=$this->transEsc('Set')?>"/>
...@@ -36,11 +62,7 @@ ...@@ -36,11 +62,7 @@
<?php $this->headScript()->appendFile('vendor/bootstrap-slider.min.js'); ?> <?php $this->headScript()->appendFile('vendor/bootstrap-slider.min.js'); ?>
<?php $this->headLink()->appendStylesheet('vendor/bootstrap-slider.min.css'); ?> <?php $this->headLink()->appendStylesheet('vendor/bootstrap-slider.min.css'); ?>
<?php <?php
$min = !empty($this->facet['values'][0]) ? min($this->facet['values'][0], 1400) : 1400; /* finc: usability date range slider #22511: variables moved to top */
$future = date('Y', time() + 31536000); // next year
$max = !empty($this->facet['values'][1]) ? max($future, $this->facet['values'][1]) : $future;
$low = !empty($this->facet['values'][0]) ? $this->facet['values'][0] : $min;
$high = !empty($this->facet['values'][1]) ? $this->facet['values'][1] : $max;
$script = <<<JS $script = <<<JS
$(document).ready(function() { $(document).ready(function() {
var fillTexts = function() { var fillTexts = function() {
...@@ -79,4 +101,4 @@ JS; ...@@ -79,4 +101,4 @@ JS;
?> ?>
<?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?> <?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?>
<?php endif; ?> <?php endif; ?>
<!-- fid_adlr: Recommend - SideFacets - range-slider - END --> <!-- fid_adlr: Recommend - SideFacets - range-slider - END -->
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment