[tor-commits] [nyx/master] Expand anchored FAQ entries

atagar at torproject.org atagar at torproject.org
Sat Aug 5 01:18:26 UTC 2017


commit 5d8bda07ca17afd6569fc7d311593ed8f6048b4c
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Jul 31 17:52:29 2017 -0700

    Expand anchored FAQ entries
---
 web/index.html | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/web/index.html b/web/index.html
index 5ec9ea8..8cf0d11 100644
--- a/web/index.html
+++ b/web/index.html
@@ -351,25 +351,11 @@ sudo python setup.py install</pre><br /></li>
 
     <script>
     $(function() {
-      // when provided an anchor select the tab it resides within
-
-      var anchor = window.location.hash;
       $(".tabs").tabs(".page", { history: true });
 
-      if (anchor) {
-        $(".page").each(function () {
-          if ($(this).find(anchor).length) {
-            $(".tabs").data("tabs").click(this.id);
-            document.getElementById(anchor.substr(1)).scrollIntoView();
-          }
-        });
-      }
-
       // show/hide for FAQ questions
 
-      $('.questions > li > span').click(function() {
-        var answer = $(this).parent().find('.answer');
-
+      var toggleFaq = function(answer) {
         if (answer.is('.open')) {
           answer.animate({'height': '0'}, 100);
           answer.removeClass('open');
@@ -385,7 +371,29 @@ sudo python setup.py install</pre><br /></li>
           answer.animate({'height': newHeight}, 100);
           answer.addClass('open');
          }
+      }
+
+      $('.questions > li > span').click(function() {
+        toggleFaq($(this).parent().find('.answer'));
       });
+
+      // when provided an anchor select the tab it resides within
+
+      var anchor = window.location.hash;
+
+      if (anchor) {
+        $(".page").each(function () {
+          if ($(this).find(anchor).length) {
+            $(".tabs").data("tabs").click(this.id);
+
+            if (this.id == "faq" && anchor != "#faq") {
+              toggleFaq($(anchor + " > .answer"));
+            }
+
+            document.getElementById(anchor.substr(1)).scrollIntoView();
+          }
+        });
+      }
     });
     </script>
   </body>





More information about the tor-commits mailing list