Pārlūkot izejas kodu

Uncollapse comments section if URL links to a comment

Fix #6

This fix assumes that disqus comments href are of the format
`#comment-<digits>`

This commit also adds the ability to uncollapse comments section if hash
is '#disqus_thread'.

User can add other collapse groups too. This fix will uncollapse them
too if proper hash is used.
Talha Mansoor 11 gadi atpakaļ
vecāks
revīzija
efc4b12b24
1 mainītis faili ar 18 papildinājumiem un 0 dzēšanām
  1. 18 0
      templates/article.html

+ 18 - 0
templates/article.html

@@ -132,4 +132,22 @@
     {% block script %}
     {{ super() }}
     {% include 'disqus_script_count.html' %}
+    {% if DISQUS_SITENAME and SITEURL and article.status != "draft" %}
+    <script  language="javascript" type="text/javascript">
+        function uncollapse() {
+            var hash_str = window.location.hash;
+            if (window.location.hash.match(/^#comment-\d+$/))
+            {
+                var hash_str = '#disqus_thread';
+            }
+            $(hash_str).collapse({
+                toggle: true
+                })
+        }
+    </script>
+
+    <script type="text/javascript" language="JavaScript">
+        uncollapse(); 
+    </script>
+    {% endif %}
     {% endblock script %}