]> gitweb.fperrin.net Git - djsite.git/commitdiff
Hide by default details about the quotes
authorFrédéric Perrin <frederic.perrin@resel.fr>
Fri, 30 Sep 2016 22:22:59 +0000 (22:22 +0000)
committerFrédéric Perrin <frederic.perrin@resel.fr>
Fri, 30 Sep 2016 22:22:59 +0000 (22:22 +0000)
quotes/static/quotes/quotes.js [new file with mode: 0644]
quotes/static/quotes/style.css
quotes/templates/quotes/base.html
quotes/templates/quotes/display.html
quotes/templates/quotes/onequote.html

diff --git a/quotes/static/quotes/quotes.js b/quotes/static/quotes/quotes.js
new file mode 100644 (file)
index 0000000..ea4ba8a
--- /dev/null
@@ -0,0 +1,9 @@
+function showDetails(id) {
+    document.getElementById(id).style.display = 'block';
+    document.getElementById(id + '_button').style.display = 'none';
+}
+
+function hideDetails(id) {
+    document.getElementById(id).style.display = 'none';
+    document.getElementById(id + '_button').style.display = 'block';
+}
index db5467189a4638c85f27d2bd39d3d02042871301..a32d644a5974cc8f842f61d5b190738589510c1a 100644 (file)
@@ -1,7 +1,10 @@
-a {
+body {
     color: black;
+    background-color: white;
 }
 
+a { color: black; }
+
 a:hover {
     text-decoration: none;
 }
@@ -25,3 +28,8 @@ a:hover {
     font-size: 0.8em;
     text-align: right;
 }
+
+.hidden_details {
+    /* displayed through Javascript */
+    display: none;
+}
index df22ab28c7ab22f5f74ffed1a4eab1f0f8406613..69b3d217d72e3ebe1d7df12b6b73f048448044ec 100644 (file)
@@ -2,6 +2,7 @@
   <head>
     {% load staticfiles %}
     <link rel="stylesheet" type="text/css" href="{% static 'quotes/style.css' %}" />
+    <script src="{% static 'quotes/quotes.js' %}"></script>
     <title>{% block title %}{% endblock %}</title>
   </head>
   <body>
index 1369e2ce96f2ac30abb2d9388aa564f587fe66cc..2e09b3540a957c03c4613b1ba4fcc72a72eef490 100644 (file)
@@ -3,23 +3,36 @@
     {{ quote.text }}
   </p>
 
-  <p class="author">
-    — <span class="name"><a href="{% url 'quotes:author' quote.author.id %}">
-       {{ quote.author.name }}
-    </a></span>
-  </p>
+  <div class="details">
+    <p id="details_{{ quote.id}}_button">
+      <a href="" class="show_details"
+         onclick="showDetails('details_{{ quote.id }}'); return false;">
+       Show details</a></p>
+    <div class="hidden_details" id="details_{{ quote.id }}">
+      <p><a href="" class="hide_details"
+           onclick="hideDetails('details_{{ quote.id }}'); return false;">
+         Hide details</a></p>
+      <p class="author">
+       — <span class="name">
+         <a href="{% url 'quotes:author' quote.author.id %}">
+           {{ quote.author.name }}
+         </a>
+       </span>
+      </p>
 
-  {% if quote.tags.all %}
-    <p class="tags">
-      Tags:
-      {% for tag in quote.tags.all %}
+      {% if quote.tags.all %}
+      <p class="tags">
+       Tags:
+       {% for tag in quote.tags.all %}
        <a href="{% url 'quotes:tags' tag.id %}" class="tag_link">
          {{ tag.tag }}
        </a>
-      {% endfor %}
-    </p>
-  {% endif %}
+       {% endfor %}
+      </p>
+      {% endif %}
 
+    </div> <!-- /hidden_details -->
+  </div>   <!-- /details -->
   <p class="permalink">
     <a href="{% url 'quotes:onequote' quote.id %}">Permalink</a>
   </p>
index e814277ba21a22e7fad356aa28d652eb67a1f796..25f7971ab62e8dc2b4ed98caeb8194c60bb3a268 100644 (file)
@@ -1,6 +1,6 @@
 {% extends 'quotes/base.html' %}
 
-{% block title %}A quote by {{quote.author.name}}...{% endblock %}
+{% block title %}One quote...{% endblock %}
 
 {% block body %}