public 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/ace.js', CClientScript::POS_END);

        $id = TbArray::getValue('id', $this->htmlOptions, $this->getId());

        /* Global value that will hold the editor */
        $cs->registerScript(uniqid(__CLASS__ . '#' . $id, true), 'var ' . $id . ';', CClientScript::POS_HEAD);

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

        echo $selector . '= ace.edit("' . $id . '");' . PHP_EOL;
        echo $selector . '.setTheme("ace/theme/' . $this->theme . '");' . PHP_EOL;
        echo $selector . '.getSession().setMode(' . (is_array($this->mode) ? CJavaScript::encode(
                $this->mode
            ) : '"ace/mode/' . $this->mode . '"') . ');' . PHP_EOL;
        echo $selector . '.setValue($("#' . $this->htmlOptions['textareaId'] . '").val());' . PHP_EOL;
        echo $selector . '.getSession().on("change", function(){
                var theVal = ' . $selector . '.getSession().getValue();
                $("#' . $this->htmlOptions['textareaId'] . '").val(theVal);
            });';

        if (!empty($this->events) && is_array($this->events)) {
            foreach ($this->events as $name => $handler) {
                $handler = ($handler instanceof CJavaScriptExpression)
                    ? $handler
                    : new CJavaScriptExpression($handler);

                echo $id . ".getSession().on('{$name}', {$handler});" . PHP_EOL;
            }
        }

        if (!empty($this->pluginOptions))
            echo $selector . '.setOptions(' . CJavaScript::encode($this->pluginOptions) . ')';

        $cs->registerScript(uniqid(__CLASS__ . '#ReadyJS' . $id, true), ob_get_clean());
    }
public 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/ace.js', CClientScript::POS_END);

        $id = TbArray::getValue('id', $this->htmlOptions, $this->getId());

        /* Global value that will hold the editor */
        $cs->registerScript(uniqid(__CLASS__ . '#' . $id, true), 'var ' . $id . ';', CClientScript::POS_HEAD);

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

        echo $selector . '= ace.edit("' . $id . '");' . PHP_EOL;
        echo $selector . '.setTheme("ace/theme/' . $this->theme . '");' . PHP_EOL;
        echo $selector . '.getSession().setMode(' . (is_array($this->mode) ? CJavaScript::encode(
                $this->mode
            ) : '"ace/mode/' . $this->mode . '"') . ');' . PHP_EOL;
        echo $selector . '.setValue($("#' . $this->htmlOptions['textareaId'] . '").val());' . PHP_EOL;
        echo $selector . '.getSession().on("change", function(){
                var theVal = ' . $selector . '.getSession().getValue();
                $("#' . $this->htmlOptions['textareaId'] . '").val(theVal);
            });';

        if (!empty($this->events) && is_array($this->events)) {
            foreach ($this->events as $name => $handler) {
                $handler = ($handler instanceof CJavaScriptExpression)
                    ? $handler
                    : new CJavaScriptExpression($handler);

                echo $id . ".getSession().on('{$name}', {$handler});" . PHP_EOL;
            }
        }

        if (!empty($this->pluginOptions))
            echo $selector . '.setOptions(' . CJavaScript::encode($this->pluginOptions) . ')';

        $cs->registerScript(uniqid(__CLASS__ . '#ReadyJS' . $id, true), ob_get_clean());
    }
public 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/ace.js' , CClientScript :: POS_END ) ; $ id = TbArray :: getValue ( 'id' , $ this -> htmlOptions , $ this -> getId ( ) ) ; /* Global value that will hold the editor */ $ cs -> registerScript ( uniqid ( __CLASS__ . '#' . $ id , true ) , 'var ' . $ id . ';' , CClientScript :: POS_HEAD ) ; ob_start ( ) ; /* initialize plugin */ $ selector = TbArray :: getValue ( 'id' , $ this -> htmlOptions , $ this -> getId ( ) ) ; echo $ selector . '= ace.edit("' . $ id . '");' . PHP_EOL ; echo $ selector . '.setTheme("ace/theme/' . $ this -> theme . '");' . PHP_EOL ; echo $ selector . '.getSession().setMode(' . ( is_array ( $ this -> mode ) ? CJavaScript :: encode ( $ this -> mode ) : '"ace/mode/' . $ this -> mode . '"' ) . ');' . PHP_EOL ; echo $ selector . '.setValue($("#' . $ this -> htmlOptions [ 'textareaId' ] . '").val());' . PHP_EOL ; echo $ selector . '.getSession().on("change", function(){
                var theVal = ' . $ selector . '.getSession().getValue();
                $("#' . $ this -> htmlOptions [ 'textareaId' ] . '").val(theVal);
            });' ; if ( ! empty ( $ this -> events ) && is_array ( $ this -> events ) ) { foreach ( $ this -> events as $ name => $ handler ) { $ handler = ( $ handler instanceof CJavaScriptExpression ) ? $ handler : new CJavaScriptExpression ( $ handler ) ; echo $ id . ".getSession().on('{$name}', {$handler});" . PHP_EOL ; } } if ( ! empty ( $ this -> pluginOptions ) ) echo $ selector . '.setOptions(' . CJavaScript :: encode ( $ this -> pluginOptions ) . ')' ; $ cs -> registerScript ( uniqid ( __CLASS__ . '#ReadyJS' . $ id , true ) , ob_get_clean ( ) ) ; }
Registers required client script for bootstrap ace editor.
Registers required client script for bootstrap ace editor .