Commit 261c9892 authored by Mat's avatar Mat
Browse files

les input et le slider s'actualisent l'un et l'autre

parent 931e982d
......@@ -130,7 +130,6 @@
{% include '@Potage/LettreInfos/ajaxDisplay.js' %}
</script>
{% endblock %}
......@@ -172,7 +172,6 @@ function editBlocLettre()
form.querySelector('#lettre_startedAt').value = formatDateISO(json.started_at);
form.querySelector('#lettre_endedAt').value = formatDateISO(json.ended_at);
console.log('ajax get read_one:');
displayDateRangeSlider(json.started_at, json.ended_at);
form.querySelector('#lettre_status').value = json.status;
......@@ -300,3 +299,46 @@ function displayDateRangeSlider(minDate, maxDate)
}]
});
}
/*
* Slider Event change input
*/
$("#dateRuleSlider").on("valuesChanged", function(e, data)
{
form.querySelector('#lettre_startedAt').value = formatDateISO(data.values.min);
form.querySelector('#lettre_endedAt').value = formatDateISO(data.values.max);
});
/*
* input Event change slider
*/
function updateSlider(sd, ed)
{
$("#dateRuleSlider").dateRangeSlider("values",
new Date(sd[0], (sd[1] > 0 ? sd[1]-1 : 11), sd[2]),
new Date(ed[0], (ed[1] > 0 ? ed[1]-1 : 11), ed[2])
);
}
$('#lettre_startedAt').on('input', function(e, data)
{
let sd = this.value.split('-');
let ed = form.querySelector('#lettre_endedAt').value.split('-');
updateSlider(sd, ed);
});
$('#lettre_endedAt').on('input', function(e, data)
{
let sd = form.querySelector('#lettre_startedAt').value.split('-');
let ed = this.value.split('-');
updateSlider(sd, ed);
});
Markdown is supported
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