spejstore/templates/hstore_default_widget.html

73 wiersze
3.0 KiB
HTML

{% load i18n %}
<script type="text/html" id="hstore-row-template-{{ field_name }}" class="hstore-row-template-inline">
<div class="form-row field-data">
<div>
<select {% for k, v in w.items %} {{k}}="{{v}}" {% endfor %}>
<option value="<%= _.escape(key) %>"><%= _.escape(key) %></option>
</select>
&nbsp; <strong>:</strong> &nbsp;&nbsp;
<input class='hs-val'
style="min-width:300px;"
value="<%= _.escape(value) %>"
type="text"
placeholder="{% trans 'value' %}">
&nbsp;&nbsp;
<a href="#" class="remove-row" title="{% trans 'remove row' %}">
<img src="{{ STATIC_URL }}admin/img/{% if use_svg %}icon-deletelink.svg{% else %}icon_deletelink.gif{% endif %}">
</a>
</div>
</div>
</script>
<script type="text/html" id="hstore-ui-template-{{ field_name }}"{% if '__prefix__' in field_name %} class="hstore-ui-template-inline"{% endif %}>
<div class="hstore" id="hstore-{{ field_name }}">
<h2><%= label %></h2>
<% if(help && help != '') { %>
<div class="form-row">
<p class="help" style="margin:0;padding:0"><%= help %></p>
</div>
<% } %>
<div class="hstore-rows">
<% if(errors){ %>
<div class="form-row field-data">
<div>
<ul class="errorlist">
<%= errors %>
</ul>
</div>
</div>
<% } %>
<% for(key in data){ %>
<%= _.template(django.jQuery('.hstore-row-template-inline').eq(0).html(), { 'key': key, 'value': data[key] }) %>
<% } %>
</div>
<div class="form-row field-data hstore-textarea" style="display:none">
<div>
<label for="<%= id %>" class="required">{% trans 'Raw textarea' %}:</label>
<textarea class="vLargeTextField" cols="40" id="<%= id %>" name="<%= name %>" rows="10"><%= value %></textarea>
</div>
</div>
<div class="form-row">
<a href="#" class="hs-add-row" title="{% trans 'Add another row' %}">
<img src="{{ STATIC_URL }}admin/img/{% if use_svg %}icon-addlink.svg{% else %}icon_addlink.gif{% endif %}" alt="{% trans 'Add Another' %}">
{% trans "Add row" %}
</a>
<a href="#" class="hstore-toggle-txtarea" title="{% trans 'toggle textarea' %}" style="float:right">
<img src="{{ STATIC_URL }}admin/img/{% if use_svg %}icon-changelink.svg{% else %}icon_changelink.gif{% endif %}" alt="{% trans 'toggle textarea' %}">
{% trans 'toggle textarea' %}
</a>
</div>
</div>
</script>
<script>
window.addEventListener("load", function (event) {
django.jQuery(function() { initDjangoHStoreWidget('{{ field_name }}') });
});
</script>