From 4fdf0be9fec3ace5a1789a155d4f7a331bb089ce Mon Sep 17 00:00:00 2001
From: "Christophe.Boulain" <>
Date: Fri, 2 Oct 2009 13:02:23 +0000
Subject: Enhancement on drag & drop controls.
---
framework/Web/UI/ActiveControls/TDraggable.php | 56 ++++++++++++++++++++++----
1 file changed, 49 insertions(+), 7 deletions(-)
(limited to 'framework/Web/UI/ActiveControls/TDraggable.php')
diff --git a/framework/Web/UI/ActiveControls/TDraggable.php b/framework/Web/UI/ActiveControls/TDraggable.php
index e4e4c4c4..4c7803a7 100755
--- a/framework/Web/UI/ActiveControls/TDraggable.php
+++ b/framework/Web/UI/ActiveControls/TDraggable.php
@@ -11,7 +11,15 @@
/**
* TDraggable is a control which can be dragged
*
- * This control will make "draggable" control.
+ * This control will make "draggable" control.
+ * Properties :
+ *
+ * {@link setGhosting Ghosting} : If set to "Ghosting" or "True", the dragged element will be cloned, and the clone will be dragged.
+ * If set to "SuperGhosting", the element will be cloned, and attached to body, so it can be dragged outside of its parent.
+ * If set to "None" of "False" (default), the element itself is dragged
+ * {@link setRevert Revert}: Set to True if you want your dragged element to revert to its initial position if not dropped on a valid area.
+ * {@link setConstraint Constraint}: Set this to Horizontal or Vertical if you want to constraint your move in one direction.
+ * {@link setHandle Handle}:
*
* @author Christophe BOULAIN (Christophe.Boulain@gmail.com)
* @copyright Copyright © 2008, PradoSoft
@@ -62,22 +70,38 @@ class TDraggable extends TPanel
* Determine if the element should be cloned when dragged
* If true, Clones the element and drags the clone, leaving the original in place until the clone is dropped.
* Defaults to false
- * @return boolean true to clone the element
+ * Since 3.2, Ghosting can be set to one of the value of {@link TDraggableGhostingOptions} enumeration.
+ * o "True" or "Ghosting" means standard pre-3.2 ghosting mechanism
+ * o "SuperGhosting" use the Superghosting patch by Christopher Williams, which allow elements to be dragged from an
+ * scrollable list
+ * o "False" or "None" means no Ghosting options
+ *
+ * @return TDraggableGhostingOption to clone the element
*/
public function getGhosting ()
{
- return $this->getViewState('Ghosting', false);
+ return $this->getViewState('Ghosting', TDraggableGhostingOptions::None);
}
/**
* Sets wether the element should be cloned when dragged
* If true, Clones the element and drags the clone, leaving the original in place until the clone is dropped.
* Defaults to false
- * @return boolean true to clone the element
+ *
+ * Since 3.2, Ghosting can be set to one of the value of {@link TDraggableGhostingOptions} enumeration.
+ * o "True" or "Ghosting" means standard pre-3.2 ghosting mechanism
+ * o "SuperGhosting" use the Superghosting patch by Christopher Williams, which allow elements to be dragged from an
+ * scrollable list
+ * o "False" or "None" means no Ghosting options
+ *
*/
public function setGhosting ($value)
{
- $this->setViewState('Ghosting', TPropertyValue::ensureBoolean($value), false);
+ if (strcasecmp($value,'true')==0 || $value===true)
+ $value=TDraggableGhostingOptions::Ghosting;
+ elseif (strcasecmp($value,'false')==0 || $value===false)
+ $value=TDraggableGhostingOptions::None;
+ $this->setViewState('Ghosting', TPropertyValue::ensureEnum($value, 'TDraggableGhostingOptions'), TDraggableGhostingOptions::None);
}
/**
@@ -108,7 +132,10 @@ class TDraggable extends TPanel
parent::addAttributesToRender($writer);
$writer->addAttribute('id',$this->getClientID());
$cs=$this->getPage()->getClientScript();
- $cs->registerPradoScript('dragdrop');
+ if ($this->getGhosting()==TDraggableGhostingOptions::SuperGhosting)
+ $cs->registerPradoScript('dragdropextra');
+ else
+ $cs->registerPradoScript('dragdrop');
$options=TJavascript::encode($this->getPostBackOptions());
$class=$this->getClientClassName();
$code="new {$class}('{$this->getClientId()}', {$options}) ";
@@ -136,7 +163,15 @@ class TDraggable extends TPanel
if (($handle=$this->getHandle())!== null) $options['handle']=$handle;
$options['revert']=$this->getRevert();
if (($constraint=$this->getConstraint())!==TDraggableConstraint::None) $options['constraint']=strtolower($constraint);
- $options['ghosting']=$this->getGhosting();
+ switch ($this->getGhosting())
+ {
+ case TDraggableGhostingOptions::SuperGhosting:
+ $options['superghosting']=true;
+ break;
+ case TDraggableGhostingOptions::Ghosting:
+ $options['ghosting']=true;
+ break;
+ }
return $options;
}
@@ -149,4 +184,11 @@ class TDraggableConstraint extends TEnumerable
const Horizontal='Horizontal';
const Vertical='Vertical';
}
+
+class TDraggableGhostingOptions extends TEnumerable
+{
+ const None='None';
+ const Ghosting='Ghosting';
+ const SuperGhosting='SuperGhosting';
+}
?>
\ No newline at end of file
--
cgit v1.2.3