3
* CJuiDraggable class file.
5
* @author Sebastian Thierer <sebas@artfos.com>
6
* @link http://www.yiiframework.com/
7
* @copyright Copyright © 2008-2010 Yii Software LLC
8
* @license http://www.yiiframework.com/license/
11
Yii::import('zii.widgets.jui.CJuiWidget');
14
* CJuiDraggable displays a draggable widget.
16
* CJuiDraggable encapsulates the {@link http://jqueryui.com/demos/draggable/ JUI Draggable}
19
* To use this widget, you may insert the following code in a view:
21
* $this->beginWidget('zii.widgets.jui.CJuiDraggable', array(
22
* // additional javascript options for the draggable plugin
27
* echo 'Your draggable content here';
33
* By configuring the {@link options} property, you may specify the options
34
* that need to be passed to the JUI Draggable plugin. Please refer to
35
* the {@link http://jqueryui.com/demos/draggable/ JUI Draggable} documentation
36
* for possible options (name-value pairs).
38
* @author Sebastian Thierer <sebathi@gmail.com>
39
* @version $Id: CJuiDraggable.php 99 2010-01-07 20:55:13Z qiang.xue $
40
* @package zii.widgets.jui
43
class CJuiDraggable extends CJuiWidget
46
* @var string the name of the Draggable element. Defaults to 'div'.
48
public $tagName='div';
51
* Renders the open tag of the draggable element.
52
* This method also registers the necessary javascript code.
54
public function init()
58
$this->htmlOptions['id']=$id;
59
$options=empty($this->options) ? '' : CJavaScript::encode($this->options);
60
Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').draggable($options);");
61
echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
65
* Renders the close tag of the draggable element.
69
echo CHtml::closeTag($this->tagName);