'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'jquery',
'tinymce',
'quotes',
)
USE_TZ = True
-
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
-function showDetails(id) {
- document.getElementById(id).style.height = 'auto';
- // document.getElementById(id).style.visibility = 'visible';
- // document.getElementById(id).style.opacity = '1';
- document.getElementById(id + '_button').style.display = 'none';
-}
+function toggleDetails(event) {
+ var detailsid = event.data
+
+ button = $(detailsid+" .showhide_button")
+ button.text(
+ button.text() == "Show details" ? "Hide details" : "Show details"
+ );
-function hideDetails(id) {
- document.getElementById(id).style.maxHeight = '0';
- // document.getElementById(id).style.opacity = '0';
- // document.getElementById(id).style.visibility = 'hidden';
- document.getElementById(id + '_button').style.display = 'block';
+ $(detailsid+">.hidden_details").slideToggle(750)
+
+ return false;
}
+
+$( function() {
+ $(".details").each(function(index, elem) {
+ var detailsid = "#" + elem.id
+ $(detailsid+" .showhide_button").click(detailsid, toggleDetails)
+ $(detailsid+" .showhide_button").text("Show details")
+ $(detailsid+">.hidden_details").hide(0)
+ })
+})
}
.hidden_details {
- /* displayed through Javascript */
- height: 0;
- overflow: hidden;
- transition: height 3s linear;
- /* visibility: hidden; */
- /* opacity: 0; */
- /* transition: opacity 2s linear; */
-
+ /* hidden, and then toggled, from Javascript. */
+ border: 1px solid transparent;
+ /* without this invisible border there is a jump at the end of the
+ animation. */
+ padding-top: -1em;
}
.tag_link {
-<!DOCTYPE HTML>
+<!DOCTYPE html>
<html>
<head>
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'quotes/style.css' %}" />
+ <script src="{% static 'js/jquery.js' %}"></script>
<script src="{% static 'quotes/quotes.js' %}"></script>
<title>{% block title %}{% endblock %}</title>
</head>
{{ quote.text|safe }}
</div>
- <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>
+ <div class="details" id="details_{{ quote.id }}">
+ <p><a href="#" class="showhide_button"></a></p>
+ <div class="hidden_details">
<p class="author">
— <span class="name">
<a href="{{ quote.work.author.get_absolute_url }}"
Tags:
{% for tag in quote.tags.all %}
<a href="{{ tag.get_absolute_url }}" class="tag_link"
- >{{ tag.tag }}</a
- >{% if not forloop.last %}, {% endif %}
+ >{{ tag.tag }}</a>{% if not forloop.last %}, {% endif %}
{% endfor %}
</p>
{% endif %}
-
</div> <!-- /hidden_details -->
</div> <!-- /details -->
<p class="permalink">