(function(k){function l(d,a,g){var m=0,e=[];g=jQuery.makeArray(g||d.querySelectorAll(a.itemSelector));var p=g.length;d=d.clientWidth-parseFloat(k(d).css("padding-left"))-parseFloat(k(d).css("padding-right"));for(var n=[],c,f=0;f<p;++f)(c=g[f].getElementsByTagName("img")[0])?n[f]={width:parseInt(c.getAttribute("width"))||c.offsetWidth,height:parseInt(c.getAttribute("height"))||c.offsetHeight}:(g.splice(f,1),--f,--p);p=g.length;for(c=0;c<p;++c){g[c].classList?(g[c].classList.remove(a.firstItemClass),
g[c].classList.remove(a.lastRowClass)):g[c].className=g[c].className.replace(new RegExp("(^|\\b)"+a.firstItemClass+"|"+a.lastRowClass+"(\\b|$)","gi")," ");m+=n[c].width;e.push(g[c]);if(c===p-1)for(var b=0;b<e.length;b++)0===b&&(e[b].className+=" "+a.lastRowClass),e[b].style.cssText="width: "+n[c+parseInt(b)-e.length+1].width+"px;height: "+n[c+parseInt(b)-e.length+1].height+"px;margin-right:"+(b<e.length-1?a.minMargin+"px":0);if(m+a.maxMargin*(e.length-1)>d){f=m+a.maxMargin*(e.length-1)-d;b=e.length;
if((a.maxMargin-a.minMargin)*(b-1)<f)var l=a.minMargin,f=f-(a.maxMargin-a.minMargin)*(b-1);else l=a.maxMargin-f/(b-1),f=0;for(var s,q=0,b=0;b<e.length;b++){s=e[b];var r=n[c+parseInt(b)-e.length+1].width,h=r-r/m*f,r=Math.round(n[c+parseInt(b)-e.length+1].height*(h/r));.5<=q+1-h%1?(q-=h%1,h=Math.floor(h)):(q+=1-h%1,h=Math.ceil(h));s.style.cssText="width: "+h+"px;height: "+r+"px;margin-right: "+(b<e.length-1?l:0)+"px";0===b&&(s.className+=" "+a.firstItemClass)}e=[];m=0}}}k.fn.rowGrid=function(d){return this.each(function(){$this=
k(this);if("appended"===d){d=$this.data("grid-options");var a=$this.children("."+d.lastRowClass),a=a.nextAll(d.itemSelector).add(a);l(this,d,a)}else if(d=k.extend({},k.fn.rowGrid.defaults,d),$this.data("grid-options",d),l(this,d),d.resize)k(window).on("resize.rowGrid",{container:this},function(a){l(a.data.container,d)})})};k.fn.rowGrid.defaults={minMargin:null,maxMargin:null,resize:!0,lastRowClass:"last-row",firstItemClass:null}})(jQuery);
(function(k){function t(d,b,f){var l=0,e=[];f=jQuery.makeArray(f||d.querySelectorAll(b.itemSelector));var p=f.length;d=d.clientWidth-parseFloat(k(d).css("padding-left"))-parseFloat(k(d).css("padding-right"));for(var m=[],c,g,n,a=0;a<p;++a)(c=f[a].getElementsByTagName("img")[0])?((g=parseInt(c.getAttribute("width")))||c.setAttribute("width",g=c.offsetWidth),(n=parseInt(c.getAttribute("height")))||c.setAttribute("height",n=c.offsetHeight),m[a]={width:g,height:n}):(f.splice(a,1),--a,--p);p=f.length;
for(c=0;c<p;++c){f[c].classList?(f[c].classList.remove(b.firstItemClass),f[c].classList.remove(b.lastRowClass)):f[c].className=f[c].className.replace(new RegExp("(^|\\b)"+b.firstItemClass+"|"+b.lastRowClass+"(\\b|$)","gi")," ");l+=m[c].width;e.push(f[c]);if(c===p-1)for(a=0;a<e.length;a++)0===a&&(e[a].className+=" "+b.lastRowClass),e[a].style.cssText="width: "+m[c+parseInt(a)-e.length+1].width+"px;height: "+m[c+parseInt(a)-e.length+1].height+"px;margin-right:"+(a<e.length-1?b.minMargin+"px":0);if(l+
b.maxMargin*(e.length-1)>d){g=l+b.maxMargin*(e.length-1)-d;a=e.length;(b.maxMargin-b.minMargin)*(a-1)<g?(n=b.minMargin,g-=(b.maxMargin-b.minMargin)*(a-1)):(n=b.maxMargin-g/(a-1),g=0);for(var s,q=0,a=0;a<e.length;a++){s=e[a];var r=m[c+parseInt(a)-e.length+1].width,h=r-r/l*g,r=Math.round(m[c+parseInt(a)-e.length+1].height*(h/r));.5<=q+1-h%1?(q-=h%1,h=Math.floor(h)):(q+=1-h%1,h=Math.ceil(h));s.style.cssText="width: "+h+"px;height: "+r+"px;margin-right: "+(a<e.length-1?n:0)+"px";0===a&&(s.className+=
" "+b.firstItemClass)}e=[];l=0}}}k.fn.rowGrid=function(d){return this.each(function(){$this=k(this);if("appended"===d){d=$this.data("grid-options");var b=$this.children("."+d.lastRowClass),b=b.nextAll(d.itemSelector).add(b);t(this,d,b)}else if(d=k.extend({},k.fn.rowGrid.defaults,d),$this.data("grid-options",d),t(this,d),d.resize)k(window).on("resize.rowGrid",{container:this},function(b){t(b.data.container,d)})})};k.fn.rowGrid.defaults={minMargin:null,maxMargin:null,resize:!0,lastRowClass:"last-row",
firstItemClass:null}})(jQuery);

compress js code