/*! * Packery layout mode PACKAGED v2.0.1 * sub-classes Packery */ !function(t,i){t.Packery=t.Packery||{},t.Packery.Rect=function(){function t(i){for(var e in t.defaults)this[e]=t.defaults[e];for(e in i)this[e]=i[e]}t.defaults={x:0,y:0,width:0,height:0};var i=t.prototype;return i.contains=function(t){var i=t.width||0,e=t.height||0;return this.x<=t.x&&this.y<=t.y&&this.x+this.width>=t.x+i&&this.y+this.height>=t.y+e},i.overlaps=function(t){var i=this.x+this.width,e=this.y+this.height,s=t.x+t.width,h=t.y+t.height;return this.xt.x&&this.yt.y},i.getMaximalFreeRects=function(i){if(!this.overlaps(i))return!1;var e,s=[],h=this.x+this.width,n=this.y+this.height,r=i.x+i.width,a=i.y+i.height;return this.yr&&(e=new t({x:r,y:this.y,width:h-r,height:this.height}),s.push(e)),n>a&&(e=new t({x:this.x,y:a,width:this.width,height:n-a}),s.push(e)),this.x=t.width&&this.height>=t.height},t}()}(window),function(t,i){var e=t.Packery=t.Packery||{};e.Packer=function(t){function i(t,i,e){this.width=t||0,this.height=i||0,this.sortDirection=e||"downwardLeftToRight",this.reset()}var e=i.prototype;e.reset=function(){this.spaces=[];var i=new t({x:0,y:0,width:this.width,height:this.height});this.spaces.push(i),this.sorter=s[this.sortDirection]||s.downwardLeftToRight},e.pack=function(t){for(var i=0;i=t.x+t.width&&e.height>=t.height-.01){t.y=e.y,this.placed(t);break}}},e.rowPack=function(t){for(var i=0;i=t.y+t.height&&e.width>=t.width-.01){t.x=e.x,this.placed(t);break}}},e.placeInSpace=function(t,i){t.x=i.x,t.y=i.y,this.placed(t)},e.placed=function(t){for(var i=[],e=0;e=t.width-1&&this.height>=t.height-1};var n=i.create("packery");n.Item=h;var r=n.prototype;function a(t,i){return t.position.y-i.position.y||t.position.x-i.position.x}function o(t,i){return t.position.x-i.position.x||t.position.y-i.position.y}function c(t,i){var e=i.x-t.x,s=i.y-t.y;return Math.sqrt(e*e+s*s)}r._create=function(){i.prototype._create.call(this),this.packer=new s,this.shiftPacker=new s,this.isEnabled=!0,this.dragItemCount=0;var t=this;this.handleDraggabilly={dragStart:function(){t.itemDragStart(this.element)},dragMove:function(){t.itemDragMove(this.element,this.position.x,this.position.y)},dragEnd:function(){t.itemDragEnd(this.element)}},this.handleUIDraggable={start:function(i,e){e&&t.itemDragStart(i.currentTarget)},drag:function(i,e){e&&t.itemDragMove(i.currentTarget,e.position.left,e.position.top)},stop:function(i,e){e&&t.itemDragEnd(i.currentTarget)}}},r._resetLayout=function(){var t,i,e;this.getSize(),this._getMeasurements(),this._getOption("horizontal")?(t=1/0,i=this.size.innerHeight+this.gutter,e="rightwardTopToBottom"):(t=this.size.innerWidth+this.gutter,i=1/0,e="downwardLeftToRight"),this.packer.width=this.shiftPacker.width=t,this.packer.height=this.shiftPacker.height=i,this.packer.sortDirection=this.shiftPacker.sortDirection=e,this.packer.reset(),this.maxY=0,this.maxX=0},r._getMeasurements=function(){this._getMeasurement("columnWidth","width"),this._getMeasurement("rowHeight","height"),this._getMeasurement("gutter","width")},r._getItemLayoutPosition=function(t){if(this._setRectSize(t.element,t.rect),this.isShifting||this.dragItemCount>0){var i=this._getPackMethod();this.packer[i](t.rect)}else this.packer.pack(t.rect);return this._setMaxXY(t.rect),t.rect},r.shiftLayout=function(){this.isShifting=!0,this.layout(),delete this.isShifting},r._getPackMethod=function(){return this._getOption("horizontal")?"rowPack":"columnPack"},r._setMaxXY=function(t){this.maxX=Math.max(t.x+t.width,this.maxX),this.maxY=Math.max(t.y+t.height,this.maxY)},r._setRectSize=function(i,e){var s=t(i),h=s.outerWidth,n=s.outerHeight;(h||n)&&(h=this._applyGridGutter(h,this.columnWidth),n=this._applyGridGutter(n,this.rowHeight)),e.width=Math.min(h,this.packer.width),e.height=Math.min(n,this.packer.height)},r._applyGridGutter=function(t,i){if(!i)return t+this.gutter;var e=t%(i+=this.gutter);return t=Math[e&&e<1?"round":"ceil"](t/i)*i},r._getContainerSize=function(){return this._getOption("horizontal")?{width:this.maxX-this.gutter}:{height:this.maxY-this.gutter}},r._manageStamp=function(t){var i,s=this.getItem(t);if(s&&s.isPlacing)i=s.rect;else{var h=this._getElementOffset(t);i=new e({x:this._getOption("originLeft")?h.left:h.right,y:this._getOption("originTop")?h.top:h.bottom})}this._setRectSize(t,i),this.packer.placed(i),this._setMaxXY(i)},r.sortItemsByPosition=function(){var t=this._getOption("horizontal")?o:a;this.items.sort(t)},r.fit=function(t,i,e){var s=this.getItem(t);s&&(this.stamp(s.element),s.enablePlacing(),this.updateShiftTargets(s),i=void 0===i?s.rect.x:i,e=void 0===e?s.rect.y:e,this.shift(s,i,e),this._bindFitEvents(s),s.moveTo(s.rect.x,s.rect.y),this.shiftLayout(),this.unstamp(s.element),this.sortItemsByPosition(),s.disablePlacing())},r._bindFitEvents=function(t){var i=this,e=0;function s(){2==++e&&i.dispatchEvent("fitComplete",null,[t])}t.once("layout",s),this.once("layoutComplete",s)},r.resize=function(){this.isResizeBound&&this.needsResizeLayout()&&(this.options.shiftPercentResize?this.resizeShiftPercentLayout():this.layout())},r.needsResizeLayout=function(){var i=t(this.element),e=this._getOption("horizontal")?"innerHeight":"innerWidth";return i[e]!=this.size[e]},r.resizeShiftPercentLayout=function(){var i=this._getItemsForLayout(this.items),e=this._getOption("horizontal"),s=e?"y":"x",h=e?"height":"width",n=e?"rowHeight":"columnWidth",r=e?"innerHeight":"innerWidth",a=this[n];if(a=a&&a+this.gutter){this._getMeasurements();var o=this[n]+this.gutter;i.forEach((function(t){var i=Math.round(t.rect[s]/a);t.rect[s]=i*o}))}else{var c=t(this.element)[r]+this.gutter,g=this.packer[h];i.forEach((function(t){t.rect[s]=t.rect[s]/g*c}))}this.shiftLayout()},r.itemDragStart=function(t){if(this.isEnabled){this.stamp(t);var i=this.getItem(t);i&&(i.enablePlacing(),i.showDropPlaceholder(),this.dragItemCount++,this.updateShiftTargets(i))}},r.updateShiftTargets=function(t){this.shiftPacker.reset(),this._getBoundingRect();var i=this._getOption("originLeft"),s=this._getOption("originTop");this.stamps.forEach((function(t){var h=this.getItem(t);if(!h||!h.isPlacing){var n=this._getElementOffset(t),r=new e({x:i?n.left:n.right,y:s?n.top:n.bottom});this._setRectSize(t,r),this.shiftPacker.placed(r)}}),this);var h,n=this._getOption("horizontal"),r=n?"rowHeight":"columnWidth",a=n?"height":"width";this.shiftTargetKeys=[],this.shiftTargets=[];var o=this[r];if(o=o&&o+this.gutter){var c=Math.ceil(t.rect[a]/o),g=Math.floor((this.shiftPacker[a]+this.gutter)/o);h=(g-c)*o;for(var u=0;ue)){var h=t+","+i;-1!=this.shiftTargetKeys.indexOf(h)||(this.shiftTargetKeys.push(h),this.shiftTargets.push({x:t,y:i}))}},r.shift=function(t,i,e){var s,h=1/0,n={x:i,y:e};this.shiftTargets.forEach((function(t){var i=c(t,n);i