From: Marek Stępniowski Date: Thu, 11 Sep 2008 17:03:15 +0000 (+0200) Subject: Folding of taq lists on main page. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/361b26f58ab84ae8682ef7e01d9423f75fb62735?ds=sidebyside Folding of taq lists on main page. --- 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 %}