(function(c){function e(a,b){this.path=a;"undefined"!==typeof b&&null!==b?(this.at_2x_path=b,this.perform_check=!1):(this.at_2x_path=a.replace(/\.\w+$/,function(a){return"@2x"+a}),this.perform_check=!0)}function f(a){if(!/@2x\.\w+$/.test(c(a).attr("src"))){this.el=a;this.path=new e(c(a).attr("src"),c(a).attr("data-at2x"));var b=this;this.path.check_2x_variant(function(a){a&&b.swap()})}}c.fn.retina=function(a){if(c.Retina.isRetina())return c.Retina.opts=c.extend(c.Retina.opts,a),this.each(function(){c(this).is("img")&&
new f(this)})};c.Retina=function(){};c.Retina.opts={check_mime_type:!0,force_original_dimensions:!0};c.Retina.isRetina=function(){return 1<window.devicePixelRatio||window.matchMedia&&window.matchMedia("(-webkit-min-device-pixel-ratio: 1.5),(min--moz-device-pixel-ratio: 1.5),(-o-min-device-pixel-ratio: 3/2),(min-resolution: 1.5dppx)").matches?!0:!1};e.confirmed_paths=[];e.prototype.is_external=function(){return!(!this.path.match(/^(https?\:|\/\/)/i)||this.path.match("//"+document.domain+"/"))};e.prototype.check_2x_variant=
function(a){var b,d=this;if(this.is_external()||!this.perform_check&&"undefined"!==typeof this.at_2x_path&&null!==this.at_2x_path||this.at_2x_path in e.confirmed_paths)return a(!0);b=new XMLHttpRequest;b.open("HEAD",this.at_2x_path);b.onreadystatechange=function(){if(4==b.readyState&&200<=b.status&&399>=b.status){if(c.Retina.opts.check_mime_type){var g=b.getResponseHeader("Content-Type");if(null===g||!g.match(/^image/i))return a(!1)}e.confirmed_paths.push(d.at_2x_path);return a(!0)}return a(!1)};
b.send()};c.RetinaImage=f;f.prototype.swap=function(a){function b(){if(d.el.complete){c.Retina.opts.force_original_dimensions&&(d.el.setAttribute("width",d.el.offsetWidth),d.el.setAttribute("height",d.el.offsetHeight));var e=d.el.src;d.el.setAttribute("src",a);c(d.el).one("error",function(){d.el.setAttribute("src",e)})}else setTimeout(b,5)}"undefined"==typeof a&&(a=this.path.at_2x_path);var d=this;b()}})(jQuery);
