wp_back/wp-content/plugins/visual-portfolio/build/assets/js/popup-gallery.js

1 line
7.1 KiB
JavaScript
Raw Normal View History

2024-05-20 15:37:46 +03:00
!function(){"use strict";var e={n:function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(o,{a:o}),o},d:function(t,o){for(var i in o)e.o(o,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:o[i]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=window.jQuery,o=e.n(t);const{VPData:i}=window,{settingsPopupGallery:r}=i,n="content"in document.createElement("template"),a={vendor:!1,vendors:[{vendor:"youtube",embedUrl:"https://www.youtube.com/embed/{{video_id}}?{{params}}",pattern:/(https?:\/\/)?(www.)?(youtube\.com|youtu\.be|youtube-nocookie\.com)\/(?:embed\/|shorts\/|v\/|watch\?v=|watch\?list=(.*)&v=|watch\?(.*[^&]&)v=)?((\w|-){11})(&list=(\w+)&?)?(.*)/,patternIndex:6,params:{autoplay:1,autohide:1,fs:1,rel:0,hd:1,wmode:"transparent",enablejsapi:1,html5:1},paramsIndex:10,embedCallback(e,t){let o=!1;const i=this,r=!(!t||!t[i.patternIndex])&&t[i.patternIndex];if(r){const n=/\/shorts\//.test(e),p=n?476:1920,l=n?847:1080;o=a.embedCallback({...i,width:p,height:l},r,e,t)}return o}},{vendor:"vimeo",embedUrl:"https://player.vimeo.com/video/{{video_id}}?{{params}}",pattern:/https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)(.*)/,patternIndex:3,params:{autoplay:1,hd:1,show_title:1,show_byline:1,show_portrait:0,fullscreen:1},paramsIndex:4}],init(){},open(){},close(){},getQueryStringParams(e){return e?(/^[?#]/.test(e)?e.slice(1):e).split("&").reduce(((e,t)=>{const[o,i]=t.split("=");return e[o]=i?decodeURIComponent(i.replace(/\+/g," ")):"",e}),{}):{}},prepareParams(e,t){let o="";const i=t.params||{};if(t.paramsIndex&&e&&e[t.paramsIndex]){const o=a.getQueryStringParams(e[t.paramsIndex]);o&&"object"==typeof o&&Object.keys(o).forEach((e=>{e&&o[e]&&(i[e]=o[e])}))}return i&&Object.keys(i).length&&Object.keys(i).forEach((e=>{e&&i[e]&&(o&&(o+="&"),o+=`${e}=${i[e]}`)})),o},embedCallback(e,t,o,i=!1){let{embedUrl:r}=e;r=r.replace(/{{video_id}}/g,t),r=r.replace(/{{video_url}}/g,o),r=r.replace(/{{video_url_encoded}}/g,encodeURIComponent(o)),r=r.replace(/{{params}}/g,i?a.prepareParams(i,e):"");const n=e.width||1920,p=e.height||1080;return{vendor:e.vendor,id:t,embed:`<iframe width="${n}" height="${p}" src="${r}" scrolling="no" frameborder="0" allowTransparency="true" allow="accelerometer; autoplay; clipboard-write; fullscreen; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>`,embedUrl:r,url:o,width:n,height:p}},parseVideo(e,t){let o=!1;return a.vendors.forEach((i=>{if(!o){const r=e.match(i.pattern),n=!(!r||!r[i.patternIndex])&&r[i.patternIndex];n&&(o=i.embedCallback?i.embedCallback(e,r,t):a.embedCallback(i,n,e,r))}})),o||(o=a.embedCallback({vendor:"unknown",embedUrl:e},e,e,!1)),o},parseItem(e){let t=!1;const o=e&&e.querySelector(".vp-portfolio__item-popup");return o&&(t={$dataElement:o,$content:o,data:o.dataset},n&&"TEMPLATE"===o.nodeName&&o.content&&(t.$content=o.content),t.$title=t?.$content?.querySelector(".vp-portfolio__item-popup-title"),t.$description=t?.$content?.querySelector(".vp-portfolio__item-popup-description")),t},parseGallery(e){const t=[];let o,i,r,n;return e.find(".vp-portfolio__item-wrap:not(.swiper-slide-duplicate)").each((function(){const e=a.parseItem(this);if(e){if(o=(e?.data?.vpPopupImgSize||"1920x1080").split("x"),r=e?.data?.vpPopupVideo,n=!1,r&&(n=a.parseVideo(r,e?.data?.vpPopupPoster)),n)i={type:"embed",el:this,poster:n.poster,src:n.embedUrl,embed:n.embed,width:n.width||1920,height:n.height||1080};else{i={type:"image",el:this,src:e?.data?.vpPopupImg,srcset:e?.data?.vpPopupImgSrcset,width:parseInt(o[0],10),height:parseInt(o[1],10)};const t=e?.data?.vpPopupSmImg||i.src;if(t){const o=(e?.data?.vpPopupSmImgSize||e?.data?.vpPopupImgSize||"1920x1080").split("x");i.srcSmall=t,i.srcSmallWidth=parseInt(o[0],10),i.srcSmallHeight=parseInt(o[1],10)}const r=e?.data?.vpPopupMdImg||i.src;if(r){const t=(e?.data?.vpPopupMdImgSize||e?.data?.vpPopupImgSize||"1920x1080").split("x");i.srcMedium=r,i.srcMediumWidth=parseInt(t[0],10),i.srcMediumHeight=parseInt(t[1],10)}