Folding of taq lists on main page.
authorMarek Stępniowski <marek@stepniowski.com>
Thu, 11 Sep 2008 17:03:15 +0000 (19:03 +0200)
committerMarek Stępniowski <marek@stepniowski.com>
Thu, 11 Sep 2008 17:03:15 +0000 (19:03 +0200)
apps/catalogue/templatetags/catalogue_tags.py
wolnelektury/media/css/master.css
wolnelektury/media/js/catalogue.js
wolnelektury/templates/catalogue/folded_tag_list.html [new file with mode: 0644]
wolnelektury/templates/catalogue/main_page.html

index 51ee863..36e80d2 100644 (file)
@@ -196,3 +196,19 @@ def tag_list(tags, choices=None):
         one_tag = tags[0]
     return locals()
 
+
+@register.inclusion_tag('catalogue/folded_tag_list.html')
+def folded_tag_list(tags, choices=None):
+    if choices is None:
+        choices = []
+    some_tags_hidden = False
+    tag_count = len(tags)
+    
+    if tag_count == 1:
+        one_tag = tags[0]
+    else:
+        shown_tags = [tag for tag in tags if tag.main_page]
+        if tag_count > len(shown_tags):
+            some_tags_hidden = True
+    return locals()
+
index 5c8974e..041de4e 100644 (file)
@@ -236,6 +236,15 @@ p .ac_input {
     float: left;
 }
 
+ul.all-tags {
+    display: none;
+}
+
+div.shown-tags p {
+    margin: -0.5em 0 0 0;
+    text-align: right;
+}
+
 /* ============== */
 /* = Propaganda = */
 /* ============== */
index c9d5457..839190f 100644 (file)
             function() { $(this).css({background: '#FFF'}); }
         );
         
+        $('.show-all-tags').click(function() {
+            $(this).parent().parent().fadeOut(function() { 
+                $(this).next().fadeIn();
+            });
+        });
+        
+        
+        
         $('#registration-form').ajaxForm({
             dataType: 'json',
             beforeSubmit: function() {
diff --git a/wolnelektury/templates/catalogue/folded_tag_list.html b/wolnelektury/templates/catalogue/folded_tag_list.html
new file mode 100644 (file)
index 0000000..cd7a672
--- /dev/null
@@ -0,0 +1,20 @@
+{% load catalogue_tags %}
+{% if one_tag %}
+    <p>Zobacz całą kategorię <a href="{% catalogue_url one_tag %}">{{ one_tag }}</a>.</p>
+{% else %}
+    <div class="shown-tags">
+        <ul class="shown-tags">
+            {% for tag in shown_tags %}
+                <li><a href="{% catalogue_url choices tag %}">{{ tag }}&nbsp;({{ tag.count }})</a></li>
+            {% endfor %}
+        </ul>
+        {% if some_tags_hidden %}
+            <p><a href="#" class="show-all-tags">[Zobacz wszystkie]</a></p>
+        {% endif %}
+    </div>
+    <ul class="all-tags">
+        {% for tag in tags %}
+            <li><a href="{% catalogue_url choices tag %}">{{ tag }}&nbsp;({{ tag.count }})</a></li>
+        {% endfor %}      
+    </ul>    
+{% endif %}
index 1e18865..9f6d0cf 100644 (file)
             <div id="categories-list">
                 {% if categories.author %}
                     <h2>Autorzy</h2>
-                    {% tag_list categories.author %}
+                    {% folded_tag_list categories.author %}
                 {% endif %}
             
                 {% if categories.epoch %}
                     <h2>Epoki</h2>
-                    {% tag_list categories.epoch %}
+                    {% folded_tag_list categories.epoch %}
                 {% endif %}
             
                 {% if categories.kind %}
                     <h2>Rodzaje</h2>
-                    {% tag_list categories.kind %}
+                    {% folded_tag_list categories.kind %}
                 {% endif %}
             
                 {% if categories.genre %}
                     <h2>Gatunki literackie</h2>
-                    {% tag_list categories.genre %}
+                    {% folded_tag_list categories.genre %}
                 {% endif %}
             </div>
             <div id="themes-list">
                 {% if fragment_tags %}
                     <h2>Motywy</h2>
-                    {% tag_list fragment_tags %}
+                    {% folded_tag_list fragment_tags %}
                 {% endif %}
             </div>
             <div class="clearboth"></div>