-{% load i18n %}
-{% load tag_list from catalogue_tags %}
+{% load i18n static %}
<ul id="menu">
+ {% for category, name, hash in categories %}
<li class="hidden-box-wrapper menu">
- <a href="{% url catalogue %}#autorzy" class="hidden-box-trigger menu">
- <span class='mono'>{% trans "Authors" %}</span></a>
- <div class="hidden-box">{% if author %}{% tag_list author %}{% endif %}</div>
- </li>
- <li class="hidden-box-wrapper menu">
- <a href="{% url catalogue %}#gatunki" class="hidden-box-trigger menu">
- <span class='mono'>{% trans "Genres" %}</span></a>
- <div class="hidden-box">{% if genre %}{% tag_list genre %}{% endif %}</div>
- </li>
- <li class="hidden-box-wrapper menu">
- <a href="{% url catalogue %}#rodzaje" class="hidden-box-trigger menu">
- <span class='mono'>{% trans "Kinds" %}</span></a>
- <div class="hidden-box">{% if kind %}{% tag_list kind %}{% endif %}</div>
- </li>
- <li class="hidden-box-wrapper menu">
- <a href="{% url catalogue %}#epoki" class="hidden-box-trigger menu">
- <span class='mono'>{% trans "Epochs" %}</span></a>
- <div class="hidden-box">{% if epoch %}{% tag_list epoch %}{% endif %}</div>
- </li>
- <li class="hidden-box-wrapper menu">
- <a href="{% url catalogue %}#motywy" class="hidden-box-trigger menu">
- <span class='mono'>{% trans "Themes" %}</span></a>
- <div class="hidden-box">{% if theme %}{% tag_list theme %}{% endif %}</div>
+ <a href="{% url catalogue %}#{{ hash }}" class="hidden-box-trigger menu load-menu">
+ <span class='mono'>{{ name }}</span></a>
+ <div class="hidden-box" id="menu-{{ category }}">
+ <img src="{% static "img/indicator.gif" %}" alt="{% trans "Please wait…" %}" />
+ </div>
</li>
+ {% endfor %}
+
<li class="menu">
<a href="{% url book_list %}" class="menu">
<span class='mono'>{% trans "All books" %}</span></a>
@register.inclusion_tag('catalogue/menu.html')
def catalogue_menu():
- tags = Tag.objects.filter(
- category__in=('author', 'epoch', 'genre', 'kind', 'theme')
- ).exclude(book_count=0)
- return split_tags(tags)
-
+ return {'categories': [
+ ('author', _('Authors'), 'autorzy'),
+ ('genre', _('Genres'), 'gatunki'),
+ ('kind', _('Kinds'), 'rodzaje'),
+ ('epoch', _('Epochs'), 'epoki'),
+ ('theme', _('Themes'), 'autorzy'),
+ ]}
@register.simple_tag
from catalogue import models
from catalogue import forms
from catalogue.utils import split_tags, MultiQuerySet
+from catalogue.templatetags.catalogue_tags import tag_list
from pdcounter import models as pdcounter_models
from pdcounter import views as pdcounter_views
from suggest.forms import PublishingSuggestForm
categories = split_tags(tags)
fragment_tags = categories.get('theme', [])
- return render_to_response('catalogue/catalogue.html', locals(),
- context_instance=RequestContext(request))
+ if request.is_ajax():
+ render_tag_list = lambda x: render_to_string(
+ 'catalogue/tag_list.html', tag_list(x))
+ output = {'theme': render_tag_list(fragment_tags)}
+ for category, tags in categories.items():
+ output[category] = render_tag_list(tags)
+ return JSONResponse(output)
+ else:
+ return render_to_response('catalogue/catalogue.html', locals(),
+ context_instance=RequestContext(request))
def book_list(request, filter=None, template_name='catalogue/book_list.html',
(function() {
var $current = null;
+ var menu_loaded = false;
$('.hidden-box-wrapper').each(function() {
var $hidden = $('.hidden-box', this);
$('.hidden-box-trigger', this).click(function(event) {
$current && $current.hide('fast');
$hidden.show('fast');
$current = $hidden;
+ if ($(this).hasClass('load-menu') && !menu_loaded) {
+ $.ajax({
+ url: '/katalog/',
+ dataType: "json",
+ }).done(function(data) {
+ $.each(data, function(index, value) {
+ $('#menu-' + index).html(value);
+ });
+ menu_loaded = true;
+ });
+ }
}
});
});
<div id="main-content">
<div id="nav-line">
- {% cache 300 catalogue-menu LANGUAGE_CODE %}
- {% catalogue_menu %}
- {% endcache %}
+ {% catalogue_menu %}
<div id="lang-menu" class="hoverget">
<span id='lang-button' class='mono hoverclick'>