/** * Renders the widget. */ public function run() { echo $this->renderWidget() . "\n"; $containerID = $this->inline ? $this->containerOptions['id'] : $this->options['id']; $language = $this->language ? $this->language : Yii::$app->language; if ($language != 'en-US') { $view = $this->getView(); $bundle = DatePickerLanguageAsset::register($view); if ($bundle->autoGenerate) { $view->registerJsFile($bundle->baseUrl . "/ui/i18n/datepicker-{$language}.js", ['depends' => [JuiAsset::className()]]); } $options = Json::encode($this->clientOptions); $view->registerJs("\$('#{$containerID}').datepicker(\$.extend({}, \$.datepicker.regional['{$language}'], {$options}));"); } else { $this->registerClientOptions('datepicker', $containerID); } $this->registerClientEvents('datepicker', $containerID); JuiAsset::register($this->getView()); }
/** * Renders the widget. */ public function run() { echo $this->renderWidget() . "\n"; $containerID = $this->inline ? $this->containerOptions['id'] : $this->options['id']; $language = $this->language ? $this->language : Yii::$app->language; $this->clientOptions = ArrayHelper::merge($this->getClientOptions(), $this->clientOptions); if (strncmp($this->dateFormat, 'php:', 4) === 0) { $this->clientOptions['dateFormat'] = FormatConverter::convertDatePhpToJui(substr($this->dateFormat, 4), 'date', $language); } else { $this->clientOptions['dateFormat'] = FormatConverter::convertDateIcuToJui($this->dateFormat, 'date', $language); } if ($language != 'en-US') { $view = $this->getView(); $bundle = DatePickerLanguageAsset::register($view); if ($bundle->autoGenerate) { $fallbackLanguage = substr($language, 0, 2); if ($fallbackLanguage !== $language && !file_exists(Yii::getAlias($bundle->sourcePath . "/ui/i18n/datepicker-{$language}.js"))) { $language = $fallbackLanguage; } $view->registerJsFile($bundle->baseUrl . "/ui/i18n/datepicker-{$language}.js", ['depends' => [JuiAsset::className()]]); } $options = Json::encode($this->clientOptions); $view->registerJs("\$('#{$containerID}').datepicker(\$.extend({}, \$.datepicker.regional['{$language}'], {$options}));"); } else { $this->registerClientOptions('datepicker', $containerID); } $this->registerClientEvents('datepicker', $containerID); JuiAsset::register($this->getView()); }
/** * Register widget assets. */ public function registerClientScript() { $view = $this->getView(); $containerID = $this->inline ? $this->containerOptions['id'] : $this->options['id']; $options = !empty($this->clientOptions) ? Json::encode($this->clientOptions) : ''; $asset = TimePickerAsset::register($view); if ($this->language !== null) { $asset->language = $this->language; $bundle = DatePickerLanguageAsset::register($view); $view->registerJsFile($bundle->baseUrl . "/ui/i18n/datepicker-{$this->language}.js", ['depends' => [JuiAsset::className()]]); } if (!empty($this->clientEvents)) { foreach ($this->clientEvents as $event => $handler) { $view->registerJs("jQuery('#{$containerID}').on('{$event}', {$handler});"); } } $view->registerJs("jQuery('#{$containerID}').{$this->mode}picker({$options});"); }
/** * Register date picker language on client side * @param \yii\web\View $view View context */ public static function registerClientSideDatePickerLanguage($view) { $language = Yii::$app->language; if ($language != 'en-US' && $language != 'en') { $bundle = DatePickerLanguageAsset::register($view); if ($bundle->autoGenerate) { $fallbackLanguage = substr($language, 0, 2); if ($fallbackLanguage !== $language && !file_exists(Yii::getAlias($bundle->sourcePath . "/ui/i18n/datepicker-{$language}.js"))) { $language = $fallbackLanguage; } $view->registerJsFile($bundle->baseUrl . "/ui/i18n/datepicker-{$language}.js", ['depends' => [JuiAsset::className()]]); $view->registerJs("\$.kalibao.core.app.datePickerLanguage = \$.datepicker.regional['{$language}'];"); } } }