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

{% load i18n %}
{% load adminmedia %}
{% load thumbnail %}

{% block js_import %}
	{{ block.super }}
    <script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}js/jquery.nyroModal.min.js"></script> 
    <script type="text/javascript" src="{% url ldt.jsi18n packages='ldt' %}" ></script>
	<script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}js/projectscontents.js" ></script> 
	<script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}js/tiny_mce/tiny_mce.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">
	
    tinyMCE.init({
        plugins : '-example', 
        mode : "textareas",
        theme : "advanced",
        language : "{{ LANGUAGE_CODE }}",
        theme_advanced_buttons1 : "bold,italic,underline,separator,justifyleft,justifycenter,justifyfull,undo,redo,link,unlink",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        width: "250",
        height: "150",
        entity_encoding : "raw"
	});
		
	$(document).ready(function() {	
		$("#close_button").click(function (e) {
			e.preventDefault();
			parent.$.nmTop().close();
		});
		
        $("#ldt_submit_delete").click(function(e){
            $(this).addClass("e-clicked");
        });
         
        $("form").submit(function(e){
           if( $(this).find(".e-clicked").attr("id") === "ldt_submit_delete" )
           {
              var con = window.confirm("{% trans 'Do you really want to delete this group ?' %}");
              if(!con){
                 e.preventDefault();
              }
           }
           //reset classes on submit buttons
           $( this ).find("button[type=submit]").removeClass("e-clicked");
        });

		
		var search_url = "{% url ldt.ldt_utils.views.workspace.share_filter filter='__FILTER__' use_groups='false' %}";
		resize_modal_window($("#add_group"));
		
	});
	</script>

{% endblock %}

{% block body %}
				 
	<div id="add_group" class="span-18 last">
	<div class="projectscontentstitle span-18 last">{% if group_id %}{% trans "Update a group" %}{% else %}{% trans "Create a group" %}{% endif %}</div>
	
	<form action="{% if group_id %}{% url ldt.ldt_utils.views.group.update_group group_id %} {% else %}{% url ldt.ldt_utils.views.group.create_group %}{% endif %}" method="POST" enctype="multipart/form-data" {% if target_parent %}target="_parent"{% endif %}>
	{% csrf_token %} 
	<input type="hidden" name="form_status" value="{{form_status}}" id="project_form_status" />
	<input type="hidden" name="id_group" value="" id="id_group"/>
	<div>
		<label for="name">{% trans "Name" %}:</label>
		{{form.name}}
		{% for error in form.errors.name %}
		<span class="error">{{ error }}</span>
		{% endfor %}
		
		<label for="description">{% trans "Description" %}</label>
		<textarea id="description" name="description">
		{{ img_container.description }}
		</textarea>
	</div>

	{% include "ldt/ldt_utils/partial/permissions.html" %}		
	{% include "ldt/ldt_utils/partial/picture.html"%}
	
	<div id="submitcontent-buttons" class="span-12 last">
		<button type="button" id="close_button"  value="close">{% trans "close_cancel" %}</button>
		{% if group_id %}
          <button class="button" style="float:right; margin-left:4px" id="ldt_submit_update" type="submit" value="update" name="submit_button">{% trans "update_group" %}</button>
          {% if is_owner_group %}
            <button class="button" id="ldt_submit_delete" type="submit" value="delete" name="submit_button">{% trans "delete_group" %}</button>
          {% endif %}
		{% else %}
		  <button class="button" id="ldt_submit_create" type="submit" value="create" name="submit_button">{% trans "create_group" %}</button>
		{% endif %}
	</div>

	</form>
	</div>
		
{% endblock %}

