Can precise a time end to countdown timers

This commit is contained in:
Pierre 2018-05-24 21:22:50 +02:00
parent fa1c1596d5
commit f5638c3196
2 changed files with 47 additions and 5 deletions

View File

@ -188,24 +188,44 @@ ComunicWeb.components.posts.form = {
}); });
//End : PDF //End : PDF
//Add countdown timer specific informations //Add countdown timer specific information
var countdownForm = createElem2({ var countdownForm = createElem2({
appendTo: boxBody, appendTo: boxBody,
type: "div", type: "div",
class: "post-countdown" class: "post-countdown"
}); });
var timeEndInput = createFormGroup({ //Date end
var dateEndInput = createFormGroup({
target: countdownForm, target: countdownForm,
label: lang("_input_countdown_enddate"), label: lang("_input_countdown_enddate"),
placeholder: "dd/mm/yyyy", placeholder: "dd/mm/yyyy",
type: "text" type: "text"
}); });
$(timeEndInput).datepicker({ $(dateEndInput).datepicker({
autoclose: true, autoclose: true,
format: "dd/mm/yyyy" format: "dd/mm/yyyy"
}); });
//Time end
var container = createElem2({
appendTo: countdownForm,
type: "div",
class: "bootstrap-timepicker"
});
var timeEndInput = createFormGroup({
target: container,
label: "Time end",
placeholder: "hh:ss",
type: "text"
});
timeEndInput.className += " timepicker";
$(timeEndInput).timepicker({
showInputs: false,
showMeridian: false,
});
//End : countdown timer //End : countdown timer
//Add survey specific informations //Add survey specific informations
@ -412,20 +432,36 @@ ComunicWeb.components.posts.form = {
else if(countdownType.checked){ else if(countdownType.checked){
//Check the given time //Check the given time
if(timeEndInput.value.length < 10){ if(dateEndInput.value.length < 10){
ComunicWeb.common.notificationSystem.showNotification("Please specify a date for the countdown timer !", "danger"); ComunicWeb.common.notificationSystem.showNotification("Please specify a date for the countdown timer !", "danger");
return; return;
} }
//Convert the date to an array //Convert the date to an array
var end_date_array = timeEndInput.value.split("/"); var end_date_array = dateEndInput.value.split("/");
if(end_date_array.length < 3) { if(end_date_array.length < 3) {
ComunicWeb.common.notificationSystem.showNotification("Specified date for the countdown timer is invalid !", "danger"); ComunicWeb.common.notificationSystem.showNotification("Specified date for the countdown timer is invalid !", "danger");
return; return;
} }
//Convert the time to an array (if any)
if(timeEndInput.value.length > 3){
//Get the specified time
var time_end = timeEndInput.value.split(":");
var hours = time_end[0];
var minutes = time_end[1];
}
else {
//Default values
var hours = 0;
var minutes = 0;
}
//Convert the end time to a timestamp //Convert the end time to a timestamp
var end_date = new Date(); var end_date = new Date();
end_date.setHours(hours, minutes, 0);
end_date.setDate(end_date_array[0]); end_date.setDate(end_date_array[0]);
end_date.setMonth(end_date_array[1] - 1); //January => 0 / December => 11 end_date.setMonth(end_date_array[1] - 1); //January => 0 / December => 11
end_date.setFullYear(end_date_array[2]); end_date.setFullYear(end_date_array[2]);

View File

@ -65,6 +65,9 @@ class Dev {
//Datepicker //Datepicker
"3rdparty/adminLTE/plugins/datepicker/datepicker3.css", "3rdparty/adminLTE/plugins/datepicker/datepicker3.css",
//Timepicker
"3rdparty/adminLTE/plugins/timepicker/bootstrap-timepicker.min.css",
//VideoJS //VideoJS
//"3rdparty/videojs/6.4.0/video-js.min.css", //"3rdparty/videojs/6.4.0/video-js.min.css",
@ -121,6 +124,9 @@ class Dev {
//Datepicker //Datepicker
"3rdparty/adminLTE/plugins/datepicker/bootstrap-datepicker.js", "3rdparty/adminLTE/plugins/datepicker/bootstrap-datepicker.js",
//Timepicker
"3rdparty/adminLTE/plugins/timepicker/bootstrap-timepicker.js",
//VideoJS //VideoJS
//"3rdparty/videojs/6.4.0/video.min.js", //"3rdparty/videojs/6.4.0/video.min.js",