/*! respeto 22-12-2013 */ var Respeto=function(a){var b={imageDataAttribute:"rsp-img",imagePathAttribute:"rsp-path",imagePath:"",retina:!1,retinaSuffix:"_x2"};this.lastState=null,this.settings=$.extend({},b,a),this._defaults=b,this._pixelRatio=window.hasOwnProperty("devicePixelRatio")?window.devicePixelRatio:1,this._scale=100,this._pixelRatio>1&&(this._scale=1/this._pixelRatio)};Respeto.prototype={load:function(a,b){b||(b={});var c=this._fetchTargets(b.match||void 0,b.exclude||void 0,b.context||document),d=b.retina||this.settings.retina;this._reSource(c,a,d)},_reSource:function(a,b,c){var d=this;b!==this.lastState&&(this.lastState=b,a.each(function(){var a=$(this),e=a.data(d.settings.imageDataAttribute);if(e){var f=a.data(d.settings.imagePathAttribute)||d.settings.imagePath,g=d._buildImagePath(f,e,b,c,d._pixelRatio);a.is("img")?a.attr("src",g):a.css("background-image","url("+g+")")}}))},_buildImagePath:function(a,b,c,d,e){var f=b.slice(-4),g=b.slice(0,-4),h="";return d===!0&&e>1&&(h=this.settings.retinaSuffix),a+g+(c?"-"+c:"")+h+f},_fetchTargets:function(a,b,c){if(a)return $(c).find(a).not(b);var d="";for(var e in this.settings.searchTags)d+=this.settings.searchTags[e]+"[data-"+this.settings.imageDataAttribute+"]";return $(c).find("img[data-rsp-img],div[data-rsp-img],section[data-rsp-img]").not(b)}},"undefined"!=typeof module&&(module.exports=Respeto);