Minimal double reader.
authorRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Tue, 19 Nov 2013 08:20:50 +0000 (09:20 +0100)
committerRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Tue, 19 Nov 2013 08:20:50 +0000 (09:20 +0100)
apps/catalogue/models/book.py
apps/catalogue/templates/catalogue/book_text.html
apps/wolnelektury_core/static/css/master.book.css
wolnelektury/settings/static.py

index d69cf2a..9025e3e 100644 (file)
@@ -391,6 +391,10 @@ class Book(models.Model):
             for child in self.children.all():
                 child.parent_cover_changed()
 
+    def other_versions(self):
+        """Find other versions (i.e. in other languages) of the book."""
+        return type(self).objects.filter(common_slug=self.common_slug).exclude(pk=self.pk)
+
     def related_info(self):
         """Keeps info about related objects (tags, media) in cache field."""
         if self._related_info is not None:
index f6f2f99..c4031a6 100644 (file)
@@ -29,6 +29,9 @@
                     <li><a class="open-player" target="_blank" href="{% url "book_player" book.slug %}">
                         {% trans "Listen" %}</a></li>
                 {% endif %}
+                {% if book.other_versions.exists %}
+                    <li><a class="menu" href="#other-versions">Inne wersje</a></li>
+                {% endif %}
             </ul>
         </div>
         <div id="info">
             {% endif %}
             </ul>
         </div>
+        {% if book.other_versions.exists %}
+        <div id="other-versions">
+            <ul>
+            {% for version in book.other_versions %}
+                <li>{{ version.pretty_title }}:
+                    <br/><a href="#" class="display-other" data-other="{{ version.html_file.url }}">porównaj</a>,
+                    <a href="{{ version.get_absolute_url }}">przejdź</a>.
+                </li>
+            {% endfor %}
+            </ul>
+        </div>
+        {% endif %}
         <div id="header">
             <a href="/"><img src="{% static "img/logo-220.png" %}" alt="Wolne Lektury" /></a>
         </div>
-        {{ book.html_file.read|safe }}
+
+        <div style="position:relative; margin: 4.5em 0">
+            {{ book.html_file.read|safe }}
+            <div id="other-text"
+                style="display:none;position: absolute; top: 0; left: 780px; border-left: 1px solid #ddd">
+                <a id="other-text-close" href="#" style="position: absolute; top: -1.5em;">(zamknij)</a>
+                <div id="other-text-waiter">wait...</div>
+                <div id="other-text-body" style="display: none;"></div>
+            </div>
+        </div>
         {{ piwik_tag|safe }}
     </body>
 </html>
index be54927..edea793 100644 (file)
@@ -11,10 +11,14 @@ a {
 }
 
 #book-text {
-    margin: 3em;
+    margin: 3em;
     max-width: 36em;
 }
 
+#other-text #book-text {
+    width: 36em;
+}
+
 /* ================================== */
 /* = Header with logo and menu      = */
 /* ================================== */
@@ -89,7 +93,7 @@ img {
 }
 
 
-#toc, #themes, #nota_red, #info {
+#toc, #themes, #nota_red, #info, #other-versions {
     position: fixed;
     left: 0em;
     top: 1.5em;
@@ -163,7 +167,7 @@ img {
 /* =================================================== */
 h1 {
     font-size: 3em;
-    margin: 1.5em 0;
+    margin: 0 0 1.5em 0;
     text-align: center;
     line-height: 1.5em;
     font-weight: bold;
index a3ff424..c38db38 100644 (file)
@@ -101,6 +101,7 @@ PIPELINE_JS = {
             'js/jquery.eventdelegation.js',
             'js/jquery.scrollto.js',
             'js/jquery.highlightfade.js',
+            'js/book_text/other.js',
             'js/book.js',
             'player/openplayer.js',
         ],