1: <?php
2: /**
3: * CJuiResizable class file.
4: *
5: * @author Sebastian Thierer <sebathi@gmail.com>
6: * @link http://www.yiiframework.com/
7: * @copyright 2008-2013 Yii Software LLC
8: * @license http://www.yiiframework.com/license/
9: */
10:
11: Yii::import('zii.widgets.jui.CJuiWidget');
12:
13: /**
14: * CJuiResizable displays a resizable widget.
15: *
16: * CJuiResizable encapsulates the {@link http://jqueryui.com/resizable/ JUI Resizable}
17: * plugin.
18: *
19: * To use this widget, you may insert the following code in a view:
20: * <pre>
21: * $this->beginWidget('zii.widgets.jui.CJuiResizable',array(
22: * // additional javascript options for the resizable plugin
23: * 'options'=>array(
24: * 'minHeight'=>'150',
25: * ),
26: * ));
27: * echo 'Your Resizable content here';
28: *
29: * $this->endWidget();
30: *
31: * </pre>
32: *
33: * By configuring the {@link options} property, you may specify the options
34: * that need to be passed to the JUI Resizable plugin. Please refer to
35: * the {@link http://api.jqueryui.com/resizable/ JUI Resizable API} documentation
36: * for possible options (name-value pairs) and
37: * {@link http://jqueryui.com/resizable/ JUI Resizable page} for general
38: * description and demo.
39: *
40: * @author Sebastian Thierer <sebathi@gmail.com>
41: * @package zii.widgets.jui
42: * @since 1.1
43: */
44: class CJuiResizable extends CJuiWidget
45: {
46: /**
47: * @var string the name of the Resizable element. Defaults to 'div'.
48: */
49: public $tagName='div';
50:
51: /**
52: * Renders the open tag of the resizable element.
53: * This method also registers the necessary javascript code.
54: */
55: public function init()
56: {
57: parent::init();
58:
59: $id=$this->getId();
60: if(isset($this->htmlOptions['id']))
61: $id=$this->htmlOptions['id'];
62: else
63: $this->htmlOptions['id']=$id;
64:
65: $options=CJavaScript::encode($this->options);
66: Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').resizable($options);");
67:
68: echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
69: }
70:
71: /**
72: * Renders the close tag of the resizable element.
73: */
74: public function run()
75: {
76: echo CHtml::closeTag($this->tagName);
77: }
78: }