From: Radek Czajka Date: Thu, 26 Jan 2012 15:00:40 +0000 (+0100) Subject: dynamic catalogue menu X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/76a5ef1307add0a97470e8927e2b3165a8d95b29?hp=--cc dynamic catalogue menu --- 76a5ef1307add0a97470e8927e2b3165a8d95b29 diff --git a/apps/catalogue/templatetags/catalogue_tags.py b/apps/catalogue/templatetags/catalogue_tags.py index 961cc015f..33eec324c 100644 --- a/apps/catalogue/templatetags/catalogue_tags.py +++ b/apps/catalogue/templatetags/catalogue_tags.py @@ -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=[ diff --git a/wolnelektury/static/css/base.css b/wolnelektury/static/css/base.css index a89116abf..7b1c9ef4d 100755 --- a/wolnelektury/static/css/base.css +++ b/wolnelektury/static/css/base.css @@ -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; diff --git a/wolnelektury/static/css/book_box.css b/wolnelektury/static/css/book_box.css index 8a91bc3fe..c23f606ab 100755 --- a/wolnelektury/static/css/book_box.css +++ b/wolnelektury/static/css/book_box.css @@ -200,8 +200,8 @@ margin-left: 14em; } -.book-wide-box #themes-list-wrapper { - margin-left: 14em; +.book-wide-box #theme-list-wrapper { + margin-left: 15.4em; } diff --git a/wolnelektury/static/css/header.css b/wolnelektury/static/css/header.css index f8cf7568b..018b9a3ca 100755 --- a/wolnelektury/static/css/header.css +++ b/wolnelektury/static/css/header.css @@ -137,16 +137,16 @@ 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; } diff --git a/wolnelektury/static/js/base.js b/wolnelektury/static/js/base.js index 36a85d06f..7af03709d 100755 --- a/wolnelektury/static/js/base.js +++ b/wolnelektury/static/js/base.js @@ -61,6 +61,23 @@ + (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; + } + }); + }); + })(); diff --git a/wolnelektury/templates/base.html b/wolnelektury/templates/base.html index 8674ee16f..6696892e2 100644 --- a/wolnelektury/templates/base.html +++ b/wolnelektury/templates/base.html @@ -31,7 +31,7 @@
- {% cache 300 tagline %} + {% cache 300 tagline LANGUAGE_CODE %} {% url book_list as b %} {% url book_list as r %} {% count_books book_count %} @@ -96,16 +96,9 @@