diff --git a/themes/fid_adlr/templates/Recommend/SideFacets/range-slider.phtml b/themes/fid_adlr/templates/Recommend/SideFacets/range-slider.phtml index f865ef4a1d5ee743c85f6b201d2f694ffe1012cb..15797843c5be0e8449afb928250b4e4ade71052e 100644 --- a/themes/fid_adlr/templates/Recommend/SideFacets/range-slider.phtml +++ b/themes/fid_adlr/templates/Recommend/SideFacets/range-slider.phtml @@ -1,6 +1,30 @@ <!-- 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"> + <?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"> <?=$results->getUrlQuery()->asHiddenFields(['page' => "/./", 'filter' => "/^{$this->title}:.*/"])?> <input type="hidden" name="<?=$this->escapeHtmlAttr($this->facet['type'])?>range[]" value="<?=$this->escapeHtmlAttr($this->title)?>"/> @@ -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> <?php endif; ?> <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 $extraInputAttribs = ($this->facet['type'] == 'date') ? 'max="'.(date('Y')+1).'" ' : ''; ?> + <?php /* finc: usability date range slider #22511: + 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"> <?php /* finc adds label ids */ ?> <label id="from-label" for="<?=$this->escapeHtmlAttr($this->title)?>from"> <?php /* fid_adlr: modify result list; remove colon #15967 */ ?> <?=$this->transEsc('date_from')?> </label> - <?php /* finc changes this to number for consistency with adv search */ ?> - <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?>/> + <?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="<?=!empty($this->facet['values'][0]) ? $this->escapeHtmlAttr($low) : ''?>" <?=$extraInputAttribs?>/> </div> <div class="date-to"> <label id="to-label" for="<?=$this->escapeHtmlAttr($this->title)?>to"> <?php /* fid_adlr: modify result list; remove colon #15967 */ ?> <?=$this->transEsc('date_to')?> </label> - <?php /* finc changes this to number for consistency with adv search */ ?> - <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?>/> + <?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="<?=!empty($this->facet['values'][1]) ? $this->escapeHtmlAttr($high) : ''?>" <?=$extraInputAttribs?>/> </div> </div> <input class="btn btn-default" type="submit" value="<?=$this->transEsc('Set')?>"/> @@ -36,11 +62,7 @@ <?php $this->headScript()->appendFile('vendor/bootstrap-slider.min.js'); ?> <?php $this->headLink()->appendStylesheet('vendor/bootstrap-slider.min.css'); ?> <?php - $min = !empty($this->facet['values'][0]) ? min($this->facet['values'][0], 1400) : 1400; - $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; + /* finc: usability date range slider #22511: variables moved to top */ $script = <<<JS $(document).ready(function() { var fillTexts = function() { @@ -79,4 +101,4 @@ JS; ?> <?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?> <?php endif; ?> -<!-- fid_adlr: Recommend - SideFacets - range-slider - END --> \ No newline at end of file +<!-- fid_adlr: Recommend - SideFacets - range-slider - END -->