Updated preEditShowValidationCheck to behave properly when dealing with shows with cc_show_days rows in the past, updated serialized form data in add-show to accommodate the change
This commit is contained in:
parent
5ea27067e2
commit
00e85de3c8
2 changed files with 164 additions and 159 deletions
|
@ -362,33 +362,22 @@ class Application_Service_ShowFormService
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Before we send the form data in for validation, there
|
* Before we send the form data in for validation, there
|
||||||
* are a few fields we may need to adjust first
|
* are a few fields we may need to adjust first
|
||||||
|
*
|
||||||
* @param $formData
|
* @param $formData
|
||||||
*/
|
*/
|
||||||
public function preEditShowValidationCheck($formData)
|
public function preEditShowValidationCheck($formData)
|
||||||
{
|
{
|
||||||
$validateStartDate = true;
|
// If the start date or time were disabled, don't validate them
|
||||||
$validateStartTime = true;
|
$validateStartDate = $formData['start_date_disabled'] === "false";
|
||||||
|
$validateStartTime = $formData['start_time_disabled'] === "false";
|
||||||
|
|
||||||
//CcShowDays object of the show currently being edited
|
//CcShowDays object of the show currently being edited
|
||||||
$currentShowDay = $this->ccShow->getFirstCcShowDay();
|
$currentShowDay = $this->ccShow->getFirstCcShowDay();
|
||||||
|
|
||||||
//DateTime object
|
//DateTime object
|
||||||
$dt = $currentShowDay->getLocalStartDateAndTime();
|
$dt = $currentShowDay->getLocalStartDateAndTime();
|
||||||
|
|
||||||
if (!array_key_exists('add_show_start_date', $formData)) {
|
|
||||||
//Changing the start date was disabled, since the
|
|
||||||
//array key does not exist. We need to repopulate this entry from the db.
|
|
||||||
$formData['add_show_start_date'] = $dt->format("Y-m-d");
|
|
||||||
|
|
||||||
if (!array_key_exists('add_show_start_time', $formData)) {
|
|
||||||
$formData['add_show_start_time'] = $dt->format("H:i");
|
|
||||||
$validateStartTime = false;
|
|
||||||
}
|
|
||||||
$validateStartDate = false;
|
|
||||||
}
|
|
||||||
$formData['add_show_record'] = $currentShowDay->getDbRecord();
|
$formData['add_show_record'] = $currentShowDay->getDbRecord();
|
||||||
|
|
||||||
//if the show is repeating, set the start date to the next
|
//if the show is repeating, set the start date to the next
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Schedule Dialog creation methods.
|
* Schedule Dialog creation methods.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -53,14 +53,14 @@ function removeAddShowButton(){
|
||||||
//$el is DOM element #add-show-form
|
//$el is DOM element #add-show-form
|
||||||
//form is the new form contents to append to $el
|
//form is the new form contents to append to $el
|
||||||
function redrawAddShowForm($el, form) {
|
function redrawAddShowForm($el, form) {
|
||||||
|
|
||||||
//need to clean up the color picker.
|
//need to clean up the color picker.
|
||||||
$el.find("#schedule-show-style input").each(function(i, el){
|
$el.find("#schedule-show-style input").each(function(i, el){
|
||||||
var $input = $(this),
|
var $input = $(this),
|
||||||
colId = $input.data("colorpickerId");
|
colId = $input.data("colorpickerId");
|
||||||
|
|
||||||
$("#"+colId).remove();
|
$("#"+colId).remove();
|
||||||
$input.removeData();
|
$input.removeData();
|
||||||
});
|
});
|
||||||
|
|
||||||
$el.empty().append(form);
|
$el.empty().append(form);
|
||||||
|
@ -74,12 +74,12 @@ function closeAddShowForm(event) {
|
||||||
|
|
||||||
var $el = $("#add-show-form");
|
var $el = $("#add-show-form");
|
||||||
|
|
||||||
$el.hide();
|
$el.hide();
|
||||||
windowResize();
|
windowResize();
|
||||||
|
|
||||||
$.get(baseUrl+"Schedule/get-form", {format:"json"}, function(json) {
|
$.get(baseUrl+"Schedule/get-form", {format:"json"}, function(json) {
|
||||||
|
|
||||||
redrawAddShowForm($el, json.form);
|
redrawAddShowForm($el, json.form);
|
||||||
});
|
});
|
||||||
|
|
||||||
makeAddShowButton();
|
makeAddShowButton();
|
||||||
|
@ -87,29 +87,29 @@ function closeAddShowForm(event) {
|
||||||
|
|
||||||
//dateText mm-dd-yy
|
//dateText mm-dd-yy
|
||||||
function startDpSelect(dateText, inst) {
|
function startDpSelect(dateText, inst) {
|
||||||
var time, date;
|
var time, date;
|
||||||
|
|
||||||
time = dateText.split("-");
|
time = dateText.split("-");
|
||||||
date = new Date(time[0], time[1] - 1, time[2]);
|
date = new Date(time[0], time[1] - 1, time[2]);
|
||||||
|
|
||||||
if (inst.input)
|
if (inst.input)
|
||||||
inst.input.trigger('input');
|
inst.input.trigger('input');
|
||||||
}
|
}
|
||||||
|
|
||||||
function endDpSelect(dateText, inst) {
|
function endDpSelect(dateText, inst) {
|
||||||
var time, date;
|
var time, date;
|
||||||
|
|
||||||
time = dateText.split("-");
|
time = dateText.split("-");
|
||||||
date = new Date(time[0], time[1] - 1, time[2]);
|
date = new Date(time[0], time[1] - 1, time[2]);
|
||||||
|
|
||||||
if (inst.input)
|
if (inst.input)
|
||||||
inst.input.trigger('input');
|
inst.input.trigger('input');
|
||||||
}
|
}
|
||||||
|
|
||||||
function createDateInput(el, onSelect) {
|
function createDateInput(el, onSelect) {
|
||||||
var date;
|
var date;
|
||||||
|
|
||||||
el.datepicker({
|
el.datepicker({
|
||||||
minDate: adjustDateToServerDate(new Date(), timezoneOffset),
|
minDate: adjustDateToServerDate(new Date(), timezoneOffset),
|
||||||
onSelect: onSelect,
|
onSelect: onSelect,
|
||||||
dateFormat: 'yy-mm-dd',
|
dateFormat: 'yy-mm-dd',
|
||||||
|
@ -119,42 +119,42 @@ function createDateInput(el, onSelect) {
|
||||||
closeText: $.i18n._('Close'),
|
closeText: $.i18n._('Close'),
|
||||||
//showButtonPanel: true,
|
//showButtonPanel: true,
|
||||||
firstDay: calendarPref.weekStart
|
firstDay: calendarPref.weekStart
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function autoSelect(event, ui) {
|
function autoSelect(event, ui) {
|
||||||
|
|
||||||
$("#add_show_hosts-"+ui.item.index).attr("checked", "checked");
|
$("#add_show_hosts-"+ui.item.index).attr("checked", "checked");
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
function findHosts(request, callback) {
|
function findHosts(request, callback) {
|
||||||
var search, url;
|
var search, url;
|
||||||
|
|
||||||
url = baseUrl+"User/get-hosts";
|
url = baseUrl+"User/get-hosts";
|
||||||
search = request.term;
|
search = request.term;
|
||||||
|
|
||||||
var noResult = new Array();
|
var noResult = new Array();
|
||||||
noResult[0] = new Array();
|
noResult[0] = new Array();
|
||||||
noResult[0]['value'] = $("#add_show_hosts_autocomplete").val();
|
noResult[0]['value'] = $("#add_show_hosts_autocomplete").val();
|
||||||
noResult[0]['label'] = $.i18n._("No result found");
|
noResult[0]['label'] = $.i18n._("No result found");
|
||||||
noResult[0]['index'] = null;
|
noResult[0]['index'] = null;
|
||||||
|
|
||||||
$.post(url,
|
$.post(url,
|
||||||
{format: "json", term: search},
|
{format: "json", term: search},
|
||||||
|
|
||||||
function(json) {
|
function(json) {
|
||||||
if(json.hosts.length<1){
|
if(json.hosts.length<1){
|
||||||
callback(noResult);
|
callback(noResult);
|
||||||
}else{
|
}else{
|
||||||
callback(json.hosts);
|
callback(json.hosts);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function beginEditShow(data){
|
function beginEditShow(data){
|
||||||
|
|
||||||
if (data.show_error == true){
|
if (data.show_error == true){
|
||||||
alertShowErrorAndReload();
|
alertShowErrorAndReload();
|
||||||
return false;
|
return false;
|
||||||
|
@ -201,11 +201,11 @@ function stringToColor(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContrastYIQ(hexcolor){
|
function getContrastYIQ(hexcolor){
|
||||||
var r = parseInt(hexcolor.substr(0,2),16);
|
var r = parseInt(hexcolor.substr(0,2),16);
|
||||||
var g = parseInt(hexcolor.substr(2,2),16);
|
var g = parseInt(hexcolor.substr(2,2),16);
|
||||||
var b = parseInt(hexcolor.substr(4,2),16);
|
var b = parseInt(hexcolor.substr(4,2),16);
|
||||||
var yiq = ((r*299)+(g*587)+(b*114))/1000;
|
var yiq = ((r*299)+(g*587)+(b*114))/1000;
|
||||||
return (yiq >= 128) ? '000000' : 'ffffff';
|
return (yiq >= 128) ? '000000' : 'ffffff';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ function setAddShowEvents(form) {
|
||||||
|
|
||||||
//var form = $("#add-show-form");
|
//var form = $("#add-show-form");
|
||||||
|
|
||||||
form.find("h3").click(function(){
|
form.find("h3").click(function(){
|
||||||
$(this).next().toggle();
|
$(this).next().toggle();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -308,16 +308,16 @@ function setAddShowEvents(form) {
|
||||||
form.find("#add_show_rebroadcast").click(function(){
|
form.find("#add_show_rebroadcast").click(function(){
|
||||||
$(this).blur();
|
$(this).blur();
|
||||||
if(form.find("#add_show_record").attr('checked')){
|
if(form.find("#add_show_record").attr('checked')){
|
||||||
if($(this).attr('checked') && !form.find("#add_show_repeats").attr('checked')) {
|
if($(this).attr('checked') && !form.find("#add_show_repeats").attr('checked')) {
|
||||||
form.find("#add_show_rebroadcast_absolute").show();
|
form.find("#add_show_rebroadcast_absolute").show();
|
||||||
}
|
}
|
||||||
else if($(this).attr('checked') && form.find("#add_show_repeats").attr('checked')) {
|
else if($(this).attr('checked') && form.find("#add_show_repeats").attr('checked')) {
|
||||||
form.find("#add_show_rebroadcast_relative").show();
|
form.find("#add_show_rebroadcast_relative").show();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
form.find("#schedule-record-rebroadcast > fieldset:not(:first-child)").hide();
|
form.find("#schedule-record-rebroadcast > fieldset:not(:first-child)").hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// in case user is creating a new show, there will be
|
// in case user is creating a new show, there will be
|
||||||
|
@ -492,9 +492,9 @@ function setAddShowEvents(form) {
|
||||||
endDateVisibility();
|
endDateVisibility();
|
||||||
form.find("#add_show_no_end").click(endDateVisibility);
|
form.find("#add_show_no_end").click(endDateVisibility);
|
||||||
|
|
||||||
createDateInput(form.find("#add_show_start_date"), startDpSelect);
|
createDateInput(form.find("#add_show_start_date"), startDpSelect);
|
||||||
createDateInput(form.find("#add_show_end_date_no_repeat"), endDpSelect);
|
createDateInput(form.find("#add_show_end_date_no_repeat"), endDpSelect);
|
||||||
createDateInput(form.find("#add_show_end_date"), endDpSelect);
|
createDateInput(form.find("#add_show_end_date"), endDpSelect);
|
||||||
|
|
||||||
$("#add_show_start_time").timepicker({
|
$("#add_show_start_time").timepicker({
|
||||||
amPmText: ['', ''],
|
amPmText: ['', ''],
|
||||||
|
@ -519,7 +519,7 @@ function setAddShowEvents(form) {
|
||||||
closeText: 'Close',
|
closeText: 'Close',
|
||||||
showButtonPanel: true,
|
showButtonPanel: true,
|
||||||
firstDay: calendarPref.weekStart
|
firstDay: calendarPref.weekStart
|
||||||
});
|
});
|
||||||
form.find('input[name^="add_show_rebroadcast_time"]').timepicker({
|
form.find('input[name^="add_show_rebroadcast_time"]').timepicker({
|
||||||
amPmText: ['', ''],
|
amPmText: ['', ''],
|
||||||
defaultTime: '',
|
defaultTime: '',
|
||||||
|
@ -569,36 +569,36 @@ function setAddShowEvents(form) {
|
||||||
list.next().show();
|
list.next().show();
|
||||||
});
|
});
|
||||||
|
|
||||||
form.find("#add_show_hosts_autocomplete").autocomplete({
|
form.find("#add_show_hosts_autocomplete").autocomplete({
|
||||||
source: findHosts,
|
source: findHosts,
|
||||||
select: autoSelect,
|
select: autoSelect,
|
||||||
delay: 200
|
delay: 200
|
||||||
});
|
});
|
||||||
|
|
||||||
form.find("#add_show_hosts_autocomplete").keypress(function(e){
|
form.find("#add_show_hosts_autocomplete").keypress(function(e){
|
||||||
if( e.which == 13 ){
|
if( e.which == 13 ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
form.find("#schedule-show-style input").ColorPicker({
|
form.find("#schedule-show-style input").ColorPicker({
|
||||||
onChange: function (hsb, hex, rgb, el) {
|
onChange: function (hsb, hex, rgb, el) {
|
||||||
$(el).val(hex);
|
$(el).val(hex);
|
||||||
},
|
},
|
||||||
onSubmit: function(hsb, hex, rgb, el) {
|
onSubmit: function(hsb, hex, rgb, el) {
|
||||||
$(el).val(hex);
|
$(el).val(hex);
|
||||||
$(el).ColorPickerHide();
|
$(el).ColorPickerHide();
|
||||||
},
|
},
|
||||||
onBeforeShow: function () {
|
onBeforeShow: function () {
|
||||||
$(this).ColorPickerSetColor(this.value);
|
$(this).ColorPickerSetColor(this.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
form.find("#add-show-close").click(closeAddShowForm);
|
form.find("#add-show-close").click(closeAddShowForm);
|
||||||
|
|
||||||
form.find(".add-show-submit").click(function(event) {
|
form.find(".add-show-submit").click(function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
var addShowButton = $(this);
|
var addShowButton = $(this);
|
||||||
|
|
||||||
$('#schedule-add-show').block({
|
$('#schedule-add-show').block({
|
||||||
|
@ -612,9 +612,25 @@ function setAddShowEvents(form) {
|
||||||
if (form.find("#add_show_record").attr("disabled", true)) {
|
if (form.find("#add_show_record").attr("disabled", true)) {
|
||||||
form.find("#add_show_record").attr("disabled", false);
|
form.find("#add_show_record").attr("disabled", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var startDateDisabled = false,
|
||||||
|
startTimeDisabled = false;
|
||||||
|
|
||||||
|
// Similarly, we need to re-enable start date and time if they're disabled
|
||||||
|
if (form.find("#add_show_start_date").prop("disabled") === true) {
|
||||||
|
form.find("#add_show_start_date").attr("disabled", false);
|
||||||
|
startDateDisabled = true;
|
||||||
|
}
|
||||||
|
if (form.find("#add_show_start_time").prop("disabled") === true) {
|
||||||
|
form.find("#add_show_start_time").attr("disabled", false);
|
||||||
|
startTimeDisabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
var data = $("form").serializeArray();
|
var data = $("form").serializeArray();
|
||||||
|
// We need to notify the application if date and time were disabled
|
||||||
|
data.push({name: 'start_date_disabled', value: startDateDisabled});
|
||||||
|
data.push({name: 'start_time_disabled', value: startTimeDisabled});
|
||||||
|
|
||||||
var hosts = $('#add_show_hosts-element input').map(function() {
|
var hosts = $('#add_show_hosts-element input').map(function() {
|
||||||
if($(this).attr("checked")) {
|
if($(this).attr("checked")) {
|
||||||
return $(this).val();
|
return $(this).val();
|
||||||
|
@ -638,21 +654,21 @@ function setAddShowEvents(form) {
|
||||||
var $addShowForm = $("#add-show-form");
|
var $addShowForm = $("#add-show-form");
|
||||||
|
|
||||||
if (json.form) {
|
if (json.form) {
|
||||||
|
|
||||||
redrawAddShowForm($addShowForm, json.form);
|
redrawAddShowForm($addShowForm, json.form);
|
||||||
|
|
||||||
$("#add_show_end_date").val(end_date);
|
$("#add_show_end_date").val(end_date);
|
||||||
$("#add_show_start_date").val(start_date);
|
$("#add_show_start_date").val(start_date);
|
||||||
showErrorSections();
|
showErrorSections();
|
||||||
}
|
}
|
||||||
else if (json.edit) {
|
else if (json.edit) {
|
||||||
|
|
||||||
$("#schedule_calendar").removeAttr("style")
|
$("#schedule_calendar").removeAttr("style")
|
||||||
.fullCalendar('render');
|
.fullCalendar('render');
|
||||||
|
|
||||||
$addShowForm.hide();
|
$addShowForm.hide();
|
||||||
$.get(baseUrl+"Schedule/get-form", {format:"json"}, function(json){
|
$.get(baseUrl+"Schedule/get-form", {format:"json"}, function(json){
|
||||||
redrawAddShowForm($addShowForm, json.form);
|
redrawAddShowForm($addShowForm, json.form);
|
||||||
});
|
});
|
||||||
makeAddShowButton();
|
makeAddShowButton();
|
||||||
}
|
}
|
||||||
|
@ -662,60 +678,60 @@ function setAddShowEvents(form) {
|
||||||
scheduleRefetchEvents(json);
|
scheduleRefetchEvents(json);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var regDate = new RegExp(/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/);
|
var regDate = new RegExp(/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/);
|
||||||
var regTime = new RegExp(/^[0-2][0-9]:[0-5][0-9]$/);
|
var regTime = new RegExp(/^[0-2][0-9]:[0-5][0-9]$/);
|
||||||
|
|
||||||
// when start date/time changes, set end date/time to start date/time+1 hr
|
// when start date/time changes, set end date/time to start date/time+1 hr
|
||||||
$('#add_show_start_date, #add_show_start_time').bind('input', 'change', function(){
|
$('#add_show_start_date, #add_show_start_time').bind('input', 'change', function(){
|
||||||
var startDateString = $('#add_show_start_date').val();
|
var startDateString = $('#add_show_start_date').val();
|
||||||
var startTimeString = $('#add_show_start_time').val();
|
var startTimeString = $('#add_show_start_time').val();
|
||||||
|
|
||||||
if(regDate.test(startDateString) && regTime.test(startTimeString)){
|
if(regDate.test(startDateString) && regTime.test(startTimeString)){
|
||||||
var startDate = startDateString.split('-');
|
var startDate = startDateString.split('-');
|
||||||
var startTime = startTimeString.split(':');
|
var startTime = startTimeString.split(':');
|
||||||
var startDateTime = new Date(startDate[0], parseInt(startDate[1], 10)-1, startDate[2], startTime[0], startTime[1], 0, 0);
|
var startDateTime = new Date(startDate[0], parseInt(startDate[1], 10)-1, startDate[2], startTime[0], startTime[1], 0, 0);
|
||||||
|
|
||||||
var endDateString = $('#add_show_end_date_no_repeat').val();
|
var endDateString = $('#add_show_end_date_no_repeat').val();
|
||||||
var endTimeString = $('#add_show_end_time').val()
|
var endTimeString = $('#add_show_end_time').val()
|
||||||
var endDate = endDateString.split('-');
|
var endDate = endDateString.split('-');
|
||||||
var endTime = endTimeString.split(':');
|
var endTime = endTimeString.split(':');
|
||||||
var endDateTime = new Date(endDate[0], parseInt(endDate[1], 10)-1, endDate[2], endTime[0], endTime[1], 0, 0);
|
var endDateTime = new Date(endDate[0], parseInt(endDate[1], 10)-1, endDate[2], endTime[0], endTime[1], 0, 0);
|
||||||
|
|
||||||
if(startDateTime.getTime() >= endDateTime.getTime()){
|
if(startDateTime.getTime() >= endDateTime.getTime()){
|
||||||
var duration = $('#add_show_duration').val();
|
var duration = $('#add_show_duration').val();
|
||||||
// parse duration
|
// parse duration
|
||||||
var time = 0;
|
var time = 0;
|
||||||
var info = duration.split(' ');
|
var info = duration.split(' ');
|
||||||
var h = parseInt(info[0], 10);
|
var h = parseInt(info[0], 10);
|
||||||
time += h * 60 * 60* 1000;
|
time += h * 60 * 60* 1000;
|
||||||
if(info.length >1 && $.trim(info[1]) !== ''){
|
if(info.length >1 && $.trim(info[1]) !== ''){
|
||||||
var m = parseInt(info[1], 10);
|
var m = parseInt(info[1], 10);
|
||||||
time += m * 60 * 1000;
|
time += m * 60 * 1000;
|
||||||
}
|
}
|
||||||
endDateTime = new Date(startDateTime.getTime() + time);
|
endDateTime = new Date(startDateTime.getTime() + time);
|
||||||
}
|
}
|
||||||
|
|
||||||
var endDateFormat = endDateTime.getFullYear() + '-' + pad(endDateTime.getMonth()+1,2) + '-' + pad(endDateTime.getDate(),2);
|
var endDateFormat = endDateTime.getFullYear() + '-' + pad(endDateTime.getMonth()+1,2) + '-' + pad(endDateTime.getDate(),2);
|
||||||
var endTimeFormat = pad(endDateTime.getHours(),2) + ':' + pad(endDateTime.getMinutes(),2);
|
var endTimeFormat = pad(endDateTime.getHours(),2) + ':' + pad(endDateTime.getMinutes(),2);
|
||||||
|
|
||||||
$('#add_show_end_date_no_repeat').val(endDateFormat);
|
$('#add_show_end_date_no_repeat').val(endDateFormat);
|
||||||
$('#add_show_end_time').val(endTimeFormat);
|
$('#add_show_end_time').val(endTimeFormat);
|
||||||
|
|
||||||
// calculate duration
|
// calculate duration
|
||||||
var startDateTimeString = startDateString + " " + startTimeString;
|
var startDateTimeString = startDateString + " " + startTimeString;
|
||||||
var endDateTimeString = $('#add_show_end_date_no_repeat').val() + " " + $('#add_show_end_time').val();
|
var endDateTimeString = $('#add_show_end_date_no_repeat').val() + " " + $('#add_show_end_time').val();
|
||||||
var timezone = $("#add_show_timezone").val();
|
var timezone = $("#add_show_timezone").val();
|
||||||
calculateDuration(startDateTimeString, endDateTimeString, timezone);
|
calculateDuration(startDateTimeString, endDateTimeString, timezone);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// when end date/time changes, check if the changed date is in past of start date/time
|
// when end date/time changes, check if the changed date is in past of start date/time
|
||||||
$('#add_show_end_date_no_repeat, #add_show_end_time').bind('input', 'change', function(){
|
$('#add_show_end_date_no_repeat, #add_show_end_time').bind('input', 'change', function(){
|
||||||
var endDateString = $('#add_show_end_date_no_repeat').val();
|
var endDateString = $('#add_show_end_date_no_repeat').val();
|
||||||
var endTimeString = $('#add_show_end_time').val()
|
var endTimeString = $('#add_show_end_time').val()
|
||||||
|
|
||||||
if(regDate.test(endDateString) && regTime.test(endTimeString)){
|
if(regDate.test(endDateString) && regTime.test(endTimeString)){
|
||||||
var startDateString = $('#add_show_start_date').val();
|
var startDateString = $('#add_show_start_date').val();
|
||||||
var startTimeString = $('#add_show_start_time').val();
|
var startTimeString = $('#add_show_start_time').val();
|
||||||
|
@ -727,21 +743,21 @@ function setAddShowEvents(form) {
|
||||||
var endTime = endTimeString.split(':');
|
var endTime = endTimeString.split(':');
|
||||||
var endDateTime = new Date(endDate[0], parseInt(endDate[1], 10)-1, endDate[2], endTime[0], endTime[1], 0, 0);
|
var endDateTime = new Date(endDate[0], parseInt(endDate[1], 10)-1, endDate[2], endTime[0], endTime[1], 0, 0);
|
||||||
|
|
||||||
if(startDateTime.getTime() > endDateTime.getTime()){
|
if(startDateTime.getTime() > endDateTime.getTime()){
|
||||||
$('#add_show_end_date_no_repeat').css('background-color', '#F49C9C');
|
$('#add_show_end_date_no_repeat').css('background-color', '#F49C9C');
|
||||||
$('#add_show_end_time').css('background-color', '#F49C9C');
|
$('#add_show_end_time').css('background-color', '#F49C9C');
|
||||||
}else{
|
}else{
|
||||||
$('#add_show_end_date_no_repeat').css('background-color', '');
|
$('#add_show_end_date_no_repeat').css('background-color', '');
|
||||||
$('#add_show_end_time').css('background-color', '');
|
$('#add_show_end_time').css('background-color', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate duration
|
// calculate duration
|
||||||
var startDateTimeString = startDateString + " " + startTimeString;
|
var startDateTimeString = startDateString + " " + startTimeString;
|
||||||
var endDateTimeString = endDateString + " " + endTimeString;
|
var endDateTimeString = endDateString + " " + endTimeString;
|
||||||
var timezone = $("#add_show_timezone").val();
|
var timezone = $("#add_show_timezone").val();
|
||||||
calculateDuration(startDateTimeString, endDateTimeString, timezone);
|
calculateDuration(startDateTimeString, endDateTimeString, timezone);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if($('#cb_custom_auth').attr('checked')){
|
if($('#cb_custom_auth').attr('checked')){
|
||||||
$('#custom_auth_div').show()
|
$('#custom_auth_div').show()
|
||||||
|
@ -757,18 +773,18 @@ function setAddShowEvents(form) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function calculateDuration(startDateTime, endDateTime, timezone){
|
function calculateDuration(startDateTime, endDateTime, timezone){
|
||||||
var loadingIcon = $('#icon-loader-small');
|
var loadingIcon = $('#icon-loader-small');
|
||||||
|
|
||||||
loadingIcon.show();
|
loadingIcon.show();
|
||||||
$.post(
|
$.post(
|
||||||
baseUrl+"Schedule/calculate-duration",
|
baseUrl+"Schedule/calculate-duration",
|
||||||
{startTime: startDateTime, endTime: endDateTime, timezone: timezone},
|
{startTime: startDateTime, endTime: endDateTime, timezone: timezone},
|
||||||
function(data) {
|
function(data) {
|
||||||
$('#add_show_duration').val(JSON.parse(data));
|
$('#add_show_duration').val(JSON.parse(data));
|
||||||
loadingIcon.hide();
|
loadingIcon.hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var bgColorEle = $("#add_show_background_color");
|
var bgColorEle = $("#add_show_background_color");
|
||||||
var textColorEle = $("#add_show_color");
|
var textColorEle = $("#add_show_color");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue