events: make sure default finish date is one hour after start date and shift the finishdate if startdate is shifted

This commit is contained in:
Mario Vavti 2015-11-25 15:05:21 +01:00
parent 0559db9cf8
commit fe57e7059b
2 changed files with 26 additions and 7 deletions

View File

@ -366,7 +366,7 @@ function events_content(&$a) {
$sdt = ((x($orig_event)) ? $orig_event['start'] : 'now');
$fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now');
$fdt = ((x($orig_event)) ? $orig_event['finish'] : '+1 hour');
$tz = date_default_timezone_get();
if(x($orig_event))
@ -380,8 +380,12 @@ function events_content(&$a) {
$smonth = datetime_convert('UTC', $tz, $sdt, 'm');
$sday = datetime_convert('UTC', $tz, $sdt, 'd');
$shour = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'H') : '00');
$sminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'i') : '00');
// $shour = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'H') : '00');
// $sminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $sdt, 'i') : '00');
$shour = datetime_convert('UTC', $tz, $sdt, 'H');
$sminute = datetime_convert('UTC', $tz, $sdt, 'i');
$stext = datetime_convert('UTC',$tz,$sdt);
$stext = substr($stext,0,14) . "00:00";
@ -393,8 +397,12 @@ function events_content(&$a) {
$fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
$fday = datetime_convert('UTC', $tz, $fdt, 'd');
$fhour = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'H') : '00');
$fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : '00');
// $fhour = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'H') : '00');
// $fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : '00');
$fhour = datetime_convert('UTC', $tz, $fdt, 'H');
$fminute = datetime_convert('UTC', $tz, $fdt, 'i');
$ftext = datetime_convert('UTC',$tz,$fdt);
$ftext = substr($ftext,0,14) . "00:00";
$type = ((x($orig_event)) ? $orig_event['type'] : 'event');

View File

@ -97,7 +97,7 @@
}
}
})
});
// center on date
var args=location.href.replace(baseurl,"").split("/");
@ -113,6 +113,18 @@
var view = $('#events-calendar').fullCalendar('getView');
$('#title').text(view.title);
// shift the finish time date on start time date change automagically
var origsval = $('#id_start_text').val();
$('#id_start_text').change(function() {
var origfval = $('#id_finish_text').val();
var sval = $('#id_start_text').val();
var diff = origsval > sval ? moment(origsval).diff(sval) : moment(sval).diff(origsval);
var fval = origsval > sval ? moment(origfval).subtract(diff, 'millisecond').format("YYYY-MM-DD HH:mm") : moment(origfval).add(diff, 'millisecond').format("YYYY-MM-DD HH:mm");
$('#id_finish_text').val(fval);
origsval = sval;
});
// ACL
$('#id_share').change(function() {
if ($('#id_share').is(':checked')) {
@ -123,7 +135,6 @@
}
}).trigger('change');
$('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
var selstr;
$('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {