{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
<form action="{% url one.views.ajax_share_edit_wizard share.id %}" method="post" id="template-wizard">
    {% csrf_token %}
    <div id="new-share" class="wizard">
        <h2>
            {% blocktrans with t=share.name%}Editing share: {{t}}{% endblocktrans %}
        </h2>
        <p>{% trans "Change the parameters as needed." %}</p>
        <ul>
            <li>
                <label for="share-name">{% trans "Name of share" %}</label>
                <input type="text" name="name" id="share-name" value="{{share.name}}" />
                <div class="clear"></div>
            </li>
            <li class="li-share-type">
                <label for="share-type">{% trans "Type" %}</label>
                <ul class="radio">
                    {% for s in types %}
                    <li>
                        <label>
                            <input type="radio" name="type" value="{{s.id}}" id="share-type-{{s.id}}"
                        {% if s.id == share.type %}checked="checked"{% endif %} />{{s.verbose_name}}
                        </label>
                    </li>
                    {% endfor %}
                </ul>
                {% for s in types %}
                    <p id="share-type-summary-{{s.id}}" class="type-summary clear"
                        {% if not s.id == share.type %}style="display:none"{% endif %}>
                        {{s.help_text}}
                        ({% if s.suspend %}
                        <span class="suspend"
                        title="{% blocktrans with time=s.suspend %}Suspend after {{time}}.{%endblocktrans%}">{{s.suspendx|timeuntil}}</span>
                        {%endif%}{% if s.delete %}
                        <span class="delete"
                        title="{% blocktrans with time=s.delete %}Delete after {{time}}.{%endblocktrans%}">{{s.deletex|timeuntil}}</span>
                        {%endif%})
                    </p>
                {% endfor %}
                <div class="clear"></div>
            </li>
            <li>
                <label for="share-instance-limit">{% trans "Maximal count of instances" %}</label>
                <input type="number" name="instance_limit" id="share-instance-limit" value="{{share.instance_limit}}" />
                <div class="clear"></div>
            </li>
            <li>
                <label for="share-per-user-limit">{% trans "Maximal count of instaces/user" %}</label>
                <input type="number" name="per_user_limit" id="share-per-user-limit" value="{{share.per_user_limit}}" />
                <div class="clear"></div>
            </li>

            <li style="border: none" class="clear">
                <label for="share-description">{% trans "Description" %}</label>
                <textarea name="description" id="share-description" style="text-align: left">{{share.description}}</textarea>
                <div class="clear"></div>
            </li>
        </ul>
        <nav>
            <input type="reset" class="prev" value="{% trans "Cancel" %}" />
            <input type="submit" value="{% trans "Save" %}"/>
            <div class="clear"></div>
        </nav>
        <script type="text/javascript">
            $(function(){
                $('#new-share nav .prev').click(function(){
                    $('#modal').hide();
                })
                $("#new-share input[name='type']").click(function(e){ /* TODO */
                    var v = $("#new-share input[name='type']:checked").val();
                    $("p.type-summary").hide();
                    $("#share-type-summary-" + v).show();
                });
            })
        </script>
    </div>
</form>
