wp_back/wp-content/plugins/visual-portfolio/build/assets/js/layout-tiles.js
2024-05-20 15:37:46 +03:00

1 line
2.2 KiB
JavaScript

!function(){"use strict";var t={n:function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,{a:o}),o},d:function(e,o){for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e=window.jQuery,o=t.n(e);const{screenSizes:n}=window.VPData;if(void 0!==window.Isotope&&void 0!==window.Isotope.LayoutMode){const t=window.Isotope.LayoutMode.modes.masonry;if(t){const e=t.prototype.measureColumns;t.prototype.measureColumns=function(){let t=!0;if(!this.columnWidth){const e=o()(this.element).closest('.vp-portfolio[data-vp-layout="tiles"]');if(e.length&&e[0].vpf){this.getContainerWidth();const{vpf:o}=e[0],i=o.getTilesSettings();let s=parseInt(i[0],10)||1,p=s-1,l=Math.min(n.length-1,p);for(;l>=0;l-=1)p>0&&void 0!==n[l]&&window.innerWidth<=n[l]&&(s=p),p-=1;s&&(this.columnWidth=this.containerWidth/s,this.columnWidth+=this.gutter,this.cols=s,t=!1)}}t&&e.call(this)}}}o()(document).on("extendClass.vpf",((t,e)=>{"vpf"===t.namespace&&(e.prototype.getTilesSettings=function(){const t=this.options.tilesType.split(/[:|]/);return void 0===t[t.length-1]||t[t.length-1]||t.pop(),t})})),o()(document).on("initOptions.vpf",((t,e)=>{"vpf"===t.namespace&&(e.defaults.tilesType="3|1,1|",e.options.tilesType||(e.options.tilesType=e.defaults.tilesType))})),o()(document).on("initLayout.vpf",((t,e)=>{if("vpf"!==t.namespace)return;if("tiles"!==e.options.layout)return;const o=e.getTilesSettings(),i=parseInt(o[0],10)||1;if(o.shift(),e.addStyle(".vp-portfolio__item-wrap",{width:100/i+"%"}),o&&o.length)for(let t=0;t<o.length;t+=1){const n=o[t].split(","),s=parseFloat(n[0])||1,p=parseFloat(n[1])||1;let l=".vp-portfolio__item-wrap";o.length>1&&(l+=`:nth-of-type(${o.length}n+${t+1})`),s&&1!==s&&e.addStyle(l,{width:100*s/i+"%"}),e.addStyle(`${l} .vp-portfolio__item-img-wrap::before`,{"padding-top":100*p+"%"})}let s=i-1,p=Math.min(n.length-1,s);for(;p>=0;p-=1)s>0&&void 0!==n[p]&&(e.addStyle(".vp-portfolio__item-wrap",{width:100/s+"%"},`screen and (max-width: ${n[p]}px)`),e.addStyle(".vp-portfolio__item-wrap:nth-of-type(n)",{width:100/s+"%"},`screen and (max-width: ${n[p]}px)`)),s-=1}))}();