{% load i18n %}
{% load txcommontags %}

<script type="text/javascript">

$(document).ready(function(){
    $("#create_new_resource").toggle(function(){
        $("#create_new_resource_form").slideDown();
    }, function(){
        $("#create_new_resource_form").slideUp();
    });

    {% if resource %}

        var uuid = '{{ resource.source_file.uuid }}';
        $("div#notification-container div").html("{% blocktrans with resource.source_file.name as resource_name %}Extracting strings from '{{ resource_name }}'. This might take a while...{% endblocktrans %}");
        $("div#notification-container").fadeIn("fast");

        $.ajax({
            type : 'POST',
            url: sprintf('{{ api_project_files }}', '{{ project.slug }}'),
            contentType : 'application/json',
            responseType: "json",
            data: JSON.stringify({'uuid':uuid}),
            dataType: 'json',
            success: function(data, textStatus, XMLHttpRequest){
                window.location = data['redirect'];
            },
            error: function(XMLHttpRequest, textStatus, errorThrown){
                alert(XMLHttpRequest.responseText);
            },
            complete: function(XMLHttpRequest, textStatus){
                $("div#notification-container").fadeOut("slow");
            }
        });


    {% endif %}

});
</script>

<span id="create_new_resource" class="i16 add submit_button buttonized houdini_toggler">Create New Resource</span>

<div id="create_new_resource_form" class="generic_form" {% if not display_form %}style="display:none;"{% endif %}> 

 <form action='' method='post' class="microform houdini">
  <fieldset style="margin-top: 1em;">
  <legend>{% trans "Create resource to be translated" %}</legend>

  <p class="i16 tip compact clear">{% trans "Upload a local file to be used as the source file of the resource. It's equivalent to the POT file for the GNU's gettext method." %}</p>

  <table>
  <tbody>
    {% form_as_table_rows create_resource_form %}
  </tbody>
  </table>
  <p class="submit"><input type="submit" class="i16 submit" name="create_resource" value="{% trans "Create Resource" %}" /></p>

  </fieldset>
 </form>

</div>


