diff options
author | Fabio Bas <ctrlaltca@gmail.com> | 2014-02-06 16:23:42 +0100 |
---|---|---|
committer | Fabio Bas <ctrlaltca@gmail.com> | 2014-02-06 16:23:42 +0100 |
commit | 2c1d9d453404ec2e3344ef477bf834a2a3c065af (patch) | |
tree | d309eca34de724db2804e0febaab76a68b50b889 /framework/Web/UI/JuiControls/TJuiDraggable.php | |
parent | 705a311b3bbc223737a51bec1d2f978554da086a (diff) |
Implemented basic support for callback events for JUI controls; TJuiDraggable and TJuiDroppable examples
Diffstat (limited to 'framework/Web/UI/JuiControls/TJuiDraggable.php')
-rw-r--r-- | framework/Web/UI/JuiControls/TJuiDraggable.php | 75 |
1 files changed, 68 insertions, 7 deletions
diff --git a/framework/Web/UI/JuiControls/TJuiDraggable.php b/framework/Web/UI/JuiControls/TJuiDraggable.php index 19d334aa..56e6c7e7 100644 --- a/framework/Web/UI/JuiControls/TJuiDraggable.php +++ b/framework/Web/UI/JuiControls/TJuiDraggable.php @@ -10,16 +10,22 @@ */ Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter'); +Prado::using('System.Web.UI.ActiveControls.TActivePanel'); /** * TJuiDraggable class. * + * TJuiDraggable is an extension to {@link TActivePanel} based on jQuery-UI's + * {@link http://jqueryui.com/draggable/ Draggable} interaction. + * The panel can be moved using the mouse, and eventually dropped over a + * {@link TJuiDroppable}. * * <code> * <com:TJuiDraggable * ID="drag1" * Style="border: 1px solid red; width:100px;height:100px" * Options.Axis="y" + * OnStop="drag1_dragged" * > * drag me * </com:TJuiDraggable> @@ -29,8 +35,10 @@ Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter'); * @package System.Web.UI.JuiControls * @since 3.3 */ -class TJuiDraggable extends TActivePanel implements IJuiOptions +class TJuiDraggable extends TActivePanel implements IJuiOptions, ICallbackEventHandler { + protected $_options; + /** * Creates a new callback control, sets the adapter to * TActiveControlAdapter. If you override this class, be sure to set the @@ -48,10 +56,9 @@ class TJuiDraggable extends TActivePanel implements IJuiOptions */ public function getOptions() { - static $options; - if($options===null) - $options=new TJuiControlOptions($this); - return $options; + if($this->_options===null) + $this->_options=new TJuiControlOptions($this); + return $this->_options; } /** @@ -64,12 +71,20 @@ class TJuiDraggable extends TActivePanel implements IJuiOptions } /** + * Array containing valid javascript events + * @return array() + */ + public function getValidEvents() + { + return array('create', 'drag', 'start', 'stop'); + } + + /** * @return array list of callback options. */ protected function getPostBackOptions() { - $options = $this->getOptions()->toArray(); - return $options; + return $this->getOptions()->toArray(); } /** @@ -86,4 +101,50 @@ class TJuiDraggable extends TActivePanel implements IJuiOptions $code="jQuery('#".$this->getClientId()."').draggable(".$options.");"; $cs->registerEndScript(sprintf('%08X', crc32($code)), $code); } + + /** + * Raises callback event. This method is required by the {@link ICallbackEventHandler} + * interface. + * @param TCallbackEventParameter the parameter associated with the callback event + */ + public function raiseCallbackEvent($param) + { + $this->getOptions()->raiseCallbackEvent($param); + } + + /** + * Raises the OnCreate event + * @param object $params event parameters + */ + public function onCreate ($params) + { + $this->raiseEvent('OnCreate', $this, $params); + } + + /** + * Raises the OnDrag event + * @param object $params event parameters + */ + public function onDrag ($params) + { + $this->raiseEvent('OnDrag', $this, $params); + } + + /** + * Raises the OnStart event + * @param object $params event parameters + */ + public function onStart ($params) + { + $this->raiseEvent('OnStart', $this, $params); + } + + /** + * Raises the OnStop event + * @param object $params event parameters + */ + public function onStop ($params) + { + $this->raiseEvent('OnStop', $this, $params); + } } |