/*! cover-img - v1.0.0 - 2014-07-23 * https://github.com/johannesjo/cover-img * Copyright (c) 2014 Johannes Millan; Licensed MIT */ !function(a){a||(a=jQuery),function(a,b){var c=function(a,b,c){var d;return function(){function e(){c||a.apply(f,g),d=null}var f=this,g=arguments;d?clearTimeout(d):c&&a.apply(f,g),d=setTimeout(e,b||100)}};jQuery.fn[b]=function(a){return a?this.bind("resize",c(a)):this.trigger(b)}}(jQuery,"smartresize"),function(a){var b=function(b,c){var d=this;this.$el=a(b),this.options=c,this.$parent=this.$el.parent(),this.setStyles(),this.setParentStyles(),a("").attr("src",this.$el.attr("src")).load(function(){d.real_width=this.width,d.real_height=this.height,a(window).trigger("resize")}),a(window).smartresize(function(){d.resizeToCover()})};b.prototype.setStyles=function(){var a=this.$el.css("position"),b=this.$el.css("max-width"),c=this.$el.css("max-height");"relative"!==a&&"absolute"!==a&&this.$el.css("position","relative"),"none"!==b&&this.$el.css("max-width","none"),"none"!==c&&this.$el.css("max-height","none")},b.prototype.handleTableCells=function(){this.$parent.css("position","relative"),this.$el.wrap('
'),this.$parent=this.$el.parent(),this.$parent.css("overflow","hidden")},b.prototype.setParentStyles=function(){var a=this.$parent.css("position"),b=this.$parent.css("overflow"),c=this.$parent.css("display");"block"!==c&&"inline-block"!==c?this.handleTableCells():("relative"!==a&&"absolute"!==a&&this.$parent.css("position","relative"),"hidden"!==b&&this.$parent.css("overflow","hidden"))},b.prototype.resizeToCover=function(){var a,b,c,d,e=this.$parent.height(),f=this.$parent.width(),g=f/this.real_width,h=e/this.real_height;g>h?(a=Math.round(g*this.real_width),b=Math.round(g*this.real_height),c=Math.round((e-b)/2),d=0):(a=Math.round(h*this.real_width),b=Math.round(h*this.real_height),c=0,d=Math.round((f-a)/2)),this.$el.width(a),this.$el.height(b),this.$el.css({top:c,left:d})},b.DEFAULTS={},a.fn.coverImg=function(){return this.each(function(){var c=a.extend({},b.DEFAULTS,c);new b(this,c)})},a(window).on("load",function(){a("[data-cover-img]").each(function(){a(this).coverImg()})})}(a)}($);