<?php
cs()->registerScriptFile(Yii::app()->baseUrl . '/js/ace/ace.js', CClientScript::POS_HEAD);
?>
<style type="text/css" media="screen">

    textarea {
        display: block;
        margin: 0px;
        width: 1000px;
        height: 300px;
    }
    #editor {
        display: block;
        margin: 0px;
        width: 1000px;
        height: 300px;
        border: 1px solid #888;
    }

</style>

<div id="editor"><?php echo $model->javascript; ?></div>


<input type="submit" value="Submit" id='submit'>
<br>
<textarea name="editor"></textarea>


<script>
    //Remember License!!!!

    var textarea = $('textarea[name="editor"]');
    var editor = ace.edit("editor");
    editor.setTheme("ace/theme/textmate");
    editor.getSession().setMode("ace/mode/javascript");
    editor.setHighlightActiveLine(true);
    editor.setKeyboardHandler("ace/keyboard/vim");
    $('#submit').on('click', function () {
        textarea.val(editor.getValue());
    });
</script>