text: function NGT(e,i,t){function n(){o(),r(),s(),a(),u()}function o(e){var i=e||_();ei=i.columns,ii=i.fixed,F=i.width,K=i.percent,J=F}function r(){X=[],Y=[],Z=[[]],Q=[]}function s(){window.addEventListener("resize",l)}function a(){E.static_proportion?c():d()}function c(){for(counter=R.length,prop=E.static_proportion.split("x"),G=ii?1:Number(prop[0]),H=ii?1:Number(prop[1]),W=G*F,B=H*J;counter-->0;)child=R[counter],child.setAttribute("style","width:"+W+"px;height:"+B+"px;display:inline-block;background-color:"+child.style.backgroundColor);M.style.width=Math.ceil((ei-ei%G)*F)+"px"}function d(){for(counter=R.length;counter-->0;)child=R[counter],prop=child.dataset.size,prop=prop&&"none"!=prop?prop.split("x"):[1,1],G=ii?1:Number(prop[0]),H=ii?1:Number(prop[1]),Q.push(new C(counter,G,H,child));Q.reverse()}function u(){0==X.length?(h(),g()):g()}function l(){V=_(),F=J=V.width/ei,V.ischange?(x(),o(V),r(),a(),u(),E.onLayoutChanged&&E.onLayoutChanged.call(null,R,ei)):E.static_proportion?c():E.squarescale&&u(),E.onResize&&E.onResize.call(null,Math.round(F)+"px | "+Math.round(K)+"%",ei)}function h(){function e(e){for(I=ri;;){if(O=si,!(D>=I))break;for(j(I);ei>O;)z(I,O),o=Z[I][O],e.call(o),O++;I++}}function i(){if(this.solved===!1)if(counter=Q.length,a=0,counter>0)for(;counter-->0;){if(S=Q[a],U=S.params,U.dw<=this.width){f.call(this),Q.splice(a,1);break}if(E.insequense){U.dw=this.width,f.call(this),Q.splice(a,1);break}a++}else this.islast=!0}function t(){if(this.solved!==!0&&this.isgap!==!1){r=this,s=new N(r.id,O,I),s.islast=r.islast;var e=function(e){if(s.merge){var i=s.merge;U=X[i.id].params,U.dw=i.w,U.dh=i.h,p(s.merge.id+1,I,I+s.dh,O,O+s.dw)}else w(s);e&&e()},i=function(e){function i(e,i){function t(t,n){s.merge={id:i,w:t,h:n,type:e},r.isgap=!1,r.solved=!0}var n=!1;if(U=X[i].params,("left"==e||"right"==e)&&U.y==_cursor.y&&U.dh<=s.dh&&U.dw+s.dw<=E.max_width_dimension){if(c=s.dh-U.dh,c>0)for(s.dh=U.dh;c-->0;)Z[_cursor.y+s.dh+c][_cursor.x].isgap=!0;t(U.dw+s.dw,U.dh),n=!0}else if(("top"==e||"bottom"==e)&&U.x==_cursor.x&&U.dw<=s.dw&&U.dh+s.dh<=E.max_height_dimension){if(d=s.dw-U.dw,d>0)for(s.dw=U.dw;d-->0;)Z[_cursor.y][_cursor.x+s.dw+d].isgap=!0;t(U.dw,U.dh+s.dh),n=!0}return n}_cursor={x:O,y:I};for(ni in ti)if(h=ti[ni],u=_cursor.x+h.x,l=_cursor.y+h.y,!(u>ei-1||0>u||l>D-1||0>l)&&(o=Z[l][u],o.solved&&o.id>0&&i(ni,o.id-1)))break;e&&e.call(this)},t=function(i){if(_cursor.y<D&&s.dh<=T)if(o=Z[++_cursor.y][_cursor.x],o.isgap===!0){if(s.dh+=1,o.isgap=!1,s.dw>1)for(d=s.dw;d-->0;)Z[_cursor.y][_cursor.x+d].isgap=!1;t(i)}else i&&E.mergewithgap?i(e):e();else i&&E.mergewithgap?i(e):e()},n=function(e){_cursor.x<ei-1&&s.dw<=A?(o=Z[_cursor.y][++_cursor.x],o.isgap===!0?(s.dw+=1,o.isgap=!1,r.isgap&&(r.isgap=!1),n(e)):(_cursor={x:O,y:I},e(i))):(_cursor={x:O,y:I},e(i))};_cursor={x:O,y:I},E.gap_extend?n.call(this,t):E.mergewithgap?i.call(this,e):e.call(this)}}function n(){var e;for(a=0,counter=Y.length;counter-->0;)s=Y.shift(),e=s.params,e.islast||(S=X[X.length-++a],U=Object.create(S.params),U.y>e.y&&(s.obj.className=s.obj.className.replace(e.dw+"x"+e.dh,U.dw+"x"+U.dh),s={obj:s.obj,params:{}},s.params.dw=U.dw,s.params.dh=U.dh,s.params.x=U.x,s.params.y=U.y,S.params.dw=e.dw,S.params.dh=e.dh,S.params.x=e.x,S.params.y=e.y)),Y.push(s)}var o={},r={},s={},a=0,c=0,d=0,u=0,l=0,h={};e(i),ii||e(t),E.insequense||ii||!E.movelastcelltoclosegap||n(),E.makegap&&!ii?m():Y=[]}function p(e,i,t,n,o){function r(e){if(e>=0)for(;e>=0;){if(z(ai,e),Z[ai][e].solved!==!1)return;Z[ai][e].setValue({width:ci-e}),e--}}for(ai=i;t>ai;){for(ci=n,j(ai),r(ci-1);o>ci;)z(ai,ci),Z[ai][ci].setValue({id:e,solved:!0,isgap:!1}),ci++;ai++}}function f(){S.zindex=O*U.dh+I*U.dw,X.push(S),U.x=O,U.y=I,p(X.length,I,I+U.dh,O,O+U.dw),D=I+U.dh,this.islast=!1}function g(){for(counter=X.length;counter-->0;)S=X[counter],U=S.params,S.obj.setAttribute("style","position:absolute;display:block;z-index:"+S.zindex+";margin-left:"+U.x*K+"%;top:"+U.y*J+"px;width:"+U.dw*K+"%;height:"+U.dh*J+"px;background-color:"+S.obj.style.backgroundColor),S.obj.dataset.index=counter}function m(){if(counter=Y.length,counter>0)for(;counter-->0;)gap=Y[counter],X.push(gap),M.appendChild(gap.obj)}function x(){if(counter=Y.length,counter>0)for(;counter-->0;)gap=Y[counter],gap=gap.obj,X.pop(),M.removeChild(gap)}function w(e){var i=document.createElement("article");"string"==typeof E.gap_markup?i.innerHTML=E.gap_markup:i.appendChild(E.gap_markup),i.style.backgroundColor=E.gap_backgound,i.className=E.gap_classname+" crossback gapsize"+e.dw+"x"+e.dh,e.zindex=1e4+Y.length,e={params:e,obj:i},Y.push(e)}function _(){var e={ischange:!1,width:E.static_proportion?P:M.clientWidth};for(P=window.innerWidth,counter=q.length;counter--;)if(value=q[counter],$!=counter&&P>value.min&&P<=value.max){e.columns=value.cols,e.width=e.width/value.cols,e.percent=100/value.cols,e.fixed=value.fixed||!1,e.ischange=!0,$=counter;break}return e}function y(){return[{min:0,max:380,cols:1,fixed:!0},{min:380,max:760,cols:2,fixed:!0},{min:760,max:1e3,cols:4},{min:1e3,max:1280,cols:6},{min:1280,max:1600,cols:8},{min:1600,max:1920,cols:10},{min:1920,max:2680,cols:12}]}function b(){return{max_width_dimension:2,max_height_dimension:2,tile_classname:!1,static_proportion:!1,insequense:!1,squarescale:!1,makegap:!1,gap_markup:"",gap_backgound:"#ffffff",gap_classname:"gap",gap_extend:!0,mergewithgap:!0,movelastcelltoclosegap:!0,onResize:null,onLayoutChanged:null}}function v(e){if(e)for(ni in e)E[ni]=e[ni]}function k(e){e&&(q=e)}function j(e){void 0==Z[e]&&(Z[e]=[])}function z(e,i){return void 0==Z[e][i]&&(Z[e][i]=new L(i)),!0}function C(e,i,t,n){this.id=e,this.params={dw:i,dh:t,x:0,y:0},this.zindex=0,this.obj=n}function N(e,i,t,n,o){this.id=e,this.x=i,this.y=t,this.dw=n||1,this.dh=o||1,this.bg="#ccc"}function L(e){this.solved=!1,this.isgap=!0,this.width=ei-e||0,this.id="none";var i=this;this.setValue=function(e){for(ni in e)i[ni]=e[ni]}}var q=i||y(),E=b(),M=document.getElementById(e),R=M.children;v(t);var V,A=E.max_width_dimension-1||1,T=E.max_height_dimension-1||1,W=0,B=0,G=0,H=0,I=0,O=0,D=0,F=0,J=0,K=0,P=0,Q=[],S={},U={},X=[],Y=[],Z=[[]],$=-1,ei=0,ii=!1,ti={left:{x:-1,y:0},top:{x:0,y:-1},right:{x:1,y:0},bottom:{x:0,y:1}},ni=0,oi={},ri=0,si=0,ai=0,ci=0;return this.reinit=function(e,i,t){x();for(ni in q)oi=q[ni].cache,oi&&(oi.gaps=[],oi.layout=[],oi.collector=[]);if(t){R=M.children,counter=R.length;for(var o=[];counter-->0;)child=R[counter],"none"!=child.style.display&&o.push(child);o.reverse(),R=o}v(e),k(i),$=-1,window.removeEventListener("resize",l),n()},n(),this}