{% extends "sketch/base.html" %}
<!--
Copyright 2015 Google Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

{% block main %}

<!-- Edit timeline modal -->
<div class="modal" id="edit-timeline-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Edit timeline</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal" role="form" action="{{ url_for('sketch_views.timeline', sketch_id=sketch.id, timeline_id=timeline.id) }}" method="post">
          <div class="form-group">
            <div class="col-sm-12">
              <strong>Title</strong>
              <input class="form-control" id="name" name="name" type="text" value="{{ timeline.name }}" autofocus="true">
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-12">
              <strong>Description</strong>
              <textarea rows="10" class="form-control" id="description" name="description">{{ timeline.description }}</textarea>
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-12">
              <div class="pull-left" style="width:20px;height:20px;background:#{{ timeline.color }}; margin-right: 10px;"></div>
              <strong>Color</strong>
              <br><br>
              <input type="text" class="form-control" id="color" name="color" value="{{ timeline.color }}" />
            </div>
          </div>
          <input type="submit" class="btn btn-primary" value="Save"/>
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          {{ timeline_form.csrf_token }}
        </form>
      </div>
    </div>
  </div>
</div>

<div class="card">
  <div class="row">
    <div class="col-md-6">
          <div class="pull-left" style="width:50px;height:50px;background:#{{ timeline.color }};"></div>
          <div style="margin-left:80px;">
            <h2>{{ timeline.name }}
              {% if sketch.has_permission(user=current_user, permission='write') %}
                  <button class="btn btn-default" data-toggle="modal" data-target="#edit-timeline-modal" style="margin-left:10px;width:50px;"><i class="fa fa-pencil"></i></button>
              {% endif %}
            </h2>
            <p style="white-space: pre-wrap;word-wrap: break-word;">{{ timeline.description }}</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

{% endblock %}
