summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes6
-rwxr-xr-xdemos/quickstart/protected/pages/ActiveControls/DragDrop.page26
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Home.page22
-rwxr-xr-xdemos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.page90
-rwxr-xr-xdemos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.php112
-rwxr-xr-xdemos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product1.pngbin0 -> 10711 bytes
-rwxr-xr-xdemos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product2.pngbin0 -> 9550 bytes
-rwxr-xr-xdemos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/trash.pngbin0 -> 783 bytes
-rw-r--r--demos/quickstart/protected/pages/GettingStarted/NewFeatures.page8
-rw-r--r--framework/Web/Javascripts/source/packages.php5
-rwxr-xr-xframework/Web/Javascripts/source/prado/activecontrols/dragdrop.js24
-rwxr-xr-xframework/Web/UI/ActiveControls/TDraggable.php152
-rwxr-xr-xframework/Web/UI/ActiveControls/TDropContainer.php275
13 files changed, 716 insertions, 4 deletions
diff --git a/.gitattributes b/.gitattributes
index 8389fd93..8777ae33 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1277,8 +1277,13 @@ demos/quickstart/protected/pages/ActiveControls/ActiveCustomValidator.page -text
demos/quickstart/protected/pages/ActiveControls/ActiveHyperLink.page -text
demos/quickstart/protected/pages/ActiveControls/ActivePager.page -text
demos/quickstart/protected/pages/ActiveControls/AutoComplete.page -text
+demos/quickstart/protected/pages/ActiveControls/DragDrop.page -text
demos/quickstart/protected/pages/ActiveControls/Home.page -text
demos/quickstart/protected/pages/ActiveControls/Introduction.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.page -text
+demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product1.png -text svneol=unset#image/png
+demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product2.png -text svneol=unset#image/png
+demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/trash.png -text svneol=unset#image/png
demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.page -text
demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.php -text
demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.page -text
@@ -2519,6 +2524,7 @@ framework/Web/Javascripts/source/packages.php -text
framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js -text
framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js -text
framework/Web/Javascripts/source/prado/activecontrols/ajax3.js -text
+framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js -text
framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js -text
framework/Web/Javascripts/source/prado/activecontrols/json.js -text
framework/Web/Javascripts/source/prado/activeratings/blocks.css -text
diff --git a/demos/quickstart/protected/pages/ActiveControls/DragDrop.page b/demos/quickstart/protected/pages/ActiveControls/DragDrop.page
new file mode 100755
index 00000000..0969ddd0
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/DragDrop.page
@@ -0,0 +1,26 @@
+<com:TContent ID="body">
+<!-- $Id$ -->
+<h1>TDropContainer</h1>
+<com:DocLink ClassPath="System.Web.UI.ActiveControls.TDropContainer" />
+
+<p class="block-content"><tt>TDropContainer</tt> represent an area where
+<tt>TDraggable</tt> controls can be dropped.
+When a <tt>TDraggable</tt> is dropped, a
+callback request is initiated. The <tt>OnCallback</tt> event is raised
+during a callback request and it is raised <strong>after</strong>
+the <tt>OnDropk</tt> event.
+</p>
+
+
+<h1>TDraggable</h1>
+<com:DocLink ClassPath="System.Web.UI.ActiveControls.TDraggable" />
+
+<p class="block-content"><tt>TDraggable</tt> will make its child controls 'draggable'.
+When a <tt>TDraggable</tt> is dropped, a
+callback request is initiated. The <tt>OnCallback</tt> event is raised
+during a callback request and it is raised <strong>after</strong>
+the <tt>OnDropk</tt> event.
+</p>
+<com:RunBar PagePath="ActiveControls.Samples.DragDrop.Home" />
+
+<div class="last-modified">$Id$</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Home.page b/demos/quickstart/protected/pages/ActiveControls/Home.page
index 5cf4ab17..3cd9b0aa 100644
--- a/demos/quickstart/protected/pages/ActiveControls/Home.page
+++ b/demos/quickstart/protected/pages/ActiveControls/Home.page
@@ -160,6 +160,12 @@ TActiveButton</a> control. See also the later part of the <a href="?page=Tutoria
* <a href="?page=ActiveControls.ValueTriggeredCallback">TValueTriggeredCallback</a>
monitors (using a timer) an attribute of an HTML element and triggers a callback request
when the attribute value changes.
+ </li>
+
+ <li>
+ <a href="?page=ActiveControls.DrapDrop">TDropContainer & TDraggable</a> represents drag and drop containers.
+ The former will make its child controls "draggable" while the latter will raise a callback when a draggable
+ control is dropped on it.
</li>
</ul>
@@ -310,7 +316,21 @@ if Javascript was disabled on the client's browser.</p>
<a href="?page=ActiveControls.ValueTriggeredCallback">TValueTriggeredCallback</a>
</td>
<td>Yes</td><td>No</td>
- </tr>
+ </tr>
+
+ <tr><td>
+ <a href="?page=ActiveControls.DragDrop">TDropContainer</a>
+ </td>
+ <td>Yes</td><td>No</td>
+ </tr>
+
+ <tr><td>
+ <a href="?page=ActiveControls.DragDrop">TDraggable</a>
+ </td>
+ <td>No</td><td>No</td>
+ </tr>
+
+
</table>
<h2 id="128036">Active Control Infrastructure Classes</h2>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.page
new file mode 100755
index 00000000..89d64110
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.page
@@ -0,0 +1,90 @@
+<com:TContent id="body">
+<style>
+.cart {
+ border: 1px solid #E8A400;
+ background-color: white;
+ padding: 8px;
+ width: 500px;
+ height: 150px;
+}
+
+.cart-hover {
+ background-color: #E8A400;
+}
+
+.cart-items {
+ width: 30px;
+ height: 30px;
+}
+
+.products {
+ float: left;
+ width: 100px;
+ height: 100px;
+ margin-right: 10px;
+}
+
+.draggable {
+ cursor: move
+}
+
+.removable {
+}
+
+.trash {
+ width: 50px;
+ height: 50px;
+ border: 1px solid black;
+}
+
+.trash-hover {
+ background-image: url(<%~ assets/trash.png%>);
+}
+
+</style>
+<h1>Drag &amp; Drop demo !</h1>
+
+<h2>Product List :</h2>
+
+<div style="margin-bottom: 20px; height: 120px">
+
+<com:TRepeater Id="ProductList" DataKeyField="ProductId">
+ <prop:ItemTemplate>
+ <com:TDraggable CssClass="products draggable" >
+ <com:TImage ImageUrl=<%#$this->Data['ProductImageUrl']%> />
+ </com:TDraggable>
+ </prop:ItemTemplate>
+</com:TRepeater>
+</div>
+<h2>Your shopping cart :</h2>
+<com:TDropContainer CssClass="cart" Id="cart"
+ AcceptCssClass="draggable"
+ HoverCssClass="cart-hover"
+ OnDrop="addItemToCart"
+ OnCallback="redrawCart"
+ >
+ <com:TRepeater id="ShoppingList" DataKeyField="ProductId">
+ <prop:EmptyTemplate>
+ Your shopping cart is empty, please add some items !
+ </prop:EmptyTemplate>
+ <prop:ItemTemplate>
+ <com:TDraggable CssClass="removable"
+ Revert="true"
+ Handle="<%=$this->itemImage->ClientId%>"
+ Ghosting=<%#($this->Data['ProductCount'] > 1)%>
+ >
+ <com:TImage id="itemImage" CssClass="cart-items" Style="cursor:move" ImageUrl=<%#$this->Data['ProductImageUrl']%>/>
+ <com:TLabel id="itemTitle" Text=<%#$this->Data['ProductTitle']%>/>
+ <com:TLabel id="itemCount" Text="(<%#$this->Data['ProductCount']%>)" />
+ </com:TDraggable>
+ </prop:ItemTemplate>
+ </com:TRepeater>
+</com:TDropContainer>
+<h2>Remove Items from cart by dropping them here</h2>
+<com:TDropContainer CssClass="trash" id="trash"
+ AcceptCssClass="removable"
+ OnDrop="removeItemFromCart"
+ OnCallback="redrawCart"
+ HoverCssClass="trash-hover"
+/>
+</com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.php
new file mode 100755
index 00000000..276ee6a4
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.php
@@ -0,0 +1,112 @@
+<?php
+
+prado::using ('System.Web.UI.ActiveControls.*');
+
+class Home extends TPage
+{
+ public function onInit ($param)
+ {
+ parent::onInit($param);
+ if (!$this->getIsPostBack() && !$this->getIsCallBack())
+ {
+
+ $this->populateProductList();
+ $this->populateShoppingList();
+ }
+ }
+
+ private function getProductData ()
+ {
+ return array (
+ array (
+ 'ProductId' => 'Product1',
+ 'ProductImageUrl' => $this->publishAsset('assets/product1.png'),
+ 'ProductTitle' => 'Cup'
+ ),
+ array (
+ 'ProductId' => 'Product2',
+ 'ProductImageUrl' => $this->publishAsset('assets/product2.png'),
+ 'ProductTitle' => 'T-Shirt'
+ )
+ );
+ }
+
+ private function getProduct ($key)
+ {
+ foreach ($this->getProductData() as $product)
+ if ($product['ProductId']==$key) return $product;
+ return null;
+ }
+
+ protected function populateProductList ()
+ {
+ $this->ProductList->DataSource=$this->getProductData();
+ $this->ProductList->Databind();
+ }
+
+ protected function populateShoppingList ()
+ {
+ $this->ShoppingList->DataSource=$this->getShoppingListData();
+ $this->ShoppingList->Databind();
+
+ }
+
+
+ public function getShoppingListData ()
+ {
+ return $this->getViewState('ShoppingList', array ());
+ }
+
+ public function setShoppingListData ($value)
+ {
+ $this->setViewState('ShoppingList', TPropertyValue::ensureArray($value), array ());
+ }
+
+ public function addItemToCart ($sender, $param)
+ {
+ $control=$param->getDroppedControl();
+ // Get the Key from the repeater item
+ $item=$control->getNamingContainer();
+ $key=$this->ProductList->getDataKeys()->itemAt($item->getItemIndex());
+ $product=$this->getProduct($key);
+ $shoppingList=$this->getShoppingListData();
+ if (isset ($shoppingList[$key]))
+ {
+ // Already an item of this type, increment counter
+ $shoppingList[$key]['ProductCount']++;
+ }
+ else
+ {
+ // Add an item to the shopping list
+ $shoppingList[$key]=$product;
+ $shoppingList[$key]['ProductCount']=1;
+ }
+ $this->setShoppingListData($shoppingList);
+
+ }
+
+ public function removeItemFromCart ($sender, $param)
+ {
+ $control=$param->getDroppedControl();
+ $item=$control->getNamingContainer();
+ $key=$this->ShoppingList->getDataKeys()->itemAt($item->getItemIndex());
+ $shoppingList=$this->getShoppingListData();
+ if (isset($shoppingList[$key]))
+ {
+ if ($shoppingList[$key]['ProductCount'] > 1)
+ $shoppingList[$key]['ProductCount'] --;
+ else
+ unset($shoppingList[$key]);
+ }
+ $this->setShoppingListData($shoppingList);
+
+ }
+
+ public function redrawCart ($sender, $param)
+ {
+ $this->populateShoppingList();
+ $this->cart->render($param->NewWriter);
+
+ }
+}
+?> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product1.png b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product1.png
new file mode 100755
index 00000000..ae03d551
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product1.png
Binary files differ
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product2.png b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product2.png
new file mode 100755
index 00000000..25e81ad7
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product2.png
Binary files differ
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/trash.png b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/trash.png
new file mode 100755
index 00000000..184f7628
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/trash.png
Binary files differ
diff --git a/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page b/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page
index 66e3111d..51dbb981 100644
--- a/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page
+++ b/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page
@@ -4,7 +4,13 @@
<p id="40005" class="block-content">
This page summarizes the main new features that are introduced in each PRADO release.
-</p>
+</p>
+
+<h2>Version 3.1.3</h2>
+<ul>
+<li>Added <a href="?page=ActiveControls.DragDrop">Drag and drop controls</a></li>
+<li>Added TActiveDatePicker control</li>
+</ul>
<h2>Version 3.1.2</h2>
<ul>
diff --git a/framework/Web/Javascripts/source/packages.php b/framework/Web/Javascripts/source/packages.php
index 7c0a1674..b19a5d18 100644
--- a/framework/Web/Javascripts/source/packages.php
+++ b/framework/Web/Javascripts/source/packages.php
@@ -47,7 +47,8 @@ $packages = array(
),
'dragdrop'=>array(
- SCRIPTACULOUS_DIR.'/dragdrop.js'
+ SCRIPTACULOUS_DIR.'/dragdrop.js',
+ 'prado/activecontrols/dragdrop.js'
),
'slider'=>array(
@@ -78,7 +79,7 @@ $dependencies = array(
'datepicker' => array('prado', 'datepicker'),
'colorpicker' => array('prado', 'colorpicker'),
'ajax' => array('prado', 'effects', 'ajax'),
- 'dragdrop' => array('prado', 'effects', 'dragdrop'),
+ 'dragdrop' => array('prado', 'effects', 'ajax', 'dragdrop'),
'slider' => array('prado', 'slider'),
'keyboard' => array('prado', 'keyboard'),
'tabpanel' => array('prado', 'tabpanel'),
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js b/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js
new file mode 100755
index 00000000..0b42afd5
--- /dev/null
+++ b/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js
@@ -0,0 +1,24 @@
+/**
+ * DropContainer control
+ */
+
+Prado.WebUI.DropContainer = Class.extend(Prado.WebUI.CallbackControl);
+
+Object.extend(Prado.WebUI.DropContainer.prototype,
+{
+ initialize: function(options)
+ {
+ this.options = options;
+ Object.extend (this.options,
+ {
+ onDrop: this.onDrop.bind(this)
+ });
+
+ Droppables.add (options.ID, this.options);
+ },
+
+ onDrop: function(dragElement, dropElement)
+ {
+ Prado.Callback(this.options.EventTarget, dragElement.id, null, this.options);
+ }
+});
diff --git a/framework/Web/UI/ActiveControls/TDraggable.php b/framework/Web/UI/ActiveControls/TDraggable.php
new file mode 100755
index 00000000..e4e4c4c4
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TDraggable.php
@@ -0,0 +1,152 @@
+<?php
+/**
+ * TDraggable class file
+ *
+ * @author Christophe BOULAIN (Christophe.Boulain@gmail.com)
+ * @copyright Copyright &copy; 2008, PradoSoft
+ * @license http://www.pradosoft.com/license
+ * @version $Id$
+ */
+
+/**
+ * TDraggable is a control which can be dragged
+ *
+ * This control will make "draggable" control.
+ *
+ * @author Christophe BOULAIN (Christophe.Boulain@gmail.com)
+ * @copyright Copyright &copy; 2008, PradoSoft
+ * @license http://www.pradosoft.com/license
+ * @version $Id$
+ */
+class TDraggable extends TPanel
+{
+ /**
+ * Set the handle id or css class
+ * @param string
+ */
+ public function setHandle ($value)
+ {
+ $this->setViewState('DragHandle', TPropertyValue::ensureString($value), null);
+ }
+
+ /**
+ * Get the handle id or css class
+ * @return string
+ */
+ public function getHandle ()
+ {
+ return $this->getViewState('DragHandle', null);
+ }
+
+ /**
+ * Determine if draggable element should revert to it orginal position
+ * upon release in an non-droppable container.
+ * @return boolean true to revert
+ */
+ public function getRevert()
+ {
+ return $this->getViewState('Revert', true);
+ }
+
+ /**
+ * Sets whether the draggable element should revert to it orginal position
+ * upon release in an non-droppable container.
+ * @param boolean true to revert
+ */
+ public function setRevert($value)
+ {
+ $this->setViewState('Revert', TPropertyValue::ensureBoolean($value), true);
+ }
+
+ /**
+ * 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
+ */
+ public function getGhosting ()
+ {
+ return $this->getViewState('Ghosting', false);
+ }
+
+ /**
+ * 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
+ */
+ public function setGhosting ($value)
+ {
+ $this->setViewState('Ghosting', TPropertyValue::ensureBoolean($value), false);
+ }
+
+ /**
+ * Determine if the element should be constrainted in one direction or not
+ * @return CDraggableConstraint
+ */
+ public function getConstraint()
+ {
+ return $this->getViewState('Constraint', TDraggableConstraint::None);
+ }
+
+ /**
+ * Set wether the element should be constrainted in one direction
+ * @param CDraggableConstraint
+ */
+ public function setConstraint($value)
+ {
+ $this->setViewState('Constraint', TPropertyValue::ensureEnum($value, 'TDraggableConstraint'), TDraggableConstraint::None);
+ }
+
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+ $writer->addAttribute('id',$this->getClientID());
+ $cs=$this->getPage()->getClientScript();
+ $cs->registerPradoScript('dragdrop');
+ $options=TJavascript::encode($this->getPostBackOptions());
+ $class=$this->getClientClassName();
+ $code="new {$class}('{$this->getClientId()}', {$options}) ";
+ $cs->registerEndScript(sprintf('%08X', crc32($code)), $code);
+ }
+
+ /**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName ()
+ {
+ return 'Draggable';
+ }
+
+ /**
+ * Gets the post back options for this textbox.
+ * @return array
+ */
+ protected function getPostBackOptions()
+ {
+ $options['ID'] = $this->getClientID();
+
+ 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();
+
+ return $options;
+ }
+
+}
+
+class TDraggableConstraint extends TEnumerable
+{
+ const None='None';
+ const Horizontal='Horizontal';
+ const Vertical='Vertical';
+}
+?> \ No newline at end of file
diff --git a/framework/Web/UI/ActiveControls/TDropContainer.php b/framework/Web/UI/ActiveControls/TDropContainer.php
new file mode 100755
index 00000000..5d090d95
--- /dev/null
+++ b/framework/Web/UI/ActiveControls/TDropContainer.php
@@ -0,0 +1,275 @@
+<?php
+/**
+ * TDropContainer class file
+ *
+ * @author Christophe BOULAIN (Christophe.Boulain@gmail.com)
+ * @copyright Copyright &copy; 2008, PradoSoft
+ * @license http://www.pradosoft.com/license
+ * @version $Id$
+ */
+
+/**
+ * Load active control adapter.
+ */
+Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
+/**
+ * Load active panel.
+ */
+Prado::using('System.Web.UI.ActiveControls.TActivePanel');
+
+
+/**
+ * TDropContainer is a panel where TDraggable controls can be dropped.
+ * When a TDraggable component is dropped into a TDropContainer, the {@link OnDrop OnDrop} event is raised.
+ * The {@link TDropContainerEventParameter} param will contain the dropped control.
+ *
+ * Properties :
+ *
+ * <b>{@link setAcceptCssClass AcceptCssClass}</b> : a coma delimited classname of elements that the drop container can accept.
+ * <b>{@link setHoverCssClass HoverCssClass}</b>: CSS classname of the container when a draggable element hovers over the container.
+ *
+ * Events:
+ *
+ * <b>{@link OnDrop OnDrop} : raised when a TDraggable control is dropped. The dropped control is encapsulated in the event parameter
+ *
+ * @author Christophe BOULAIN (Christophe.Boulain@gmail.com)
+ * @copyright Copyright &copy; 2008, PradoSoft
+ * @license http://www.pradosoft.com/license
+ * @version $Id$
+ */
+class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHandler
+{
+ private $_container=null;
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ }
+
+ /**
+ * @return TBaseActiveControl standard active control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+
+ /**
+ * Gets the Css class name that this container can accept.
+ * @return string
+ */
+ public function getAcceptCssClass()
+ {
+ return $this->getViewState('Accepts', '');
+ }
+
+ /**
+ * Sets the Css class name that this container can accept.
+ * @param string comma delimited css class names.
+ */
+ public function setAcceptCssClass($value)
+ {
+ $this->setViewState('Accepts', TPropertyValue::ensureArray($value), '');
+ }
+
+ /**
+ * Sets the Css class name used when a draggble element is hovering
+ * over this container.
+ * @param string css class name during draggable hover.
+ */
+ public function setHoverCssClass($value)
+ {
+ $this->setViewState('HoverClass', $value, '');
+ }
+
+ /**
+ * Gets the Css class name used when a draggble element is hovering
+ * over this container.
+ * @return string css class name during draggable hover.
+ */
+ public function getHoverCssClass()
+ {
+ return $this->getViewState('HoverClass', '');
+ }
+
+
+ /**
+ * Raises callback event. This method is required bu {@link ICallbackEventHandler}
+ * interface.
+ * It raises the {@link onDrop OnDrop} event, then, the {@link onCallback OnCallback} event
+ * This method is mainly used by framework and control developers.
+ * @param TCallbackEventParameter the parameter associated with the callback event
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->onDrop($param->getCallbackParameter());
+ $this->onCallback($param);
+ }
+
+ /**
+ * Raises the onDrop event.
+ * The dropped control is encapsulated into a {@link TDropContainerEventParameter}
+ *
+ * @param string $dropControlId
+ */
+ public function onDrop ($dropControlId)
+ {
+ // Find the control
+ // Warning, this will not work if you have a '_' in your control Id !
+ $control=$this->getPage();
+ $namingContainers=explode(TControl::CLIENT_ID_SEPARATOR, $dropControlId);
+ foreach ($namingContainers as $nc)
+ {
+ $control=$control->findControl($nc);
+ }
+ $this->raiseEvent('OnDrop', $this, new TDropContainerEventParameter ($control));
+
+ }
+
+ /**
+ * This method is invoked when a callback is requested. The method raises
+ * 'OnCallback' event to fire up the event handlers. If you override this
+ * method, be sure to call the parent implementation so that the event
+ * handler can be invoked.
+ * @param TCallbackEventParameter event parameter to be passed to the event handlers
+ */
+ public function onCallback($param)
+ {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
+
+ /**
+ * Gets the post back options for this textbox.
+ * @return array
+ */
+ protected function getPostBackOptions()
+ {
+ $options['ID'] = $this->getClientID();
+ $options['EventTarget'] = $this->getUniqueID();
+
+ $options['accept'] = TJavascript::encode($this->getAcceptCssClass());
+ $options['hoverclass'] = $this->getHoverCssClass();
+ return $options;
+ }
+
+ /**
+ * Gets the name of the javascript class responsible for performing postback for this control.
+ * This method overrides the parent implementation.
+ * @return string the javascript class name
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.DropContainer';
+ }
+
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+ $writer->addAttribute('id',$this->getClientID());
+
+ $this->getPage()->getClientScript()->registerPradoScript('dragdrop');
+
+ $this->getActiveControl()->registerCallbackClientScript(
+ $this->getClientClassName(), $this->getPostBackOptions());
+ }
+
+ /**
+ * Creates child control
+ * Override parent implementation to create a container which will contain all
+ * child controls. This container will be a TActivePanel, in order to allow user
+ * to update its content on callback.
+ */
+ public function createChildControls ()
+ {
+ if ($this->_container===null)
+ {
+ $this->_container=Prado::CreateComponent('System.Web.UI.ActiveControls.TActivePanel');
+ $this->_container->setId($this->getId().'_content');
+ parent::getControls()->add($this->_container);
+ }
+ }
+
+ /**
+ * Override parent implementation to return the container control collection.
+ *
+ * @return TControlCollection
+ */
+ public function getControls()
+ {
+ $this->ensureChildControls();
+ return $this->_container->getControls();
+ }
+
+ /**
+ * Renders and replaces the panel's content on the client-side.
+ * When render() is called before the OnPreRender event, such as when render()
+ * is called during a callback event handler, the rendering
+ * is defered until OnPreRender event is raised.
+ * @param THtmlWriter html writer
+ */
+ public function render ($writer)
+ {
+ if($this->getHasPreRendered())
+ {
+ parent::render($writer);
+ if($this->getActiveControl()->canUpdateClientSide())
+ $this->getPage()->getCallbackClient()->replaceContent($this->_container,$writer);
+ }
+ else
+ {
+ $this->getPage()->getAdapter()->registerControlToRender($this->_container,$writer);
+ }
+ }
+
+}
+
+/**
+ * TDropContainerEventParameter class
+ *
+ * TDropContainerEventParameter encapsulate the parameter
+ * data for <b>OnDrop</b> event of TDropContainer components
+ *
+ * @author Christophe BOULAIN (Christophe.Boulain@ceram.fr)
+ * @copyright Copyright &copy; 2008, PradoSoft
+ * @license http://www.pradosoft.com/license
+ * @version $Id$
+ */
+class TDropContainerEventParameter extends TEventParameter
+{
+ /*
+ * the id of control which has been dropped
+ * @var string
+ */
+ private $_droppedControl;
+
+ /**
+ * constructor
+ *
+ * @param string the id of control which been dropped
+ */
+ public function __construct ($control)
+ {
+ $this->_droppedControl=$control;
+ }
+
+ /**
+ * @return TDraggable
+ */
+ public function getDroppedControl ()
+ {
+ return $this->_droppedControl;
+ }
+}
+?> \ No newline at end of file