Skip to content

Commit 756cd2d

Browse files
committed
Update to release v1.3.5 fix #63, fix #64
1 parent 3e701cc commit 756cd2d

File tree

75 files changed

+148
-103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+148
-103
lines changed

CHANGE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Change Log: `yii2-widget-datepicker`
22
====================================
33

4+
## version 1.3.5
5+
6+
**Date:** 28-Dec-2015
7+
8+
- (bug #63): Fix extra brace bug in plugin JS code.
9+
- (enh #64): Enhance and improve language & locale validation.
10+
411
## version 1.3.4
512

613
**Date:** 27-Dec-2015

DatePicker.php

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015
55
* @package yii2-widgets
66
* @subpackage yii2-widget-datepicker
7-
* @version 1.3.4
7+
* @version 1.3.5
88
*/
99

1010
namespace kartik\date;
@@ -86,25 +86,25 @@ class DatePicker extends InputWidget
8686
/**
8787
* @var mixed the calendar picker button configuration.
8888
* - if this is passed as a string, it will be displayed as is (will not be HTML encoded).
89-
* - if this is set to false, the picker button will not be displayed.
90-
* - if this is passed as an array (this is the DEFAULT) it will treat this as HTML attributes
91-
* for the button (to be displayed as a Bootstrap addon). The following special keys are recognized;
92-
* - icon - string, the bootstrap glyphicon name/suffix. Defaults to 'calendar'.
93-
* - title - string|bool, the title to be displayed on hover. Defaults to 'Select date & time'. To disable,
94-
* set it to `false`.
89+
* - if this is set to `false`, the picker button will not be displayed.
90+
* - if this is passed as an array (this is the DEFAULT) it will treat this as HTML attributes for the button (to
91+
* be displayed as a Bootstrap addon). The following special keys are recognized;
92+
* - icon: string, the bootstrap glyphicon name/suffix. Defaults to 'calendar'.
93+
* - title: string|bool, the title to be displayed on hover. Defaults to 'Select date & time'. To disable, set it
94+
* to `false`.
9595
*/
9696
public $pickerButton = [];
9797

9898
/**
9999
* @var mixed the calendar remove button configuration - applicable only for type set to
100100
* `DatePicker::TYPE_COMPONENT_PREPEND` or `DatePicker::TYPE_COMPONENT_APPEND`.
101101
* - if this is passed as a string, it will be displayed as is (will not be HTML encoded).
102-
* - if this is set to false, the remove button will not be displayed.
103-
* - if this is passed as an array (this is the DEFAULT) it will treat this as HTML attributes
104-
* for the button (to be displayed as a Bootstrap addon). The following special keys are recognized;
102+
* - if this is set to `false`, the remove button will not be displayed.
103+
* - if this is passed as an array (this is the DEFAULT) it will treat this as HTML attributes for the button (to
104+
* be displayed as a Bootstrap addon). The following special keys are recognized;
105105
* - icon - string, the bootstrap glyphicon name/suffix. Defaults to 'remove'.
106-
* - title - string, the title to be displayed on hover. Defaults to 'Clear field'. To disable,
107-
* set it to `false`.
106+
* - title - string, the title to be displayed on hover. Defaults to 'Clear field'. To disable, set it to
107+
* `false`.
108108
*/
109109
public $removeButton = [];
110110

@@ -178,16 +178,17 @@ protected function renderDatePicker()
178178
$this->_container['data-date'] = $this->value;
179179
}
180180
if (empty($this->layout)) {
181-
if ($this->type == self::TYPE_COMPONENT_PREPEND) {
181+
if ($this->type === self::TYPE_COMPONENT_PREPEND) {
182182
$this->layout = '{picker}{remove}{input}';
183-
} elseif ($this->type == self::TYPE_COMPONENT_APPEND) {
183+
} elseif ($this->type === self::TYPE_COMPONENT_APPEND) {
184184
$this->layout = '{input}{remove}{picker}';
185-
} elseif ($this->type == self::TYPE_RANGE) {
185+
} elseif ($this->type === self::TYPE_RANGE) {
186186
$this->layout = '{input1}{separator}{input2}';
187187
}
188188
}
189189
Html::addCssClass($this->options, 'krajee-datepicker');
190-
$this->options['data-datepicker-source'] = $this->type == self::TYPE_INPUT ? $this->options['id'] : $this->_container['id'];
190+
$this->options['data-datepicker-source'] = $this->type === self::TYPE_INPUT ? $this->options['id'] :
191+
$this->_container['id'];
191192
$this->options['data-datepicker-type'] = $this->type;
192193
$this->registerAssets();
193194
echo $this->renderInput();
@@ -213,14 +214,14 @@ protected static function err($msg = '')
213214
protected function validateConfig()
214215
{
215216
if ($this->type < 1 || $this->type > 6 || !is_int($this->type)) {
216-
self::err("Invalid value for the property 'type'. Must be an integer between 1 and 6.");
217+
static::err("Invalid value for the property 'type'. Must be an integer between 1 and 6.");
217218
}
218219
if ($this->type === self::TYPE_RANGE) {
219220
if ($this->attribute2 === null && $this->name2 === null) {
220-
self::err("Either 'name2' or 'attribute2' properties must be specified for a datepicker 'range' markup.");
221+
static::err("Either 'name2' or 'attribute2' properties must be specified for a datepicker 'range' markup.");
221222
}
222-
if (!class_exists('\\kartik\\field\\FieldRangeAsset')) {
223-
self::err(
223+
if (!class_exists("\\kartik\\field\\FieldRangeAsset")) {
224+
static::err(
224225
"The yii2-field-range extension is not installed and is a pre-requisite for a DatePicker " .
225226
"RANGE type. To install this extension run this command on your console: \n\n" .
226227
"php composer.phar require kartik-v/yii2-field-range \"*\""
@@ -231,13 +232,13 @@ protected function validateConfig()
231232
return;
232233
}
233234
if (!$this->form instanceof ActiveForm) {
234-
self::err("The 'form' property must be of type \\yii\\widgets\\ActiveForm");
235+
static::err("The 'form' property must be of type \\yii\\widgets\\ActiveForm");
235236
}
236237
if (!$this->hasModel()) {
237-
self::err("You must set the 'model' and 'attribute' properties when the 'form' property is set.");
238+
static::err("You must set the 'model' and 'attribute' properties when the 'form' property is set.");
238239
}
239240
if ($this->type === self::TYPE_RANGE && !isset($this->attribute2)) {
240-
self::err("The 'attribute2' property must be set for a 'range' type markup and a defined 'form' property.");
241+
static::err("The 'attribute2' property must be set for a 'range' type markup and a defined 'form' property.");
241242
}
242243
}
243244

@@ -383,25 +384,25 @@ public function registerAssets()
383384
}
384385
$view = $this->getView();
385386
if (!empty($this->_langFile)) {
386-
DatePickerAsset::register($view)->js[] = $this->_langFile;
387-
} else {
388-
DatePickerAsset::register($view);
387+
LanguageAsset::register($view)->js[] = $this->_langFile;
389388
}
390-
$id = "jQuery('#" . $this->options['id'] . "')";
389+
DatePickerAsset::register($view);
390+
$id = $this->options['id'];
391+
$input = "jQuery('#{$id}')";
391392
$el = "jQuery('#" . $this->options['data-datepicker-source'] . "')";
392393
$this->registerPlugin($this->pluginName, $el);
393394
if ($this->type === self::TYPE_INLINE) {
394-
$view->registerJs("{$el}.on('changeDate',function(e){{$id}.val(e.format()).trigger('change')});");
395+
$view->registerJs("{$el}.on('changeDate',function(e){{$input}.val(e.format()).trigger('change')});");
395396
}
396397
if ($this->_hasAddon && $this->removeButton !== false) {
397-
$view->registerJs("initDPRemove('" . $this->options['id'] . "');");
398+
$view->registerJs("initDPRemove('{$id}');");
398399
}
399400
if ($this->_hasAddon) {
400-
$view->registerJs("initDPAddon('" . $this->options['id'] . "');");
401+
$view->registerJs("initDPAddon('{$id}');");
401402
}
402403
if ($this->type === self::TYPE_RANGE) {
403404
FieldRangeAsset::register($view);
404-
$view->registerJs("initDPRemove('" . $this->options['id'] . "', true);");
405+
$view->registerJs("initDPRemove('{$id}', true);");
405406
}
406407
}
407408
}

DatePickerAsset.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015
55
* @package yii2-widgets
66
* @subpackage yii2-widget-datepicker
7-
* @version 1.3.4
7+
* @version 1.3.5
88
*/
99

1010
namespace kartik\date;
@@ -19,6 +19,14 @@
1919
*/
2020
class DatePickerAsset extends AssetBundle
2121
{
22+
/**
23+
* @inheritdoc
24+
*/
25+
public $depends = ['\kartik\date\LanguageAsset'];
26+
27+
/**
28+
* @inheritdoc
29+
*/
2230
public function init()
2331
{
2432
$this->setSourcePath(__DIR__ . '/assets');

LanguageAsset.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015
5+
* @package yii2-date-range
6+
* @version 1.6.5
7+
*/
8+
9+
namespace kartik\date;
10+
11+
use kartik\base\AssetBundle;
12+
13+
/**
14+
* Language asset bundle for \kartik\date\DatePicker.
15+
*
16+
* @author Kartik Visweswaran <[email protected]>
17+
* @since 1.0
18+
*/
19+
class LanguageAsset extends AssetBundle
20+
{
21+
/**
22+
* @inheritdoc
23+
*/
24+
public function init()
25+
{
26+
$this->setSourcePath(__DIR__ . '/assets');
27+
parent::init();
28+
}
29+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ to the `require` section of your `composer.json` file.
3838

3939
## Latest Release
4040

41-
> NOTE: The latest version of the module is v1.3.4. Refer the [CHANGE LOG](https://github.com/kartik-v/yii2-widget-datepicker/blob/master/CHANGE.md) for details.
41+
> NOTE: The latest version of the module is v1.3.5. Refer the [CHANGE LOG](https://github.com/kartik-v/yii2-widget-datepicker/blob/master/CHANGE.md) for details.
4242
4343
## Demo
4444

assets/css/datepicker-kv.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015
33
* @package yii2-widgets
44
* @subpackage yii2-widget-datepicker
5-
* @version 1.3.4
5+
* @version 1.3.5
66
*
77
* Custom styling for Datepicker
88
* Built for Yii Framework 2.0

assets/css/datepicker-kv.min.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015
33
* @package yii2-widgets
44
* @subpackage yii2-widget-datepicker
5-
* @version 1.3.4
5+
* @version 1.3.5
66
*
77
* Custom styling for Datepicker
88
* Built for Yii Framework 2.0

assets/js/bootstrap-datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@
460460
show: function(){
461461
// validate specifically for Krajee Yii2 Datepicker container and layout enhancements
462462
var el = this.element.is('input') ? this.element : this.element.find('input.krajee-datepicker');
463-
if (el.attr('readonly') && this.o.enableOnReadonly === false) {
463+
if (el.attr('readonly') && this.o.enableOnReadonly === false)
464464
return;
465465
if (!this.isInline)
466466
this.picker.appendTo(this.o.container);

assets/js/datepicker-kv.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015
33
* @package yii2-widgets
44
* @subpackage yii2-widget-datepicker
5-
* @version 1.3.4
5+
* @version 1.3.5
66
*
77
* Extension to bootstrap datepicker to use noconflict approach
88
* so that the plugin does not conflict with other jquery plugins

assets/js/datepicker-kv.min.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015
33
* @package yii2-widgets
44
* @subpackage yii2-widget-datepicker
5-
* @version 1.3.4
5+
* @version 1.3.5
66
*
77
* Extension to bootstrap datepicker to use noconflict approach
88
* so that the plugin does not conflict with other jquery plugins

assets/js/locales/bootstrap-datepicker.ar.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/locales/bootstrap-datepicker.az.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/locales/bootstrap-datepicker.bg.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/locales/bootstrap-datepicker.bs.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/locales/bootstrap-datepicker.ca.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/locales/bootstrap-datepicker.cs.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/locales/bootstrap-datepicker.cy.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/locales/bootstrap-datepicker.da.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)