2008-06-07 19:45:33 +02:00
|
|
|
/**
|
|
|
|
* Calendar - dragNdrop
|
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Christian Binder <christian.binder@freakmail.de>
|
|
|
|
* @package calendar
|
|
|
|
* @copyright (c) 2006 by Christian Binder <christian.binder@freakmail.de>
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
2006-12-15 21:05:47 +01:00
|
|
|
function dragEvent()
|
|
|
|
{
|
|
|
|
if(minOffset())
|
|
|
|
{
|
2010-04-09 16:15:00 +02:00
|
|
|
// set a fixed width
|
|
|
|
dd.obj.css.width = dd.obj.w + dd.px;
|
|
|
|
|
2006-12-15 21:05:47 +01:00
|
|
|
// make a snapshot of the old (original) innerHTML of the dragged event
|
|
|
|
if(!dd.obj.oldInnerHTML)
|
2008-06-07 19:45:33 +02:00
|
|
|
{
|
2006-12-15 21:05:47 +01:00
|
|
|
dd.obj.oldInnerHTML = dd.obj.div.innerHTML;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dropTarget = dd.obj.getEltBelow())
|
|
|
|
{
|
|
|
|
var datetime = dropTarget.my_datetime;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we just allow to drop within the users own calendar
|
|
|
|
// and not crossing into another calendar ATM
|
|
|
|
if(datetime && (dd.obj.my_calendarOwner == dropTarget.my_owner ))
|
|
|
|
{
|
|
|
|
dd.obj.div.innerHTML = '<div style="font-size: 1.1em; font-weight: bold; text-align: center;">' + datetime.substr(9,2) + ":" + datetime.substr(11,2) + '</div>';
|
|
|
|
} else {
|
|
|
|
|
|
|
|
dd.obj.div.innerHTML = '<div style="background-color: red; height: 100%; width: 100%; text-align: center;">' + dd.obj.my_errorImage + '</div>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function dropEvent()
|
2008-06-07 19:45:33 +02:00
|
|
|
{
|
2006-12-15 21:05:47 +01:00
|
|
|
// minimum requirements for ajax call
|
2008-06-07 19:45:33 +02:00
|
|
|
if( minOffset() &&
|
|
|
|
(dropTarget = dd.obj.getEltBelow()) &&
|
2006-12-15 21:05:47 +01:00
|
|
|
(dropTarget.my_datetime) &&
|
|
|
|
(dd.obj.my_calendarOwner == dropTarget.my_owner)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
dd.obj.div.innerHTML = '<div style="height: 100%; width: 100%; text-align: center;">' + dd.obj.my_loaderImage + '</div>';
|
|
|
|
|
|
|
|
xajax_doXMLHTTP(
|
2008-06-07 19:45:33 +02:00
|
|
|
'calendar.calendar_ajax.moveEvent',
|
2006-12-15 21:05:47 +01:00
|
|
|
dd.obj.my_eventId,
|
|
|
|
dd.obj.my_calendarOwner,
|
|
|
|
dropTarget.my_datetime,
|
|
|
|
dropTarget.my_owner
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// abort - move to old position and restore old innerHTML
|
|
|
|
if(dd.obj.oldInnerHTML)
|
|
|
|
{
|
|
|
|
dd.obj.div.innerHTML = dd.obj.oldInnerHTML;
|
|
|
|
}
|
2010-04-09 16:15:00 +02:00
|
|
|
|
|
|
|
// restore old width (calEvent width = 100%)
|
|
|
|
dd.obj.div.style.width = "100%";
|
|
|
|
|
2006-12-15 21:05:47 +01:00
|
|
|
dd.obj.moveTo(dd.obj.defx,dd.obj.defy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function minOffset()
|
|
|
|
{
|
|
|
|
var offsetX = Math.abs(dd.obj.defx - dd.obj.x);
|
|
|
|
var offsetY = Math.abs(dd.obj.defy - dd.obj.y);
|
2008-06-07 19:45:33 +02:00
|
|
|
|
2006-12-15 21:05:47 +01:00
|
|
|
if(offsetX > 5 || offsetY > 5) { return true; }
|
|
|
|
return false;
|
|
|
|
}
|