Skip to content

Commit

Permalink
Update to release v1.3.5 fix #63, fix #64
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Dec 28, 2015
1 parent 3e701cc commit 756cd2d
Show file tree
Hide file tree
Showing 75 changed files with 148 additions and 103 deletions.
7 changes: 7 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change Log: `yii2-widget-datepicker`
====================================

## version 1.3.5

**Date:** 28-Dec-2015

- (bug #63): Fix extra brace bug in plugin JS code.
- (enh #64): Enhance and improve language & locale validation.

## version 1.3.4

**Date:** 27-Dec-2015
Expand Down
63 changes: 32 additions & 31 deletions DatePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015
* @package yii2-widgets
* @subpackage yii2-widget-datepicker
* @version 1.3.4
* @version 1.3.5
*/

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

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

Expand Down Expand Up @@ -178,16 +178,17 @@ protected function renderDatePicker()
$this->_container['data-date'] = $this->value;
}
if (empty($this->layout)) {
if ($this->type == self::TYPE_COMPONENT_PREPEND) {
if ($this->type === self::TYPE_COMPONENT_PREPEND) {
$this->layout = '{picker}{remove}{input}';
} elseif ($this->type == self::TYPE_COMPONENT_APPEND) {
} elseif ($this->type === self::TYPE_COMPONENT_APPEND) {
$this->layout = '{input}{remove}{picker}';
} elseif ($this->type == self::TYPE_RANGE) {
} elseif ($this->type === self::TYPE_RANGE) {
$this->layout = '{input1}{separator}{input2}';
}
}
Html::addCssClass($this->options, 'krajee-datepicker');
$this->options['data-datepicker-source'] = $this->type == self::TYPE_INPUT ? $this->options['id'] : $this->_container['id'];
$this->options['data-datepicker-source'] = $this->type === self::TYPE_INPUT ? $this->options['id'] :
$this->_container['id'];
$this->options['data-datepicker-type'] = $this->type;
$this->registerAssets();
echo $this->renderInput();
Expand All @@ -213,14 +214,14 @@ protected static function err($msg = '')
protected function validateConfig()
{
if ($this->type < 1 || $this->type > 6 || !is_int($this->type)) {
self::err("Invalid value for the property 'type'. Must be an integer between 1 and 6.");
static::err("Invalid value for the property 'type'. Must be an integer between 1 and 6.");
}
if ($this->type === self::TYPE_RANGE) {
if ($this->attribute2 === null && $this->name2 === null) {
self::err("Either 'name2' or 'attribute2' properties must be specified for a datepicker 'range' markup.");
static::err("Either 'name2' or 'attribute2' properties must be specified for a datepicker 'range' markup.");
}
if (!class_exists('\\kartik\\field\\FieldRangeAsset')) {
self::err(
if (!class_exists("\\kartik\\field\\FieldRangeAsset")) {
static::err(
"The yii2-field-range extension is not installed and is a pre-requisite for a DatePicker " .
"RANGE type. To install this extension run this command on your console: \n\n" .
"php composer.phar require kartik-v/yii2-field-range \"*\""
Expand All @@ -231,13 +232,13 @@ protected function validateConfig()
return;
}
if (!$this->form instanceof ActiveForm) {
self::err("The 'form' property must be of type \\yii\\widgets\\ActiveForm");
static::err("The 'form' property must be of type \\yii\\widgets\\ActiveForm");
}
if (!$this->hasModel()) {
self::err("You must set the 'model' and 'attribute' properties when the 'form' property is set.");
static::err("You must set the 'model' and 'attribute' properties when the 'form' property is set.");
}
if ($this->type === self::TYPE_RANGE && !isset($this->attribute2)) {
self::err("The 'attribute2' property must be set for a 'range' type markup and a defined 'form' property.");
static::err("The 'attribute2' property must be set for a 'range' type markup and a defined 'form' property.");
}
}

Expand Down Expand Up @@ -383,25 +384,25 @@ public function registerAssets()
}
$view = $this->getView();
if (!empty($this->_langFile)) {
DatePickerAsset::register($view)->js[] = $this->_langFile;
} else {
DatePickerAsset::register($view);
LanguageAsset::register($view)->js[] = $this->_langFile;
}
$id = "jQuery('#" . $this->options['id'] . "')";
DatePickerAsset::register($view);
$id = $this->options['id'];
$input = "jQuery('#{$id}')";
$el = "jQuery('#" . $this->options['data-datepicker-source'] . "')";
$this->registerPlugin($this->pluginName, $el);
if ($this->type === self::TYPE_INLINE) {
$view->registerJs("{$el}.on('changeDate',function(e){{$id}.val(e.format()).trigger('change')});");
$view->registerJs("{$el}.on('changeDate',function(e){{$input}.val(e.format()).trigger('change')});");
}
if ($this->_hasAddon && $this->removeButton !== false) {
$view->registerJs("initDPRemove('" . $this->options['id'] . "');");
$view->registerJs("initDPRemove('{$id}');");
}
if ($this->_hasAddon) {
$view->registerJs("initDPAddon('" . $this->options['id'] . "');");
$view->registerJs("initDPAddon('{$id}');");
}
if ($this->type === self::TYPE_RANGE) {
FieldRangeAsset::register($view);
$view->registerJs("initDPRemove('" . $this->options['id'] . "', true);");
$view->registerJs("initDPRemove('{$id}', true);");
}
}
}
10 changes: 9 additions & 1 deletion DatePickerAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015
* @package yii2-widgets
* @subpackage yii2-widget-datepicker
* @version 1.3.4
* @version 1.3.5
*/

namespace kartik\date;
Expand All @@ -19,6 +19,14 @@
*/
class DatePickerAsset extends AssetBundle
{
/**
* @inheritdoc
*/
public $depends = ['\kartik\date\LanguageAsset'];

/**
* @inheritdoc
*/
public function init()
{
$this->setSourcePath(__DIR__ . '/assets');
Expand Down
29 changes: 29 additions & 0 deletions LanguageAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015
* @package yii2-date-range
* @version 1.6.5
*/

namespace kartik\date;

use kartik\base\AssetBundle;

/**
* Language asset bundle for \kartik\date\DatePicker.
*
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @since 1.0
*/
class LanguageAsset extends AssetBundle
{
/**
* @inheritdoc
*/
public function init()
{
$this->setSourcePath(__DIR__ . '/assets');
parent::init();
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ to the `require` section of your `composer.json` file.

## Latest Release

> 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.
> 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.
## Demo

Expand Down
2 changes: 1 addition & 1 deletion assets/css/datepicker-kv.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015
* @package yii2-widgets
* @subpackage yii2-widget-datepicker
* @version 1.3.4
* @version 1.3.5
*
* Custom styling for Datepicker
* Built for Yii Framework 2.0
Expand Down
2 changes: 1 addition & 1 deletion assets/css/datepicker-kv.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015
* @package yii2-widgets
* @subpackage yii2-widget-datepicker
* @version 1.3.4
* @version 1.3.5
*
* Custom styling for Datepicker
* Built for Yii Framework 2.0
Expand Down
2 changes: 1 addition & 1 deletion assets/js/bootstrap-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@
show: function(){
// validate specifically for Krajee Yii2 Datepicker container and layout enhancements
var el = this.element.is('input') ? this.element : this.element.find('input.krajee-datepicker');
if (el.attr('readonly') && this.o.enableOnReadonly === false) {
if (el.attr('readonly') && this.o.enableOnReadonly === false)
return;
if (!this.isInline)
this.picker.appendTo(this.o.container);
Expand Down
2 changes: 1 addition & 1 deletion assets/js/datepicker-kv.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015
* @package yii2-widgets
* @subpackage yii2-widget-datepicker
* @version 1.3.4
* @version 1.3.5
*
* Extension to bootstrap datepicker to use noconflict approach
* so that the plugin does not conflict with other jquery plugins
Expand Down
2 changes: 1 addition & 1 deletion assets/js/datepicker-kv.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2015
* @package yii2-widgets
* @subpackage yii2-widget-datepicker
* @version 1.3.4
* @version 1.3.5
*
* Extension to bootstrap datepicker to use noconflict approach
* so that the plugin does not conflict with other jquery plugins
Expand Down
2 changes: 1 addition & 1 deletion assets/js/locales/bootstrap-datepicker.ar.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/locales/bootstrap-datepicker.az.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/locales/bootstrap-datepicker.bg.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/locales/bootstrap-datepicker.bs.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/locales/bootstrap-datepicker.ca.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/locales/bootstrap-datepicker.cs.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/locales/bootstrap-datepicker.cy.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/locales/bootstrap-datepicker.da.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 756cd2d

Please sign in to comment.