/** * register the all files */ protected function registerAsset() { $view = $this->getView(); if (is_null($this->initJs)) { $this->initJs = 'SirTrevor.config.debug = ' . $this->debug . ';' . PHP_EOL; $this->initJs .= 'SirTrevor.config.language = "' . $this->language . '";' . PHP_EOL; $this->initJs .= 'SirTrevor.config.disableScroll = ' . $this->disableScroll . ';' . PHP_EOL; $this->initJs .= 'SirTrevor.setDefaults({ uploadUrl: "' . $this->getImageUploadUrl() . '" });' . PHP_EOL; $this->initJs .= $this->getOtherBlocksOptions(); $this->initJs .= "window.editor = new SirTrevor.Editor(" . $this->getBlockOptions() . ");" . PHP_EOL; } $asset = SirTrevorAsset::register($view); $asset->language = $this->language; $asset->debug = $this->debug; $view->registerJs('$(function(){' . $this->initJs . '});' . PHP_EOL); }
/** * register the all files */ protected function registerAsset() { $view = $this->getView(); if (is_null($this->initJs)) { $this->initJs = 'SirTrevor.DEBUG = ' . $this->debug . ';' . PHP_EOL; $this->initJs .= 'SirTrevor.LANGUAGE = "' . $this->language . '";' . PHP_EOL; $this->initJs .= 'SirTrevor.setDefaults({ uploadUrl: "' . $this->getImageUploadUrl() . '" });' . PHP_EOL; $this->initJs .= $this->getTextAreaOptions(); $this->initJs .= "window.editor = new SirTrevor.Editor(" . $this->getBlockOptions() . ");" . PHP_EOL; } // Registering assets through the ESirTrevorView yii1 bridge methods $assetBundle = new SirTrevorAsset(); $assetBundle->depends = []; // To prevent triggering inclusion of yii2 jquery asset bundle $assetBundle->language = $this->language; $this->view->assetPath = $assetBundle->sourcePath; $assetBundle->registerAssetFiles($view); // For yii1 compatibility we need to refrain from using View::POS_LOAD or View::POS_READY since that would attempt to include the yii2 jquery asset bundle $view->registerJs('(function($){ "use strict"; $(function(){ ' . $this->initJs . ' }); })(jQuery);', $view::POS_END); }