From a23807e0c77d8c879dc9562c927d89a21b32eb94 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 19 Dec 2011 11:39:07 -0500 Subject: [PATCH] CC-3211: When TimeTicker is open and user clicks on the calendar, it resets the time value - fixed - removed some unnecessary code --- .../schedule/full-calendar-functions.js | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js index 1bd193bde..6eec2aefc 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -123,23 +123,35 @@ function dayClick(date, allDay, jsEvent, view) { $(span).remove(); } - // 1 hr - var duration = 60 * 60* 1000; + // get current duration value on the form + var duration_string = $("#add_show_duration").val();//60 * 60* 1000; + var duration_info = duration_string.split(" "); + var duration_h = 0; + var duration_m = 0; + if(duration_info[0] != null){ + duration_h = parseInt(duration_info[0], 10); + } + if(duration_info[1] != null){ + duration_m = parseInt(duration_info[1], 10); + } - var endDateTime = new Date(selected.getTime() + duration); + // duration in milisec + var duration = (duration_h * 60 * 60 * 1000) + (duration_m * 60 * 1000); + + // get start time value on the form + var startTime_string = $("#add_show_start_time").val(); + var startTime_info = startTime_string.split(':'); + var startTime = (startTime_info[0] * 60 * 60 * 1000) + (startTime_info[1] * 60 * 1000); + + // calculate endDateTime + var endDateTime = new Date(selected.getTime() + startTime + duration); chosenDate = selected.getFullYear() + '-' + pad(selected.getMonth()+1,2) + '-' + pad(selected.getDate(),2); - chosenTime = pad(selected.getHours(),2) + ':' + pad(selected.getMinutes(),2); var endDateFormat = endDateTime.getFullYear() + '-' + pad(endDateTime.getMonth()+1,2) + '-' + pad(endDateTime.getDate(),2); - var endTimeFormat = pad(endDateTime.getHours(),2) + ':' + pad(endDateTime.getMinutes(),2); $("#add_show_start_date").val(chosenDate); $("#add_show_end_date_no_repeat").val(endDateFormat); - $("#add_show_end_date").datepicker("option", "minDate", endDateFormat); $("#add_show_end_date").val(endDateFormat); - $("#add_show_start_time").val(chosenTime); - $("#add_show_end_time").val(endTimeFormat); - $("#add_show_duration").val('1h'); $("#schedule-show-when").show(); openAddShowForm();