balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

video.509fb0e07b97e0f603d7.bundle.js (6634B)


      1 /*! elementor - v3.4.4 - 13-09-2021 */
      2 (self["webpackChunkelementor"] = self["webpackChunkelementor"] || []).push([["video"],{
      3 
      4 /***/ "../assets/dev/js/frontend/handlers/video.js":
      5 /*!***************************************************!*\
      6   !*** ../assets/dev/js/frontend/handlers/video.js ***!
      7   \***************************************************/
      8 /***/ ((__unused_webpack_module, exports) => {
      9 
     10 "use strict";
     11 
     12 
     13 Object.defineProperty(exports, "__esModule", ({
     14   value: true
     15 }));
     16 exports.default = void 0;
     17 
     18 class Video extends elementorModules.frontend.handlers.Base {
     19   getDefaultSettings() {
     20     return {
     21       selectors: {
     22         imageOverlay: '.elementor-custom-embed-image-overlay',
     23         video: '.elementor-video',
     24         videoIframe: '.elementor-video-iframe'
     25       }
     26     };
     27   }
     28 
     29   getDefaultElements() {
     30     const selectors = this.getSettings('selectors');
     31     return {
     32       $imageOverlay: this.$element.find(selectors.imageOverlay),
     33       $video: this.$element.find(selectors.video),
     34       $videoIframe: this.$element.find(selectors.videoIframe)
     35     };
     36   }
     37 
     38   handleVideo() {
     39     if (this.getElementSettings('lightbox')) {
     40       return;
     41     }
     42 
     43     if ('youtube' === this.getElementSettings('video_type')) {
     44       this.apiProvider.onApiReady(apiObject => {
     45         this.elements.$imageOverlay.remove();
     46         this.prepareYTVideo(apiObject, true);
     47       });
     48     } else {
     49       this.elements.$imageOverlay.remove();
     50       this.playVideo();
     51     }
     52   }
     53 
     54   playVideo() {
     55     if (this.elements.$video.length) {
     56       // this.youtubePlayer exists only for YouTube videos, and its play function is different.
     57       if (this.youtubePlayer) {
     58         this.youtubePlayer.playVideo();
     59       } else {
     60         this.elements.$video[0].play();
     61       }
     62 
     63       return;
     64     }
     65 
     66     const $videoIframe = this.elements.$videoIframe,
     67           lazyLoad = $videoIframe.data('lazy-load');
     68 
     69     if (lazyLoad) {
     70       $videoIframe.attr('src', lazyLoad);
     71     }
     72 
     73     $videoIframe[0].src = this.apiProvider.getAutoplayURL($videoIframe[0].src);
     74   }
     75 
     76   async animateVideo() {
     77     const lightbox = await elementorFrontend.utils.lightbox;
     78     lightbox.setEntranceAnimation(this.getCurrentDeviceSetting('lightbox_content_animation'));
     79   }
     80 
     81   async handleAspectRatio() {
     82     const lightbox = await elementorFrontend.utils.lightbox;
     83     lightbox.setVideoAspectRatio(this.getElementSettings('aspect_ratio'));
     84   }
     85 
     86   async hideLightbox() {
     87     const lightbox = await elementorFrontend.utils.lightbox;
     88     lightbox.getModal().hide();
     89   }
     90 
     91   prepareYTVideo(YT, onOverlayClick) {
     92     const elementSettings = this.getElementSettings(),
     93           playerOptions = {
     94       videoId: this.videoID,
     95       events: {
     96         onReady: () => {
     97           if (elementSettings.mute) {
     98             this.youtubePlayer.mute();
     99           }
    100 
    101           if (elementSettings.autoplay || onOverlayClick) {
    102             this.youtubePlayer.playVideo();
    103           }
    104         },
    105         onStateChange: event => {
    106           if (event.data === YT.PlayerState.ENDED && elementSettings.loop) {
    107             this.youtubePlayer.seekTo(elementSettings.start || 0);
    108           }
    109         }
    110       },
    111       playerVars: {
    112         controls: elementSettings.controls ? 1 : 0,
    113         rel: elementSettings.rel ? 1 : 0,
    114         playsinline: elementSettings.play_on_mobile ? 1 : 0,
    115         modestbranding: elementSettings.modestbranding ? 1 : 0,
    116         autoplay: elementSettings.autoplay ? 1 : 0,
    117         start: elementSettings.start,
    118         end: elementSettings.end
    119       }
    120     }; // To handle CORS issues, when the default host is changed, the origin parameter has to be set.
    121 
    122     if (elementSettings.yt_privacy) {
    123       playerOptions.host = 'https://www.youtube-nocookie.com';
    124       playerOptions.origin = window.location.hostname;
    125     }
    126 
    127     this.youtubePlayer = new YT.Player(this.elements.$video[0], playerOptions);
    128   }
    129 
    130   bindEvents() {
    131     this.elements.$imageOverlay.on('click', this.handleVideo.bind(this));
    132   }
    133 
    134   onInit() {
    135     super.onInit();
    136     const elementSettings = this.getElementSettings();
    137 
    138     if (elementorFrontend.utils[elementSettings.video_type]) {
    139       this.apiProvider = elementorFrontend.utils[elementSettings.video_type];
    140     } else {
    141       this.apiProvider = elementorFrontend.utils.baseVideoLoader;
    142     }
    143 
    144     if ('youtube' !== elementSettings.video_type) {
    145       // Currently the only API integration in the Video widget is for the YT API
    146       return;
    147     }
    148 
    149     this.videoID = this.apiProvider.getVideoIDFromURL(elementSettings.youtube_url); // If there is an image overlay, the YouTube video prep method will be triggered on click
    150 
    151     if (!this.videoID) {
    152       return;
    153     } // If the user is using an image overlay, loading the API happens on overlay click instead of on init.
    154 
    155 
    156     if (elementSettings.show_image_overlay && elementSettings.image_overlay.url) {
    157       return;
    158     }
    159 
    160     if (elementSettings.lazy_load) {
    161       this.intersectionObserver = elementorModules.utils.Scroll.scrollObserver({
    162         callback: event => {
    163           if (event.isInViewport) {
    164             this.intersectionObserver.unobserve(this.elements.$video.parent()[0]);
    165             this.apiProvider.onApiReady(apiObject => this.prepareYTVideo(apiObject));
    166           }
    167         }
    168       }); // We observe the parent, since the video container has a height of 0.
    169 
    170       this.intersectionObserver.observe(this.elements.$video.parent()[0]);
    171       return;
    172     } // When Optimized asset loading is set to off, the video type is set to 'Youtube', and 'Privacy Mode' is set
    173     // to 'On', there might be a conflict with other videos that are loaded WITHOUT privacy mode, such as a
    174     // video bBackground in a section. In these cases, to avoid the conflict, a timeout is added to postpone the
    175     // initialization of the Youtube API object.
    176 
    177 
    178     if (!elementorFrontend.config.experimentalFeatures['e_optimized_assets_loading']) {
    179       setTimeout(() => {
    180         this.apiProvider.onApiReady(apiObject => this.prepareYTVideo(apiObject));
    181       }, 0);
    182     } else {
    183       this.apiProvider.onApiReady(apiObject => this.prepareYTVideo(apiObject));
    184     }
    185   }
    186 
    187   onElementChange(propertyName) {
    188     if (0 === propertyName.indexOf('lightbox_content_animation')) {
    189       this.animateVideo();
    190       return;
    191     }
    192 
    193     const isLightBoxEnabled = this.getElementSettings('lightbox');
    194 
    195     if ('lightbox' === propertyName && !isLightBoxEnabled) {
    196       this.hideLightbox();
    197       return;
    198     }
    199 
    200     if ('aspect_ratio' === propertyName && isLightBoxEnabled) {
    201       this.handleAspectRatio();
    202     }
    203   }
    204 
    205 }
    206 
    207 exports.default = Video;
    208 
    209 /***/ })
    210 
    211 }]);
    212 //# sourceMappingURL=video.509fb0e07b97e0f603d7.bundle.js.map