/** * Registers the needed JavaScript. */ public function registerClientScript() { $view = $this->getView(); KCFinderWidgetAsset::register($view); $this->clientOptions['kcfUrl'] = Yii::$app->assetManager->getPublishedUrl((new KCFinderAsset())->sourcePath); if ($this->iframe) { $this->clientOptions['iframeModalId'] = $this->getIFrameModalId(); } $clientOptions = Json::encode($this->clientOptions); $view->registerJs("jQuery('#{$this->buttonOptions['id']}').KCFinderInputWidget({$clientOptions})"); }
/** * Registers the needed JavaScript. */ public function registerClientScript() { static $kcfAssetPathRegistered = false; $view = $this->getView(); KCFinderWidgetAsset::register($view); if (!$kcfAssetPathRegistered) { $assetPath = Json::encode(Yii::$app->assetManager->getPublishedUrl((new KCFinderAsset())->sourcePath)); $view->registerJs("var kcfAssetPath = {$assetPath};", View::POS_BEGIN); $kcfAssetPathRegistered = true; } $clientOptions = Json::encode($this->clientOptions); $view->registerJs("jQuery('#{$this->buttonOptions['id']}').KCFinderInputWidget({$clientOptions})"); }