From 361b26f58ab84ae8682ef7e01d9423f75fb62735 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20St=C4=99pniowski?= Date: Thu, 11 Sep 2008 19:03:15 +0200 Subject: [PATCH] Folding of taq lists on main page. --- apps/catalogue/templatetags/catalogue_tags.py | 16 +++++++++++++++ wolnelektury/media/css/master.css | 9 +++++++++ wolnelektury/media/js/catalogue.js | 8 ++++++++ .../templates/catalogue/folded_tag_list.html | 20 +++++++++++++++++++ .../templates/catalogue/main_page.html | 10 +++++----- 5 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 wolnelektury/templates/catalogue/folded_tag_list.html diff --git a/apps/catalogue/templatetags/catalogue_tags.py b/apps/catalogue/templatetags/catalogue_tags.py index 51ee86333..36e80d273 100644 --- a/apps/catalogue/templatetags/catalogue_tags.py +++ b/apps/catalogue/templatetags/catalogue_tags.py @@ -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() + diff --git a/wolnelektury/media/css/master.css b/wolnelektury/media/css/master.css index 5c8974e55..041de4e53 100644 --- a/wolnelektury/media/css/master.css +++ b/wolnelektury/media/css/master.css @@ -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 = */ /* ============== */ diff --git a/wolnelektury/media/js/catalogue.js b/wolnelektury/media/js/catalogue.js index c9d5457d2..839190fb6 100644 --- a/wolnelektury/media/js/catalogue.js +++ b/wolnelektury/media/js/catalogue.js @@ -35,6 +35,14 @@ 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 index 000000000..cd7a6724c --- /dev/null +++ b/wolnelektury/templates/catalogue/folded_tag_list.html @@ -0,0 +1,20 @@ +{% load catalogue_tags %} +{% if one_tag %} +

Zobacz całą kategorię {{ one_tag }}.

+{% else %} +
+ + {% if some_tags_hidden %} +

[Zobacz wszystkie]

+ {% endif %} +
+ +{% endif %} diff --git a/wolnelektury/templates/catalogue/main_page.html b/wolnelektury/templates/catalogue/main_page.html index 1e188658b..9f6d0cfdc 100644 --- a/wolnelektury/templates/catalogue/main_page.html +++ b/wolnelektury/templates/catalogue/main_page.html @@ -41,28 +41,28 @@
{% if categories.author %}

Autorzy

- {% tag_list categories.author %} + {% folded_tag_list categories.author %} {% endif %} {% if categories.epoch %}

Epoki

- {% tag_list categories.epoch %} + {% folded_tag_list categories.epoch %} {% endif %} {% if categories.kind %}

Rodzaje

- {% tag_list categories.kind %} + {% folded_tag_list categories.kind %} {% endif %} {% if categories.genre %}

Gatunki literackie

- {% tag_list categories.genre %} + {% folded_tag_list categories.genre %} {% endif %}
{% if fragment_tags %}

Motywy

- {% tag_list fragment_tags %} + {% folded_tag_list fragment_tags %} {% endif %}
-- 2.20.1