Skip to content

Commit

Permalink
+ Update Composer version
Browse files Browse the repository at this point in the history
  • Loading branch information
mortezakarimi committed Sep 27, 2018
1 parent 44df5d6 commit 02437c3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions widgets/PersianDatePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,15 @@ public function registerAssetBundle()
{
$view = $this->getView();
\app\assets\PersianDatePickerAsset::register($view);
$initDate = null;
if (!empty($this->initDateValue)) {
$initDate = Yii::$app->formatter->asTimestamp($this->initDateValue);
}

if ($this->inline === true) {
$script = "var pd_" . Html::getAttributeName($this->attribute) . "=$('#" . $this->options['id'] . "_inlineDatePicker').persianDatepicker(" . Json::encode($this->pluginOptions) . ");$(document).on('click','#" . $this->options['id'] . "_clearInput" . "',function(e){e.preventDefault();pd_" . Html::getAttributeName($this->attribute) . ".setDate(new Date()); $('#" . $this->options['id'] . "').val('');pd_" . Html::getAttributeName($this->attribute) . ".options.onSelect()})";
$script = "var pd_" . Html::getAttributeName($this->attribute) . "=$('#" . $this->options['id'] . "_inlineDatePicker').persianDatepicker(" . Json::encode($this->pluginOptions) . ");$(document).on('click','#" . $this->options['id'] . "_clearInput" . "',function(e){e.preventDefault();pd_" . Html::getAttributeName($this->attribute) . ".setDate(new persianDate.unix({$initDate})); $('#" . $this->options['id'] . "').val('');pd_" . Html::getAttributeName($this->attribute) . ".options.onSelect()})";
} else {
$script = "var pd_" . Html::getAttributeName($this->attribute) . "=$('#" . $this->options['id'] . "_datePickerInput').persianDatepicker(" . Json::encode($this->pluginOptions) . ");$(document).on('click','#" . $this->options['id'] . "_clearInput" . "',function(e){e.preventDefault();pd_" . Html::getAttributeName($this->attribute) . ".setDate(new Date()); $('#" . $this->options['id'] . "').val('');$('#" . $this->options['id'] . "_datePickerInput').val('');pd_" . Html::getAttributeName($this->attribute) . ".options.onSelect()})";
$script = "var pd_" . Html::getAttributeName($this->attribute) . "=$('#" . $this->options['id'] . "_datePickerInput').persianDatepicker(" . Json::encode($this->pluginOptions) . ");$(document).on('click','#" . $this->options['id'] . "_clearInput" . "',function(e){e.preventDefault();pd_" . Html::getAttributeName($this->attribute) . ".setDate(new persianDate.unix({$initDate})); $('#" . $this->options['id'] . "').val('');$('#" . $this->options['id'] . "_datePickerInput').val('');pd_" . Html::getAttributeName($this->attribute) . ".options.onSelect()})";
}
$view->registerJs($script);
if (!empty(Html::getAttributeValue($this->model, $this->attribute))) {
Expand All @@ -141,4 +146,4 @@ public function registerAssetBundle()
}

}
}
}

0 comments on commit 02437c3

Please sign in to comment.