~horux-dev/horux-webcli/thfo

« back to all changes in this revision

Viewing changes to yii/framework/zii/widgets/jui/CJuiProgressBar.php

  • Committer: Thierry Forchelet
  • Date: 2011-02-25 13:30:15 UTC
  • Revision ID: thierry.forchelet@letux.ch-20110225133015-zxyj9w7sqv8ly971
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * CJuiProgressBar class file.
 
4
 *
 
5
 * @author Sebastian Thierer <sebathi@gmail.com>
 
6
 * @link http://www.yiiframework.com/
 
7
 * @copyright Copyright &copy; 2008-2011 Yii Software LLC
 
8
 * @license http://www.yiiframework.com/license/
 
9
 */
 
10
 
 
11
Yii::import('zii.widgets.jui.CJuiWidget');
 
12
 
 
13
/**
 
14
 * CJuiProgressBar displays a progress bar widget.
 
15
 *
 
16
 * CJuiProgressBar encapsulates the {@link http://jqueryui.com/demos/progressbar/ JUI
 
17
 * Progressbar} plugin.
 
18
 *
 
19
 * To use this widget, you may insert the following code in a view:
 
20
 * <pre>
 
21
 * $this->widget('zii.widgets.jui.CJuiProgressBar', array(
 
22
 *     'value'=>75,
 
23
 *     // additional javascript options for the progress bar plugin
 
24
 *     'options'=>array(
 
25
 *         'change'=>'js:function(event, ui) {...}',
 
26
 *     ),
 
27
 *     'htmlOptions'=>array(
 
28
 *         'style'=>'height:20px;'
 
29
 *     ),
 
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 progressbar plugin. Please refer to
 
35
 * the {@link http://jqueryui.com/demos/progressbar/ JUI Progressbar} documentation
 
36
 * for possible options (name-value pairs).
 
37
 *
 
38
 * @author Sebastian Thierer <sebathi@gmail.com>
 
39
 * @version $Id: CJuiProgressBar.php 2799 2011-01-01 19:31:13Z qiang.xue $
 
40
 * @package zii.widgets.jui
 
41
 * @since 1.1
 
42
 */
 
43
class CJuiProgressBar extends CJuiWidget
 
44
{
 
45
        /**
 
46
         * @var string the name of the container element that contains the progress bar. Defaults to 'div'.
 
47
         */
 
48
        public $tagName = 'div';
 
49
        /**
 
50
         * @var integer the percentage of the progress. This must be an integer between 0 and 100. Defaults to 0.
 
51
         */
 
52
        public $value = 0;
 
53
 
 
54
        /**
 
55
         * Run this widget.
 
56
         * This method registers necessary javascript and renders the needed HTML code.
 
57
         */
 
58
        public function run()
 
59
        {
 
60
                $id=$this->getId();
 
61
                if (isset($this->htmlOptions['id']))
 
62
                        $id = $this->htmlOptions['id'];
 
63
                else
 
64
                        $this->htmlOptions['id']=$id;
 
65
 
 
66
                echo CHtml::openTag($this->tagName,$this->htmlOptions);
 
67
                echo CHtml::closeTag($this->tagName);
 
68
 
 
69
                $this->options['value']=$this->value;
 
70
                $options=CJavaScript::encode($this->options);
 
71
                Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').progressbar($options);");
 
72
        }
 
73
 
 
74
}
 
 
b'\\ No newline at end of file'