/*! * Retina.js v1.1.0 * * Copyright 2013 Imulus, LLC * Released under the MIT license * * Retina.js is an open source script that makes it easy to serve * high-resolution images to devices with retina displays. */ (function(){function n(){}function r(e,t){this.path=e,typeof t!="undefined"&&t!==null?(this.at_2x_path=t,this.perform_check=!1):(this.at_2x_path=e.replace(/\.\w+$/,function(e){return"@2x"+e}),this.perform_check=!0)}function i(e){this.el=e,this.path=new r(this.el.getAttribute("src"),this.el.getAttribute("data-at2x"));var t=this;this.path.check_2x_variant(function(e){e&&t.swap()})}var e=typeof exports=="undefined"?window:exports,t={check_mime_type:!0};e.Retina=n,n.configure=function(e){e==null&&(e={});for(var n in e)t[n]=e[n]},n.init=function(t){t==null&&(t=e);var n=t.onload||new Function;t.onload=function(){var e=document.getElementsByTagName("img"),t=[],r,s;for(r=0;r1?!0:e.matchMedia&&e.matchMedia(t).matches?!0:!1},e.RetinaImagePath=r,r.confirmed_paths=[],r.prototype.is_external=function(){return!!this.path.match(/^https?\:/i)&&!this.path.match("//"+document.domain)},r.prototype.check_2x_variant=function(e){var n,i=this;if(this.is_external())return e(!1);if(!this.perform_check&&typeof this.at_2x_path!="undefined"&&this.at_2x_path!==null)return e(!0);if(this.at_2x_path in r.confirmed_paths)return e(!0);n=new XMLHttpRequest,n.open("HEAD",this.at_2x_path),n.onreadystatechange=function(){if(n.readyState!=4)return e(!1);if(n.status>=200&&n.status<=399){if(t.check_mime_type){var s=n.getResponseHeader("Content-Type");if(s==null||!s.match(/^image/i))return e(!1)}return r.confirmed_paths.push(i.at_2x_path),e(!0)}return e(!1)},n.send()},e.RetinaImage=i,i.prototype.swap=function(e){function n(){t.el.complete?(t.el.setAttribute("width",t.el.offsetWidth),t.el.setAttribute("height",t.el.offsetHeight),t.el.setAttribute("src",e)):setTimeout(n,5)}typeof e=="undefined"&&(e=this.path.at_2x_path);var t=this;n()},n.isRetina()&&n.init(e)})();