summaryrefslogtreecommitdiff
path: root/framework/Web/UI/ActiveControls/TDraggable.php
diff options
context:
space:
mode:
authorChristophe.Boulain <>2009-10-02 13:02:23 +0000
committerChristophe.Boulain <>2009-10-02 13:02:23 +0000
commit4fdf0be9fec3ace5a1789a155d4f7a331bb089ce (patch)
tree15bcf6693ae53e59cdbe62ed98e522eeaafa58f4 /framework/Web/UI/ActiveControls/TDraggable.php
parent8206257a146a93722ef5251e057866c8d4d5505c (diff)
Enhancement on drag & drop controls.
Diffstat (limited to 'framework/Web/UI/ActiveControls/TDraggable.php')
-rwxr-xr-xframework/Web/UI/ActiveControls/TDraggable.php56
1 files changed, 49 insertions, 7 deletions
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 :
+ *
+ * <b>{@link setGhosting Ghosting}</b> : 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
+ * <b>{@link setRevert Revert}</b>: Set to True if you want your dragged element to revert to its initial position if not dropped on a valid area.
+ * <b>{@link setConstraint Constraint}</b>: Set this to Horizontal or Vertical if you want to constraint your move in one direction.
+ * <b>{@link setHandle Handle}</b>:
*
* @author Christophe BOULAIN (Christophe.Boulain@gmail.com)
* @copyright Copyright &copy; 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