[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tpo/master] Move inline js



commit 1f88f22c351e9d6ce88e8050f1eddb643992410c
Author: hiro <hiro@xxxxxxxxxxxxxx>
Date:   Thu Apr 4 18:03:49 2019 +0200

    Move inline js
---
 assets/static/js/fallback.js | 38 ++++++++++++++++++++++++++++++++++++++
 templates/footer.html        | 42 +-----------------------------------------
 2 files changed, 39 insertions(+), 41 deletions(-)

diff --git a/assets/static/js/fallback.js b/assets/static/js/fallback.js
new file mode 100644
index 0000000..b5f88ea
--- /dev/null
+++ b/assets/static/js/fallback.js
@@ -0,0 +1,38 @@
+if (Modernizr.addTest('svgasimg', document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#Image', '1.1'))) {
+  a = $('[class*="-png"]');
+  a.each(function(i, obj) {
+    var iterator = obj.classList.entries();
+    for(var value of iterator) {
+      if(/-png/.test(value)) {
+        cl = value[1];
+        $(obj).removeClass(cl);
+        ej = cl.replace(/-png/,"");
+        $(obj).addClass(ej)
+        console.log(obj);
+      }
+    }
+  });
+}
+
+$('.side-nav').click(function(){
+  if ($('.side-nav.active').length > 0) {
+    $('.side-nav.active').removeClass('active')
+  }
+  $(this).addClass('active');
+});
+
+if($('.show').length !== 1 ) {
+  $('.show').collapse();
+}
+
+// Coming from search result page click
+if(window.location.hash !== "") {
+  // Somehow collapse is not working sync and calling show directly after
+  // yields no effect and there is no callback when it is ready
+  setTimeout(() => {
+    // Folds out the answer manually
+    $(window.location.hash).collapse('show')
+    // Avoids the answer being hidden by the floating header
+    window.scrollTo(0, $(window.location.hash).position().top)
+  }, 500)
+}
diff --git a/templates/footer.html b/templates/footer.html
index f2d07a6..63080db 100644
--- a/templates/footer.html
+++ b/templates/footer.html
@@ -88,46 +88,6 @@
     <script src="{{ '/static/js/bootstrap.bundle.min.js'|asseturl }}" ></script>
     <script src="{{ '/static/js/scrollspy.min.js'|asseturl }}" ></script>
     <script src="{{ '/static/js/modernizr.js'|asseturl }}" ></script>
-    <script type="text/javascript">
-
-      if (Modernizr.addTest('svgasimg', document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#Image', '1.1'))) {
-        a = $('[class*="-png"]');
-        a.each(function(i, obj) {
-          var iterator = obj.classList.entries();
-          for(var value of iterator) {
-            if(/-png/.test(value)) {
-              cl = value[1];
-              $(obj).removeClass(cl);
-              ej = cl.replace(/-png/,"");
-              $(obj).addClass(ej)
-              console.log(obj);
-            }
-          }
-        });
-      }
-
-      $('.side-nav').click(function(){
-        if ($('.side-nav.active').length > 0) {
-          $('.side-nav.active').removeClass('active')
-        }
-        $(this).addClass('active');
-      });
-
-      if($('.show').length !== 1 ) {
-        $('.show').collapse();
-      }
-
-      // Coming from search result page click
-      if(window.location.hash !== "") {
-        // Somehow collapse is not working sync and calling show directly after
-        // yields no effect and there is no callback when it is ready
-        setTimeout(() => {
-          // Folds out the answer manually
-          $(window.location.hash).collapse('show')
-          // Avoids the answer being hidden by the floating header
-          window.scrollTo(0, $(window.location.hash).position().top)
-        }, 500)
-      }
-    </script>
+    <script src="{{ '/static/js/fallback.js'|asseturl }}" ></script>
     {% include 'script-download.html' %}
   </div>

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits