{% extends "html/notebook/base.html" %}
{#
INPUT:
- worksheet - an instance of Worksheet
- notebook - an instance of Notebook which contains worksheet
- do_print - a boolean stating whether the file is for print mode
#}

{% block page_id %}user-worksheet-page{% endblock %}
{% block body_classes %}active-worksheet{% endblock %}
 
{% set select = "use" %}

{% block worksheet_main %}
{% set toggle=true %}
<div class="worksheet" id="worksheet">
    {{ worksheet.html(username=username) | safe }}
    <div class="insert_new_cell" id="insert_last_cell">
        <div class="ui-icon ui-icon-circle-plus wksht-icon_button" 
            id="insert_new_last_compute_cell" 
            title="{{ gettext('Click to insert new compute cell.') }}"></div>
        {% if not worksheet.docbrowser() %}
        <div class="ui-icon ui-icon-comment wksht-icon_button" 
            id="insert_new_last_text_cell"
            title="{{ gettext('Click to insert new rich-text cell.') }}"></div>
        {% endif %}
        <div class="legacy_insert_new_cell" id="legacy_new_last_cell"></div>
    </div>  
    <script type="text/javascript">
        state_number = {{ worksheet.state_number() }};
        cell_id_list = {{ worksheet.cell_id_list() }};
        queue_id_list = {{ worksheet.queue_id_list() }};
        {% if worksheet.is_only_viewer(username) %}
        worksheet_locked = true;
        {% else %}
        worksheet_locked = false;
	    {% endif %}

        $(document).ready(function () {
            if (worksheet_name === "{{ gettext('Untitled') }}") {
                rename_worksheet();
            }
         });
        $("#insert_new_last_compute_cell").bind("click", function (e) {
            insert_new_cell_after(cell_id_list[cell_id_list.length - 1]);
        });
    
        {% if not worksheet.docbrowser() %}
        $("#insert_new_last_text_cell").bind("click", function (e) {
            insert_new_text_cell_after(cell_id_list[cell_id_list.length - 1]);
        });
        $("#legacy_new_last_cell").bind("click",function (e) {
            if (e.shiftKey){
                insert_new_text_cell_after(cell_id_list[cell_id_list.length - 1]);
            } else {
                insert_new_cell_after(cell_id_list[cell_id_list.length - 1]);
            }
         });
        {% endif %}
    </script>
</div>
{% endblock %}
