diff --git a/vendor/magento/module-product-video/view/frontend/requirejs-config.js b/vendor/magento/module-product-video/view/frontend/requirejs-config.js index 17710d2c023..145cce768ed 100644 --- a/vendor/magento/module-product-video/view/frontend/requirejs-config.js +++ b/vendor/magento/module-product-video/view/frontend/requirejs-config.js @@ -7,10 +7,14 @@ var config = { map: { '*': { loadPlayer: 'Magento_ProductVideo/js/load-player', - fotoramaVideoEvents: 'Magento_ProductVideo/js/fotorama-add-video-events' + fotoramaVideoEvents: 'Magento_ProductVideo/js/fotorama-add-video-events', + 'vimeoWrapper': 'vimeo/vimeo-wrapper' } }, shim: { - vimeoAPI: {} + vimeoAPI: {}, + 'Magento_ProductVideo/js/load-player': { + deps: ['vimeoWrapper'] + } } }; diff --git a/vendor/magento/module-product-video/view/frontend/web/js/fotorama-add-video-events.js b/vendor/magento/module-product-video/view/frontend/web/js/fotorama-add-video-events.js index 151c5196db2..a37d2fd56c3 100644 --- a/vendor/magento/module-product-video/view/frontend/web/js/fotorama-add-video-events.js +++ b/vendor/magento/module-product-video/view/frontend/web/js/fotorama-add-video-events.js @@ -100,8 +100,7 @@ define([ videoData: '', videoSettings: '', optionsVideoData: '', - dataMergeStrategy: 'replace', - vimeoJSFrameworkLoaded: false + dataMergeStrategy: 'replace' }, /** @@ -163,7 +162,6 @@ define([ if (this._checkForVideoExist()) { this._checkFullscreen(); this._listenForFullscreen(); - this._checkForVimeo(); this._isVideoBase(); this._initFotoramaVideo(); this._attachFotoramaEvents(); @@ -396,27 +394,6 @@ define([ return checker; }, - /** - * - * @private - */ - _checkForVimeo: function () { - var allVideoData = this.options.videoData, - videoItem; - - if (window.Froogaloop) { // prevent duplicated initialization - return; - } - - for (videoItem in allVideoData) { - if (allVideoData[videoItem].provider === this.VI) { - this._loadVimeoJSFramework(); - - return; - } - } - }, - /** * * @private @@ -448,27 +425,6 @@ define([ } }, - /** - * - * @private - */ - _loadVimeoJSFramework: function () { - var element = document.createElement('script'), - scriptTag = document.getElementsByTagName('script')[0]; - - element.async = true; - element.src = 'https://f.vimeocdn.com/js/froogaloop2.min.js'; - - /** - * Vimeo js framework on load callback. - */ - element.onload = function () { - this.onVimeoJSFramework(); - this.vimeoJSFrameworkLoaded = true; - }.bind(this); - scriptTag.parentNode.insertBefore(element, scriptTag); - }, - /** * * @param {Event} e @@ -708,7 +664,7 @@ define([ $(event.target).removeClass(this.VU); type = $(event.target).find('.' + this.PV).data('type'); - if (this.vimeoJSFrameworkLoaded && type === this.VI) { + if (type === this.VI) { $(event.target).find('.' + this.PV).productVideoLoader(); } else if (type === this.VI) { this._showLoader(); @@ -732,8 +688,7 @@ define([ * @private */ _handleBaseVideo: function (fotorama, srcNumber) { - var waitForFroogaloop, - videoData = this.options.videoData, + var videoData = this.options.videoData, activeIndex = fotorama.activeIndex, number = parseInt(srcNumber, 10), activeIndexIsBase = videoData[activeIndex]; @@ -743,22 +698,11 @@ define([ } if (activeIndexIsBase && number === 1 && $(window).width() > this.MobileMaxWidth) { - if (this.options.videoData[fotorama.activeIndex].provider === this.VI) { - waitForFroogaloop = setInterval($.proxy(function () { - if (window.Froogaloop) { - clearInterval(waitForFroogaloop); - fotorama.requestFullScreen(); - this.fotoramaItem.data('fotorama').activeFrame.$stageFrame[0].click(); - this.Base = false; - } - }, this), 50); - } else { //if not a vimeo - play it immediately with a little lag in case for fotorama fullscreen - setTimeout($.proxy(function () { - fotorama.requestFullScreen(); - this.fotoramaItem.data('fotorama').activeFrame.$stageFrame[0].click(); - this.Base = false; - }, this), 50); - } + setTimeout($.proxy(function () { + fotorama.requestFullScreen(); + this.fotoramaItem.data('fotorama').activeFrame.$stageFrame[0].trigger('click'); + this.Base = false; + }, this), 50); } }, diff --git a/vendor/magento/module-product-video/view/frontend/web/js/load-player.js b/vendor/magento/module-product-video/view/frontend/web/js/load-player.js index aead9510434..6ec719bf8ba 100644 --- a/vendor/magento/module-product-video/view/frontend/web/js/load-player.js +++ b/vendor/magento/module-product-video/view/frontend/web/js/load-player.js @@ -9,7 +9,8 @@ */ define([ 'jquery', - 'jquery-ui-modules/widget' + 'jquery-ui-modules/widget', + 'vimeoWrapper' ], function ($) { 'use strict'; @@ -315,7 +316,8 @@ define([ _create: function () { var timestamp, additionalParams = '', - src; + src, + id; this._initialize(); timestamp = new Date().getTime(); @@ -333,10 +335,11 @@ define([ this._code + timestamp + additionalParams; + id = 'vimeo' + this._code + timestamp; this.element.append( $('