[
  {
    "path": "index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\" />\n<style>\nbody {\n    font-family: sans-serif;\n}\n.wrap {\n    width: 75%;\n    max-width: 800px;\n    margin: 2em auto;\n}\nimg {\n    width: 100%;\n    border: none;\n}\npre {\n    overflow: auto;\n    padding: 1em;\n    border: 1px solid #999;\n}\n</style>\n<title>Responsive Enhance</title>\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n</head>\n<body>\n<div class=\"wrap\">\n<h1>Responsive Enhance</h1>\n<p>Depending on the size of your viewport, you may see a 400px by 300px wide image, or a 800px by 600px image. Try refreshing the page with a small or wide browser window. The standard image is always downloaded, full images are then downloaded as needed.</p>\n<p><img id=\"demo1\" src=\"http://dummyimage.com/400x300\" alt=\"Responsive Image\" data-fullsrc=\"http://dummyimage.com/800x600\"></p>\n<p><pre><code>&lt;img id=\"demo1\" src=\"http://dummyimage.com/400x300\" alt=\"Responsive Image\" data-fullsrc=\"http://dummyimage.com/800x600\"&gt;\n&lt;script&gt;responsiveEnhance(document.getElementById('demo1'), 400);&lt;/script&gt;</code></pre></p>\n<p>Here's a photo of some lovely star biscuits that <a href=\"http://twitter.com/qwertykate\">@qwertykate</a> bought us. Image courtesy of <a href=\"http://www.flickr.com/photos/adactio/\">adactio</a>.</p>\n<p><a href=\"http://www.flickr.com/photos/adactio/6806617685\"><img id=\"demo2\" src=\"http://farm8.staticflickr.com/7022/6806617685_3be0d007c3_m.jpg\" alt=\"Responsive Image\" data-fullsrc=\"http://farm8.staticflickr.com/7022/6806617685_b793771008_o.jpg\"></a></p>\n<p><pre><code>&lt;img id=\"demo2\" src=\"http://farm8.staticflickr.com/7022/6806617685_3be0d007c3_m.jpg\" alt=\"Responsive Image\" data-fullsrc=\"http://farm8.staticflickr.com/7022/6806617685_b793771008_o.jpg\"&gt;\n&lt;script&gt;responsiveEnhance(document.getElementById('demo2'), 240);&lt;/script&gt;</code></pre></p>\n</div>\n</body>\n<script src=\"responsive-enhance.js\"></script>\n<script>\nresponsiveEnhance(document.getElementById('demo1'), 400);\nresponsiveEnhance(document.getElementById('demo2'), 240);\n</script>\n</html>"
  },
  {
    "path": "readme.md",
    "content": "Responsive Enhance\n==================\n\nThis script will check whether an image is larger than a specified width and load a full resolution image if necessary.\n\n    <img id=\"demo\" src=\"http://dummyimage.com/400x300\" alt=\"Responsive Image\" data-fullsrc=\"http://dummyimage.com/800x600\">\n    <script>responsiveEnhance(document.getElementById('demo'), 400);</script>\n    \nThis will replace the image with the image defined in the `data-fullsrc` when the image is wider than 400 pixels."
  },
  {
    "path": "responsive-enhance.js",
    "content": "var addEvent=function(){return document.addEventListener?function(a,c,d){if(a&&a.nodeName||a===window)a.addEventListener(c,d,!1);else if(a&&a.length)for(var b=0;b<a.length;b++)addEvent(a[b],c,d)}:function(a,c,d){if(a&&a.nodeName||a===window)a.attachEvent(\"on\"+c,function(){return d.call(a,window.event)});else if(a&&a.length)for(var b=0;b<a.length;b++)addEvent(a[b],c,d)}}();\n\nvar responsiveEnhance = function(img, width, monitor) {\n    if (img.length) {\n        for (var i=0, len=img.length; i<len; i++) {\n            responsiveEnhance(img[i], width, monitor);\n        }\n    } else {\n        if (((' '+img.className+' ').replace(/[\\n\\t]/g, ' ').indexOf(' large ') == -1) && img.clientWidth > width) {\n            var fullimg = new Image();\n            addEvent(fullimg, 'load', function(e) {\n                img.className += ' large';\n                img.src = this.src;\n            });\n            fullimg.src = img.getAttribute('data-fullsrc');\n        }\n    }\n    if (monitor != false) {\n        addEvent(window, 'resize', function(e) {\n            responsiveEnhance(img, width, false);\n        });\n        addEvent(img, 'load', function(e) {\n            responsiveEnhance(img, width, false);\n        });\n    }\n};"
  }
]