summaryrefslogtreecommitdiff
path: root/framework/zii/widgets/jui
diff options
context:
space:
mode:
Diffstat (limited to 'framework/zii/widgets/jui')
-rw-r--r--framework/zii/widgets/jui/CJuiAccordion.php94
-rw-r--r--framework/zii/widgets/jui/CJuiAutoComplete.php100
-rw-r--r--framework/zii/widgets/jui/CJuiButton.php184
-rw-r--r--framework/zii/widgets/jui/CJuiDatePicker.php133
-rw-r--r--framework/zii/widgets/jui/CJuiDialog.php83
-rw-r--r--framework/zii/widgets/jui/CJuiDraggable.php78
-rw-r--r--framework/zii/widgets/jui/CJuiDroppable.php78
-rw-r--r--framework/zii/widgets/jui/CJuiInputWidget.php74
-rw-r--r--framework/zii/widgets/jui/CJuiProgressBar.php74
-rw-r--r--framework/zii/widgets/jui/CJuiResizable.php79
-rw-r--r--framework/zii/widgets/jui/CJuiSelectable.php84
-rw-r--r--framework/zii/widgets/jui/CJuiSlider.php76
-rw-r--r--framework/zii/widgets/jui/CJuiSliderInput.php148
-rw-r--r--framework/zii/widgets/jui/CJuiSortable.php89
-rw-r--r--framework/zii/widgets/jui/CJuiTabs.php135
-rw-r--r--framework/zii/widgets/jui/CJuiWidget.php145
16 files changed, 1654 insertions, 0 deletions
diff --git a/framework/zii/widgets/jui/CJuiAccordion.php b/framework/zii/widgets/jui/CJuiAccordion.php
new file mode 100644
index 0000000..d1bc43f
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiAccordion.php
@@ -0,0 +1,94 @@
+<?php
+/**
+ * CJuiAccordion class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @author Qiang XUe <qiang.xue@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiWidget');
+
+/**
+ * CJuiAccordion displays an accordion widget.
+ *
+ * CJuiAccordion encapsulates the {@link http://jqueryui.com/demos/accordion/ JUI Accordion}
+ * plugin.
+ *
+ * To use this widget, you may insert the following code in a view:
+ * <pre>
+ * $this->widget('zii.widgets.jui.CJuiAccordion', array(
+ * 'panels'=>array(
+ * 'panel 1'=>'content for panel 1',
+ * 'panel 2'=>'content for panel 2',
+ * // panel 3 contains the content rendered by a partial view
+ * 'panel 3'=>$this->renderPartial('_partial',null,true),
+ * ),
+ * // additional javascript options for the accordion plugin
+ * 'options'=>array(
+ * 'animated'=>'bounceslide',
+ * ),
+ * ));
+ * </pre>
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI accordion plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/accordion/ JUI Accordion} documentation
+ * for possible options (name-value pairs).
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @author Qiang XUe <qiang.xue@gmail.com>
+ * @version $Id: CJuiAccordion.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+class CJuiAccordion extends CJuiWidget
+{
+ /**
+ * @var array list of panels (panel title=>panel content).
+ * Note that neither panel title nor panel content will be HTML-encoded.
+ */
+ public $panels=array();
+ /**
+ * @var string the name of the container element that contains all panels. Defaults to 'div'.
+ */
+ public $tagName='div';
+ /**
+ * @var string the template that is used to generated every panel header.
+ * The token "{title}" in the template will be replaced with the panel title.
+ * Note that if you make change to this template, you may also need to adjust
+ * the 'header' setting in {@link options}.
+ */
+ public $headerTemplate='<h3><a href="#">{title}</a></h3>';
+ /**
+ * @var string the template that is used to generated every panel content.
+ * The token "{content}" in the template will be replaced with the panel content.
+ */
+ public $contentTemplate='<div>{content}</div>';
+
+ /**
+ * Run this widget.
+ * This method registers necessary javascript and renders the needed HTML code.
+ */
+ public function run()
+ {
+ $id=$this->getId();
+ if (isset($this->htmlOptions['id']))
+ $id = $this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+
+ echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
+ foreach($this->panels as $title=>$content)
+ {
+ echo strtr($this->headerTemplate,array('{title}'=>$title))."\n";
+ echo strtr($this->contentTemplate,array('{content}'=>$content))."\n";
+ }
+ echo CHtml::closeTag($this->tagName);
+
+ $options=empty($this->options) ? '' : CJavaScript::encode($this->options);
+ Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').accordion($options);");
+ }
+}
diff --git a/framework/zii/widgets/jui/CJuiAutoComplete.php b/framework/zii/widgets/jui/CJuiAutoComplete.php
new file mode 100644
index 0000000..07e3ee7
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiAutoComplete.php
@@ -0,0 +1,100 @@
+<?php
+/**
+ * CJuiAutoComplete class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiInputWidget');
+
+/**
+ * CJuiAutoComplete displays an autocomplete field.
+ *
+ * CJuiAutoComplete encapsulates the {@link http://jqueryui.com/demos/autocomplete/ JUI
+ * autocomplete} plugin.
+ *
+ * To use this widget, you may insert the following code in a view:
+ * <pre>
+ * $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
+ * 'name'=>'city',
+ * 'source'=>array('ac1', 'ac2', 'ac3'),
+ * // additional javascript options for the autocomplete plugin
+ * 'options'=>array(
+ * 'minLength'=>'2',
+ * ),
+ * 'htmlOptions'=>array(
+ * 'style'=>'height:20px;'
+ * ),
+ * ));
+ * </pre>
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI autocomplete plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/autocomplete/ JUI
+ * autocomplete} documentation for possible options (name-value pairs).
+ *
+ * By configuring the {@link source} property, you may specify where to search
+ * the autocomplete options for each item. If source is an array, the list is
+ * used for autocomplete. You may also configure {@link sourceUrl} to retrieve
+ * autocomplete items from an ajax response.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @version $Id: CJuiAutoComplete.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @package zii.widgets.jui
+ * @since 1.1.2
+ */
+class CJuiAutoComplete extends CJuiInputWidget
+{
+ /**
+ * @var mixed the entries that the autocomplete should choose from. This can be
+ * <ul>
+ * <li>an Array with local data</li>
+ * <li>a String, specifying a URL that returns JSON data as the entries.</li>
+ * <li>a javascript callback. Please make sure you prefix the callback name with "js:" in this case.</li>
+ * </ul>
+ */
+ public $source = array();
+ /**
+ * @var mixed the URL that will return JSON data as the autocomplete items.
+ * CHtml::normalizeUrl() will be applied to this property to convert the property
+ * into a proper URL. When this property is set, the {@link source} property will be ignored.
+ */
+ public $sourceUrl;
+
+ /**
+ * Run this widget.
+ * This method registers necessary javascript and renders the needed HTML code.
+ */
+ public function run()
+ {
+ list($name,$id)=$this->resolveNameID();
+
+ if(isset($this->htmlOptions['id']))
+ $id=$this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+
+ if(isset($this->htmlOptions['name']))
+ $name=$this->htmlOptions['name'];
+
+ if($this->hasModel())
+ echo CHtml::activeTextField($this->model,$this->attribute,$this->htmlOptions);
+ else
+ echo CHtml::textField($name,$this->value,$this->htmlOptions);
+
+ if($this->sourceUrl!==null)
+ $this->options['source']=CHtml::normalizeUrl($this->sourceUrl);
+ else
+ $this->options['source']=$this->source;
+
+ $options=CJavaScript::encode($this->options);
+
+ $js = "jQuery('#{$id}').autocomplete($options);";
+
+ $cs = Yii::app()->getClientScript();
+ $cs->registerScript(__CLASS__.'#'.$id, $js);
+ }
+}
diff --git a/framework/zii/widgets/jui/CJuiButton.php b/framework/zii/widgets/jui/CJuiButton.php
new file mode 100644
index 0000000..f8859f8
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiButton.php
@@ -0,0 +1,184 @@
+<?php
+/**
+ * CJuiButton class file.
+ *
+ * @author Sebastian Thierer <sebas@artfos.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiInputWidget');
+
+/**
+ * CJuiButton displays a button widget.
+ *
+ * CJuiButton encapsulates the {@link http://jqueryui.com/demos/button/ JUI Button}
+ * plugin.
+ *
+ * To use this widget as a submit button, you may insert the following code in a view:
+ * <pre>
+ * $this->widget('zii.widgets.jui.CJuiButton', array(
+ * 'name'=>'submit',
+ * 'caption'=>'Save',
+ * 'options'=>array(
+ * 'onclick'=>'js:function(){alert("Yes");}',
+ * ),
+ * ));
+ * </pre>
+ *
+ * To use this widget as a button, you may insert the following code in a view:
+ * <pre>
+ * $this->widget('zii.widgets.jui.CJuiButton',
+ * array(
+ * 'name'=>'button',
+ * 'caption'=>'Save',
+ * 'value'=>'asd',
+ * 'onclick'=>'js:function(){alert("Save button clicked"); this.blur(); return false;}',
+ * )
+ * );
+ * </pre>
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI button plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/button/ JUI Button} documentation
+ * for possible options (name-value pairs).
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @version $Id: CJuiButton.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @package zii.widgets.jui
+ * @since 1.1.3
+ */
+class CJuiButton extends CJuiInputWidget
+{
+ /**
+ * @var string The button type (possible types: submit, button, link, radio, checkbox, buttonset).
+ * "submit" is used as default.
+ */
+ public $buttonType = 'submit';
+
+ /**
+ * @var string The default html tag for the buttonset
+ */
+ public $htmlTag = 'div';
+ /**
+ * @var string The url used when a buttonType "link" is selected.
+ */
+ public $url = null;
+
+ /**
+ * @var mixed The value of the current item. Used only for "radio" and "checkbox"
+ */
+ public $value;
+
+ /**
+ * @var string The button text
+ */
+ public $caption="";
+ /**
+ * @var string The javascript function to be raised when this item is clicked (client event).
+ */
+ public $onclick;
+
+ /**
+ * (non-PHPdoc)
+ * @see framework/zii/widgets/jui/CJuiWidget::init()
+ */
+ public function init(){
+ parent::init();
+ if ($this->buttonType=='buttonset')
+ {
+ list($name,$id)=$this->resolveNameID();
+
+ if(isset($this->htmlOptions['id']))
+ $id=$this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+ if(isset($this->htmlOptions['name']))
+ $name=$this->htmlOptions['name'];
+ else
+ $this->htmlOptions['name']=$name;
+
+ echo CHtml::openTag($this->htmlTag, $this->htmlOptions);
+ }
+ }
+
+ /**
+ * (non-PHPdoc)
+ * @see framework/CWidget::run()
+ */
+ public function run()
+ {
+ $cs = Yii::app()->getClientScript();
+ list($name,$id)=$this->resolveNameID();
+
+ if(isset($this->htmlOptions['id']))
+ $id=$this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+ if(isset($this->htmlOptions['name']))
+ $name=$this->htmlOptions['name'];
+ else
+ $this->htmlOptions['name']=$name;
+
+ if ($this->buttonType=='buttonset')
+ {
+ echo CHtml::closeTag($this->htmlTag);
+ $cs->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').buttonset();");
+ }
+ else
+ {
+ switch($this->buttonType)
+ {
+ case 'submit':
+ echo CHtml::submitButton($this->caption, $this->htmlOptions) . "\n";
+ break;
+ case 'button':
+ echo CHtml::htmlButton($this->caption, $this->htmlOptions) . "\n";
+ break;
+ case 'link':
+ echo CHtml::link($this->caption, $this->url, $this->htmlOptions) . "\n";
+ break;
+ case 'radio':
+ if ($this->hasModel())
+ {
+ echo CHtml::activeRadioButton($this->model, $this->attribute, $this->htmlOptions);
+ echo CHtml::label($this->caption, CHtml::activeId($this->model, $this->attribute)) . "\n";
+ }
+ else
+ {
+ echo CHtml::radioButton($name, $this->value, $this->htmlOptions);
+ echo CHtml::label($this->caption, $id) . "\n";
+ }
+ break;
+ case 'checkbox':
+ if ($this->hasModel())
+ {
+ echo CHtml::activeCheckbox($this->model, $this->attribute, $this->htmlOptions);
+ echo CHtml::label($this->caption, CHtml::activeId($this->model, $this->attribute)) . "\n";
+ }
+ else
+ {
+ echo CHtml::checkbox($name, $this->value, $this->htmlOptions);
+ echo CHtml::label($this->caption, $id) . "\n";
+ }
+ break;
+ default:
+ throw new CException(Yii::t('zii','The button type "{type}" is not supported.',array('{type}'=>$this->buttonType)));
+ }
+
+ $options=empty($this->options) ? '' : CJavaScript::encode($this->options);
+ if (isset($this->onclick))
+ {
+ if(strpos($this->onclick,'js:')!==0)
+ $this->onclick='js:'.$this->onclick;
+ $click = CJavaScript::encode($this->onclick);
+ $cs->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').button($options).click($click);");
+ }
+ else
+ {
+ $cs->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').button($options);");
+ }
+ }
+ }
+}
diff --git a/framework/zii/widgets/jui/CJuiDatePicker.php b/framework/zii/widgets/jui/CJuiDatePicker.php
new file mode 100644
index 0000000..25c9ec4
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiDatePicker.php
@@ -0,0 +1,133 @@
+<?php
+/**
+ * CJuiDatePicker class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiInputWidget');
+
+/**
+ * CJuiDatePicker displays a datepicker.
+ *
+ * CJuiDatePicker encapsulates the {@link http://jqueryui.com/demos/datepicker/ JUI
+ * datepicker} plugin.
+ *
+ * To use this widget, you may insert the following code in a view:
+ * <pre>
+ * $this->widget('zii.widgets.jui.CJuiDatePicker', array(
+ * 'name'=>'publishDate',
+ * // additional javascript options for the date picker plugin
+ * 'options'=>array(
+ * 'showAnim'=>'fold',
+ * ),
+ * 'htmlOptions'=>array(
+ * 'style'=>'height:20px;'
+ * ),
+ * ));
+ * </pre>
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI datepicker plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/datepicker/ JUI datepicker} documentation
+ * for possible options (name-value pairs).
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @version $Id: CJuiDatePicker.php 3539 2012-01-15 18:55:01Z mdomba $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+class CJuiDatePicker extends CJuiInputWidget
+{
+ /**
+ * @var string the locale ID (eg 'fr', 'de') for the language to be used by the date picker.
+ * If this property is not set, I18N will not be involved. That is, the date picker will show in English.
+ * You can force English language by setting the language attribute as '' (empty string)
+ */
+ public $language;
+
+ /**
+ * @var string The i18n Jquery UI script file. It uses scriptUrl property as base url.
+ */
+ public $i18nScriptFile = 'jquery-ui-i18n.min.js';
+
+ /**
+ * @var array The default options called just one time per request. This options will alter every other CJuiDatePicker instance in the page.
+ * It has to be set at the first call of CJuiDatePicker widget in the request.
+ */
+ public $defaultOptions;
+
+ /**
+ * @var boolean If true, shows the widget as an inline calendar and the input as a hidden field. Use the onSelect event to update the hidden field
+ */
+ public $flat = false;
+
+ /**
+ * Run this widget.
+ * This method registers necessary javascript and renders the needed HTML code.
+ */
+ public function run()
+ {
+
+ list($name,$id)=$this->resolveNameID();
+
+ if(isset($this->htmlOptions['id']))
+ $id=$this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+ if(isset($this->htmlOptions['name']))
+ $name=$this->htmlOptions['name'];
+
+ if ($this->flat===false)
+ {
+ if($this->hasModel())
+ echo CHtml::activeTextField($this->model,$this->attribute,$this->htmlOptions);
+ else
+ echo CHtml::textField($name,$this->value,$this->htmlOptions);
+ }
+ else
+ {
+ if($this->hasModel())
+ {
+ echo CHtml::activeHiddenField($this->model,$this->attribute,$this->htmlOptions);
+ $attribute = $this->attribute;
+ $this->options['defaultDate'] = $this->model->$attribute;
+ }
+ else
+ {
+ echo CHtml::hiddenField($name,$this->value,$this->htmlOptions);
+ $this->options['defaultDate'] = $this->value;
+ }
+
+ if (!isset($this->options['onSelect']))
+ $this->options['onSelect']="js:function( selectedDate ) { jQuery('#{$id}').val(selectedDate);}";
+
+ $id = $this->htmlOptions['id'] = $id.'_container';
+ $this->htmlOptions['name'] = $name.'_container';
+
+ echo CHtml::tag('div', $this->htmlOptions, '');
+ }
+
+ $options=CJavaScript::encode($this->options);
+ $js = "jQuery('#{$id}').datepicker($options);";
+
+ if ($this->language!='' && $this->language!='en')
+ {
+ $this->registerScriptFile($this->i18nScriptFile);
+ $js = "jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));";
+ }
+
+ $cs = Yii::app()->getClientScript();
+
+ if (isset($this->defaultOptions))
+ {
+ $this->registerScriptFile($this->i18nScriptFile);
+ $cs->registerScript(__CLASS__, $this->defaultOptions!==null?'jQuery.datepicker.setDefaults('.CJavaScript::encode($this->defaultOptions).');':'');
+ }
+ $cs->registerScript(__CLASS__.'#'.$id, $js);
+
+ }
+} \ No newline at end of file
diff --git a/framework/zii/widgets/jui/CJuiDialog.php b/framework/zii/widgets/jui/CJuiDialog.php
new file mode 100644
index 0000000..56ba007
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiDialog.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * CJuiDialog class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiWidget');
+
+/**
+ * CJuiDialog displays a dialog widget.
+ *
+ * CJuiDialog encapsulates the {@link http://jqueryui.com/demos/dialog/ JUI Dialog}
+ * plugin.
+ *
+ * To use this widget, you may insert the following code in a view:
+ * <pre>
+ * $this->beginWidget('zii.widgets.jui.CJuiDialog', array(
+ * 'id'=>'mydialog',
+ * // additional javascript options for the dialog plugin
+ * 'options'=>array(
+ * 'title'=>'Dialog box 1',
+ * 'autoOpen'=>false,
+ * ),
+ * ));
+ *
+ * echo 'dialog content here';
+ *
+ * $this->endWidget('zii.widgets.jui.CJuiDialog');
+ *
+ * // the link that may open the dialog
+ * echo CHtml::link('open dialog', '#', array(
+ * 'onclick'=>'$("#mydialog").dialog("open"); return false;',
+ * ));
+ * </pre>
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI dialog plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/dialog/ JUI Dialog} documentation
+ * for possible options (name-value pairs).
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @version $Id: CJuiDialog.php 2805 2011-01-03 16:33:46Z qiang.xue $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+class CJuiDialog extends CJuiWidget
+{
+ /**
+ * @var string the name of the container element that contains all panels. Defaults to 'div'.
+ */
+ public $tagName='div';
+
+ /**
+ * Renders the open tag of the dialog.
+ * This method also registers the necessary javascript code.
+ */
+ public function init()
+ {
+ parent::init();
+
+ $id=$this->getId();
+ if (isset($this->htmlOptions['id']))
+ $id = $this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+
+ $options=empty($this->options) ? '' : CJavaScript::encode($this->options);
+ Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').dialog($options);");
+ echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
+ }
+
+ /**
+ * Renders the close tag of the dialog.
+ */
+ public function run()
+ {
+ echo CHtml::closeTag($this->tagName);
+ }
+}
diff --git a/framework/zii/widgets/jui/CJuiDraggable.php b/framework/zii/widgets/jui/CJuiDraggable.php
new file mode 100644
index 0000000..67947e2
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiDraggable.php
@@ -0,0 +1,78 @@
+<?php
+/**
+ * CJuiDraggable class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiWidget');
+
+/**
+ * CJuiDraggable displays a draggable widget.
+ *
+ * CJuiDraggable encapsulates the {@link http://jqueryui.com/demos/draggable/ JUI Draggable}
+ * plugin.
+ *
+ * To use this widget, you may insert the following code in a view:
+ * <pre>
+ * $this->beginWidget('zii.widgets.jui.CJuiDraggable', array(
+ * // additional javascript options for the draggable plugin
+ * 'options'=>array(
+ * 'scope'=>'myScope',
+ * ),
+ * ));
+ * echo 'Your draggable content here';
+ *
+ * $this->endWidget();
+ *
+ * </pre>
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI Draggable plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/draggable/ JUI Draggable} documentation
+ * for possible options (name-value pairs).
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @version $Id: CJuiDraggable.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+class CJuiDraggable extends CJuiWidget
+{
+ /**
+ * @var string the name of the Draggable element. Defaults to 'div'.
+ */
+ public $tagName='div';
+
+ /**
+ * Renders the open tag of the draggable element.
+ * This method also registers the necessary javascript code.
+ */
+ public function init(){
+ parent::init();
+
+ $id=$this->getId();
+ if (isset($this->htmlOptions['id']))
+ $id = $this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+
+ $options=empty($this->options) ? '' : CJavaScript::encode($this->options);
+ Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').draggable($options);");
+
+ echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
+ }
+
+ /**
+ * Renders the close tag of the draggable element.
+ */
+ public function run(){
+ echo CHtml::closeTag($this->tagName);
+ }
+
+}
+
+
diff --git a/framework/zii/widgets/jui/CJuiDroppable.php b/framework/zii/widgets/jui/CJuiDroppable.php
new file mode 100644
index 0000000..0c5f4cd
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiDroppable.php
@@ -0,0 +1,78 @@
+<?php
+/**
+ * CJuiDroppable class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiWidget');
+
+/**
+ * CJuiDroppable displays a droppable widget.
+ *
+ * CJuiDroppable encapsulates the {@link http://jqueryui.com/demos/droppable/ JUI Droppable}
+ * plugin.
+ *
+ * To use this widget, you may insert the following code in a view:
+ * <pre>
+ * $this->beginWidget('zii.widgets.jui.CJuiDroppable', array(
+ * // additional javascript options for the droppable plugin
+ * 'options'=>array(
+ * 'scope'=>'myScope',
+ * ),
+ * ));
+ * echo 'Your droppable content here';
+ *
+ * $this->endWidget();
+ *
+ * </pre>
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI Droppable plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/droppable/ JUI Droppable} documentation
+ * for possible options (name-value pairs).
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @version $Id: CJuiDroppable.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+class CJuiDroppable extends CJuiWidget
+{
+ /**
+ * @var string the HTML tag name of the Droppable element. Defaults to 'div'.
+ */
+ public $tagName='div';
+
+ /**
+ * Renders the open tag of the droppable element.
+ * This method also registers the necessary javascript code.
+ */
+ public function init()
+ {
+ parent::init();
+ $id=$this->getId();
+ if (isset($this->htmlOptions['id']))
+ $id = $this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+
+ echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
+
+ $options=empty($this->options) ? '' : CJavaScript::encode($this->options);
+ Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').droppable($options);");
+ }
+
+ /**
+ * Renders the close tag of the droppable element.
+ */
+ public function run(){
+ echo CHtml::closeTag($this->tagName);
+ }
+
+}
+
+
diff --git a/framework/zii/widgets/jui/CJuiInputWidget.php b/framework/zii/widgets/jui/CJuiInputWidget.php
new file mode 100644
index 0000000..971ecfa
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiInputWidget.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * CJuiInputWidget class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiWidget');
+
+/**
+ * CJuiInputWidget is the base class for JUI widgets that can collect user input.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @version $Id: CJuiInputWidget.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+abstract class CJuiInputWidget extends CJuiWidget
+{
+ /**
+ * @var CModel the data model associated with this widget.
+ */
+ public $model;
+ /**
+ * @var string the attribute associated with this widget.
+ * The name can contain square brackets (e.g. 'name[1]') which is used to collect tabular data input.
+ */
+ public $attribute;
+ /**
+ * @var string the input name. This must be set if {@link model} is not set.
+ */
+ public $name;
+ /**
+ * @var string the input value
+ */
+ public $value;
+
+
+ /**
+ * @return array the name and the ID of the input.
+ */
+ protected function resolveNameID()
+ {
+ if($this->name!==null)
+ $name=$this->name;
+ else if(isset($this->htmlOptions['name']))
+ $name=$this->htmlOptions['name'];
+ else if($this->hasModel())
+ $name=CHtml::activeName($this->model,$this->attribute);
+ else
+ throw new CException(Yii::t('zii','{class} must specify "model" and "attribute" or "name" property values.',array('{class}'=>get_class($this))));
+
+ if(($id=$this->getId(false))===null)
+ {
+ if(isset($this->htmlOptions['id']))
+ $id=$this->htmlOptions['id'];
+ else
+ $id=CHtml::getIdByName($name);
+ }
+
+ return array($name,$id);
+ }
+
+ /**
+ * @return boolean whether this widget is associated with a data model.
+ */
+ protected function hasModel()
+ {
+ return $this->model instanceof CModel && $this->attribute!==null;
+ }
+}
diff --git a/framework/zii/widgets/jui/CJuiProgressBar.php b/framework/zii/widgets/jui/CJuiProgressBar.php
new file mode 100644
index 0000000..24ca6dc
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiProgressBar.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * CJuiProgressBar class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiWidget');
+
+/**
+ * CJuiProgressBar displays a progress bar widget.
+ *
+ * CJuiProgressBar encapsulates the {@link http://jqueryui.com/demos/progressbar/ JUI
+ * Progressbar} plugin.
+ *
+ * To use this widget, you may insert the following code in a view:
+ * <pre>
+ * $this->widget('zii.widgets.jui.CJuiProgressBar', array(
+ * 'value'=>75,
+ * // additional javascript options for the progress bar plugin
+ * 'options'=>array(
+ * 'change'=>'js:function(event, ui) {...}',
+ * ),
+ * 'htmlOptions'=>array(
+ * 'style'=>'height:20px;'
+ * ),
+ * ));
+ * </pre>
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI progressbar plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/progressbar/ JUI Progressbar} documentation
+ * for possible options (name-value pairs).
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @version $Id: CJuiProgressBar.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+class CJuiProgressBar extends CJuiWidget
+{
+ /**
+ * @var string the name of the container element that contains the progress bar. Defaults to 'div'.
+ */
+ public $tagName = 'div';
+ /**
+ * @var integer the percentage of the progress. This must be an integer between 0 and 100. Defaults to 0.
+ */
+ public $value = 0;
+
+ /**
+ * Run this widget.
+ * This method registers necessary javascript and renders the needed HTML code.
+ */
+ public function run()
+ {
+ $id=$this->getId();
+ if (isset($this->htmlOptions['id']))
+ $id = $this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+
+ echo CHtml::openTag($this->tagName,$this->htmlOptions);
+ echo CHtml::closeTag($this->tagName);
+
+ $this->options['value']=$this->value;
+ $options=CJavaScript::encode($this->options);
+ Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').progressbar($options);");
+ }
+
+} \ No newline at end of file
diff --git a/framework/zii/widgets/jui/CJuiResizable.php b/framework/zii/widgets/jui/CJuiResizable.php
new file mode 100644
index 0000000..fd41210
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiResizable.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * CJuiResizable class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiWidget');
+
+/**
+ * CJuiResizable displays a resizable widget.
+ *
+ * CJuiResizable encapsulates the {@link http://jqueryui.com/demos/resizable/ JUI Resizable}
+ * plugin.
+ *
+ * To use this widget, you may insert the following code in a view:
+ * <pre>
+ * $this->beginWidget('zii.widgets.jui.CJuiResizable', array(
+ * // additional javascript options for the resizable plugin
+ * 'options'=>array(
+ * 'minHeight'=>'150',
+ * ),
+ * ));
+ * echo 'Your Resizable content here';
+ *
+ * $this->endWidget();
+ *
+ * </pre>
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI Resizable plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/resizable/ JUI Resizable} documentation
+ * for possible options (name-value pairs).
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @version $Id: CJuiResizable.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+class CJuiResizable extends CJuiWidget
+{
+ /**
+ * @var string the name of the Resizable element. Defaults to 'div'.
+ */
+ public $tagName='div';
+
+ /**
+ * Renders the open tag of the resizable element.
+ * This method also registers the necessary javascript code.
+ */
+ public function init()
+ {
+ parent::init();
+ $id=$this->getId();
+ if (isset($this->htmlOptions['id']))
+ $id = $this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+
+ $options=empty($this->options) ? '' : CJavaScript::encode($this->options);
+
+ Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').resizable($options);");
+
+ echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
+ }
+
+ /**
+ * Renders the close tag of the resizable element.
+ */
+ public function run(){
+ echo CHtml::closeTag($this->tagName);
+ }
+
+}
+
+
diff --git a/framework/zii/widgets/jui/CJuiSelectable.php b/framework/zii/widgets/jui/CJuiSelectable.php
new file mode 100644
index 0000000..426a359
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiSelectable.php
@@ -0,0 +1,84 @@
+<?php
+/**
+ * CJuiSelectable class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiWidget');
+
+/**
+ * CJuiSelectable displays an accordion widget.
+ *
+ * CJuiSelectable encapsulates the {@link http://jqueryui.com/demos/selectable/ JUI Selectable}
+ * plugin.
+ *
+ * To use this widget, you may insert the following code in a view:
+ * <pre>
+ * $this->widget('zii.widgets.jui.CJuiSelectable', array(
+ * 'items'=>array(
+ * 'id1'=>'Item 1',
+ * 'id2'=>'Item 2',
+ * 'id3'=>'Item 3',
+ * ),
+ * // additional javascript options for the selectable plugin
+ * 'options'=>array(
+ * 'delay'=>'300',
+ * ),
+ * ));
+ * </pre>
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI Selectable plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/selectable/ JUI Selectable} documentation
+ * for possible options (name-value pairs).
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @version $Id: CJuiSelectable.php 3207 2011-05-12 08:05:26Z mdomba $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+class CJuiSelectable extends CJuiWidget {
+ /**
+ * @var array list of selectable items (id=>item content).
+ * Note that the item contents will not be HTML-encoded.
+ */
+ public $items=array();
+ /**
+ * @var string the name of the container element that contains all items. Defaults to 'ol'.
+ */
+ public $tagName='ol';
+ /**
+ * @var string the template that is used to generated every selectable item.
+ * The token "{content}" in the template will be replaced with the item content,
+ * while "{id}" will be replaced with the item ID.
+ */
+ public $itemTemplate='<li id="{id}">{content}</li>';
+
+ /**
+ * Run this widget.
+ * This method registers necessary javascript and renders the needed HTML code.
+ */
+ public function run(){
+ $id=$this->getId();
+ if (isset($this->htmlOptions['id']))
+ $id = $this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+
+ $options=empty($this->options) ? '' : CJavaScript::encode($this->options);
+ Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').selectable({$options});");
+
+ echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
+ foreach($this->items as $id=>$content)
+ {
+ echo strtr($this->itemTemplate,array('{id}'=>$id,'{content}'=>$content))."\n";
+ }
+ echo CHtml::closeTag($this->tagName);
+ }
+}
+
+
diff --git a/framework/zii/widgets/jui/CJuiSlider.php b/framework/zii/widgets/jui/CJuiSlider.php
new file mode 100644
index 0000000..240f305
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiSlider.php
@@ -0,0 +1,76 @@
+<?php
+/**
+ * CJuiSlider class file.
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiWidget');
+
+/**
+ * CJuiSlider displays a slider.
+ *
+ * CJuiSlider encapsulates the {@link http://jqueryui.com/demos/slider/ JUI
+ * slider} plugin.
+ *
+ * To use this widget, you may insert the following code in a view:
+ * <pre>
+ * $this->widget('zii.widgets.jui.CJuiSlider', array(
+ * 'value'=>37,
+ * // additional javascript options for the slider plugin
+ * 'options'=>array(
+ * 'min'=>10,
+ * 'max'=>50,
+ * ),
+ * 'htmlOptions'=>array(
+ * 'style'=>'height:20px;'
+ * ),
+ * ));
+ * </pre>
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI slider plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/slider/ JUI slider} documentation
+ * for possible options (name-value pairs).
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Id: CJuiSlider.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+class CJuiSlider extends CJuiWidget
+{
+ /**
+ * @var string the name of the container element that contains the slider. Defaults to 'div'.
+ */
+ public $tagName = 'div';
+ /**
+ * @var integer determines the value of the slider, if there's only one handle. If there is more than one handle, determines the value of the first handle.
+ */
+ public $value;
+
+ /**
+ * Run this widget.
+ * This method registers necessary javascript and renders the needed HTML code.
+ */
+ public function run()
+ {
+ $id=$this->getId();
+ if (isset($this->htmlOptions['id']))
+ $id = $this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+
+ echo CHtml::openTag($this->tagName,$this->htmlOptions);
+ echo CHtml::closeTag($this->tagName);
+
+ if($this->value!==null)
+ $this->options['value']=$this->value;
+
+ $options=empty($this->options) ? '' : CJavaScript::encode($this->options);
+ Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').slider($options);");
+ }
+} \ No newline at end of file
diff --git a/framework/zii/widgets/jui/CJuiSliderInput.php b/framework/zii/widgets/jui/CJuiSliderInput.php
new file mode 100644
index 0000000..dfd3aaf
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiSliderInput.php
@@ -0,0 +1,148 @@
+<?php
+/**
+ * CJuiSliderInput class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiInputWidget');
+
+/**
+ * CJuiSliderInput displays a slider. It can be used in forms and post its value.
+ *
+ * CJuiSlider encapsulates the {@link http://jqueryui.com/demos/slider/ JUI
+ * slider} plugin.
+ *
+ * To use this widget, you may insert the following code in a view:
+ * <pre>
+ * $this->widget('zii.widgets.jui.CJuiSliderInput', array(
+ * 'name'=>'rate',
+ * 'value'=>37,
+ * // additional javascript options for the slider plugin
+ * 'options'=>array(
+ * 'min'=>10,
+ * 'max'=>50,
+ * ),
+ * 'htmlOptions'=>array(
+ * 'style'=>'height:20px;'
+ * ),
+ * ));
+ * </pre>
+ *
+ * The widget can also be used in range mode which uses 2 sliders to set a range.
+ * In this mode, {@link attribute} and {@link maxAttribute} will define the attribute
+ * names for the minimum and maximum range values, respectively. For example:
+ *
+ * <pre>
+ * $this->widget('zii.widgets.jui.CJuiSliderInput', array(
+ * 'model'=>$model,
+ * 'attribute'=>'timeMin',
+ * 'maxAttribute'=>'timeMax,
+ * // additional javascript options for the slider plugin
+ * 'options'=>array(
+ * 'range'=>true,
+ * 'min'=>0,
+ * 'max'=>24,
+ * ),
+ * ));
+ *
+ * If you need to use the slider event, please change the event value for 'stop' or 'change'.
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI slider plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/slider/ JUI slider} documentation
+ * for possible options (name-value pairs).
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @version $Id: CJuiSliderInput.php 2948 2011-02-09 13:27:05Z haertl.mike $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+class CJuiSliderInput extends CJuiInputWidget
+{
+ /**
+ * @var string the name of the container element that contains the slider. Defaults to 'div'.
+ */
+ public $tagName = 'div';
+ /**
+ * @var integer determines the value of the slider, if there's only one handle. If there is more than one handle, determines the value of the first handle.
+ */
+ public $value;
+
+ /**
+ * @var string the name of the event where the input will be attached to the slider. It
+ * can be 'slide', 'stop' or 'change'. If you want to use 'slide' event change $event property to 'change'
+ */
+ public $event = 'slide';
+
+ /**
+ * @var string name of attribute for max value if slider is used in range mode
+ */
+ public $maxAttribute;
+
+ /**
+ * Run this widget.
+ * This method registers necessary javascript and renders the needed HTML code.
+ */
+ public function run()
+ {
+ list($name,$id)=$this->resolveNameID();
+
+ $isRange=isset($this->options['range']) && $this->options['range'];
+
+ if(isset($this->htmlOptions['id']))
+ $id=$this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+ if(isset($this->htmlOptions['name']))
+ $name=$this->htmlOptions['name'];
+
+ if($this->hasModel())
+ {
+ $attribute=$this->attribute;
+ if ($isRange)
+ {
+ $options=$this->htmlOptions;
+ echo CHtml::activeHiddenField($this->model,$this->attribute,$options);
+ $options['id']=$options['id'].'_end';
+ echo CHtml::activeHiddenField($this->model,$this->maxAttribute,$options);
+ $attrMax=$this->maxAttribute;
+ $this->options['values']=array($this->model->$attribute,$this->model->$attrMax);
+ }
+ else
+ {
+ echo CHtml::activeHiddenField($this->model,$this->attribute,$this->htmlOptions);
+ $this->options['value']=$this->model->$attribute;
+ }
+ }
+ else
+ {
+ echo CHtml::hiddenField($name,$this->value,$this->htmlOptions);
+ if($this->value!==null)
+ $this->options['value']=$this->value;
+ }
+
+
+ $idHidden = $this->htmlOptions['id'];
+ $nameHidden = $name;
+
+ $this->htmlOptions['id']=$idHidden.'_slider';
+ $this->htmlOptions['name']=$nameHidden.'_slider';
+
+ echo CHtml::openTag($this->tagName,$this->htmlOptions);
+ echo CHtml::closeTag($this->tagName);
+
+ $this->options[$this->event]= $isRange ?
+ "js:function(e,ui){ v=ui.values; jQuery('#{$idHidden}').val(v[0]); jQuery('#{$idHidden}_end').val(v[1]); }":
+ 'js:function(event, ui) { jQuery(\'#'. $idHidden .'\').val(ui.value); }';
+
+ $options=empty($this->options) ? '' : CJavaScript::encode($this->options);
+
+ $js = "jQuery('#{$id}_slider').slider($options);\n";
+ Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id, $js);
+ }
+
+}
diff --git a/framework/zii/widgets/jui/CJuiSortable.php b/framework/zii/widgets/jui/CJuiSortable.php
new file mode 100644
index 0000000..7204814
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiSortable.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ * CJuiSortable class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiWidget');
+
+/**
+ * CJuiSortable makes selected elements sortable by dragging with the mouse.
+ *
+ * CJuiSortable encapsulates the {@link http://jqueryui.com/demos/sortable/ JUI Sortable}
+ * plugin.
+ *
+ * To use this widget, you may insert the following code in a view:
+ * <pre>
+ * $this->widget('zii.widgets.jui.CJuiSortable', array(
+ * 'items'=>array(
+ * 'id1'=>'Item 1',
+ * 'id2'=>'Item 2',
+ * 'id3'=>'Item 3',
+ * ),
+ * // additional javascript options for the accordion plugin
+ * 'options'=>array(
+ * 'delay'=>'300',
+ * ),
+ * ));
+ * </pre>
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI Sortable plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/sortable/ JUI Sortable} documentation
+ * for possible options (name-value pairs).
+ *
+ * If you are using javascript code anywhere in the code, please add "js:" at the
+ * start of the js code definition and Yii will use this string as js code.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @version $Id: CJuiSortable.php 3217 2011-05-12 23:59:50Z alexander.makarow $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+class CJuiSortable extends CJuiWidget
+{
+ /**
+ * @var array list of sortable items (id=>item content).
+ * Note that the item contents will not be HTML-encoded.
+ */
+ public $items=array();
+ /**
+ * @var string the name of the container element that contains all items. Defaults to 'ul'.
+ */
+ public $tagName='ul';
+ /**
+ * @var string the template that is used to generated every sortable item.
+ * The token "{content}" in the template will be replaced with the item content,
+ * while "{id}" be replaced with the item ID.
+ */
+ public $itemTemplate='<li id="{id}">{content}</li>';
+
+ /**
+ * Run this widget.
+ * This method registers necessary javascript and renders the needed HTML code.
+ */
+ public function run()
+ {
+ $id=$this->getId();
+ if (isset($this->htmlOptions['id']))
+ $id = $this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+
+ $options=empty($this->options) ? '' : CJavaScript::encode($this->options);
+ Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').sortable({$options});");
+
+ echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
+ foreach($this->items as $id=>$content)
+ {
+ echo strtr($this->itemTemplate,array('{id}'=>$id,'{content}'=>$content))."\n";
+ }
+ echo CHtml::closeTag($this->tagName);
+ }
+}
+
+
diff --git a/framework/zii/widgets/jui/CJuiTabs.php b/framework/zii/widgets/jui/CJuiTabs.php
new file mode 100644
index 0000000..b4ea8e1
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiTabs.php
@@ -0,0 +1,135 @@
+<?php
+/**
+ * CJuiTabs class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+Yii::import('zii.widgets.jui.CJuiWidget');
+
+/**
+ * CJuiTabs displays a tabs widget.
+ *
+ * CJuiTabs encapsulates the {@link http://jqueryui.com/demos/tabs/ JUI tabs}
+ * plugin.
+ *
+ * To use this widget, you may insert the following code in a view:
+ * <pre>
+ * $this->widget('zii.widgets.jui.CJuiTabs', array(
+ * 'tabs'=>array(
+ * 'StaticTab 1'=>'Content for tab 1',
+ * 'StaticTab 2'=>array('content'=>'Content for tab 2', 'id'=>'tab2'),
+ * // panel 3 contains the content rendered by a partial view
+ * 'AjaxTab'=>array('ajax'=>$ajaxUrl),
+ * ),
+ * // additional javascript options for the tabs plugin
+ * 'options'=>array(
+ * 'collapsible'=>true,
+ * ),
+ * ));
+ * </pre>
+ *
+ * By configuring the {@link options} property, you may specify the options
+ * that need to be passed to the JUI tabs plugin. Please refer to
+ * the {@link http://jqueryui.com/demos/tabs/ JUI tabs} documentation
+ * for possible options (name-value pairs).
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @version $Id: CJuiTabs.php 3400 2011-09-22 00:47:39Z sebathi $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+class CJuiTabs extends CJuiWidget
+{
+ /**
+ * @var array list of tabs (tab title=>tab content).
+ * Note that the tab title will not be HTML-encoded.
+ * The tab content can be either a string or an array. When it is an array, it can
+ * be in one of the following two formats:
+ * <pre>
+ * array('id'=>'myTabID', 'content'=>'tab content')
+ * array('id'=>'myTabID', 'ajax'=>URL)
+ * </pre>
+ * where the 'id' element is optional. The second format allows the tab content
+ * to be dynamically fetched from the specified URL via AJAX. The URL can be either
+ * a string or an array. If an array, it will be normalized into a URL using {@link CHtml::normalizeUrl}.
+ */
+ public $tabs=array();
+ /**
+ * @var string the name of the container element that contains all panels. Defaults to 'div'.
+ */
+ public $tagName='div';
+ /**
+ * @var string the template that is used to generated every panel title.
+ * The token "{title}" in the template will be replaced with the panel title and
+ * the token "{url}" will be replaced with "#TabID" or with the url of the ajax request.
+ */
+ public $headerTemplate='<li><a href="{url}" title="{id}">{title}</a></li>';
+ /**
+ * @var string the template that is used to generated every tab content.
+ * The token "{content}" in the template will be replaced with the panel content
+ * and the token "{id}" with the tab ID.
+ */
+ public $contentTemplate='<div id="{id}">{content}</div>';
+
+ /**
+ * Run this widget.
+ * This method registers necessary javascript and renders the needed HTML code.
+ */
+ public function run()
+ {
+ $id=$this->getId();
+ if (isset($this->htmlOptions['id']))
+ $id = $this->htmlOptions['id'];
+ else
+ $this->htmlOptions['id']=$id;
+
+ echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
+
+ $tabsOut = "";
+ $contentOut = "";
+ $tabCount = 0;
+
+ foreach($this->tabs as $title=>$content)
+ {
+ $tabId = (is_array($content) && isset($content['id']))?$content['id']:$id.'_tab_'.$tabCount++;
+
+ if (!is_array($content))
+ {
+ $tabsOut .= strtr($this->headerTemplate, array('{title}'=>$title, '{url}'=>'#'.$tabId, '{id}'=>'#' . $tabId))."\n";
+ $contentOut .= strtr($this->contentTemplate, array('{content}'=>$content,'{id}'=>$tabId))."\n";
+ }
+ elseif (isset($content['ajax']))
+ {
+ $tabsOut .= strtr($this->headerTemplate, array('{title}'=>$title, '{url}'=>CHtml::normalizeUrl($content['ajax']), '{id}'=>'#' . $tabId))."\n";
+ }
+ else
+ {
+ $tabsOut .= strtr($this->headerTemplate, array('{title}'=>$title, '{url}'=>'#'.$tabId, '{id}'=>$tabId))."\n";
+ if(isset($content['content']))
+ $contentOut .= strtr($this->contentTemplate, array('{content}'=>$content['content'],'{id}'=>$tabId))."\n";
+ }
+ }
+ echo "<ul>\n" . $tabsOut . "</ul>\n";
+ echo $contentOut;
+
+ echo CHtml::closeTag($this->tagName)."\n";
+
+ $options=empty($this->options) ? '' : CJavaScript::encode($this->options);
+ Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').tabs($options);");
+ }
+
+ /**
+ * Registers the core script files.
+ * This method overrides the parent implementation by registering the cookie plugin when cookie option is used.
+ */
+ protected function registerCoreScripts()
+ {
+ parent::registerCoreScripts();
+ if(isset($this->options['cookie']))
+ Yii::app()->getClientScript()->registerCoreScript('cookie');
+ }
+}
diff --git a/framework/zii/widgets/jui/CJuiWidget.php b/framework/zii/widgets/jui/CJuiWidget.php
new file mode 100644
index 0000000..3649444
--- /dev/null
+++ b/framework/zii/widgets/jui/CJuiWidget.php
@@ -0,0 +1,145 @@
+<?php
+/**
+ * CJuiWidget class file.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2011 Yii Software LLC
+ * @license http://www.yiiframework.com/license/
+ */
+
+/**
+ * This is the base class for all JUI widget classes.
+ *
+ * @author Sebastian Thierer <sebathi@gmail.com>
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Id: CJuiWidget.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @package zii.widgets.jui
+ * @since 1.1
+ */
+abstract class CJuiWidget extends CWidget
+{
+ /**
+ * @var string the root URL that contains all JUI JavaScript files.
+ * If this property is not set (default), Yii will publish the JUI package included in the zii release and use
+ * that to infer the root script URL. You should set this property if you intend to use
+ * a JUI package whose version is different from the one included in zii.
+ * Note that under this URL, there must be a file whose name is specified by {@link scriptFile}.
+ * Do not append any slash character to the URL.
+ */
+ public $scriptUrl;
+ /**
+ * @var string the root URL that contains all JUI theme folders.
+ * If this property is not set (default), Yii will publish the JUI package included in the zii release and use
+ * that to infer the root theme URL. You should set this property if you intend to use
+ * a theme that is not found in the JUI package included in zii.
+ * Note that under this URL, there must be a directory whose name is specified by {@link theme}.
+ * Do not append any slash character to the URL.
+ */
+ public $themeUrl;
+ /**
+ * @var string the JUI theme name. Defaults to 'base'. Make sure that under {@link themeUrl} there
+ * is a directory whose name is the same as this property value (case-sensitive).
+ */
+ public $theme='base';
+ /**
+ * @var mixed the main JUI JavaScript file. Defaults to 'jquery-ui.min.js'.
+ * Note the file must exist under the URL specified by {@link scriptUrl}.
+ * If you need to include multiple script files (e.g. during development, you want to include individual
+ * plugin script files rather than the minized JUI script file), you may set this property
+ * as an array of the script file names.
+ * This property can also be set as false, which means the widget will not include any script file,
+ * and it is your responsibility to explicitly include it somewhere else.
+ */
+ public $scriptFile='jquery-ui.min.js';
+ /**
+ * @var mixed the theme CSS file name. Defaults to 'jquery-ui.css'.
+ * Note the file must exist under the URL specified by {@link themeUrl}/{@link theme}.
+ * If you need to include multiple theme CSS files (e.g. during development, you want to include individual
+ * plugin CSS files), you may set this property as an array of the CSS file names.
+ * This property can also be set as false, which means the widget will not include any theme CSS file,
+ * and it is your responsibility to explicitly include it somewhere else.
+ */
+ public $cssFile='jquery-ui.css';
+ /**
+ * @var array the initial JavaScript options that should be passed to the JUI plugin.
+ */
+ public $options=array();
+ /**
+ * @var array the HTML attributes that should be rendered in the HTML tag representing the JUI widget.
+ */
+ public $htmlOptions=array();
+
+ /**
+ * Initializes the widget.
+ * This method will publish JUI assets if necessary.
+ * It will also register jquery and JUI JavaScript files and the theme CSS file.
+ * If you override this method, make sure you call the parent implementation first.
+ */
+ public function init()
+ {
+ $this->resolvePackagePath();
+ $this->registerCoreScripts();
+ parent::init();
+ }
+
+ /**
+ * Determine the JUI package installation path.
+ * This method will identify the JavaScript root URL and theme root URL.
+ * If they are not explicitly specified, it will publish the included JUI package
+ * and use that to resolve the needed paths.
+ */
+ protected function resolvePackagePath()
+ {
+ if($this->scriptUrl===null || $this->themeUrl===null)
+ {
+ $cs=Yii::app()->getClientScript();
+ if($this->scriptUrl===null)
+ $this->scriptUrl=$cs->getCoreScriptUrl().'/jui/js';
+ if($this->themeUrl===null)
+ $this->themeUrl=$cs->getCoreScriptUrl().'/jui/css';
+ }
+ }
+
+ /**
+ * Registers the core script files.
+ * This method registers jquery and JUI JavaScript files and the theme CSS file.
+ */
+ protected function registerCoreScripts()
+ {
+ $cs=Yii::app()->getClientScript();
+ if(is_string($this->cssFile))
+ $cs->registerCssFile($this->themeUrl.'/'.$this->theme.'/'.$this->cssFile);
+ else if(is_array($this->cssFile))
+ {
+ foreach($this->cssFile as $cssFile)
+ $cs->registerCssFile($this->themeUrl.'/'.$this->theme.'/'.$cssFile);
+ }
+
+ $cs->registerCoreScript('jquery');
+ if(is_string($this->scriptFile))
+ $this->registerScriptFile($this->scriptFile);
+ else if(is_array($this->scriptFile))
+ {
+ foreach($this->scriptFile as $scriptFile)
+ $this->registerScriptFile($scriptFile);
+ }
+ }
+
+ /**
+ * Registers a JavaScript file under {@link scriptUrl}.
+ * Note that by default, the script file will be rendered at the end of a page to improve page loading speed.
+ * @param string $fileName JavaScript file name
+ * @param integer $position the position of the JavaScript file. Valid values include the following:
+ * <ul>
+ * <li>CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.</li>
+ * <li>CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.</li>
+ * <li>CClientScript::POS_END : the script is inserted at the end of the body section.</li>
+ * </ul>
+ */
+ protected function registerScriptFile($fileName,$position=CClientScript::POS_END)
+ {
+ Yii::app()->getClientScript()->registerScriptFile($this->scriptUrl.'/'.$fileName,$position);
+ }
+}