localize outfits#edit search helpers
This commit is contained in:
parent
9c37e894f7
commit
8c348d4535
4 changed files with 32 additions and 18 deletions
|
@ -25,22 +25,29 @@ module OutfitsHelper
|
||||||
link_to content, wardrobe_path(:anchor => query), options
|
link_to content, wardrobe_path(:anchor => query), options
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_helper(filter)
|
def search_helper(filter, standard_key)
|
||||||
key = translate("#{filter}.key")
|
key = translate("#{filter}.key")
|
||||||
default_value = translate("#{filter}.default_value")
|
default_value = translate("#{filter}.default_value")
|
||||||
content_tag :span, default_value, :class => 'search-helper',
|
content_tag :span, default_value, :class => 'search-helper',
|
||||||
'data-search-filter' => key
|
'data-search-filter-key' => standard_key,
|
||||||
|
'data-search-filter-name' => key
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_query_description(base)
|
def search_query_description(base, standard_key)
|
||||||
translate "#{base}.description_html",
|
translate "#{base}.description_html",
|
||||||
:default_value => search_helper("#{base}.filter")
|
:default_value => search_helper("#{base}.filter", standard_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_query_with_helper(base)
|
def search_query_with_helper(base, standard_key)
|
||||||
translate "#{base}.query_html",
|
translate "#{base}.query_html",
|
||||||
:filter_key => content_tag(:span, translate("#{base}.filter.key")),
|
:filter_key => content_tag(:span, translate("#{base}.filter.key")),
|
||||||
:filter_value => search_helper("#{base}.filter")
|
:filter_value => search_helper("#{base}.filter", standard_key)
|
||||||
|
end
|
||||||
|
|
||||||
|
def search_query(translation_key, filter_key)
|
||||||
|
base = "outfits.edit.search.examples.#{translation_key}"
|
||||||
|
content_tag(:dt, search_query_with_helper(base, filter_key)) +
|
||||||
|
content_tag(:dd, search_query_description(base, filter_key))
|
||||||
end
|
end
|
||||||
|
|
||||||
def outfit_creation_summary(outfit)
|
def outfit_creation_summary(outfit)
|
||||||
|
|
|
@ -109,12 +109,8 @@
|
||||||
%div
|
%div
|
||||||
%dt= t '.search.examples.flags.query'
|
%dt= t '.search.examples.flags.query'
|
||||||
%dd= t '.search.examples.flags.description'
|
%dd= t '.search.examples.flags.description'
|
||||||
%div
|
%div= search_query 'species', 'species'
|
||||||
%dt= search_query_with_helper '.search.examples.species'
|
%div= search_query 'type', 'occupies'
|
||||||
%dd= search_query_description '.search.examples.species'
|
|
||||||
%div
|
|
||||||
%dt= search_query_with_helper '.search.examples.type'
|
|
||||||
%dd= search_query_description '.search.examples.type'
|
|
||||||
#preview-search-form-loading= t '.search.loading'
|
#preview-search-form-loading= t '.search.loading'
|
||||||
#preview-search-form-error.possible-error
|
#preview-search-form-error.possible-error
|
||||||
#preview-search-form-no-results
|
#preview-search-form-no-results
|
||||||
|
|
|
@ -202,7 +202,7 @@ pt:
|
||||||
query: espécies:shoyru
|
query: espécies:shoyru
|
||||||
description: mostra qualquer item que um Shoyru pode vestir
|
description: mostra qualquer item que um Shoyru pode vestir
|
||||||
type:
|
type:
|
||||||
query: ocupa:chapéu -restringe:cabelo
|
query: ocupa:chapéus -restringe:cabelo
|
||||||
description: 'mostra qualquer item que ocupa a zona do "chapéu", mas não se restringe a zona do "cabelo" '
|
description: 'mostra qualquer item que ocupa a zona do "chapéu", mas não se restringe a zona do "cabelo" '
|
||||||
newest_items:
|
newest_items:
|
||||||
header: Novos itens
|
header: Novos itens
|
||||||
|
@ -462,7 +462,7 @@ pt:
|
||||||
type:
|
type:
|
||||||
filter:
|
filter:
|
||||||
key: ocupa
|
key: ocupa
|
||||||
default_value: fundo
|
default_value: fundosdeimagem
|
||||||
query_html: "%{filter_key}:%{filter_value}"
|
query_html: "%{filter_key}:%{filter_value}"
|
||||||
description_html: 'mostra como resultado qualquer item que ocupe a zona de %{default_value} '
|
description_html: 'mostra como resultado qualquer item que ocupe a zona de %{default_value} '
|
||||||
userbar:
|
userbar:
|
||||||
|
|
|
@ -1260,9 +1260,13 @@ View.Search = function (wardrobe) {
|
||||||
|
|
||||||
function prepBuildHelper(type, getSet) {
|
function prepBuildHelper(type, getSet) {
|
||||||
return function (objs) {
|
return function (objs) {
|
||||||
var select = $('<select/>',
|
var span = $('span.search-helper[data-search-filter-key=' + type + ']');
|
||||||
{'class': 'search-helper', 'data-search-filter': type}),
|
var filterName = span.attr('data-search-filter-name');
|
||||||
span = $('span.search-helper[data-search-filter=' + type + ']');
|
var select = $('<select/>', {
|
||||||
|
'class': 'search-helper',
|
||||||
|
'data-search-filter': filterName
|
||||||
|
});
|
||||||
|
var defaultValue = span.get(0).innerText;
|
||||||
objs = getSet(objs);
|
objs = getSet(objs);
|
||||||
for(var i = 0, l = objs.length; i < l; i++) {
|
for(var i = 0, l = objs.length; i < l; i++) {
|
||||||
$('<option/>', {text: objs[i].name}).appendTo(select);
|
$('<option/>', {text: objs[i].name}).appendTo(select);
|
||||||
|
@ -1270,12 +1274,19 @@ View.Search = function (wardrobe) {
|
||||||
span.replaceWith(function () {
|
span.replaceWith(function () {
|
||||||
return select.clone().fadeIn('fast');
|
return select.clone().fadeIn('fast');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// have to set selected after it's already in the DOM; not sure why :/
|
||||||
|
$('select.search-helper[data-search-filter=' + filterName + '] option').each(function () {
|
||||||
|
if(this.innerText == defaultValue) {
|
||||||
|
this.selected = "selected";
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSpecies(x) { return x.species }
|
function getSpecies(x) { return x.species }
|
||||||
|
|
||||||
wardrobe.item_zone_sets.bind('update', prepBuildHelper('type', function (x) {
|
wardrobe.item_zone_sets.bind('update', prepBuildHelper('occupies', function (x) {
|
||||||
return x;
|
return x;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue