{% 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" />
	<style type="text/css" >
		textarea {
			padding: 0px;
			width:390px;
			height: 100px;
		}
	
	</style>
{% endblock %}

{% block js_declaration %}
	{{ block.super }}
	<script type="text/javascript">
	$(document).ready(function() {	
		$("#close_button").click(function (e) {
			e.preventDefault();
			parent.$.nmTop().close();
		});
		
		var check_all = '{% trans "check all" %}';
		var uncheck_all = '{% trans "uncheck all" %}';
		
		$("#check_projects").attr('title', uncheck_all);
		$("#check_projects").change(function () {
			if ($("#check_projects").is(":checked")) {
				$(".cellcheckbox input").attr('checked', 'true');
				$("#check_projects").attr('title', uncheck_all );
			} else {
				$(".cellcheckbox input").removeAttr('checked');
				$("#check_projects").attr('title', check_all);
			}
		});
				
	});
	</script>
	<script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}js/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript">
    tinyMCE.init({
        plugins : '-example', 
        mode : "textareas",
        theme : "advanced",
        language : "{{ LANGUAGE_CODE }}",
        theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,undo,redo,link,unlink",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        width: "470",
        plugins : "autoresize"        
	});


    </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 for="description" class="projectdesc">{% trans "Description :" %}</label>
	{{form.description}}
	<label>{% trans "List of contents" %}</label>	
	<div class="span-12 last projectscontentsdiv" id="ldtcreatecontentslistcontainer">
		<div class="span-12 last projectscontentstablediv" id="ldtcreatecontentstablediv">
			<table class="projectscontentstable">
			
				<tr class="projectscontentsheader last" id="contentslistheader">
					<td class="cellcheckbox">
					{% if not ldt_id %}
						{% if contents|length > 1 %}
						<input class="selectallprojects" id="check_projects" type="checkbox" checked="true" />	 
						{% endif %}
					{% endif %}	
					</td>				
					<td class="projectcontentsheadertitle">{% trans "name" %}</td>
				</tr>
			
			    <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>

		
	</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 %}

