/*
* Cube Portfolio - Responsive jQuery Grid Plugin
*
* version: 4.3.2 (7 April, 2018)
* require: jQuery v1.8+
*
* Copyright 2013-2018, Mihai Buricea (http://scriptpie.com/cubeportfolio/live-preview/)
* Licensed under CodeCanyon License (http://codecanyon.net/licenses)
*
*/
!function(t,e,n,i){"use strict";function o(e,n,a){var r=this;if(t.data(e,"cubeportfolio"))throw new Error("cubeportfolio is already initialized. Destroy it before initialize again!");r.obj=e,r.$obj=t(e),t.data(r.obj,"cubeportfolio",r),n.sortToPreventGaps!==i&&(n.sortByDimension=n.sortToPreventGaps,delete n.sortToPreventGaps),r.options=t.extend({},t.fn.cubeportfolio.options,n,r.$obj.data("cbp-options")),r.isAnimating=!0,r.defaultFilter=r.options.defaultFilter,r.registeredEvents=[],r.queue=[],r.addedWrapp=!1,t.isFunction(a)&&r.registerEvent("initFinish",a,!0);var s=r.$obj.children();r.$obj.addClass("cbp"),(0===s.length||s.first().hasClass("cbp-item"))&&(r.wrapInner(r.obj,"cbp-wrapper"),r.addedWrapp=!0),r.$ul=r.$obj.children().addClass("cbp-wrapper"),r.wrapInner(r.obj,"cbp-wrapper-outer"),r.wrapper=r.$obj.children(".cbp-wrapper-outer"),r.blocks=r.$ul.children(".cbp-item"),r.blocksOn=r.blocks,r.wrapInner(r.blocks,"cbp-item-wrapper"),r.plugins={},t.each(o.plugins,function(t,e){var n=e(r);n&&(r.plugins[t]=n)}),r.triggerEvent("afterPlugins"),r.removeAttrAfterStoreData=t.Deferred(),r.loadImages(r.$obj,r.display)}t.extend(o.prototype,{storeData:function(e,n){var i=this;n=n||0,e.each(function(e,o){var a=t(o),r=a.width(),s=a.height();a.data("cbp",{index:n+e,indexInitial:n+e,wrapper:a.children(".cbp-item-wrapper"),widthInitial:r,heightInitial:s,width:r,height:s,widthAndGap:r+i.options.gapVertical,heightAndGap:s+i.options.gapHorizontal,left:null,leftNew:null,top:null,topNew:null,pack:!1})}),this.removeAttrAfterStoreData.resolve()},wrapInner:function(t,e){var o,a,r;if(e=e||"",!(t.length&&t.length<1))for(t.length===i&&(t=[t]),a=t.length-1;a>=0;a--){for(o=t[a],(r=n.createElement("div")).setAttribute("class",e);o.childNodes.length;)r.appendChild(o.childNodes[0]);o.appendChild(r)}},removeAttrImage:function(t){this.removeAttrAfterStoreData.then(function(){t.removeAttribute("width"),t.removeAttribute("height"),t.removeAttribute("style")})},loadImages:function(e,n){var i=this;requestAnimationFrame(function(){var o=e.find("img").map(function(e,n){if(n.hasAttribute("width")&&n.hasAttribute("height")){if(n.style.width=n.getAttribute("width")+"px",n.style.height=n.getAttribute("height")+"px",n.hasAttribute("data-cbp-src"))return null;if(null===i.checkSrc(n))i.removeAttrImage(n);else{var o=t("");o.on("load.cbp error.cbp",function(){t(this).off("load.cbp error.cbp"),i.removeAttrImage(n)}),n.srcset?(o.attr("sizes",n.sizes||"100vw"),o.attr("srcset",n.srcset)):o.attr("src",n.src)}return null}return i.checkSrc(n)}),a=o.length;0!==a?t.each(o,function(e,o){var r=t("");r.on("load.cbp error.cbp",function(){t(this).off("load.cbp error.cbp"),0===--a&&n.call(i)}),o.srcset?(r.attr("sizes",o.sizes),r.attr("srcset",o.srcset)):r.attr("src",o.src)}):n.call(i)})},checkSrc:function(e){var n=e.srcset,o=e.src;if(""===o)return null;var a=t("");n?(a.attr("sizes",e.sizes||"100vw"),a.attr("srcset",n)):a.attr("src",o);var r=a[0];return r.complete&&r.naturalWidth!==i&&0!==r.naturalWidth?null:r},display:function(){var t=this;t.width=t.$obj.outerWidth(),t.triggerEvent("initStartRead"),t.triggerEvent("initStartWrite"),t.width>0&&(t.storeData(t.blocks),t.layoutAndAdjustment()),t.triggerEvent("initEndRead"),t.triggerEvent("initEndWrite"),t.$obj.addClass("cbp-ready"),t.runQueue("delayFrame",t.delayFrame)},delayFrame:function(){var t=this;requestAnimationFrame(function(){t.resizeEvent(),t.triggerEvent("initFinish"),t.isAnimating=!1,t.$obj.trigger("initComplete.cbp")})},resizeEvent:function(){var t=this;o["private"].resize.initEvent({instance:t,fn:function(){t.triggerEvent("beforeResizeGrid");var e=t.$obj.outerWidth();e&&t.width!==e&&(t.width=e,"alignCenter"===t.options.gridAdjustment&&(t.wrapper[0].style.maxWidth=""),t.layoutAndAdjustment(),t.triggerEvent("resizeGrid")),t.triggerEvent("resizeWindow")}})},gridAdjust:function(){var e=this;"responsive"===e.options.gridAdjustment?e.responsiveLayout():(e.blocks.removeAttr("style"),e.blocks.each(function(n,i){var o=t(i).data("cbp"),a=i.getBoundingClientRect(),r=e.columnWidthTruncate(a.right-a.left),s=Math.round(a.bottom-a.top);o.height=s,o.heightAndGap=s+e.options.gapHorizontal,o.width=r,o.widthAndGap=r+e.options.gapVertical}),e.widthAvailable=e.width+e.options.gapVertical),e.triggerEvent("gridAdjust")},layoutAndAdjustment:function(t){t&&(this.width=this.$obj.outerWidth()),this.gridAdjust(),this.layout()},layout:function(){var e=this;e.computeBlocks(e.filterConcat(e.defaultFilter)),"slider"===e.options.layoutMode?(e.sliderLayoutReset(),e.sliderLayout()):(e.mosaicLayoutReset(),e.mosaicLayout()),e.blocksOff.addClass("cbp-item-off"),e.blocksOn.removeClass("cbp-item-off").each(function(e,n){var i=t(n).data("cbp");i.left=i.leftNew,i.top=i.topNew,n.style.left=i.left+"px",n.style.top=i.top+"px"}),e.resizeMainContainer()},computeFilter:function(t){this.computeBlocks(t),this.mosaicLayoutReset(),this.mosaicLayout(),this.filterLayout()},filterLayout:function(){this.blocksOff.addClass("cbp-item-off"),this.blocksOn.removeClass("cbp-item-off").each(function(e,n){var i=t(n).data("cbp");i.left=i.leftNew,i.top=i.topNew,n.style.left=i.left+"px",n.style.top=i.top+"px"}),this.resizeMainContainer(),this.filterFinish()},filterFinish:function(){this.isAnimating=!1,this.$obj.trigger("filterComplete.cbp"),this.triggerEvent("filterFinish")},computeBlocks:function(t){var e=this;e.blocksOnInitial=e.blocksOn,e.blocksOn=e.blocks.filter(t),e.blocksOff=e.blocks.not(t),e.triggerEvent("computeBlocksFinish",t)},responsiveLayout:function(){var e=this;e.cols=e[t.isArray(e.options.mediaQueries)?"getColumnsBreakpoints":"getColumnsAuto"](),e.columnWidth=e.columnWidthTruncate((e.width+e.options.gapVertical)/e.cols),e.widthAvailable=e.columnWidth*e.cols,"mosaic"===e.options.layoutMode&&e.getMosaicWidthReference(),e.blocks.each(function(n,i){var o,a=t(i).data("cbp"),r=1;"mosaic"===e.options.layoutMode&&(r=e.getColsMosaic(a.widthInitial)),o=e.columnWidth*r-e.options.gapVertical,i.style.width=o+"px",a.width=o,a.widthAndGap=o+e.options.gapVertical,i.style.height=""});var n=[];e.blocks.each(function(e,i){t.each(t(i).find("img").filter("[width][height]"),function(e,i){var o=0;t(i).parentsUntil(".cbp-item").each(function(e,n){var i=t(n).width();if(i>0)return o=i,!1});var a=parseInt(i.getAttribute("width"),10),r=parseInt(i.getAttribute("height"),10),s=parseFloat((a/r).toFixed(10));n.push({el:i,width:o,height:Math.round(o/s)})})}),t.each(n,function(t,e){e.el.width=e.width,e.el.height=e.height,e.el.style.width=e.width+"px",e.el.style.height=e.height+"px"}),e.blocks.each(function(n,i){var o=t(i).data("cbp"),a=i.getBoundingClientRect(),r=Math.round(a.bottom-a.top);o.height=r,o.heightAndGap=r+e.options.gapHorizontal})},getMosaicWidthReference:function(){var e=[];this.blocks.each(function(n,i){var o=t(i).data("cbp");e.push(o.widthInitial)}),e.sort(function(t,e){return t-e}),e[0]?this.mosaicWidthReference=e[0]:this.mosaicWidthReference=this.columnWidth},getColsMosaic:function(t){if(t===this.width)return this.cols;var e=t/this.mosaicWidthReference;return e=e%1>=.79?Math.ceil(e):Math.floor(e),Math.min(Math.max(e,1),this.cols)},getColumnsAuto:function(){if(0===this.blocks.length)return 1;var t=this.blocks.first().data("cbp").widthInitial+this.options.gapVertical;return Math.max(Math.round(this.width/t),1)},getColumnsBreakpoints:function(){var e,n=this,i=n.width;return t.each(n.options.mediaQueries,function(t,n){if(i>=n.width)return e=n,!1}),e||(e=n.options.mediaQueries[n.options.mediaQueries.length-1]),n.triggerEvent("onMediaQueries",e.options),e.cols},columnWidthTruncate:function(t){return Math.floor(t)},resizeMainContainer:function(){var e,n=this,a=Math.max(n.freeSpaces.slice(-1)[0].topStart-n.options.gapHorizontal,0);"alignCenter"===n.options.gridAdjustment&&(e=0,n.blocksOn.each(function(n,i){var o=t(i).data("cbp"),a=o.left+o.width;a>e&&(e=a)}),n.wrapper[0].style.maxWidth=e+"px"),a!==n.height?(n.obj.style.height=a+"px",n.height!==i&&(o["private"].modernBrowser?n.$obj.one(o["private"].transitionend,function(){n.$obj.trigger("pluginResize.cbp")}):n.$obj.trigger("pluginResize.cbp")),n.height=a,n.triggerEvent("resizeMainContainer")):n.triggerEvent("resizeMainContainer")},filterConcat:function(t){return t.replace(/\|/gi,"")},pushQueue:function(t,e){this.queue[t]=this.queue[t]||[],this.queue[t].push(e)},runQueue:function(e,n){var i=this.queue[e]||[];t.when.apply(t,i).then(t.proxy(n,this))},clearQueue:function(t){this.queue[t]=[]},registerEvent:function(t,e,n){this.registeredEvents[t]||(this.registeredEvents[t]=[]),this.registeredEvents[t].push({func:e,oneTime:n||!1})},triggerEvent:function(t,e){var n,i,o=this;if(o.registeredEvents[t])for(n=0,i=o.registeredEvents[t].length;n0?(n=null,!1):null===n&&void 0}),n},generateF1F2:function(t,e){var n=this.freeSpaces[t],i={leftStart:n.leftStart+e.widthAndGap,leftEnd:n.leftEnd,topStart:n.topStart,topEnd:n.topEnd},o={leftStart:n.leftStart,leftEnd:n.leftEnd,topStart:n.topStart+e.heightAndGap,topEnd:n.topEnd};this.freeSpaces.splice(t,1),i.leftEnd>i.leftStart&&i.topEnd>i.topStart&&(this.freeSpaces.splice(t,0,i),t++),o.leftEnd>o.leftStart&&o.topEnd>o.topStart&&this.freeSpaces.splice(t,0,o)},generateG1G2G3G4:function(e){var n=this,i=[];t.each(n.freeSpaces,function(t,o){var a=n.intersectSpaces(o,e);null!==a?(n.generateG1(o,a,i),n.generateG2(o,a,i),n.generateG3(o,a,i),n.generateG4(o,a,i)):i.push(o)}),n.freeSpaces=i},intersectSpaces:function(t,e){var n={leftStart:e.leftNew,leftEnd:e.leftNew+e.widthAndGap,topStart:e.topNew,topEnd:e.topNew+e.heightAndGap};if(t.leftStart===n.leftStart&&t.leftEnd===n.leftEnd&&t.topStart===n.topStart&&t.topEnd===n.topEnd)return null;var i=Math.max(t.leftStart,n.leftStart),o=Math.min(t.leftEnd,n.leftEnd),a=Math.max(t.topStart,n.topStart),r=Math.min(t.topEnd,n.topEnd);return o<=i||r<=a?null:{leftStart:i,leftEnd:o,topStart:a,topEnd:r}},generateG1:function(t,e,n){t.topStart!==e.topStart&&n.push({leftStart:t.leftStart,leftEnd:t.leftEnd,topStart:t.topStart,topEnd:e.topStart})},generateG2:function(t,e,n){t.leftEnd!==e.leftEnd&&n.push({leftStart:e.leftEnd,leftEnd:t.leftEnd,topStart:t.topStart,topEnd:t.topEnd})},generateG3:function(t,e,n){t.topEnd!==e.topEnd&&n.push({leftStart:t.leftStart,leftEnd:t.leftEnd,topStart:e.topEnd,topEnd:t.topEnd})},generateG4:function(t,e,n){t.leftStart!==e.leftStart&&n.push({leftStart:t.leftStart,leftEnd:e.leftStart,topStart:t.topStart,topEnd:t.topEnd})},cleanFreeSpaces:function(){this.freeSpaces.sort(function(t,e){return t.topStart>e.topStart?1:t.topStarte.leftStart?1:t.leftStart=n.leftEnd&&e.topStart<=n.topStart&&e.topEnd>=n.topEnd?(n=null,!1):void 0}),n})},uniqueFreeSpaces:function(){var e=[];t.each(this.freeSpaces,function(n,i){t.each(e,function(t,e){if(e.leftStart===i.leftStart&&e.leftEnd===i.leftEnd&&e.topStart===i.topStart&&e.topEnd===i.topEnd)return i=null,!1}),null!==i&&e.push(i)}),this.freeSpaces=e},addHeightToBlocks:function(){var e=this;t.each(e.freeSpaces,function(n,i){e.blocksOn.each(function(n,o){var a=t(o).data("cbp");!0===a.pack&&(e.intersectSpaces(i,a)&&-1===i.topStart-a.topNew-a.heightAndGap&&(o.style.height=a.height-1+"px"))})})},sortBlocks:function(e,n,i,o){i=void 0===i?"leftNew":i,o=void 0===o?1:-1,e.sort(function(e,a){var r=t(e).data("cbp"),s=t(a).data("cbp");return r[n]>s[n]?o:r[n]s[i]?o:r[i]s.index?o:r.index