[tor-commits] [tpo/master] Use fallback script for svg and fonts

hiro at torproject.org hiro at torproject.org
Thu Apr 4 15:50:49 UTC 2019


commit 372d415279ddf5f30c8e535399d45c0a7f1b67b8
Author: hiro <hiro at torproject.org>
Date:   Thu Apr 4 17:50:43 2019 +0200

    Use fallback script for svg and fonts
---
 assets/static/js/modernizr.js |  3 +++
 templates/footer.html         | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/assets/static/js/modernizr.js b/assets/static/js/modernizr.js
new file mode 100644
index 0000000..a2c9822
--- /dev/null
+++ b/assets/static/js/modernizr.js
@@ -0,0 +1,3 @@
+/*! modernizr 3.6.0 (Custom Build) | MIT *
+ * https://modernizr.com/download/?-inlinesvg-smil-svg-svgasimg-svgclippaths-svgfilters-svgforeignobject-setclasses !*/
+!function(e,t,n){function o(e,t){return typeof e===t}function s(){var e,t,n,s,a,i,r;for(var f in c)if(c.hasOwnProperty(f)){if(e=[],t=c[f],t.name&&(e.push(t.name.toLowerCase()),t.options&&t.options.aliases&&t.options.aliases.length))for(n=0;n<t.options.aliases.length;n++)e.push(t.options.aliases[n].toLowerCase());for(s=o(t.fn,"function")?t.fn():t.fn,a=0;a<e.length;a++)i=e[a],r=i.split("."),1===r.length?Modernizr[r[0]]=s:(!Modernizr[r[0]]||Modernizr[r[0]]instanceof Boolean||(Modernizr[r[0]]=new Boolean(Modernizr[r[0]])),Modernizr[r[0]][r[1]]=s),l.push((s?"":"no-")+r.join("-"))}}function a(e){var t=u.className,n=Modernizr._config.classPrefix||"";if(g&&(t=t.baseVal),Modernizr._config.enableJSClass){var o=new RegExp("(^|\\s)"+n+"no-js(\\s|$)");t=t.replace(o,"$1"+n+"js$2")}Modernizr._config.enableClasses&&(t+=" "+n+e.join(" "+n),g?u.className.baseVal=t:u.className=t)}function i(){return"function"!=typeof t.createElement?t.createElement(arguments[0]):g?t.createElementNS.call(t,"http://www.
 w3.org/2000/svg",arguments[0]):t.createElement.apply(t,arguments)}function r(e,t){if("object"==typeof e)for(var n in e)p(e,n)&&r(n,e[n]);else{e=e.toLowerCase();var o=e.split("."),s=Modernizr[o[0]];if(2==o.length&&(s=s[o[1]]),"undefined"!=typeof s)return Modernizr;t="function"==typeof t?t():t,1==o.length?Modernizr[o[0]]=t:(!Modernizr[o[0]]||Modernizr[o[0]]instanceof Boolean||(Modernizr[o[0]]=new Boolean(Modernizr[o[0]])),Modernizr[o[0]][o[1]]=t),a([(t&&0!=t?"":"no-")+o.join("-")]),Modernizr._trigger(e,t)}return Modernizr}var l=[],c=[],f={_version:"3.6.0",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,t){var n=this;setTimeout(function(){t(n[e])},0)},addTest:function(e,t,n){c.push({name:e,fn:t,options:n})},addAsyncTest:function(e){c.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=f,Modernizr=new Modernizr,Modernizr.addTest("svg",!!t.createElementNS&&!!t.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect),
 Modernizr.addTest("svgfilters",function(){var t=!1;try{t="SVGFEColorMatrixElement"in e&&2==SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_SATURATE}catch(n){}return t});var u=t.documentElement,g="svg"===u.nodeName.toLowerCase(),d={}.toString;Modernizr.addTest("svgclippaths",function(){return!!t.createElementNS&&/SVGClipPath/.test(d.call(t.createElementNS("http://www.w3.org/2000/svg","clipPath")))}),Modernizr.addTest("svgforeignobject",function(){return!!t.createElementNS&&/SVGForeignObject/.test(d.call(t.createElementNS("http://www.w3.org/2000/svg","foreignObject")))}),Modernizr.addTest("smil",function(){return!!t.createElementNS&&/SVGAnimate/.test(d.call(t.createElementNS("http://www.w3.org/2000/svg","animate")))}),Modernizr.addTest("inlinesvg",function(){var e=i("div");return e.innerHTML="<svg/>","http://www.w3.org/2000/svg"==("undefined"!=typeof SVGRect&&e.firstChild&&e.firstChild.namespaceURI)});var p;!function(){var e={}.hasOwnProperty;p=o(e,"undefined")||o(e.call,"undefined")?f
 unction(e,t){return t in e&&o(e.constructor.prototype[t],"undefined")}:function(t,n){return e.call(t,n)}}(),f._l={},f.on=function(e,t){this._l[e]||(this._l[e]=[]),this._l[e].push(t),Modernizr.hasOwnProperty(e)&&setTimeout(function(){Modernizr._trigger(e,Modernizr[e])},0)},f._trigger=function(e,t){if(this._l[e]){var n=this._l[e];setTimeout(function(){var e,o;for(e=0;e<n.length;e++)(o=n[e])(t)},0),delete this._l[e]}},Modernizr._q.push(function(){f.addTest=r}),Modernizr.addTest("svgasimg",t.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image","1.1")),s(),a(l),delete f.addTest,delete f.addAsyncTest;for(var w=0;w<Modernizr._q.length;w++)Modernizr._q[w]();e.Modernizr=Modernizr}(window,document);
diff --git a/templates/footer.html b/templates/footer.html
index f22867f..f2d07a6 100644
--- a/templates/footer.html
+++ b/templates/footer.html
@@ -87,8 +87,25 @@
     <script src="{{ '/static/js/popper.min.js'|asseturl }}" ></script>
     <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')



More information about the tor-commits mailing list