The Great Listing of all Books improvement (TOC).
authorLukasz Anwajler <lukasz@anwajler.com>
Wed, 1 Sep 2010 11:33:01 +0000 (06:33 -0500)
committerLukasz Anwajler <lukasz@anwajler.com>
Wed, 1 Sep 2010 11:33:01 +0000 (06:33 -0500)
apps/catalogue/views.py
wolnelektury/static/css/master.css
wolnelektury/static/js/catalogue.js
wolnelektury/templates/catalogue/book_list.html

index 556bae1..d9ae442 100644 (file)
@@ -81,8 +81,13 @@ def book_list(request):
 
     orphans = []
     books_by_author = SortedDict()
+    books_nav = SortedDict()
     for tag in models.Tag.objects.filter(category='author'):
         books_by_author[tag] = []
+        if books_nav.has_key(tag.sort_key[0]):
+            books_nav[tag.sort_key[0]].append(tag)
+        else:
+            books_nav[tag.sort_key[0]] = [tag]
 
     for book in books_by_parent[None]:
         authors = list(book.tags.filter(category='author'))
index 80677d2..e9c42dc 100644 (file)
@@ -784,12 +784,28 @@ div.shown-tags p, div.all-tags p {
 /* ======================== */
 /* = Alphabetic book list = */
 /* ======================== */
-#book-a-list #book-list {
-    -moz-column-width: 24em;
-    -webkit-column-width: 24em;
-    column-width: 24em;
+#book-list-nav {
+    position: fixed;
+    right: 50px;
+    width: 200px;
+    border: 2px #325F70 solid;
+    padding: 10px;
+    font-size: 1.2em;
+}
+
+#book-list-nav ul {
+    list-style-type: none;
+    margin: 5px;
+    padding: 0;
+}
+
+.book-list-show-index {
+    display: none;
+    margin: 0;
+    padding: 0;
 }
 
+
 #book-a-list #book-list ol {
     padding-left: 1em;
     margin: 0.3em 0 1.2em 0;
index 4b09de8..cb31654 100644 (file)
@@ -479,6 +479,12 @@ function serverTime() {
                 })
             } 
         );
+        
+        $('.book-list-index').click(function(){
+            $('.book-list-show-index').hide('slow');
+            $(this).parent().next('ul').toggle('slow');
+            return false;
+        });
 
     });
 })(jQuery)
index 7d49cff..f385a19 100644 (file)
     <form action="{% url search %}" method="GET" accept-charset="utf-8" id="search-form">
         <p>{{ form.q }} <input type="submit" value="{% trans "Search" %}" /> <strong>{% trans "or" %}</strong> <a href="{% url main_page %}">{% trans "return to main page" %}</a></p>
     </form>
-
+    <div id="book-list-nav">
+        {% trans "Table of Content" %}
+        {% for index, authors in books_nav.items %}
+                <ul>
+                    <li><a class="book-list-index" href="#">{{ index|upper }}</a></li>
+                    <ul class="book-list-show-index">
+                    {% for author in authors %}
+                        <li><a href="#{{ author.slug }}">{{ author }}</a></li>
+                    {% endfor %}
+                    </ul>
+                </ul>
+        {% endfor %}    
+    </div>
     <div id="book-list">
         {% book_tree orphans books_by_parent %}
         {% for author, group in books_by_author.items %}
             {% if group %}
+                <a name="{{ author.slug }}">
                 <div class="group">
                     <h2><a href="{{ author.get_absolute_url }}">{{ author }}</a></h2>
                     {% book_tree group books_by_parent %}
@@ -23,4 +36,4 @@
             {% endif %}
         {% endfor %}
     </div>
-{% endblock %}
\ No newline at end of file
+{% endblock %}