-
Notifications
You must be signed in to change notification settings - Fork 0
/
svgfall-v2.min.js
2 lines (2 loc) · 1.08 KB
/
svgfall-v2.min.js
1
2
/*! SVGfall - SVG with reliabale fallback. You can safely use SVG as image tags, with a regular image tag. Author: Agustín Amenabar, Médula Diseño, 2014 | License: MIT/GPLv2 **Forked from picturefill ny: Scott Jehl */
(function(a){a.hasSvgSupport="no-svg";if(window.Modernizr!==undefined&&window.Modernizr.svg!==undefined){a.hasSvgSupport=Modernizr.svg?"svg":"no-svg"}else{var b={svg:"http://www.w3.org/2000/svg"};if(!!document.createElementNS&&!!document.createElementNS(b.svg,"svg").createSVGRect){a.hasSvgSupport="svg"}}a.svgfall=function(){if(a.hasSvgSupport==="svg"){return}var g=a.document.getElementsByTagName("img");for(var e=0,c=g.length;e<c;e++){if(g[e].getAttribute("data-svgfall")!==null){var f=g[e].getAttribute("data-fallback");if(f===null){var d=g[e].getAttribute("src");f=d.substr(0,d.lastIndexOf("."))+".png"||d}g[e].setAttribute("src",f)}}};if(a.addEventListener){a.addEventListener("DOMContentLoaded",function(){a.svgfall();a.removeEventListener("load",a.svgfall,false)},false);a.addEventListener("load",a.svgfall,false)}else{if(a.attachEvent){a.attachEvent("onload",a.svgfall)}}}(this));