dynamic catalogue menu
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 26 Jan 2012 15:00:40 +0000 (16:00 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 26 Jan 2012 15:31:50 +0000 (16:31 +0100)
apps/catalogue/templatetags/catalogue_tags.py
wolnelektury/static/css/base.css
wolnelektury/static/css/book_box.css
wolnelektury/static/css/header.css
wolnelektury/static/js/base.js
wolnelektury/templates/base.html
wolnelektury/templates/catalogue/book_wide.html
wolnelektury/templates/catalogue/menu.html [new file with mode: 0644]
wolnelektury/templates/catalogue/tagged_object_list.html

index 961cc01..33eec32 100644 (file)
@@ -358,6 +358,15 @@ def related_books(book, limit=6):
     }
 
 
+@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)
+    
+
+
 @register.simple_tag
 def tag_url(category, slug):
     return reverse('catalogue.views.tagged_object_list', args=[
index a89116a..7b1c9ef 100755 (executable)
@@ -121,17 +121,19 @@ h2 {
     font-size: 1.1em;
 }
 
-#themes-list-toggle:after {
+.theme-list-link:after {
     padding-left: 1em;
     content: "↓";
     font-family: WL-Nav;
     vertical-align: middle;
 }
-#themes-list-wrapper {
-    position: relative;
+.theme-list-link {
     font-size: 1.1em;
 }
-#themes-list {
+.hidden-box-wrapper {
+    position: relative;
+}
+.hidden-box {
     position: absolute;
     display: none;
     border: 1px solid #ddd;
@@ -142,7 +144,7 @@ h2 {
     box-shadow: 2px 2px 2px #ddd;
     z-index: 500;
 }
-#themes-list ul {
+.hidden-box ul {
     list-style: none;
     padding: 0;
     margin: 0;
index 8a91bc3..c23f606 100755 (executable)
     margin-left: 14em;
 }
 
-.book-wide-box #themes-list-wrapper {
-    margin-left: 14em;
+.book-wide-box #theme-list-wrapper {
+    margin-left: 15.4em;
 }
 
 
index f8cf756..018b9a3 100755 (executable)
     height: 4.9em;
 }
 
-ul#catalogue {
+ul#menu {
     list-style: none;
     padding: 0;
     margin: 0 0 0 .6em;
 }
-ul#catalogue li {
+li.menu {
     background-color: #e2e2e2;
     float: left;
 }
-ul#catalogue a {
+a.menu {
     display: block;
     padding-left: 1.4em;
     padding-right: 1.4em;
@@ -154,7 +154,7 @@ ul#catalogue a {
     height: 3.1em;
     padding-top: 1.8em;
 }
-ul#catalogue span {
+a.menu span {
     font-size: 1.1em;
 }
 
index 36a85d0..7af0370 100755 (executable)
 
 
 
+               (function() {
+                       var $current = null;
+                       $('.hidden-box-wrapper').each(function() {
+                               var $hidden = $('.hidden-box', this);
+                               $('.hidden-box-trigger', this).click(function(event) {
+                                       event.preventDefault();
+                                       if ($current == $hidden) {
+                                               $current = null;
+                                               $hidden.hide('fast');
+                                       } else {
+                                               $current && $current.hide('fast');
+                                               $hidden.show('fast');
+                                               $current = $hidden;
+                                       } 
+                               });
+                       });
+               })();
 
 
 
index 8674ee1..6696892 100644 (file)
@@ -31,7 +31,7 @@
 
             <div id="tagline">
                 <span>
-                {% cache 300 tagline %}
+                {% cache 300 tagline LANGUAGE_CODE %}
                     {% url book_list as b %}
                     {% url book_list as r %}
                         {% count_books book_count %}
         <div id="main-content">
 
             <div id="nav-line">
-            <ul id="catalogue">
-                <li><a href="{% url catalogue %}#autorzy"><span class='mono'>{% trans "Authors" %}</span></a></li>
-                <li><a href="{% url catalogue %}#gatunki"><span class='mono'>{% trans "Genres" %}</span></a></li>
-                <li><a href="{% url catalogue %}#rodzaje"><span class='mono'>{% trans "Kinds" %}</span></a></li>
-                <li><a href="{% url catalogue %}#epoki"><span class='mono'>{% trans "Epochs" %}</span></a></li>
-                <li><a href="{% url catalogue %}#motywy"><span class='mono'>{% trans "Themes" %}</span></a></li>
-                <li><a href="{% url book_list %}"><span class='mono'>{% trans "All books" %}</span></a></li>
-                <li><a href="{% url audiobook_list %}"><span class='mono'>{% trans "Audiobooks" %}</span></a></li>
-                <li><a href="{% url daisy_list %}"><span class='mono'>{% trans "DAISY" %}</span></a></li>
-            </ul>
+               {% cache 300 catalogue-menu LANGUAGE_CODE %}
+                       {% catalogue_menu %}
+               {% endcache %}
 
             <form action="{% url django.views.i18n.set_language %}" method="post">
             <div id="lang-menu">
index 2ea5555..1507f36 100644 (file)
@@ -9,10 +9,10 @@
 
 {% block book-box-extra-info %}
 {% if themes %}
-    <div id="themes-list-wrapper">
-        <p><a class="mono" id="themes-list-toggle"
+    <div class="hidden-box-wrapper" id="theme-list-wrapper">
+        <p><a class="mono hidden-box-trigger theme-list-link"
                 href="#">{% trans "motifs and themes" %}</a></p>
-        <div id="themes-list">
+        <div class="hidden-box">
             <ul>
             {% for theme in themes %}
                 <li><a href="{% url book_fragments book.slug theme.slug %}">{{ theme }} ({{ theme.count }})</a></li>
diff --git a/wolnelektury/templates/catalogue/menu.html b/wolnelektury/templates/catalogue/menu.html
new file mode 100644 (file)
index 0000000..99d8515
--- /dev/null
@@ -0,0 +1,42 @@
+{% load i18n %}
+{% load tag_list from catalogue_tags %}
+
+<ul id="menu">
+       <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">{% tag_list author %}</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">{% tag_list genre %}</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">{% tag_list kind %}</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">{% tag_list epoch %}</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">{% tag_list theme %}</div>
+       </li>
+       <li class="menu">
+               <a href="{% url book_list %}" class="menu">
+                       <span class='mono'>{% trans "All books" %}</span></a>
+       </li>
+       <li class="menu">
+               <a href="{% url audiobook_list %}" class="menu">
+                       <span class='mono'>{% trans "Audiobooks" %}</span></a>
+       </li>
+       <li class="menu">
+               <a href="{% url daisy_list %}" class="menu">
+                       <span class='mono'>{% trans "DAISY" %}</span></a>
+       </li>
+</ul>
\ No newline at end of file
index 45459f1..1a6843a 100644 (file)
     </div>
 
     {% if categories.theme %}
-        <div id="themes-list-wrapper">
-            <p><a href="#" id="themes-list-toggle" class="mono">{% trans "Motifs and themes" %}</a></p>
-            <div id="themes-list">
+        <div class="hidden-box-wrapper">
+            <p><a href="#" class="hidden-box-trigger theme-list-link" class="mono">
+               {% trans "Motifs and themes" %}</a></p>
+            <div class="hidden-box">
                 {% tag_list categories.theme tags %}
             </div>
         </div>