Registers CMS javascript code

@param      $script
@param bool $once        if true, only registers script with these exact contents once
@return $this
484520
public function registerScript($script, $once = true)
    {
        if ( ! $once) {
            $this->scripts[] = $script;

            return $this;
        }

        // Make sure the script is added only once
        $hash = md5($script);

        if (array_key_exists($hash, $this->scriptHashes)) {
            return $this;
        }

        $this->scripts[] = $script;

        // Map the hash for adding the script only once
        end($this->scripts);
        $index = key($this->scripts);

        $this->scriptHashes[$hash] = $index;

        return $this;
    }
631673
public function registerClientScript()
    {
        $view = $this->getView();
        $selector = Json::encode($this->selector);
        $asset = TrumbowygAsset::register($view);

        if (isset($this->settings['lang'])) {
            $asset->language = $this->settings['lang'];
        }

        if (isset($this->settings['plugins'])) {
            $asset->plugins = $this->settings['plugins'];
        }

        $settings = !empty($this->settings) ? Json::encode($this->settings) : '';

        $view->registerJs("jQuery($selector).trumbowyg($settings);");
    }
321788
public function addScript(string $name, AbstractScript $script): self
    {
        if (!\strlen($name)) {
            throw new InvalidException('The name of a Script is required and must be a string');
        }
        $this->setParam($name, $script);

        return $this;
    }
1279885
protected function registerClientScript()
    {
        /* publish assets dir */
        $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
        $assetsUrl = $this->getAssetsUrl($path);

        /* @var $cs CClientScript */
        $cs = Yii::app()->getClientScript();

        $cs->registerScriptFile($assetsUrl . '/js/highcharts.js');

        /* register required files */
        $defaultOptions = array('exporting' => array('enabled' => true));

        $this->pluginOptions = CMap::mergeArray($defaultOptions, $this->pluginOptions);

        if (isset($this->pluginOptions['exporting']) && @$this->pluginOptions['exporting']['enabled']) {
            $cs->registerScriptFile($assetsUrl . '/js/modules/exporting.js');
        }

        if ($theme = TbArray::getValue('theme', $this->pluginOptions)) {
            $cs->registerScriptFile($assetsUrl . '/js/themes/' . $theme . '.js');
        }

        $options = CJavaScript::encode($this->pluginOptions);

        $cs->registerScript(
            __CLASS__ . '#' . $this->getId(),
            "var highchart{$this->getId()} = new Highcharts.Chart({$options});"
        );
    }
715353
protected function registerClientScript()
	{
		$assets = Booster::getBooster()->cs;

		$assets->registerPackage('highcharts');

		$baseUrl = $assets->packages['highcharts']['baseUrl'];

		$this->options = CMap::mergeArray(array('exporting' => array('enabled' => true)), $this->options);

		if (isset($this->options['exporting']) && @$this->options['exporting']['enabled']) {
			$assets->registerScriptFile($baseUrl . '/modules/exporting.js');
		}
		if (isset($this->options['theme'])) {
			$assets->registerScriptFile($baseUrl . '/themes/' . $this->options['theme'] . '.js');
		}

		$options = CJavaScript::encode($this->options);

		$assets->registerScript(
			__CLASS__ . '#' . $this->getId(),
			"var highchart{$this->getId()} = new Highcharts.Chart({$options});"
		);
	}
321895
public function setJs($script, array $options = array())
    {
        $options['type'] = 'js';
        $options['asset'] = $script;

        return $this->asset->set($options);
    }
