-
Notifications
You must be signed in to change notification settings - Fork 2
/
jquery.retinize.min.js
3 lines (3 loc) · 1.35 KB
/
jquery.retinize.min.js
1
2
3
(function(a,d,k,l){function g(b,c){this.element=b;this.options=a.extend({},h,c);this._defaults=h;this._name=f;this.init()}var f="retinize",h={forceCanvas:!1};g.prototype={init:function(){if(d.devicePixelRatio&&1!==d.devicePixelRatio){if(!a.browser){a.browser={chrome:!1,mozilla:!1,opera:!1,msie:!1,safari:!1};var b=navigator.userAgent;a.each(a.browser,function(c,d){a.browser[c]=RegExp(c,"i").test(b)?!0:!1;a.browser.mozilla&&"mozilla"===c&&(a.browser.mozilla=/firefox/i.test(b)?!0:!1);a.browser.chrome&&
"safari"===c&&(a.browser.safari=!1)})}!0===this.options.forceCanvas||a.browser.mozilla||a.browser.chrome?this.convertToCanvas(this.element):a.browser.safari&&a(this).css({"image-rendering":"-webkit-optimize-contrast"}).css({"image-rendering":"pixelated"})}},convertToCanvas:function(b){var c=k.createElement("canvas");c.id=b.id;a(c).addClass(a(b).attr("class")).attr("title",a(b).attr("title"));c.width=b.width*d.devicePixelRatio;c.height=b.height*d.devicePixelRatio;c.style.width=b.width+"px";c.style.height=
b.height+"px";var e=c.getContext("2d");e.imageSmoothingEnabled=!1;e.mozImageSmoothingEnabled=!1;e.webkitImageSmoothingEnabled=!1;e.scale(d.devicePixelRatio,d.devicePixelRatio);e.drawImage(b,0,0);b.parentNode.replaceChild(c,b)}};a.fn[f]=function(b){return this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new g(this,b))})}})(jQuery,window,document);