Current File : /home/kelaby89/muzza.fit/wp-content/themes/deadlift/assets/js/lib/jquery.flex-images.min.js |
/*!
jQuery flexImages v1.0.4
Copyright (c) 2014 Simon Steinberger / P1xabay
GitHub: https://github.com/P1xabay/jQuery-flexImages
License: http://www.opensource.org/licenses/mit-license.php
*/
!function(a){function b(a,c,d,e){function f(a){d.maxRows&&l>d.maxRows||d.truncate&&a&&l>1?n[g][0].style.display="none":(n[g][4]&&(n[g][3].attr("src",n[g][4]),n[g][4]=""),n[g][0].style.width=j+"px",n[g][0].style.height=p+"px",n[g][0].style.display="block")}var g,j,k=1,l=1,m=a.width()-2,n=[],o=0,p=d.rowHeight;for(m||(m=a.width()-2),i=0;i<c.length;i++)if(n.push(c[i]),o+=c[i][2]+d.margin,o>=m){var q=n.length*d.margin;for(k=(m-q)/(o-q),p=Math.ceil(d.rowHeight*k),exact_w=0,j,g=0;g<n.length;g++)j=Math.ceil(n[g][2]*k),exact_w+=j+d.margin,exact_w>m&&(j-=exact_w-m),f();n=[],o=0,l++}for(g=0;g<n.length;g++)j=Math.floor(n[g][2]*k),h=Math.floor(d.rowHeight*k),f(!0);e||m==a.width()||b(a,c,d,!0)}a.fn.flexImages=function(c){var d=a.extend({container:".item",object:"img",rowHeight:180,maxRows:0,truncate:0},c);return this.each(function(){var c=a(this),e=a(c).find(d.container),f=[],g=(new Date).getTime(),h=window.getComputedStyle?getComputedStyle(e[0],null):e[0].currentStyle;for(d.margin=(parseInt(h.marginLeft)||0)+(parseInt(h.marginRight)||0)+(Math.round(parseFloat(h.borderLeftWidth))||0)+(Math.round(parseFloat(h.borderRightWidth))||0),j=0;j<e.length;j++){var i=e[j],k=parseInt(i.getAttribute("data-w")),l=k*(d.rowHeight/parseInt(i.getAttribute("data-h"))),m=a(i).find(d.object);f.push([i,k,l,m,m.data("src")])}b(c,f,d),a(window).off("resize.flexImages"+c.data("flex-t")),a(window).on("resize.flexImages"+g,function(){b(c,f,d)}),c.data("flex-t",g)})}}(jQuery);