Skip to content

Commit c7372f6

Browse files
MAGETWO-69690: Add froogaloop library as a dependency to load-player module #9690
1 parent 97466b6 commit c7372f6

File tree

4 files changed

+54
-11
lines changed

4 files changed

+54
-11
lines changed

app/code/Magento/ProductVideo/view/frontend/requirejs-config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ var config = {
77
map: {
88
'*': {
99
loadPlayer: 'Magento_ProductVideo/js/load-player',
10-
fotoramaVideoEvents: 'Magento_ProductVideo/js/fotorama-add-video-events',
11-
vimeoAPI: 'https://secure-a.vimeocdn.com/js/froogaloop2.min.js'
10+
fotoramaVideoEvents: 'Magento_ProductVideo/js/fotorama-add-video-events'
1211
}
1312
},
1413
shim: {

app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,20 @@ define([
9494
options: {
9595
videoData: '',
9696
videoSettings: '',
97-
optionsVideoData: ''
97+
optionsVideoData: '',
98+
vimeoJSFrameworkLoaded: false
9899
},
99-
100+
onVimeoJSFramework: function () {},
100101
PV: 'product-video', // [CONST]
101102
VU: 'video-unplayed',
102103
PVLOADED: 'fotorama__product-video--loaded', // [CONST]
104+
PVLOADING: 'fotorama__product-video--loading', // [CONST]
103105
VID: 'video', // [CONST]
104106
VI: 'vimeo', // [CONST]
105107
FTVC: 'fotorama__video-close',
106108
FTAR: 'fotorama__arr',
109+
fotoramaSpinner: 'fotorama__spinner',
110+
fotoramaSpinnerShow: 'fotorama__spinner--show',
107111
TI: 'video-thumb-icon',
108112
isFullscreen: false,
109113
FTCF: '[data-gallery-role="fotorama__fullscreen-icon"]',
@@ -147,7 +151,6 @@ define([
147151
* @private
148152
*/
149153
_setOptions: function (options) {
150-
151154
if (options.videoData && options.videoData.length) {
152155
this.options.videoData = options.videoData;
153156
}
@@ -402,6 +405,14 @@ define([
402405

403406
element.async = true;
404407
element.src = 'https://secure-a.vimeocdn.com/js/froogaloop2.min.js';
408+
409+
/**
410+
* Vimeo js framework on load callback.
411+
*/
412+
element.onload = function () {
413+
this.onVimeoJSFramework();
414+
this.vimeoJSFrameworkLoaded = true;
415+
}.bind(this);
405416
scriptTag.parentNode.insertBefore(element, scriptTag);
406417
},
407418

@@ -620,15 +631,41 @@ define([
620631
},
621632

622633
/**
623-
*
624-
* @param {Event} event
625634
* @private
626635
*/
627-
_clickHandler: function (event) {
628-
if ($(event.target).hasClass(this.VU) && $(event.target).find('iframe').length === 0) {
636+
_showLoader: function () {
637+
var spinner = this.fotoramaItem.find('.' + this.fotoramaSpinner);
638+
639+
spinner.addClass(this.fotoramaSpinnerShow);
640+
this.fotoramaItem.data('fotorama').activeFrame.$stageFrame.addClass(this.PVLOADING);
641+
},
642+
643+
/**
644+
* @private
645+
*/
646+
_hideLoader: function () {
647+
var spinner = this.fotoramaItem.find('.' + this.fotoramaSpinner);
648+
649+
spinner.removeClass(this.fotoramaSpinnerShow);
650+
this.fotoramaItem.data('fotorama').activeFrame.$stageFrame.removeClass(this.PVLOADING);
651+
},
629652

653+
/**
654+
* @param {Event} event
655+
* @private
656+
*/
657+
_clickHandler: function (event) {if ($(event.target).hasClass(this.VU) && $(event.target).find('iframe').length === 0) {
630658
$(event.target).removeClass(this.VU);
631-
$(event.target).find('.' + this.PV).productVideoLoader();
659+
660+
if (this.vimeoJSFrameworkLoaded) {
661+
$(event.target).find('.' + this.PV).productVideoLoader();
662+
} else {
663+
this._showLoader();
664+
this.onVimeoJSFramework = function () {
665+
$(event.target).find('.' + this.PV).productVideoLoader();
666+
this._hideLoader();
667+
}.bind(this);
668+
}
632669

633670
$('.' + this.FTAR).addClass(this.isFullscreen ? 'fotorama__arr--shown' : 'fotorama__arr--hidden');
634671
}
@@ -686,6 +723,7 @@ define([
686723
}
687724

688725
$wrapper.find('.' + this.PVLOADED).removeClass(this.PVLOADED);
726+
this._hideLoader();
689727

690728
$wrapper.find('.' + this.PV).each(function () {
691729
var $item = $(this).parent(),

app/code/Magento/ProductVideo/view/frontend/web/js/load-player.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@version 0.0.1
88
@requires jQuery & jQuery UI
99
*/
10-
define(['jquery', 'jquery/ui', 'vimeoAPI'], function ($) {
10+
define(['jquery', 'jquery/ui'], function ($) {
1111
'use strict';
1212

1313
var videoRegister = {

app/design/frontend/Magento/blank/Magento_ProductVideo/web/css/source/_module.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@
8383
top: 12px;
8484
width: 100px;
8585
}
86+
87+
.fotorama__product-video--loading {
88+
&:after {
89+
visibility: hidden;
90+
}
91+
}
8692
}
8793

8894
//

0 commit comments

Comments
 (0)