Skip to content
Snippets Groups Projects
Commit b8563542 authored by Demian Katz's avatar Demian Katz
Browse files

Fixed bug: "from" date could be set higher than max.

Style fixes.
parent 7c453e97
No related merge requests found
function makePublishDateSlider(prefix) {
// create the slider widget
$('#' + prefix + 'Slider').slider({
range: true,
min: 0, max: 9999, values: [0, 9999],
slide: function(event, ui) {
$('#' + prefix + 'from').val(ui.values[0]);
$('#' + prefix + 'to').val(ui.values[1]);
}
});
// initialize the slider with the original values
// in the text boxes
updatePublishDateSlider(prefix);
// when user enters values into the boxes
// the slider needs to be updated too
$('#' + prefix + 'from, #' + prefix + 'to').change(function(){
updatePublishDateSlider(prefix);
});
}
function updatePublishDateSlider(prefix) { function updatePublishDateSlider(prefix) {
var from = parseInt($('#' + prefix + 'from').val()); var from = parseInt($('#' + prefix + 'from').val(), 10);
var to = parseInt($('#' + prefix + 'to').val()); var to = parseInt($('#' + prefix + 'to').val(), 10);
// assuming our oldest item is published in the 15th century // assuming our oldest item is published in the 15th century
var min = 1500; var min = 1500;
if (!from || from < min) { if (!from || from < min) {
...@@ -36,12 +16,36 @@ function updatePublishDateSlider(prefix) { ...@@ -36,12 +16,36 @@ function updatePublishDateSlider(prefix) {
if (!to || to > max) { if (!to || to > max) {
to = max; to = max;
} }
if (from > max) {
from = max;
}
// update the slider with the new min/max/values // update the slider with the new min/max/values
$('#' + prefix + 'Slider').slider('option', { $('#' + prefix + 'Slider').slider('option', {
min: min, max: max, values: [from, to] min: min, max: max, values: [from, to]
}); });
} }
function makePublishDateSlider(prefix) {
// create the slider widget
$('#' + prefix + 'Slider').slider({
range: true,
min: 0, max: 9999, values: [0, 9999],
slide: function(event, ui) {
$('#' + prefix + 'from').val(ui.values[0]);
$('#' + prefix + 'to').val(ui.values[1]);
}
});
// initialize the slider with the original values
// in the text boxes
updatePublishDateSlider(prefix);
// when user enters values into the boxes
// the slider needs to be updated too
$('#' + prefix + 'from, #' + prefix + 'to').change(function(){
updatePublishDateSlider(prefix);
});
}
$(document).ready(function(){ $(document).ready(function(){
// create the slider for the publish date facet // create the slider for the publish date facet
$('.dateSlider').each(function(i) { $('.dateSlider').each(function(i) {
......
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