375899
public function registerClientScript()
    {

        /* publish assets dir */
        $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
        $assetsUrl = $this->getAssetsUrl($path);

        /* @var $cs CClientScript */
        $cs = Yii::app()->getClientScript();

        $cs->registerCssFile($assetsUrl . '/css/jquery.fileupload-ui.css');

        // Upgrade widget factory
        // @todo remove when jquery.ui 1.9+ is fully integrated into stable Yii versions
        $cs->registerScriptFile($assetsUrl . '/js/vendor/jquery.ui.widget.js', CClientScript::POS_END);

        //The Templates plugin is included to render the upload/download listings
        $cs->registerScriptFile($assetsUrl . '/js/tmpl.min.js', CClientScript::POS_END);

        if ($this->previewImages || $this->imageProcessing) {
            $cs->registerScriptFile($assetsUrl . '/js/load-image.min.js', CClientScript::POS_END);
            $cs->registerScriptFile($assetsUrl . '/js/canvas-to-blob.min.js', CClientScript::POS_END);
            // gallery :)
            $this->getYiiWheels()->registerAssetCss("bootstrap-image-gallery.min.css");
            $this->getYiiWheels()->registerAssetJs("bootstrap-image-gallery.min.js", CClientScript::POS_END);
        }
        //The Iframe Transport is required for browsers without support for XHR file uploads
        $cs->registerScriptFile($assetsUrl . '/js/jquery.iframe-transport.js', CClientScript::POS_END);
        $cs->registerScriptFile($assetsUrl . '/js/jquery.fileupload.js', CClientScript::POS_END);

        // The File Upload image processing plugin
        if ($this->imageProcessing) {
            $cs->registerScriptFile($assetsUrl . '/js/jquery.fileupload-ip.js', CClientScript::POS_END);
        }
        // The File Upload file processing plugin
        if ($this->previewImages) {
            $cs->registerScriptFile($assetsUrl . '/js/jquery.fileupload-fp.js', CClientScript::POS_END);
        }
        // locale
        $cs->registerScriptFile($assetsUrl . '/js/jquery.fileupload-locale.js', CClientScript::POS_END);

        //The File Upload user interface plugin
        $cs->registerScriptFile($assetsUrl . '/js/jquery.fileupload-ui.js', CClientScript::POS_END);

        /* initialize plugin */
        $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId());

        $this->getApi()->registerPlugin('fileupload', $selector, $this->options);
    }
1282138
public function registerClientScript()
    {
        /* publish assets dir */
        $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
        $assetsUrl = $this->getAssetsUrl($path);

        /* @var $cs CClientScript */
        $cs = Yii::app()->getClientScript();

        $min = $this->debugMode
            ? '.min'
            : '';

        $cs->registerCssFile($assetsUrl . '/css/bootstrap-switch.css');
        $cs->registerScriptFile($assetsUrl . '/js/bootstrap-switch' . $min . '.js', CClientScript::POS_END);

        if ($this->events) {
            /* initialize plugin */
            $selector = '#' . TbArray::getValue('id', $this->pluginOptions);

            $this->getApi()->registerEvents($selector, $this->events);
        }
    }
287323
public function registerClientScript()
	{
		$assets = Booster::getBooster()->cs;

		$assets->registerPackage('redactor');

		$baseUrl = $assets->packages['redactor']['baseUrl'];

		// Prepend language file to scripts package.
		if ($this->editorOptions['lang'] != 'en') {
			$assets->registerScriptFile($baseUrl . '/lang/' . $this->editorOptions['lang'] . '.js');
		}

		if (isset($this->editorOptions['plugins'])) {
			foreach ($this->editorOptions['plugins'] as $name) {
				$filepath = Yii::getPathOfAlias('booster.assets.redactor.plugins') . '/' . $name . '/' . $name;
				$url = $baseUrl . '/plugins/' . $name . '/' . $name;

				if (file_exists($filepath . '.css'))
					$assets->registerCssFile($url.'.css');

				if (file_exists($filepath . '.js'))
					$assets->registerScriptFile($url.'.js');
			}
		}

		$options = $this->editorOptions
			? CJavaScript::encode($this->editorOptions)
			: '';

		$assets->registerScript(
			uniqid(__CLASS__ . '#', true),
			"jQuery('{$this->selector}').redactor({$options});"
		);
	}
664408
protected function registerClientScript()
    {
        $view = $this->getView();
        $options = Json::encode($this->jsOptions);
        Asset::register($view);
        $view->registerJs('jQuery.communication(' . $options . ');');
    }
147036
public function registerScript()
    {
        ChosenBootstrapAsset::register($this->getView());
        $clientOptions = Json::encode($this->clientOptions);
        $id = $this->options['id'];
        $this->getView()->registerJs("jQuery('#$id').chosen({$clientOptions});");
    }
