Make calendar entry resizable

This commit is contained in:
Hadi Nategh 2013-12-16 18:10:08 +00:00
parent 2f083e41e4
commit a014b7ba7c
3 changed files with 35 additions and 9 deletions

View File

@ -34,9 +34,10 @@ class calendar_ajax {
* @param string $calendarOwner the owner of the calendar the event is in
* @param string $targetDateTime the datetime where the event should be moved to, format: YYYYMMDD
* @param string $targetOwner the owner of the target calendar
* @param string $durationT the duration to support resizable calendar event
* @return string XML response if no error occurs
*/
function moveEvent($eventId,$calendarOwner,$targetDateTime,$targetOwner)
function moveEvent($eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null)
{
// we do not allow dragging into another users calendar ATM
if(!$calendarOwner == $targetOwner)
@ -45,7 +46,14 @@ class calendar_ajax {
}
$old_event=$event=$this->calendar->read($eventId);
$duration=$event['end']-$event['start'];
if (!$durationT)
{
$duration=$event['end']-$event['start'];
}
else
{
$duration = $durationT;
}
$event['start'] = $this->calendar->date2ts($targetDateTime);
$event['end'] = $event['start']+$duration;
@ -65,7 +73,7 @@ class calendar_ajax {
case 'startday':
if ($sameday) break;
default:
$status_reset_to_unknown = true;
$status_reset_to_unknown = true;
$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
// todo: report reset status to user
}

View File

@ -1864,8 +1864,8 @@ class calendar_uiviews extends calendar_ui
.'onmousemove="event.cancelBubble=true;"';
}
}
$html = $indent.'<div id="'.$draggableID.'" class="calendar_calEvent'.($is_private ? 'Private' : '').' '.$status_class.
$resizableHelper = $this->bo->date2string($event['start']). '|' .$this->bo->format_date($event['start'],false) . '|' . $this->cal_prefs['interval'];
$html = $indent.'<div id="'.$draggableID.'" data-resize="'.$resizableHelper.' " class="calendar_calEvent'.($is_private ? 'Private' : '').' '.$status_class.
'" style="'.$style.' border-color: '.$headerbgcolor.'; background: '.$background.'; z-index: '.$z_index.';"'.
$popup.' '.html::tooltip($tooltip,False,$ttip_options).
$dd_emulation.'>'.$prefix_icon."\n".$ie_fix.$html."\n".

View File

@ -137,7 +137,23 @@ app.classes.calendar = AppJS.extend(
event.helper.width(jQuery("#calColumn").width());
},
});
}).resizable({
handles: "s",
start:function(ui,event){
},
stop:function(ui,event){
var resizeHelper = ui.target.getAttribute('data-resize');
var dataResize = resizeHelper.split("|");
var time = dataResize[1].split(":");
var dropDate = dataResize[0]+"T"+time[0]+time[1];
var drop = jQuery("div[id^='drop_"+dropDate+"']");
var newDuration = Math.round(this.clientHeight/drop[0].clientHeight)* parseInt(dataResize[2]) * 60;
that.dropEvent(this.getAttribute('id'),dropDate,newDuration);
},
});;
//Droppable
@ -168,7 +184,7 @@ app.classes.calendar = AppJS.extend(
if (dpOwner == null) dpOwner = dgOwner;
if (dpOwner == dgOwner )
{
that.dropEvent(event.draggable[0].id, id.target.getAttribute('id').substring(id.target.getAttribute('id').lastIndexOf("drop_")+5, id.target.getAttribute('id').lastIndexOf("_O")));
that.dropEvent(event.draggable[0].id, id.target.getAttribute('id').substring(id.target.getAttribute('id').lastIndexOf("drop_")+5, id.target.getAttribute('id').lastIndexOf("_O")),null);
}
else
{
@ -222,9 +238,10 @@ app.classes.calendar = AppJS.extend(
*
* @param {string} _id dragged event id
* @param {array} _date array of date,hour, and minute of dropped cell
* @param {string} _duration description
*
*/
dropEvent : function(_id, _date)
dropEvent : function(_id, _date, _duration)
{
var eventId = _id.substring(_id.lastIndexOf("drag_")+5,_id.lastIndexOf("_O"));
var calOwner = _id.substring(_id.lastIndexOf("_O")+2,_id.lastIndexOf("_C"));
@ -235,7 +252,8 @@ app.classes.calendar = AppJS.extend(
eventId,
calOwner,
date,
eventOwner
eventOwner,
_duration
);
},
/**