{% extends "base.html" %}
{% load staticfiles %}

{% block YACMS_HEAD %}
<link href="{%static "yacms/css/pageadmin.css" %}" rel="stylesheet">
<link href="{%static "yacms/css/yacms.css" %}" rel="stylesheet">
    <script>
    var cmsentry_id = {{view_object.id}}
    </script>


    <script>

        var view_json = {{view_object.json_data | safe}}
    </script>

    <link rel="stylesheet" href="/static/yacms/mediauploader/css/jquery.fileupload.css">
    <link rel="stylesheet" href="/static/yacms/mediauploader/css/jquery.fileupload-ui.css">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="/static/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">



{% endblock YACMS_HEAD %}


{% block TITLE%} {{view_object.title}}{% endblock TITLE %}
{% block BODY_TITLE%} {{view_object.title}}{% endblock BODY_TITLE %}
{

  {% block YACMS_PAGE_MAIN_BODY %}
<div class="row-fluid">

{% comment %}
{{view_object.html_content | safe}}
{% endcomment %}
{% comment %}
Here starts the main view for the article. non logged in
{% endcomment%}


        <div class="span3">
                <!-- Nav List -->

                <div class="widget" style="padding-top:5px;">
                <ul class="nav nav-list">
 {% comment %}Also do the parent page contents.{% endcomment %}

                        <li class="nav-header">
                                <a  style="color:#555555;" href="/cms{{view_object.page_object.path.path}}">{{view_object.page_object.title}} </a>
                        </li>
                        {% for topic in view_object.content_topics %}
                        <li><a style="color: #444444;" href="/cms{{view_object.page_object.path.path}}#{{topic.anchor_text}}">{{topic.title}}</a></li>
                        {% endfor %}

                         {% for mb_page_object in view_object.member_page_objects %}

                        <li class="nav-header">
                                <a  style="color:#555555;" href="/cms{{mb_page_object.path.path}}">{{mb_page_object.title}}</a>
                        </li>
                            {% for topic in mb_page_object.view.content_topics %}
                               <li><a style="color: #444444;" href="/cms{{mb_page_object.path.path}}#{{topic.anchor_text}}">{{topic.title}}</a></li>

                            {% endfor %}

                        {% endfor%}

                </ul>
                </div>
                <!-- Nav List End -->
        </div>

        <div class="span9">
                <div id="page_body">
                    {{view_object.html_content | safe }}




                </div>

                <div class="span12" style="margin-left: 0px; margin-right:0px; border-top-style: solid; border-bottom-style: solid;">
                                <div class="span4"></div>
                                <div class="span4"><center></center></div>

                                {% if view_object.has_first_page == False %}
                                <div class="span4"><span style="float:right"><a href=""></a></span></div>
                                {% else %}
                                <div class="span4"><span style="float:right;margin-top:5px;">
                                <a class="btn btn-small btn-info" href="/cms{{view_object.first_page.path.path}}"><i class="icon-info-sign"></i> Next</a></span></div>
                                {% endif %}
                </div>

        </div>
    </div>


{% if view_object.request.user.username == "admin" %}

<div class="col-md-12">
        <h3>Page Admin</h3>
        <!-- tabs -->
        <div class="tabbable">
          <ul class="nav nav-tabs">
            <li class="active"><a href="#one" data-toggle="tab">Content Editor</a></li>
            <li class=""><a href="#two" data-toggle="tab">File Uploader</a></li>
            <li class=""><a href="#twee" data-toggle="tab">Twee</a></li>
          </ul>

            <div class="tab-content">
                <div class="tab-pane active" id="one">
                    <div class="pageadmin_menu_container">
                      <a href="#" id='editor_save_button' class="btn btn-primary" role="button">Save</a>
                      <!-- a href="#" class="btn btn-primary" role="button" id="editor_publish">Publish</a -->
                      <!-- a href="#" class="btn btn-primary" role="button" id="editor_frontpage">Frontpage</a -->
                        <div class="pageadmin_checkbox"><input id="published_checkbox" type="checkbox" name="published" value="published"  onclick="handle_published_checked(this)">published</div>
                        <div class="pageadmin_checkbox"><input id="frontpage_checkbox" type="checkbox" name="frontpage" value="frontpage"  onclick="handle_frontpage_checked(this)">frontpage</div>
                    </div>

                <div class='clear'></div>
                <div><textarea id="editor_textarea" style="width:100%" rows="30" ></textarea></div>
            </div>


            <div class="tab-pane" id="two">
                <!-- The file upload form used as target for the file upload widget -->
                <form id="fileupload"  method="POST" enctype="multipart/form-data">

                    <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
                    <div class="row fileupload-buttonbar">
                        <div class="col-lg-7">
                            <!-- The fileinput-button span is used to style the file input field as button -->
                            <span class="btn btn-success fileinput-button">
                                <i class="glyphicon glyphicon-plus"></i>
                                <span>Add files...</span>
                                <input type="file" name="files[]" multiple>
                            </span>
                            <button type="submit" class="btn btn-primary start">
                                <i class="glyphicon glyphicon-upload"></i>
                                <span>Start upload</span>
                            </button>
                            <button type="reset" class="btn btn-warning cancel">
                                <i class="glyphicon glyphicon-ban-circle"></i>
                                <span>Cancel upload</span>
                            </button>
                            <button type="button" class="btn btn-danger delete">
                                <i class="glyphicon glyphicon-trash"></i>
                                <span>Delete</span>
                            </button>
                            <input type="checkbox" class="toggle">
                            <!-- The global file processing state -->
                            <span class="fileupload-process"></span>
                        </div>
                        <!-- The global progress state -->
                        <div class="col-lg-5 fileupload-progress fade">
                        <!-- The global progress bar -->
                            <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
                                <div class="progress-bar progress-bar-success" style="width:0%;"></div>
                            </div>
                            <!-- The extended global progress state -->
                            <div class="progress-extended">&nbsp;</div>
                        </div>
                    </div>
                    <!-- The table listing the files available for upload/download -->
                    <table role="presentation" class="table table-striped"><tbody class="files"></tbody></table>
                </form>
                <br>
            </div>


            <div class="tab-pane" id="twee">
            Thirdamuno, ipsum dolor sit amet, consectetur adipiscing elit.
            Duis pharetra varius quam sit amet vulputate.
            Quisque mauris augue, molestie tincidunt condimentum vitae.
            </div>
        <!-- /tabs -->

        </div>
        <!-- end tab content-->

    </div>
</div>




<div class="row-fluid">
<form class="form" id="createpage_form">
    <div class="col-sm-4">
        <input id="createpage_title" type="text" placeholder="title" class="form-control" style="width: 100%; padding-top: 0px !important; padding-bottom: 0px !important; height: 30px !important;">
    </div>
    <div class="col-sm-4"><input id="createpage_slug" type="text" placeholder="slug"  class="form-control" style="width: 100%; padding-top: 0px !important; padding-bottom: 0px !important; height: 30px !important;"></div>
    <div class="col-sm-2"><select id="createpage_pagetype_select" type="text" class="form-control">
    {% for page_type in view_object.page_types %}
    <option value={{page_type.id}}>{{page_type}}</option>
    {%endfor%}
    </select></div>
    <div class="col-sm-2"><button class="btn btn-primary" type="button" style="height: 40px;" id="createpage_button">Create Page</button></div>
</form>
</div>


  <div id="notifications"></div>
  <div id="category_table"></div>
  <div id="category_table_output"></div>
  {% endif %}
 </div>






<p>CategoryPage.html</p>
<p>{{view_object.request.user.username}}</p>


{% endblock YACMS_PAGE_MAIN_BODY %}




{% block YACMS_JAVASCRIPT %}

{% if view_object.request.user.username == "admin" %}
<script src="{% static "yacms/js/dustjs/dust-full.min.js" %}"></script>
<script src="{% static "yacms/js/yacms.js" %}"></script>
<!-- category_table.js - dust.js template-->
<script src="{% static "yacms/js/category_table.js"%}"></script>


{% endif %}


 <script>

 $( document ).ready(function() {
    update_child_categories();
});

</script>
<script>

 $( document ).ready(function() {
    get_content(view_json.content[0]);
});

$('#published_checkbox').prop('checked', view_json.published);
$('#frontpage_checkbox').prop('checked', view_json.frontpage);

$('#frontpage_checkbox').click(function(){

  handle_frontpage_checked(this);

})


</script>


</script>

<!-- End of SCRIPTS-->
{% endblock YACMS_JAVASCRIPT %}

