Skip to content
Snippets Groups Projects
Commit 03d03e0c authored by André Lahmann's avatar André Lahmann
Browse files

refs #8178:

* added update to range slider in advanced search on changing input value
parent 2b040e57
No related merge requests found
<!-- search - advanced - RANGES.phtml -->
<? if (isset($this->ranges) && !empty($this->ranges)): ?>
<? $params = $this->searchParams($this->searchClassId);
$params->activateAllFacets(); ?>
<? foreach ($this->ranges as $current): $escField = $this->escapeHtmlAttr($current['field']); ?>
<? $extraInputAttribs = ($current['type'] == 'date') ? 'maxlength="4" ' : ''; ?>
<div class="medium-4 columns">
<fieldset>
<legend><?= $this->transEsc($params->getFacetLabel($current['field'])) ?></legend>
<input type="hidden" name="<?= $this->escapeHtmlAttr($current['type']) ?>range[]" value="<?= $escField ?>"/>
<div class="row">
<div class="medium-6 columns">
<label for="<?= $escField ?>from"><?= $this->transEsc('date_from') ?>:</label>
<input type="text" name="<?= $escField ?>from" id="<?= $escField ?>from" value="<?= isset($current['values'][0]) ? $this->escapeHtmlAttr($current['values'][0]):''?>" <?= $extraInputAttribs ?>/>
</div>
<div class="medium-6 columns">
<label for="<?= $escField ?>to"><?= $this->transEsc('date_to') ?>:</label>
<input type="text" name="<?= $escField ?>to" id="<?= $escField ?>to" value="<?= isset($current['values'][1]) ? $this->escapeHtmlAttr($current['values'][1]):''?>" <?= $extraInputAttribs ?>/>
</div>
</div>
<? if ($current['type'] == 'date'): ?>
<div class="slider-container">
<input type="text" id="<?= $escField ?><?= $this->escapeHtmlAttr($current['type']) ?>Slider">
</div>
<?
$this->headScript()->appendFile('vendor/bootstrap-slider.js');
$min = !empty($current['values'][0]) ? min($current['values'][0], 1400) : 1400;
$future = date('Y', time() + 31536000);
$max = !empty($current['values'][1]) ? max($future, $current['values'][1]) : $future;
$low = !empty($current['values'][0]) ? $current['values'][0] : $min;
$high = !empty($current['values'][1]) ? $current['values'][1] : $max;
$min = intval($min);
$max = intval($max);
$low = intval($low);
$high = intval($high);
$reversed = $this->layout()->rtl ? 'true' : 'false';
$init = !empty($current['values'][0]) ? 'fillTexts()' : '';
$script = <<<JS
$(document).ready(function() {
var fillTexts = function() {
var v = {$escField}dateSlider.getValue();
$('#${escField}from').val(v[0]);
$('#${escField}to').val(v[1]);
};
var {$escField}dateSlider = $('#{$escField}dateSlider')
.slider({
'min':{$min},
'max':{$max},
'handle':"square",
'tooltip':"hide",
'value':[{$low},{$high}],
'reversed': {$reversed}
})
.on('slide', fillTexts)
.data('slider');
{$init}
});
$('#${escField}from, #${escField}to').change(function () {
var from = Number($('#{$escField}from').val());
var to = Number($('#{$escField}to').val());
if (from <= 0) {
from = {$min};
}
if (to <= 0) {
to = {$max};
}
$('#{$escField}dateSlider').slider('setValue', [from, to], true);
})
JS;
?>
<?= $this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); ?>
</fieldset>
</div>
<? endif; ?>
<? endforeach; ?>
<? endif; ?>
<!-- search - advanced - RANGES.phtml 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