{% extends "ldt/ldt_raw_base.html" %}

{% load i18n %} {# form of creation of content #}
{% load adminmedia %}

{% block js_import %}
	{{ block.super }}
    <script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}/js/jquery.nyroModal.min.js"></script>    
	{{ content_form.media.js }}
{% endblock %}

{% block css_import %}
	{{ block.super }}
	{{ content_form.media.css }}
	<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/ldt.css" />
	<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/ldtform.css" />
	<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/workspace.css" />
{% endblock %}

{% block js_declaration %}
	{{ block.super }}
	<script type="text/javascript">
	$(document).ready(function() {	
		$("#close_button").click(function (e) {
			e.preventDefault();
			parent.$.nmTop().close();
		});
		
		$("#check_projects").change(function () {
			if ($("#check_projects").is(":checked")) {
				$(".cellcheckbox input").attr('checked', 'true');
			} else {
				$(".cellcheckbox input").removeAttr('checked');
			}
		});
				
	});
	</script>
{% endblock %}

{% block body %}
	<div id="add_contribution" class="span-12 last">
	<div class="projectscontentstitle span-12 last">{% if ldt_id %}{% trans "Update your project" %}{% else %}{% trans "Create your project" %}{% endif %}</div>
	<form action="{{create_project_action}}" method="POST" {% if target_parent %}target="_parent"{% endif %}>
	{% csrf_token %} 
	<input type="hidden" name="form_status" value="{{form_status}}" id="project_form_status" />
	<label for="title">{% trans "Title" %}:</label>
	{{form.title}}
	<label>{% trans "List of contents" %}</label>	
	<div class="span-12 last projectscontentsdiv" id="ldtcreatecontentslistcontainer">
		<div class="projectscontentsheader span-12 last" id="contentslistheader">{% trans "name" %}</div>
		<div class="span-12 last projectscontentstablediv" id="ldtcreatecontentstablediv">
			<table class="projectscontentstable">
			    <tbody class="projectscontentsbody">
			{% for content in contents %}
				<tr class="imageline {% cycle 'projectscontentsoddline' 'projectscontentsevenline'%}">
				    <td class="cellcheckbox"><input type="checkbox" name="contents" value="{{ content.id }}" checked="true" {% if ldt_id %}disabled="disabled"{% endif %} /></td>
				    <td class="contenttitle">{{ content.title }}</td>
				</tr>
			{% endfor %}
				</tbody>
			</table>			
		</div>
		{% if not ldt_id %}
			<input class="selectallprojects" style="width: 35px; text-align: center;" id="check_projects" type="checkbox" checked="true"/>	 
		{% endif %}
		
	</div>
	
	<div id="submitcontent-buttons" class="span-12 last">
		<button type="button" id="close_button"  value="close">{% trans 'close_cancel' %}</button>
		{% if ldt_id %}
		<button class="button" id="ldt_submit" type="submit" value="prepare_delete" name="submit_button">{% trans "delete_project" %}</button>
		<button class="button" id="ldt_submit" type="submit" value="update" name="submit_button">{% trans "update_project" %}</button>
		{% else %}
		<button class="button" id="ldt_submit" type="submit" value="create" name="submit_button">{% trans "create_project" %}</button>
		{% endif %}
	</div>
	</form>
	</div>
		
{% endblock %}

