factor out the category arrow code

This commit is contained in:
Jeff Balogh 2010-08-04 20:27:20 -07:00
Родитель e62eaf0b65
Коммит 75c9dee1bc
5 изменённых файлов: 26 добавлений и 33 удалений

Просмотреть файл

@ -299,3 +299,11 @@ def field(field, label=None):
if label is not None: if label is not None:
field.label = label field.label = label
return jinja2.Markup(u'%s<p>%s%s</p>' % (field.errors, field.label_tag(), field)) return jinja2.Markup(u'%s<p>%s%s</p>' % (field.errors, field.label_tag(), field))
@register.inclusion_tag('amo/category-arrow.html')
@jinja2.contextfunction
def category_arrow(context, key, prefix):
d = dict(context.items())
d.update(key=key, prefix=prefix)
return d

Просмотреть файл

@ -0,0 +1,11 @@
<style>
#{{ prefix }}-{{ key }} {
background: url({{ MEDIA_URL }}img/zamboni/arrow-right-blue.png) no-repeat left center;
}
.html-rtl #{{ prefix }}-{{ key }} {
background: url({{ MEDIA_URL }}img/zamboni/arrow-left-blue.png) no-repeat right center;
}
#{{ prefix }}-{{ key }} a {
color: inherit;
}
</style>

Просмотреть файл

@ -9,17 +9,9 @@
{% block extrahead %} {% block extrahead %}
{% if not is_homepage %} {% if not is_homepage %}
<style> {% with key = category.id if category else filter.field %}
#p-{{ category.id if category else filter.field }} { {{ category_arrow(key, prefix='p') }}
background: url({{ MEDIA_URL }}img/zamboni/arrow-right-blue.png) no-repeat left center; {% endwith %}
}
.html-rtl #p-{{ category.id if category else filter.field }} {
background: url({{ MEDIA_URL }}img/zamboni/arrow-left-blue.png) no-repeat right center;
}
#p-{{ category.id if category else filter.field }} a {
color: inherit;
}
</style>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

Просмотреть файл

@ -13,17 +13,9 @@
{% endblock %} {% endblock %}
{% block extrahead %} {% block extrahead %}
<style> {% with key = category.id if category else filter.field %}
#p-{{ category.id if category else filter.field }} { {{ category_arrow(key, prefix='p') }}
background: url({{ MEDIA_URL }}img/zamboni/arrow-right-blue.png) no-repeat left center; {% endwith %}
}
.html-rtl #p-{{ category.id if category else filter.field }} {
background: url({{ MEDIA_URL }}img/zamboni/arrow-left-blue.png) no-repeat right center;
}
#p-{{ category.id if category else filter.field }} a {
color: inherit;
}
</style>
{% endblock %} {% endblock %}
{% block content %} {% block content %}

Просмотреть файл

@ -22,17 +22,7 @@
{% block extrahead %} {% block extrahead %}
{% with selector=category.id if category else sorting %} {% with selector=category.id if category else sorting %}
<style> {{ category_arrow(selector, prefix='c') }}
#c-{{ selector }} {
background: url({{ MEDIA_URL }}img/zamboni/arrow-right-blue.png) no-repeat left center;
}
.html-rtl #c-{{ selector }} {
background: url({{ MEDIA_URL }}img/zamboni/arrow-left-blue.png) no-repeat right center;
}
#c-{{ selector }} a {
color: inherit;
}
</style>
{% endwith %} {% endwith %}
{% endblock %} {% endblock %}