From f5638c3196d834ed0b03aeda6294b2f1b5aa1677 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 24 May 2018 21:22:50 +0200 Subject: [PATCH] Can precise a time end to countdown timers --- assets/js/components/posts/form.js | 46 ++++++++++++++++++++++++++---- system/config/dev.config.php | 6 ++++ 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/assets/js/components/posts/form.js b/assets/js/components/posts/form.js index c3f39c08..2a2c1350 100644 --- a/assets/js/components/posts/form.js +++ b/assets/js/components/posts/form.js @@ -188,24 +188,44 @@ ComunicWeb.components.posts.form = { }); //End : PDF - //Add countdown timer specific informations + //Add countdown timer specific information var countdownForm = createElem2({ appendTo: boxBody, type: "div", class: "post-countdown" }); - var timeEndInput = createFormGroup({ + //Date end + var dateEndInput = createFormGroup({ target: countdownForm, label: lang("_input_countdown_enddate"), placeholder: "dd/mm/yyyy", type: "text" }); - $(timeEndInput).datepicker({ + $(dateEndInput).datepicker({ autoclose: true, 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 //Add survey specific informations @@ -412,20 +432,36 @@ ComunicWeb.components.posts.form = { else if(countdownType.checked){ //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"); return; } //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) { ComunicWeb.common.notificationSystem.showNotification("Specified date for the countdown timer is invalid !", "danger"); 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 var end_date = new Date(); + end_date.setHours(hours, minutes, 0); end_date.setDate(end_date_array[0]); end_date.setMonth(end_date_array[1] - 1); //January => 0 / December => 11 end_date.setFullYear(end_date_array[2]); diff --git a/system/config/dev.config.php b/system/config/dev.config.php index 8dd55df7..b4922c33 100644 --- a/system/config/dev.config.php +++ b/system/config/dev.config.php @@ -65,6 +65,9 @@ class Dev { //Datepicker "3rdparty/adminLTE/plugins/datepicker/datepicker3.css", + //Timepicker + "3rdparty/adminLTE/plugins/timepicker/bootstrap-timepicker.min.css", + //VideoJS //"3rdparty/videojs/6.4.0/video-js.min.css", @@ -121,6 +124,9 @@ class Dev { //Datepicker "3rdparty/adminLTE/plugins/datepicker/bootstrap-datepicker.js", + //Timepicker + "3rdparty/adminLTE/plugins/timepicker/bootstrap-timepicker.js", + //VideoJS //"3rdparty/videojs/6.4.0/video.min.js",