mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
modified walter zorns wz_dragdrop.js to have a defined focus on the draggables (e.g. top left or center center) - sent these changes to walter zorn as he thought himself about implementing that, set calendar events to focus now on top center with a border of 2 pixels to make dragging more logical for the user - modified dragdrop class to take focus as e.g. 'top left 5' focuses draggable on top left with a border of 5 pixels inside
This commit is contained in:
parent
363f287892
commit
6f78261f7f
@ -1239,7 +1239,8 @@ class uiviews extends uical
|
||||
'loaderImage'=>addslashes($this->html->image('phpgwapi','ajax-loader')),
|
||||
),
|
||||
'calendar.dragDropFunctions.dragEvent',
|
||||
'calendar.dragDropFunctions.dropEvent'
|
||||
'calendar.dragDropFunctions.dropEvent',
|
||||
'top center 2'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -68,12 +68,13 @@ class dragdrop
|
||||
* @param array $values=false optional associative array with values of the object
|
||||
* @param string $dragAction=false ActionScript executed while item is dragged e.g. calendar.myscript.mydrag
|
||||
* @param string $dropAction=false ActionScript executed when item is dropped e.g. calendar.myscript.mydrop
|
||||
* @param string $focus=false position of the focus for underlying objects, something like 'top left 5' or 'center center 0'
|
||||
* @return boolean true if all actions succeded, false otherwise
|
||||
*/
|
||||
function addDraggable($name,$values = false,$dragAction = false,$dropAction = false)
|
||||
function addDraggable($name,$values = false,$dragAction = false,$dropAction = false,$focus = false)
|
||||
{
|
||||
if(!$this->checkUnique($name)) { return false; }
|
||||
$this->draggables[] = array('name'=>$name,'values'=>$values,'dragAction'=>$this->registerActionScript($dragAction),'dropAction'=>$this->registerActionScript($dropAction));
|
||||
$this->draggables[] = array('name'=>$name,'values'=>$values,'dragAction'=>$this->registerActionScript($dragAction),'dropAction'=>$this->registerActionScript($dropAction),'focus'=>$this->addApostrophes($focus));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -170,6 +171,7 @@ class dragdrop
|
||||
}
|
||||
if($element['dragAction']) { $GLOBALS['egw_info']['flags']['need_footer'] .= 'dd.elements.'.$element['name'].'.setDragFunc('.$element['dragAction'].');'."\n"; }
|
||||
if($element['dropAction']) { $GLOBALS['egw_info']['flags']['need_footer'] .= 'dd.elements.'.$element['name'].'.setDropFunc('.$element['dropAction'].');'."\n"; }
|
||||
if($element['focus']) { $GLOBALS['egw_info']['flags']['need_footer'] .= 'dd.elements.'.$element['name'].'.setFocus('.$element['focus'].');'."\n"; }
|
||||
}
|
||||
$GLOBALS['egw_info']['flags']['need_footer'] .= '</script>'."\n";
|
||||
}
|
||||
@ -293,4 +295,24 @@ class dragdrop
|
||||
return $functionname;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds apostrophes to each value in a space separated string
|
||||
*
|
||||
* @param string $val space separated values
|
||||
* @return string comma separated values in apostrophes if $val is true, otherwise false
|
||||
*/
|
||||
function addApostrophes($val=false)
|
||||
{
|
||||
if($val)
|
||||
{
|
||||
foreach(explode(' ',$val) as $id=>$value)
|
||||
{
|
||||
$apostropheVal[] = '"'.$value.'"';
|
||||
}
|
||||
return implode(',',$apostropheVal);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -374,6 +374,9 @@ dd.addProps = function(d_o)
|
||||
d_o._setCrs(d_o.nodrag? 'auto' : d_o.cursor);
|
||||
d_o.diaphan = d_o.diaphan || dd.diaphan || 0;
|
||||
d_o.opacity = 1.0;
|
||||
d_o.focus_x = 'center';
|
||||
d_o.focus_y = 'center';
|
||||
d_o.focus_border = 0;
|
||||
d_o.visible = true;
|
||||
};
|
||||
dd.initz = function()
|
||||
@ -865,6 +868,12 @@ DDObj.prototype._setOpaRel = function(d_x, d_kd, d_y, d_o)
|
||||
if(!(d_o = this.children[d_i]).detached) d_o._setOpaRel(d_x, 1);
|
||||
}
|
||||
};
|
||||
DDObj.prototype.setFocus = function(d_y, d_x,d_b)
|
||||
{
|
||||
this.focus_y = d_y;
|
||||
this.focus_x = d_x;
|
||||
this.focus_border = d_b;
|
||||
};
|
||||
DDObj.prototype.setCursor = function(d_x)
|
||||
{
|
||||
this._setCrs(this.cursor = (d_x.indexOf('c:')+1)? d_x.substring(2) : d_x);
|
||||
@ -890,11 +899,38 @@ DDObj.prototype.setScalable = function(d_x)
|
||||
};
|
||||
DDObj.prototype.getEltBelow = function(d_ret, d_x, d_y)
|
||||
{
|
||||
switch(this.focus_y)
|
||||
{
|
||||
case 'top':
|
||||
var f_y = 0 + this.focus_border;
|
||||
break;
|
||||
case 'bottom':
|
||||
var f_y = this.h - this.focus_border;
|
||||
break;
|
||||
case 'center':
|
||||
default:
|
||||
var f_y = this.h/2;
|
||||
break;
|
||||
}
|
||||
switch(this.focus_x)
|
||||
{
|
||||
case 'left':
|
||||
var f_x = 0 + this.focus_border;
|
||||
break;
|
||||
case 'right':
|
||||
var f_x = this.w - this.focus_border;
|
||||
break;
|
||||
case 'center':
|
||||
default:
|
||||
var f_x = this.w/2;
|
||||
break;
|
||||
}
|
||||
|
||||
var d_o, d_cmp = -1, d_i = dd.elements.length; while(d_i--)
|
||||
{
|
||||
d_o = dd.elements[d_i];
|
||||
d_x = d_o.x-this.w/2;
|
||||
d_y = d_o.y-this.h/2;
|
||||
d_x = d_o.x-f_x;
|
||||
d_y = d_o.y-f_y;
|
||||
if(d_o.visible && d_o.z < this.z && this.x >= d_x && this.x <= d_x+d_o.w && this.y >= d_y && this.y <= d_y+d_o.h)
|
||||
{
|
||||
if(d_o.z > d_cmp)
|
||||
|
Loading…
Reference in New Issue
Block a user