├── .github
├── PULL_REQUEST_TEMPLATE.md
├── stale.yml
├── ISSUE_TEMPLATE.md
└── CONTRIBUTING.md
├── src
├── TimePickerAsset.php
├── assets
│ ├── css
│ │ ├── bootstrap-timepicker.min.css
│ │ └── bootstrap-timepicker.css
│ └── js
│ │ ├── bootstrap-timepicker.min.js
│ │ └── bootstrap-timepicker.js
└── TimePicker.php
├── composer.json
├── CHANGE.md
├── LICENSE.md
└── README.md
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Scope
2 | This pull request includes a
3 |
4 | - [ ] Bug fix
5 | - [ ] New feature
6 | - [ ] Translation
7 |
8 | ## Changes
9 | The following changes were made (this change is also documented in the [change log](https://github.com/kartik-v/yii2-widget-timepicker/blob/master/CHANGE.md)):
10 |
11 | -
12 | -
13 | -
14 |
15 | ## Related Issues
16 | If this is related to an existing ticket, include a link to it as well.
--------------------------------------------------------------------------------
/.github/stale.yml:
--------------------------------------------------------------------------------
1 | # Number of days of inactivity before an issue becomes stale
2 | daysUntilStale: 60
3 | # Number of days of inactivity before a stale issue is closed
4 | daysUntilClose: 7
5 | # Issues with these labels will never be considered stale
6 | exemptLabels:
7 | - bug
8 | - enhancement
9 | - pinned
10 | - security
11 | # Label to use when marking an issue as stale
12 | staleLabel: wontfix
13 | # Comment to post when marking an issue as stale. Set to `false` to disable
14 | markComment: >
15 | This issue has been automatically marked as stale because it has not had
16 | recent activity. It will be closed if no further activity occurs. Thank you
17 | for your contributions.
18 | # Comment to post when closing a stale issue. Set to `false` to disable
19 | closeComment: false
--------------------------------------------------------------------------------
/src/TimePickerAsset.php:
--------------------------------------------------------------------------------
1 |
18 | * @since 1.0
19 | */
20 | class TimePickerAsset extends AssetBundle
21 | {
22 | /**
23 | * @inheritdoc
24 | */
25 | public function init()
26 | {
27 | $this->setSourcePath(__DIR__ . '/assets');
28 | $this->setupAssets('css', ['css/bootstrap-timepicker']);
29 | $this->setupAssets('js', ['js/bootstrap-timepicker']);
30 | parent::init();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "kartik-v/yii2-widget-timepicker",
3 | "description": "Enhanced Yii2 wrapper for the bootstrap timepicker plugin (sub repo split from yii2-widgets)",
4 | "keywords": [
5 | "yii2",
6 | "extension",
7 | "widget",
8 | "form",
9 | "time",
10 | "picker",
11 | "bootstrap",
12 | "jquery",
13 | "plugin"
14 | ],
15 | "homepage": "https://github.com/kartik-v/yii2-widget-timepicker",
16 | "type": "yii2-extension",
17 | "license": "BSD-3-Clause",
18 | "authors": [
19 | {
20 | "name": "Kartik Visweswaran",
21 | "email": "kartikv2@gmail.com",
22 | "homepage": "http://www.krajee.com/"
23 | }
24 | ],
25 | "require": {
26 | "kartik-v/yii2-krajee-base": ">=2.0.0"
27 | },
28 | "autoload": {
29 | "psr-4": {
30 | "kartik\\time\\": "src"
31 | }
32 | },
33 | "extra": {
34 | "branch-alias": {
35 | "dev-master": "1.0.x-dev"
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/CHANGE.md:
--------------------------------------------------------------------------------
1 | Change Log: `yii2-widget-timepicker`
2 | ====================================
3 |
4 | ## Version 1.0.5
5 |
6 | **Date:** 28-Oct-2021
7 |
8 | - Enhancements to support Bootstrap v5.x.
9 |
10 | ## Version 1.0.4
11 |
12 | **Date:** 09-Oct-2018
13 |
14 | - Bump composer version dependencies.
15 | - Add Bootstrap 4.x support.
16 | - Reorganize source code in `src` directory.
17 |
18 | ## Version 1.0.3
19 |
20 | **Date:** 08-Jan-2017
21 |
22 | - (enh #12): Correct timepicker change initialization.
23 |
24 | ## Version 1.0.2
25 |
26 | **Date:** 04-Jan-2017
27 |
28 | - (enh #12): Prevent timepicker plugin triggering change on init.
29 | - Add github contribution and issue/PR logging templates.
30 | - Add branch alias for dev-master latest release.
31 |
32 | ## Version 1.0.1
33 |
34 | **Date:** 12-Jan-2016
35 |
36 | - enh #7: Enhancements for PJAX based reinitialization. Complements enhancements in kartik-v/yii2-krajee-base#52 and kartik-v/yii2-krajee-base#53.
37 |
38 | ## Version 1.0.0
39 |
40 | **Date:** 08-Nov-2014
41 |
42 | - Initial release
43 | - Sub repo split from [yii2-widgets](https://github.com/kartik-v/yii2-widgets)
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Prerequisites
2 |
3 | - [ ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
4 | - [ ] The issue still exists against the latest `master` branch of yii2-widget-timepicker.
5 | - [ ] This is not an usage question. I confirm having gone through and read the [documentation and demos](http://demos.krajee.com/widget-details/timepicker).
6 | - [ ] This is not a general programming / coding question. (Those should be directed to the [webtips Q & A forum](http://webtips.krajee.com/questions)).
7 | - [ ] I have attempted to find the simplest possible steps to reproduce the issue.
8 | - [ ] I have included a failing test as a pull request (Optional).
9 |
10 | ## Steps to reproduce the issue
11 |
12 | 1.
13 | 2.
14 | 3.
15 |
16 | ## Expected behavior and actual behavior
17 |
18 | When I follow those steps, I see...
19 |
20 | I was expecting...
21 |
22 | ## Environment
23 |
24 | #### Browsers
25 |
26 | - [ ] Google Chrome
27 | - [ ] Mozilla Firefox
28 | - [ ] Internet Explorer
29 | - [ ] Safari
30 |
31 | #### Operating System
32 |
33 | - [ ] Windows
34 | - [ ] Mac OS X
35 | - [ ] Linux
36 | - [ ] Mobile
37 |
38 | #### Libraries
39 |
40 | - jQuery version:
41 | - yii2-widget-timepicker version:
42 |
43 | ## Isolating the problem
44 |
45 | - [ ] This bug happens [on the demos page](https://demos.krajee.com/widget-details/timepicker)
46 | - [ ] The bug happens consistently across all tested browsers
47 | - [ ] This bug happens when using yii2-widget-timepicker without other plugins.
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014 - 2021, Kartik Visweswaran
2 | Krajee.com
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without modification,
6 | are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 |
11 | * Redistributions in binary form must reproduce the above copyright notice, this
12 | list of conditions and the following disclaimer in the documentation and/or
13 | other materials provided with the distribution.
14 |
15 | * Neither the names of Kartik Visweswaran or Krajee nor the names of its
16 | contributors may be used to endorse or promote products derived from
17 | this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
--------------------------------------------------------------------------------
/src/assets/css/bootstrap-timepicker.min.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * Timepicker Component for Twitter Bootstrap
3 | *
4 | * Improvements by: Kartik Visweswaran, Krajee.com, 2014 - 2021
5 | *
6 | * Copyright 2013 Joris de Wit
7 | *
8 | * Contributors https://github.com/jdewit/bootstrap-timepicker/graphs/contributors
9 | *
10 | * For the full copyright and license information, please view the LICENSE
11 | * file that was distributed with this source code.
12 | */.bootstrap-timepicker{position:relative}.bootstrap-timepicker-widget{min-width:19rem}.bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu{left:auto;right:0}.bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu:before{left:auto;right:.75rem}.bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu:after{left:auto;right:.8125rem}.bootstrap-timepicker .disabled-addon{cursor:not-allowed!important}.bootstrap-timepicker .inline-addon{position:absolute;display:inline-block;top:.675rem;right:.625rem;line-height:1.5;z-index:3}.bootstrap-timepicker .inline-addon-lg{font-size:1.875rem}.bootstrap-timepicker .inline-addon-sm{font-size:1.2rem}.bootstrap-timepicker4 .inline-addon{top:.5rem}.bootstrap-timepicker3 .inline-addon-lg{top:1.05rem}.bootstrap-timepicker4 .inline-addon-lg{font-size:1.25rem}.bootstrap-timepicker4 .inline-addon-sm{top:.375rem;font-size:.85rem}.bootstrap-timepicker-widget.dropdown-menu{padding:.125rem .1875rem .125rem .125rem}.bootstrap-timepicker-widget.dropdown-menu.open{display:inline-block}.bootstrap-timepicker-widget.dropdown-menu:before{border-bottom:.4375rem solid rgba(0,0,0,.2);border-left:.4375rem solid transparent;border-right:.4375rem solid transparent;content:"";display:inline-block;left:.5625rem;position:absolute;top:-.4375rem}.bootstrap-timepicker-widget.dropdown-menu:after{border-bottom:.375rem solid #FFF;border-left:.375rem solid transparent;border-right:.375rem solid transparent;content:"";display:inline-block;left:.625rem;position:absolute;top:-.375rem}.bootstrap-timepicker-widget a.btn,.bootstrap-timepicker-widget input{border-radius:.25rem!important}.bootstrap-timepicker input{border-top-left-radius:.25rem!important;border-bottom-left-radius:.25rem!important}.bootstrap-timepicker-widget table{width:100%;margin:0}.bootstrap-timepicker-widget table td{text-align:center;height:1.875rem;margin:0;padding:.125rem}.bootstrap-timepicker .separator{font-weight:700;font-family:Monaco,Consolas,monospace}.bootstrap-timepicker-widget table td:not(.separator){min-width:1.875rem}.bootstrap-timepicker-widget table td span{width:100%}.bootstrap-timepicker-widget table td a{border:.0625rem solid transparent;width:100%;display:inline-block;margin:0;padding:.125rem 0;outline:0;color:#333}.bootstrap-timepicker-widget table td a:hover{text-decoration:none;background-color:#eee;-webkit-border-radius:.25rem;-moz-border-radius:.25rem;border-radius:.25rem;border-color:#ddd}.bootstrap-timepicker-widget table td a i{margin-top:.125rem}.bootstrap-timepicker-widget table td input{margin:0;text-align:center}.bootstrap-timepicker-widget .modal-content{padding:.25rem}.bootstrap-timepicker .picker{cursor:pointer}@media (min-width:767px){.bootstrap-timepicker-widget.modal{width:200px;margin-left:-100px}}@media (max-width:767px){.bootstrap-timepicker,.bootstrap-timepicker .dropdown-menu{width:100%}}
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
24 |
25 | The TimePicker widget allows you to easily select a time for a text input using your mouse or keyboards arrow keys. The widget is a wrapper enhancement of the TimePicker plugin by rendom forked from jdewit's TimePicker. This widget as used here has been specially enhanced for Yii framework 2.0 and Bootstrap 3. With release v1.0.4, the extension has been enhanced to support Bootstrap 4.x version.
26 |
27 | > NOTE: This extension is a sub repo split of [yii2-widgets](https://github.com/kartik-v/yii2-widgets). The split has been done since 08-Nov-2014 to allow developers to install this specific widget in isolation if needed. One can also use the extension the previous way with the whole suite of [yii2-widgets](http://demos.krajee.com/widgets).
28 |
29 | ## Installation
30 |
31 | The preferred way to install this extension is through [composer](http://getcomposer.org/download/). Check the [composer.json](https://github.com/kartik-v/yii2-widget-timepicker/blob/master/composer.json) for this extension's requirements and dependencies. Read this [web tip /wiki](http://webtips.krajee.com/setting-composer-minimum-stability-application/) on setting the `minimum-stability` settings for your application's composer.json.
32 |
33 | To install, either run
34 |
35 | ```
36 | $ php composer.phar require kartik-v/yii2-widget-timepicker "*"
37 | ```
38 |
39 | or add
40 |
41 | ```
42 | "kartik-v/yii2-widget-timepicker": "*"
43 | ```
44 |
45 | to the ```require``` section of your `composer.json` file.
46 |
47 | ## Release Changes
48 |
49 | > NOTE: Refer the [CHANGE LOG](https://github.com/kartik-v/yii2-widget-timepicker/blob/master/CHANGE.md) for details on changes to various releases.
50 |
51 | ## Demo
52 |
53 | You can refer detailed [documentation and demos](http://demos.krajee.com/widget-details/timepicker) on usage of the extension.
54 |
55 | ## Usage
56 |
57 | ```php
58 | use kartik\time\TimePicker;
59 |
60 | // usage without model
61 | echo '';
62 | echo TimePicker::widget([
63 | 'name' => 'start_time',
64 | 'value' => '11:24 AM',
65 | 'pluginOptions' => [
66 | 'showSeconds' => true
67 | ]
68 | ]);
69 | ```
70 |
71 | ## License
72 |
73 | **yii2-widget-timepicker** is released under the BSD-3-Clause License. See the bundled `LICENSE.md` for details.
--------------------------------------------------------------------------------
/src/assets/css/bootstrap-timepicker.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * Timepicker Component for Twitter Bootstrap
3 | *
4 | * Improvements by: Kartik Visweswaran, Krajee.com, 2014 - 2021
5 | *
6 | * Copyright 2013 Joris de Wit
7 | *
8 | * Contributors https://github.com/jdewit/bootstrap-timepicker/graphs/contributors
9 | *
10 | * For the full copyright and license information, please view the LICENSE
11 | * file that was distributed with this source code.
12 | */
13 | .bootstrap-timepicker {
14 | position: relative;
15 | }
16 |
17 | .bootstrap-timepicker-widget {
18 | min-width: 19rem;
19 | }
20 |
21 | .bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu {
22 | left: auto;
23 | right: 0;
24 | }
25 |
26 | .bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu:before {
27 | left: auto;
28 | right: 0.75rem;
29 | }
30 |
31 | .bootstrap-timepicker.pull-right .bootstrap-timepicker-widget.dropdown-menu:after {
32 | left: auto;
33 | right: 0.8125rem;
34 | }
35 |
36 | .bootstrap-timepicker .disabled-addon {
37 | cursor: not-allowed !important;
38 | }
39 |
40 | .bootstrap-timepicker .inline-addon {
41 | position: absolute;
42 | display: inline-block;
43 | top: 0.675rem;
44 | right: 0.625rem;
45 | line-height: 1.5;
46 | z-index: 3;
47 | }
48 |
49 | .bootstrap-timepicker .inline-addon-lg {
50 | font-size: 1.875rem;
51 | }
52 |
53 | .bootstrap-timepicker .inline-addon-sm {
54 | font-size: 1.2rem;
55 | }
56 |
57 | .bootstrap-timepicker4 .inline-addon {
58 | top: 0.5rem;
59 | }
60 |
61 | .bootstrap-timepicker3 .inline-addon-lg {
62 | top: 1.05rem;
63 | }
64 |
65 | .bootstrap-timepicker4 .inline-addon-lg {
66 | font-size: 1.25rem;
67 | }
68 |
69 | .bootstrap-timepicker4 .inline-addon-sm {
70 | top: 0.375rem;
71 | font-size: 0.85rem;
72 | }
73 |
74 | .bootstrap-timepicker-widget.dropdown-menu {
75 | padding: 0.125rem 0.1875rem 0.125rem 0.125rem;
76 | }
77 |
78 | .bootstrap-timepicker-widget.dropdown-menu.open {
79 | display: inline-block;
80 | }
81 |
82 | .bootstrap-timepicker-widget.dropdown-menu:before {
83 | border-bottom: 0.4375rem solid rgba(0, 0, 0, 0.2);
84 | border-left: 0.4375rem solid transparent;
85 | border-right: 0.4375rem solid transparent;
86 | content: "";
87 | display: inline-block;
88 | left: 0.5625rem;
89 | position: absolute;
90 | top: -0.4375rem;
91 | }
92 |
93 | .bootstrap-timepicker-widget.dropdown-menu:after {
94 | border-bottom: 0.375rem solid #FFFFFF;
95 | border-left: 0.375rem solid transparent;
96 | border-right: 0.375rem solid transparent;
97 | content: "";
98 | display: inline-block;
99 | left: 0.625rem;
100 | position: absolute;
101 | top: -0.375rem;
102 | }
103 |
104 | .bootstrap-timepicker-widget a.btn,
105 | .bootstrap-timepicker-widget input {
106 | border-radius: 0.25rem !important;
107 | }
108 |
109 | .bootstrap-timepicker input {
110 | border-top-left-radius: 0.25rem !important;
111 | border-bottom-left-radius: 0.25rem !important;
112 | }
113 |
114 | .bootstrap-timepicker-widget table {
115 | width: 100%;
116 | margin: 0;
117 | }
118 |
119 | .bootstrap-timepicker-widget table td {
120 | text-align: center;
121 | height: 1.875rem;
122 | margin: 0;
123 | padding: 0.125rem;
124 | }
125 |
126 | .bootstrap-timepicker .separator {
127 | font-weight: bold;
128 | font-family: Monaco, Consolas, monospace;
129 | }
130 |
131 | .bootstrap-timepicker-widget table td:not(.separator) {
132 | min-width: 1.875rem;
133 | }
134 |
135 | .bootstrap-timepicker-widget table td span {
136 | width: 100%;
137 | }
138 |
139 | .bootstrap-timepicker-widget table td a {
140 | border: 0.0625rem transparent solid;
141 | width: 100%;
142 | display: inline-block;
143 | margin: 0;
144 | padding: 0.125rem 0;
145 | outline: 0;
146 | color: #333;
147 | }
148 |
149 | .bootstrap-timepicker-widget table td a:hover {
150 | text-decoration: none;
151 | background-color: #eee;
152 | -webkit-border-radius: 0.25rem;
153 | -moz-border-radius: 0.25rem;
154 | border-radius: 0.25rem;
155 | border-color: #ddd;
156 | }
157 |
158 | .bootstrap-timepicker-widget table td a i {
159 | margin-top: 0.125rem;
160 | }
161 |
162 | .bootstrap-timepicker-widget table td input {
163 | margin: 0;
164 | text-align: center;
165 | }
166 |
167 | .bootstrap-timepicker-widget .modal-content {
168 | padding: 0.25rem;
169 | }
170 |
171 | .bootstrap-timepicker .picker {
172 | cursor: pointer;
173 | }
174 |
175 | @media (min-width: 767px) {
176 | .bootstrap-timepicker-widget.modal {
177 | width: 200px;
178 | margin-left: -100px;
179 | }
180 | }
181 |
182 | @media (max-width: 767px) {
183 | .bootstrap-timepicker {
184 | width: 100%;
185 | }
186 |
187 | .bootstrap-timepicker .dropdown-menu {
188 | width: 100%;
189 | }
190 | }
191 |
--------------------------------------------------------------------------------
/src/TimePicker.php:
--------------------------------------------------------------------------------
1 |
24 | * @since 1.0
25 | * @see https://github.com/rendom/bootstrap-3-timepicker
26 | * @see https://github.com/jdewit/bootstrap-timepicker
27 | */
28 | class TimePicker extends InputWidget
29 | {
30 | /**
31 | * @var string the size of the input - 'lg', 'md', 'sm', 'xs'
32 | */
33 | public $size;
34 |
35 | /**
36 | * @var string|boolean the addon content
37 | */
38 | public $addon;
39 |
40 | /**
41 | * @var array HTML attributes for the addon container. The following special options are recognized:
42 | * - `asButton`: _boolean_, if the addon is to be displayed as a button.
43 | * - `buttonOptions`: _array_, HTML attributes if the addon is to be displayed like a button. If [[asButton]] is
44 | * `true`, this will default to :
45 | * - `['class' => 'btn btn-default']` for [[bsVersion]] = '3.x' or .
46 | * - `['class' => 'btn btn-secondary']` for [[bsVersion]] = '4.x' and '5.x'
47 | */
48 | public $addonOptions = [];
49 |
50 | /**
51 | * @var array HTML attributes for the input group container
52 | */
53 | public $containerOptions = [];
54 |
55 | /**
56 | * @inheritdoc
57 | */
58 | public $pluginName = 'timepicker';
59 |
60 | /**
61 | * @inheritdoc
62 | * @throws InvalidConfigException
63 | */
64 | public function run()
65 | {
66 | $this->initIcon('up');
67 | $this->initIcon('down');
68 | $this->registerAssets();
69 | echo Html::tag('div', $this->renderInput(), $this->containerOptions);
70 | }
71 |
72 | /**
73 | * Initializes icon for time units up and down buttons
74 | * @param string $type whether 'up' or 'down'
75 | * @throws InvalidConfigException|\Exception
76 | */
77 | protected function initIcon($type)
78 | {
79 | $prop = $type . 'ArrowStyle';
80 | if (!isset($this->pluginOptions[$prop])) {
81 | $prefix = !$this->isBs(3) ? 'fas fa-' : 'glyphicon glyphicon-';
82 | $this->pluginOptions[$prop] = $prefix . 'chevron-' . $type;
83 | }
84 | }
85 |
86 | /**
87 | * Renders the input
88 | *
89 | * @return string
90 | * @throws InvalidConfigException|\Exception
91 | */
92 | protected function renderInput()
93 | {
94 | $notBs3 = !$this->isBs(3);
95 | $isBs5 = $this->isBs(5);
96 | if (!isset($this->addon)) {
97 | $this->addon = $notBs3 ? '' : '';
98 | }
99 | Html::addCssClass($this->options, 'form-control');
100 | if (!empty($this->options['disabled'])) {
101 | Html::addCssClass($this->addonOptions, 'disabled-addon');
102 | }
103 | if (ArrayHelper::getValue($this->pluginOptions, 'template', true) === false) {
104 | $css = $notBs3 ? 'bootstrap-timepicker4' : 'bootstrap-timepicker3';
105 | Html::addCssClass($this->containerOptions, ['bootstrap-timepicker', $css]);
106 | if (isset($this->size)) {
107 | Html::addCssClass($this->options, ($notBs3 ? 'form-control-' : 'input-') . $this->size);
108 | Html::addCssClass($this->addonOptions, 'inline-addon inline-addon-' . $this->size);
109 | } else {
110 | Html::addCssClass($this->addonOptions, 'inline-addon');
111 | }
112 | return $this->getInput('textInput') . Html::tag('span', $this->addon, $this->addonOptions);
113 | }
114 | Html::addCssClass($this->containerOptions, 'bootstrap-timepicker input-group');
115 | $asButton = ArrayHelper::remove($this->addonOptions, 'asButton', false);
116 | $buttonOptions = ArrayHelper::remove($this->addonOptions, 'buttonOptions', []);
117 |
118 | if ($asButton) {
119 | $css = $notBs3 ? 'input-group-append' : 'input-group-btn';
120 | $tag = $notBs3 ? 'div' : 'span';
121 | Html::addCssClass($this->addonOptions, [$css, 'picker']);
122 | $buttonOptions['type'] = 'button';
123 | if (empty($buttonOptions['class'])) {
124 | Html::addCssClass($buttonOptions, 'btn btn-default');
125 | }
126 | $button = Html::button($this->addon, $buttonOptions);
127 | $addon = $isBs5 ? $button : Html::tag($tag, $button, $this->addonOptions);
128 | } else {
129 | $css = $notBs3 ? 'input-group-text' : 'input-group-addon';
130 | Html::addCssClass($this->addonOptions, [$css, 'picker']);
131 | $addon = Html::tag('span', $this->addon, $this->addonOptions);
132 | if ($notBs3 && !$isBs5) {
133 | $addon = Html::tag('div', $addon, ['class' => 'input-group-append']);
134 | }
135 | }
136 | if (isset($this->size)) {
137 | Html::addCssClass($this->containerOptions, 'input-group-' . $this->size);
138 | }
139 | return $this->getInput('textInput') . $addon;
140 | }
141 |
142 | /**
143 | * Registers the client assets for [[Timepicker]] widget
144 | */
145 | public function registerAssets()
146 | {
147 | $view = $this->getView();
148 | TimePickerAsset::register($view);
149 | $this->registerPlugin($this->pluginName);
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing to yii2-widget-timepicker
2 | ======================================
3 | Looking to contribute something to yii2-widget-timepicker? **Here's how you can help.**
4 |
5 | Please take a moment to review this document in order to make the contribution
6 | process easy and effective for everyone involved.
7 |
8 | Following these guidelines helps to communicate that you respect the time of
9 | the developers managing and developing this open source project. In return,
10 | they should reciprocate that respect in addressing your issue or assessing
11 | patches and features.
12 |
13 | Using the issue tracker
14 | -----------------------
15 | When [reporting bugs][reporting-bugs] or
16 | [requesting features][requesting-features], the
17 | [issue tracker on GitHub][issue-tracker] is the recommended channel to use.
18 |
19 | The issue tracker **is not** a place for support requests. Refer the
20 | [extension documentation and demos](http://demos.krajee.com/widget-details/timepicker) and/or refer to the
21 | [webtips Q & A forum](http://webtips.krajee.com/questions) which are the better places to get help.
22 |
23 | Reporting bugs with yii2-widget-timepicker
24 | ------------------------------------------
25 |
26 | We really appreciate clear bug reports that _consistently_ show an issue
27 | _within yii2-widget-timepicker_.
28 |
29 | The ideal bug report follows these guidelines:
30 |
31 | 1. **Use the [GitHub issue search][issue-search]** — Check if the issue
32 | has already been reported.
33 | 2. **Check if the issue has been fixed** — Try to reproduce the problem
34 | using the code in the `master` branch.
35 | 3. **Isolate the problem** — Try to share a demo or a test case that
36 | consistently reproduces the problem.
37 |
38 | Please try to be as detailed as possible in your bug report, especially if an
39 | isolated test case cannot be made. Some useful questions to include the answer
40 | to are:
41 |
42 | - What steps can be used to reproduce the issue?
43 | - What is the bug and what is the expected outcome?
44 | - What browser(s) and Operating System have you tested with?
45 | - Does the bug happen consistently across all tested browsers?
46 | - What version of jQuery are you using? And what version of yii2-widget-timepicker?
47 | - Are you using yii2-widget-timepicker with other plugins?
48 |
49 | All of these questions will help others fix and identify any potential bugs.
50 |
51 | Requesting features in yii2-widget-timepicker
52 | ------------------------------------------
53 | Before starting work on a major feature for yii2-widget-timepicker, **read the
54 | [documentation](http://demos.krajee.com/widget-details/timepicker) first** or you may risk spending a considerable amount of
55 | time on something which the project developers are not interested in bringing into the project.
56 |
57 | ### Submitting a pull request
58 |
59 | We use GitHub's pull request system for submitting patches. Here are some
60 | guidelines to follow when creating the pull request for your fix.
61 |
62 | 1. Make sure to create a ticket for your pull request. This will serve as the
63 | bug ticket, and any discussion about the bug will take place there. Your pull
64 | request will be focused on the specific changes that fix the bug.
65 | 2. Make sure to reference the ticket you are fixing within your pull request.
66 | This will allow us to close off the ticket once we merge the pull request, or
67 | follow up on the ticket if there are any related blocking issues.
68 | 3. Explain why the specific change was made. Not everyone who is reviewing your
69 | pull request will be familiar with the problem it is fixing.
70 | 4. Run your tests first. If your tests aren't passing, the pull request won't
71 | be able to be merged. If you're breaking existing tests, make sure that you
72 | aren't causing any breaking changes.
73 | 5. Only include source changes. While it's not required, only including changes
74 | from the `src` directory will prevent merge conflicts from occuring. Making
75 | this happen can be as a simple as not committing changes from the `dist`
76 | directory.
77 |
78 | By following these steps, you will make it easier for your pull request to be
79 | reviewed and eventually merged.
80 |
81 | Triaging issues and pull requests
82 | ---------------------------------
83 | Anyone can help the project maintainers triage issues and review pull requests.
84 |
85 | ### Handling new issues
86 |
87 | yii2-widget-timepicker regularly receives new issues which need to be tested and organized.
88 |
89 | When a new issue that comes in that is similar to another existing issue, it
90 | should be checked to make sure it is not a duplicate. Duplicates issues should
91 | be marked by replying to the issue with "Duplicate of #[issue number]" where
92 | `[issue number]` is the url or issue number for the existing issue. This will
93 | allow the project maintainers to quickly close off additional issues and keep
94 | the discussion focused within a single issue.
95 |
96 | If you can test issues that are reported to yii2-widget-timepicker that contain test cases and
97 | confirm under what conditions bugs happen, that will allow others to identify
98 | what causes a bug quicker.
99 |
100 | ### Reviewing pull requests
101 |
102 | It is very common for pull requests to be opened for issues that contain a clear
103 | solution to the problem. These pull requests should be rigorously reviewed by
104 | the community before being accepted. If you are not sure about a piece of
105 | submitted code, or know of a better way to do something, do not hesitate to make
106 | a comment on the pull request.
107 |
108 | ### Reviving old tickets
109 |
110 | If you come across tickets which have not been updated for a while, you are
111 | encouraged to revive them. While this can be as simple as saying `:+1:`, it is
112 | best if you can include more information on the issue. Common bugs and feature
113 | requests are more likely to be fixed, whether it is by the community or the
114 | developers, so keeping tickets up to date is encouraged.
115 |
116 | Licensing
117 | ---------
118 |
119 | It should also be made clear that **all code contributed to yii2-widget-timepicker** must be
120 | licensable under the [BSD-3 license][licensing]. Code that cannot be released
121 | under this license **cannot be accepted** into the project.
122 |
123 | [issue-search]: https://github.com/kartik-v/yii2-widget-timepicker/search?q=&type=Issues
124 | [issue-tracker]: https://github.com/kartik-v/yii2-widget-timepicker/issues
125 | [licensing]: https://github.com/kartik-v/yii2-widget-timepicker/blob/master/LICENSE.md
126 | [reporting-bugs]: #reporting-bugs-with-yii2-widget-timepicker
127 | [requesting-features]: #requesting-features-in-yii2-widget-timepicker
--------------------------------------------------------------------------------
/src/assets/js/bootstrap-timepicker.min.js:
--------------------------------------------------------------------------------
1 | /*! bootstrap-timepicker v0.2.3
2 | * Improvements by: Kartik Visweswaran, Krajee.com, 2014 - 2021
3 | * http://jdewit.github.com/bootstrap-timepicker
4 | * Copyright (c) 2013 Joris de Wit
5 | * MIT License
6 | */!function(t,i,e,s){"use strict";var h=function(i,e){this.widget="",this.$element=t(i),this.defaultTime=e.defaultTime,this.disableFocus=e.disableFocus,this.isOpen=e.isOpen,this.minuteStep=e.minuteStep,this.modalBackdrop=e.modalBackdrop,this.secondStep=e.secondStep,this.showInputs=e.showInputs,this.showMeridian=e.showMeridian,this.showSeconds=e.showSeconds,this.template=e.template,this.appendWidgetTo=e.appendWidgetTo,this.upArrowStyle=e.upArrowStyle,this.downArrowStyle=e.downArrowStyle,this.containerClass=e.containerClass,this._init()};h.prototype={constructor:h,_init:function(){var i=this;this.$element.parent().hasClass("bootstrap-timepicker")?(this.$element.parent(".bootstrap-timepicker").find(".picker").length?this.$element.parent(".bootstrap-timepicker").find(".picker").on({"click.timepicker":t.proxy(this.showWidget,this)}):this.$element.closest(this.containerClass).find(".input-group-addon").on({"click.timepicker":t.proxy(this.showWidget,this)}),this.$element.on({"focus.timepicker":t.proxy(this.highlightUnit,this),"click.timepicker":t.proxy(this.highlightUnit,this),"keydown.timepicker":t.proxy(this.elementKeydown,this),"blur.timepicker":t.proxy(this.blurElement,this)})):this.template?this.$element.on({"focus.timepicker":t.proxy(this.showWidget,this),"click.timepicker":t.proxy(this.showWidget,this),"blur.timepicker":t.proxy(this.blurElement,this)}):this.$element.on({"focus.timepicker":t.proxy(this.highlightUnit,this),"click.timepicker":t.proxy(this.highlightUnit,this),"keydown.timepicker":t.proxy(this.elementKeydown,this),"blur.timepicker":t.proxy(this.blurElement,this)}),this.template!==!1?this.$widget=t(this.getTemplate()).prependTo(this.$element.parents(this.appendWidgetTo)).on("click",t.proxy(this.widgetClick,this)):this.$widget=!1,this.showInputs&&this.$widget!==!1&&this.$widget.find("input").each(function(){t(this).on({"click.timepicker":function(){t(this).select()},"keydown.timepicker":t.proxy(i.widgetKeydown,i)})}),this.setDefaultTime(this.defaultTime)},blurElement:function(){this.highlightedUnit=s,this.updateFromElementVal()},decrementHour:function(){if(this.showMeridian)if(1===this.hour)this.hour=12;else{if(12===this.hour)return this.hour--,this.toggleMeridian();if(0===this.hour)return this.hour=11,this.toggleMeridian();this.hour--}else 0===this.hour?this.hour=23:this.hour--;this.update()},decrementMinute:function(t){var i;i=t?this.minute-t:this.minute-this.minuteStep,0>i?(this.decrementHour(),this.minute=i+60):this.minute=i,this.update()},decrementSecond:function(){var t=this.second-this.secondStep;0>t?(this.decrementMinute(!0),this.second=t+60):this.second=t,this.update()},elementKeydown:function(t){switch(t.keyCode){case 9:switch(this.updateFromElementVal(),this.highlightedUnit){case"hour":t.preventDefault(),this.highlightNextUnit();break;case"minute":(this.showMeridian||this.showSeconds)&&(t.preventDefault(),this.highlightNextUnit());break;case"second":this.showMeridian&&(t.preventDefault(),this.highlightNextUnit())}break;case 27:this.updateFromElementVal();break;case 37:t.preventDefault(),this.highlightPrevUnit(),this.updateFromElementVal();break;case 38:switch(t.preventDefault(),this.highlightedUnit){case"hour":this.incrementHour(),this.highlightHour();break;case"minute":this.incrementMinute(),this.highlightMinute();break;case"second":this.incrementSecond(),this.highlightSecond();break;case"meridian":this.toggleMeridian(),this.highlightMeridian()}break;case 39:t.preventDefault(),this.updateFromElementVal(),this.highlightNextUnit();break;case 40:switch(t.preventDefault(),this.highlightedUnit){case"hour":this.decrementHour(),this.highlightHour();break;case"minute":this.decrementMinute(),this.highlightMinute();break;case"second":this.decrementSecond(),this.highlightSecond();break;case"meridian":this.toggleMeridian(),this.highlightMeridian()}}},formatTime:function(t,i,e,s){return t=10>t?"0"+t:t,i=10>i?"0"+i:i,e=10>e?"0"+e:e,t+":"+i+(this.showSeconds?":"+e:"")+(this.showMeridian?" "+s:"")},getCursorPosition:function(){var t=this.$element.get(0);if("selectionStart"in t)return t.selectionStart;if(e.selection){t.focus();var i=e.selection.createRange(),s=e.selection.createRange().text.length;return i.moveStart("character",-t.value.length),i.text.length-s}},getTemplate:function(){var t,i,e,s,h,n;switch(this.showInputs?(i='',e='',s='',h=''):(i='',e='',s='',h=''),n='