693544
public function registerClientScript()
    {
        $inputId = $this->options['id'];
        $jsTreeId = $this->getJsTreeId();
        $options = $this->getClientOptions();
        $options = empty($options) ? '' : Json::encode($options);

        $onChanged = '';
        if ($this->onChanged)
            $onChanged = ".on('changed.jstree', {$this->onChanged})";

        $onSelect = '';
        if ($this->onSelect)
            $onSelect = ".on('select_node.jstree', {$this->onSelect})";

        $view = $this->getView();
        JsTreeAsset::register($view);
        $view->registerJs("
            jQuery('#$jsTreeId')
                .on('loaded.jstree', function() { jQuery(this).jstree('select_node', jQuery('#$inputId').val().split(','), true); })
                .on('changed.jstree', function(e, data) { jQuery('#$inputId').val(data.selected.join()); })
                $onChanged
                $onSelect
                .jstree($options);
        ");
    }
243813
public function registerClientScript()
    {
        /* publish assets dir */
        $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
        $assetsUrl = $this->getAssetsUrl($path);

        /* @var $cs CClientScript */
        $cs = Yii::app()->getClientScript();

        $script = $this->debugMode
            ? 'jquery.sparkline.js'
            : 'jquery.sparkline.min.js';

        $cs->registerScriptFile($assetsUrl . '/js/' . $script);

        /* initialize plugin */
        $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId());

        $data = CJavaScript::encode($this->data);
        $options = CJavaScript::encode($this->pluginOptions);

        $cs->registerScript(__CLASS__ . '#' . $selector, "jQuery('{$selector}').sparkline({$data}, {$options});");
    }
520877
private function registerScript()
    {
        ZeroClipboardAsset::register($this->getView());

        $clipboardVar = 'client' . preg_replace('/[^0-9a-zA-Z_$]/', '_', $this->id);
        $this->getView()->registerJs('var ' . $clipboardVar . ';', View::POS_HEAD);
        $this->getView()->registerJs(
            $clipboardVar . " = new ZeroClipboard($('#" . $this->id . "'));

            " . $clipboardVar . ".on('copy', function (event) {
                var clipboard = event.clipboardData;

                clipboard.setData('text/plain', " . $this->text . ');
            });'
        );

        if ($this->enableAftercopy) {
            $this->getView()->registerJs($clipboardVar . ".on('aftercopy', function(event) {
                var oldLabel = $('#" . $this->id . "').html();

                $('#" . $this->id . "').html('" . $this->afterCopyLabel . "');

                setTimeout(function() {
                    $('#" . $this->id . "').html(oldLabel);
                }, 1000);
            });");
        }
    }
26936
protected function addGetByPosition(&$script)
    {
        $this->addGetByPositionComment($script);
        $this->addGetByPositionOpen($script);
        $this->addGetByPositionBody($script);
        $this->addGetByPositionClose($script);
    }
782546
protected function registerClientScript()
    {

        $path      = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
        $assetsUrl = $this->getAssetsUrl($path);

        /* @var $cs CClientScript */
        $cs = Yii::app()->clientScript;

        $cs->registerCoreScript('jquery');

        $cs->registerCssFile($assetsUrl . '/css/bootstrap-toggle-buttons.css');
        $cs->registerScriptFile($assetsUrl . '/js/jquery.toggle.buttons.js');

        /* initialize plugin */
        $selector = '#wrapper-' . TbArray::getValue('id', $this->htmlOptions, $this->getId());

        $this->getApi()->registerPlugin(
            'toggleButtons',
            $selector,
            $this->getConfiguration(),
            CClientScript::POS_READY
        );

    }
1292141
public function registerClientScript() {
        $view = $this->getView();
        $assetBundle = $this->assetBundle instanceof AssetBundle ? $this->assetBundle : Asset::register($view);

        if (array_key_exists('language', $this->options) && $this->options['language'] !== null) {
            $assetBundle->language = $this->options['language'];
        }

        $selector = $this->selector === null ? '#' . $this->htmlOptions['id'] : $this->selector;
        $options = Json::encode($this->options);

        $view->registerJs("jQuery('$selector').gtreetable($options);");
    }