Display labels according to ['locales.I18n.available']

This commit is contained in:
Nicolas Le Goff
2013-05-31 17:48:45 +02:00
parent 16d79abd43
commit a59ff1a3ac
4 changed files with 5 additions and 27 deletions

View File

@@ -51,20 +51,6 @@
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="new-name"">{% trans %}Labels{% endtrans %}</label>
<div class="controls">
<ul class="unstyled inline">
<% _.each(languages, function(placeholder, code) { %>
<li class="lng-label <%= code === 'fr' ? 'select' : ''%>"><a href="#new-label_<%= code %>"><%= code %></a></li>
<% }); %>
</ul>
<% _.each(languages, function(placeholder, code) { %>
<input type="text" id="new-label_<%= code %>" class="input-block-level input-label" <%= code === 'fr' ? '' : 'style="display:none"'%> placeholder="<%= placeholder %>">
<% }); %>
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="new-source">{% trans %}Source{% endtrans %}</label>
<div class="controls">
@@ -105,7 +91,7 @@
<ul class="unstyled inline">
<ul class="unstyled inline">
<% _.each(field.labels, function(value, code) { %>
<li class="lng-label <%= code === 'fr' ? 'select' : ''%>"><a href="#label_<%= code %>"><%= code %></a></li>
<li class="lng-label <%= code === 'fr' ? 'select' : ''%>"><a href="#label_<%= code %>"><%= languages[code] %></a></li>
<% }); %>
</ul>
</ul>

View File

@@ -21,8 +21,7 @@ define([
events: {
"click .btn-submit-field": "createAction",
"click .btn-add-field": "toggleCreateFormAction",
"click .btn-cancel-field": "toggleCreateFormAction",
"click .lng-label a": "_toggleLabels"
"click .btn-cancel-field": "toggleCreateFormAction"
},
render: function() {
var template = _.template($("#create_template").html(), {
@@ -164,14 +163,6 @@ define([
AdminFieldApp.resizeListBlock();
return this;
},
_toggleLabels: function(event) {
event.preventDefault();
var curLabel = $(event.target);
$('.lng-label', this.$el).removeClass("select");
curLabel.closest(".lng-label").addClass("select");
$('.input-label', this.$el).hide();
$(curLabel.attr('href'), this.$el).show();
}
});

View File

@@ -37,7 +37,8 @@ define([
var template = _.template($("#edit_template").html(), {
field: this.model.toJSON(),
vocabularyTypes: AdminFieldApp.vocabularyCollection.toJSON(),
modelErrors: AdminFieldApp.errorManager.getModelError(this.model)
modelErrors: AdminFieldApp.errorManager.getModelError(this.model),
languages: AdminFieldApp.languages
});
this.$el.empty().html(template);

View File

@@ -19,7 +19,7 @@
#admin-field-app .lng-label a {
color: #aaa;
text-transform: uppercase;
text-transform: capitalize;
font-weight: bold;
font-size: 14px;
}