-
Notifications
You must be signed in to change notification settings - Fork 0
/
DatePickerAsset.php
executable file
·49 lines (39 loc) · 1.08 KB
/
DatePickerAsset.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace filsh\datepicker;
use \Yii;
/**
* Description of DateTimePicker
* @property type $name Description
*/
class DatePickerAsset extends \yii\web\AssetBundle
{
public $sourcePath = '@bower/bootstrap-datepicker/dist';
public $enableLocale = true;
public $js = [
'js/bootstrap-datepicker.min.js'
];
public $css = [
'css/bootstrap-datepicker3.min.css'
];
public $depends = [
\yii\web\JqueryAsset::class
];
public function init()
{
if(!empty($this->js) && $this->enableLocale && ($language = $this->getLanguage()) !== null) {
$this->js[] = 'js/locales/bootstrap-datepicker.'. $language .'.min.js';
}
parent::init();
}
protected function getLanguage()
{
$language = str_replace('-', '_', strtolower(Yii::$app->language));
if(strpos($language, '_') !== false) {
$language = explode('_', $language)[0];
}
if($language === 'en') {
$language = null;
}
return $language;
}
}