1 | <?php |
||
18 | class TbTimePicker extends TbBaseInputWidget { |
||
19 | |||
20 | /** |
||
21 | * @var TbActiveForm If we're called from the form, here lies the reference to it. |
||
22 | */ |
||
23 | public $form; |
||
24 | |||
25 | /** |
||
26 | * @var array The options for the "bootstrap-timepicker" plugin. |
||
27 | * @see http://jdewit.github.com/bootstrap-timepicker/ |
||
28 | * |
||
29 | * Available options: |
||
30 | * template string |
||
31 | * 'dropdown' (default), Show picker in a dropdown |
||
32 | * 'modal', Show picker in a modal |
||
33 | * false, Don't show a widget |
||
34 | * minuteStep integer 15 Specify a step for the minute field. |
||
35 | * showSeconds boolean false Show the seconds field. |
||
36 | * secondStep integer 15 Specify a step for the second field. |
||
37 | * defaultTime string |
||
38 | * 'current' (default) Set to the current time. |
||
39 | * 'value' Set to inputs current value |
||
40 | * false Do not set a default time |
||
41 | * showMeridian boolean |
||
42 | * true (default) 12hr mode |
||
43 | * false24hr mode |
||
44 | * showInputs boolean |
||
45 | * true (default )Shows the text inputs in the widget. |
||
46 | * false Hide the text inputs in the widget |
||
47 | * disableFocus boolean false Disables the input from focusing. This is useful for touch screen devices that |
||
48 | * display a keyboard on input focus. |
||
49 | * modalBackdrop boolean false Show modal backdrop. |
||
50 | */ |
||
51 | public $options = array(); |
||
52 | |||
53 | /** |
||
54 | * @var string[] the JavaScript event handlers. |
||
55 | * @deprecated 2.0.0 You have the ability to set unique ID and/or class to this element. |
||
56 | * Define Javascript handlers inside Javascript files, not here. |
||
57 | * You can generate the Javascript files from PHP, too, there's no need in hand-crafted snippets of Javascript polluting view files. |
||
58 | */ |
||
59 | public $events = array(); |
||
60 | |||
61 | /** |
||
62 | * @var array HTML attributes for the wrapper "div" tag. |
||
63 | */ |
||
64 | public $wrapperHtmlOptions = array(); |
||
65 | |||
66 | /** |
||
67 | * @var boolean Whether to not append the time icon at end of input. |
||
68 | * NOTE that the timepicker is opening after click on this icon if it's present! |
||
69 | */ |
||
70 | public $noAppend = false; |
||
71 | |||
72 | /** |
||
73 | * Runs the widget. |
||
74 | */ |
||
75 | 1 | public function run() { |
|
76 | |||
77 | 1 | list($name) = $this->resolveNameID(); |
|
78 | |||
79 | // TODO: what is this? |
||
80 | // Add a class of no-user-select to widget |
||
81 | 1 | $this->htmlOptions['class'] = empty($this->htmlOptions['class']) |
|
82 | 1 | ? 'no-user-select' |
|
83 | 1 | : 'no-user-select ' . $this->htmlOptions['class']; |
|
84 | |||
85 | // We are overriding the result of $this->resolveNameID() here, because $id which it emits is not unique through the page. |
||
86 | 1 | if (empty($this->htmlOptions['id'])) { |
|
87 | 1 | $this->htmlOptions['id'] = $this->id; |
|
88 | 1 | } |
|
89 | |||
90 | // Adding essential class for timepicker to work. |
||
91 | 1 | $this->wrapperHtmlOptions = $this->injectClass($this->wrapperHtmlOptions, 'bootstrap-timepicker'); |
|
92 | |||
93 | 1 | if (!$this->noAppend) |
|
94 | 1 | $this->wrapperHtmlOptions = $this->injectClass($this->wrapperHtmlOptions, 'input-group'); |
|
95 | |||
96 | |||
97 | 1 | echo CHtml::openTag('div', $this->wrapperHtmlOptions); |
|
98 | 1 | if ($this->hasModel()) { |
|
99 | 1 | if ($this->form) { |
|
100 | echo $this->form->textField($this->model, $this->attribute, $this->htmlOptions); |
||
101 | } else { |
||
102 | 1 | echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); |
|
103 | } |
||
104 | 1 | } else { |
|
105 | echo CHtml::textField($name, $this->value, $this->htmlOptions); |
||
106 | } |
||
107 | 1 | if (!$this->noAppend) |
|
108 | 1 | $this->echoAppend(); |
|
109 | 1 | echo CHtml::closeTag('div'); |
|
110 | |||
111 | 1 | $this->registerClientScript($this->id); |
|
112 | 1 | } |
|
113 | |||
114 | /** |
||
115 | * Registers required javascript files |
||
116 | * |
||
117 | * @param string $id |
||
118 | */ |
||
119 | 1 | public function registerClientScript($id) { |
|
134 | |||
135 | /** |
||
136 | * @param array $valueset |
||
137 | * @param string $className |
||
138 | * |
||
139 | * @return array |
||
140 | */ |
||
141 | 1 | private function injectClass($valueset, $className) { |
|
160 | |||
161 | 1 | private function echoAppend() { |
|
165 | } |
||
166 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.