{% 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="{{ADMIN_MEDIA_PREFIX}}js/core.js" ></script>
    <script type="text/javascript" src="{% url jsi18n %}" ></script>
    <script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}js/projectscontents.js"></script>
    <script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}js/jquery.nyroModal.min.js"></script>
    <script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}js/jquery.textchange.min.js"></script>
    <script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}js/jquery-ui.min.js"></script>
    <script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}js/swfupload/swfupload.js"></script>
    <script type="text/javascript" src="{% url django.views.i18n.javascript_catalog %}"></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/jq-css/themes/base/jquery-ui.css" />
{% endblock %}


{% block js_declaration %}
	<script type="text/javascript">
	window.__admin_media_prefix__ = "{% filter escapejs %}{% admin_media_prefix %}{% endfilter %}";
	
	$(document).ready(function() {
		// url_upload, media_prefix, post_added_params, btn_label, success_label, wait_label, cancel_label, remove_url, get_dur_url
		post_added_params = {"csrfmiddlewaretoken" : "{{csrf_token}}",
                    		"{{cookie_name}}" : "{{session_key}}"};
		
		onCreateContentReady("{% url ldt.ldt_utils.views.upload %}",
							"{{LDT_MEDIA_PREFIX}}",
							post_added_params,
							'{% trans "Browse" %}',
							'{% trans "File uploaded" %}',
							'{% trans "Please wait, the upload is not finished yet" %}',
							'{% trans "Cancel upload" %}',
							"{% url ldt.ldt_utils.views.remove_temp_file %}",
							"{% url ldt.ldt_utils.views.get_duration %}");
	});
	
    </script>
{% endblock %}

{% block body %}
	{% if content_form.errors %}
	<div id="content-form-error">
		<p>{% trans "The operation could not be performed because one or more error(s) occurred.<br />Please resubmit the content form after making the following changes:" %}</p>
		<ul>
		{% for field in content_form %}
		{% if field.errors%}<li>{{field.name}} : {{ field.errors|striptags }}</li>{% endif %}
		{% endfor %}
		</ul>
	</div>
	{% endif %}

	{% if media_form.errors %}
	<div id="media-form-error">
		<p>{% trans "The operation could not be performed because one or more error(s) occurred.<br />Please resubmit the media form after making the following changes:" %}</p>
		<ul>
		{% for field in media_form %}
		{% if field.errors%}<li>{{field.name}} : {{ field.errors|striptags }}</li>{% endif %}
		{% endfor %}
		</ul>
	</div>
	{% endif %}

	<div id="add_content" class="span-18 last">
	<div class="projectscontentstitle">{% trans "Create content" %}</div>
	<form action="{{create_content_action}}" id="my_form" method="POST" enctype="multipart/form-data" >
	<div id="contentformhidden">
		{% csrf_token %}
		<input type="hidden" name="form_status" value="{{form_status}}" id="content_form_status" />
		{% for hidden in form.hidden_fields %}
	    	{{ hidden }}
	    {% endfor %}
	    {{content_form.iri_id}}
    </div>
    <div id="contentformfields" class="span-18 last">
	<div id="contentleft" class="span-9">
		<div>{{ content_form.src.errors }}{{ content_form.src.label_tag }}{{content_form.src}}</div>
		<div>{{ content_form.videopath.errors }}{{ content_form.videopath.label_tag }}{{content_form.videopath}}</div>
		<div>{{ content_form.title.errors }}{{ content_form.title.label_tag }}{{content_form.title}}</div>
		<div>{{ content_form.description.errors }}{{ content_form.description.label_tag }}{{content_form.description}}</div>
		<div>{{ media_form.external_id.errors }}{{ media_form.external_id.label_tag }}{{media_form.external_id}}</div>
		<div>{{ media_form.external_publication_url.errors }}{{ media_form.external_publication_url.label_tag }}{{media_form.external_publication_url}}</div>
	</div>
	<div id="contentright" class="span-9 last" >
		<div>{{ content_form.external_id.errors }}{{ content_form.external_id.label_tag }}{{content_form.external_id}}</div>
		<div>{{ content_form.duration.errors }}{{ content_form.duration.label_tag }}{{content_form.duration}}</div>
		<div>{{ content_form.content_creation_date.errors }}{{ content_form.content_creation_date.label_tag }}{{content_form.content_creation_date}}</div>
		<div>{{ content_form.tags.errors }}{{ content_form.tags.label_tag }}{{content_form.tags}}</div>
		<div>{{ content_form.media_input_type.errors }}{{ content_form.media_input_type.label_tag }}{{content_form.media_input_type}}</div>
		<div id="media_fields_div">
			<div id="media_field_link" class="media_fields">{{ content_form.media_obj.errors }}{{ content_form.media_obj.label_tag }}{{content_form.media_obj}}</div>
			<div id="media_field_upload" class="media_fields">
				{{ media_form.media_file.errors }}
				{% comment %}{{ media_form.media_file.label_tag }}{{media_form.media_file}}{% endcomment %}
				<div id="upload_btn"></div>
				<input type="text" name="media-local_file_name" id="id_media-local_file_name" readonly/>
				<div id="upload_progress_bar"></div>
				<div id="upload_progress_info"></div>
			</div>
			<div id="media_field_url" class="media_fields">{{ media_form.external_src_url.errors }}{{ media_form.external_src_url.label_tag }}{{ media_form.external_src_url }}</div>
			<div id="media_field_create" class="media_fields">{{ media_form.src.errors }}{{ media_form.src.label_tag }}{{ media_form.src }}</div>
		</div>
	</div>
	</div>
	<div id="submitcontent" class="span-18 last">
		<div id="submitcontent-loader" class="span-10">
			<div id="submitcontent-loader-img" class="submitcontent-loader-content span-10 last"><img alt="loader" src="{{LDT_MEDIA_PREFIX}}img/ajax-loader-220x19.gif"/></div>
			<div id="submitcontent-loader-msg" class="submitcontent-loader-content span-10 last">{% trans "media file is being processed please wait." %}</div>
			<span>&nbsp;</span>
		</div>
		<div id="submitcontent-buttons" class="span-8 last">
			<button id="close_button"  value="close">{% trans 'close_cancel' %}</button>
			{% if iri_id %}<button type="submit" value="prepare_delete" name="submit_button">{% trans "delete" %}</button>{% endif %}
			<button type="submit" value="write" name="submit_button" id="submit_button_write">{% trans "write" %}</button>
		</div>
	</div>
	</form>
	</div>
{% endblock %}
