Skip to content

Commit 02437c3

Browse files
committed
+ Update Composer version
1 parent 44df5d6 commit 02437c3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

widgets/PersianDatePicker.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,15 @@ public function registerAssetBundle()
126126
{
127127
$view = $this->getView();
128128
\app\assets\PersianDatePickerAsset::register($view);
129+
$initDate = null;
130+
if (!empty($this->initDateValue)) {
131+
$initDate = Yii::$app->formatter->asTimestamp($this->initDateValue);
132+
}
133+
129134
if ($this->inline === true) {
130-
$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()})";
135+
$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()})";
131136
} else {
132-
$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()})";
137+
$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()})";
133138
}
134139
$view->registerJs($script);
135140
if (!empty(Html::getAttributeValue($this->model, $this->attribute))) {
@@ -141,4 +146,4 @@ public function registerAssetBundle()
141146
}
142147

143148
}
144-
}
149+
}

0 commit comments

Comments
 (0)