{% extends 'layout.html' %}
{% block js %}
    {% assets "js_editor" %}
        <script type="text/javascript" src="{{ ASSET_URL }}"></script>
    {% endassets %}
        <script>
        $(function(){
            $("#start-togetherjs").click(function(){
                $(this).prop('disabled', true).html("Loading");
            });
        });
        TogetherJSConfig_toolName = "Collaboration";
        TogetherJSConfig_suppressJoinConfirmation = true;
        TogetherJSConfig_getUserName = function () {
            return {{ session['user'].get('username')|tojson }};
        };

        TogetherJSConfig_getUserAvatar = function () {
            return {{ session['user'].get('avatar')|tojson }};
        };

        TogetherJSConfig_on_ready = function () {
            MDR.sanitize = true;
           $("#start-togetherjs").addClass('btn-danger').html('End Collaboration').prop('disabled', false);
        };
        TogetherJSConfig_on_close = function () {
            MDR.sanitize = null;
            $("#start-togetherjs").removeClass('btn-danger').html('Collaborate').prop('disabled', false);
        };

    </script>
    <script src="https://togetherjs.com/togetherjs-min.js"></script>

{% endblock %}
{% block body %}
{% block css %}
<style>
    #main-body {
        background: inherit;
        border: inherit;
        padding: 0;
        -webkit-box-shadow: 0;
        -moz-box-shadow: 0;
        box-shadow: 0;
    }
</style>
{% endblock %}


    <div id="app-wrap" class="container-fluid">
        <div id="app-controls" class="row">
            <div class="col-xs-3">
                <input id="page-name" type="text" class="form-control input-sm" name="name" placeholder="Name" value="{{- name -}}" />
            </div>
            <div class="col-xs-3">
                <input id="page-message" type="text" class="form-control input-sm" name="page-message" placeholder="Comment" value="" />
            </div>

            <div class="col-xs-6">
                <div class="pull-right">

                    <button class="btn btn-success btn-sm" id="start-togetherjs" type="button"
                     onclick="TogetherJS(this); return false">
                      Collaborate
                    </button>

                    <a href="#" id="drop6" role="button" class="dropdown-toggle btn btn-default btn-sm" data-toggle="dropdown">Theme <b class="caret"></b></a>
                    <ul id="theme-list" class="dropdown-menu" role="menu" aria-labelledby="drop6">
                        <li><a tabindex="-1" href="#" data-value="ace/theme/chrome" class="">Chrome</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/clouds" class="">Clouds</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/clouds_midnight" class="">Clouds Midnight</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/cobalt" class="">Cobalt</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/crimson_editor" class="">Crimson Editor</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/dawn" class="selected">Dawn</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/dreamweaver" class="">Dreamweaver</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/eclipse" class="">Eclipse</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/idle_fingers" class="">idleFingers</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/kr_theme" class="">krTheme</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/merbivore" class="">Merbivore</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/merbivore_soft" class="">Merbivore Soft</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/mono_industrial" class="">Mono Industrial</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/monokai" class="">Monokai</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/pastel_on_dark">Pastel on Dark</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/solarized_dark" class="">Solarized Dark</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/solarized_light" class="">Solarized Light</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/textmate" class="">TextMate</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/tomorrow" class="">Tomorrow</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/tomorrow_night">Tomorrow Night</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/tomorrow_night_blue" class="">Tomorrow Night Blue</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/tomorrow_night_bright" class="">Tomorrow Night Bright</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/tomorrow_night_eighties" class="">Tomorrow Night 80s</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/twilight" class="">Twilight</a></li>
                        <li><a tabindex="-1" href="#" data-value="ace/theme/vibrant_ink" class="">Vibrant Ink</a></li>
                    </ul>
                    <a id="save-native" class="btn btn-primary btn-sm"><i class="icon-save"></i> Save</a>
                </div>
            </div>
        </div>
        <div id="editor">{{ content }}</div>
        <div id="preview"></div>
    </div>

{% endblock %}