init
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
define(['jquery'], function ($) {
|
||||
'use strict';
|
||||
|
||||
return function (Widget) {
|
||||
Widget = Widget || ($.mage && $.mage.productVideoLoader);
|
||||
|
||||
if (!Widget || !Widget.prototype || Widget.prototype._esunHtml5VideoPatched) {
|
||||
return Widget;
|
||||
}
|
||||
|
||||
var originalCreate = Widget.prototype._create;
|
||||
Widget.prototype._esunHtml5VideoPatched = true;
|
||||
|
||||
Widget.prototype._create = function () {
|
||||
var video;
|
||||
if (this.element.data('type') !== 'html5') {
|
||||
return originalCreate.apply(this, arguments);
|
||||
}
|
||||
video = $('<video controls autoplay playsinline></video>').attr('src', this.element.data('code'));
|
||||
if (this.element.data('loop')) {
|
||||
video.attr('loop', 'loop');
|
||||
}
|
||||
this.element.empty().append(video).addClass('responsive');
|
||||
this.element.closest('.fotorama__stage__frame').addClass('fotorama__product-video--loaded');
|
||||
this._player = {
|
||||
play: function () { video.get(0).play(); },
|
||||
pause: function () { video.get(0).pause(); },
|
||||
stop: function () { video.get(0).pause(); video.get(0).currentTime = 0; },
|
||||
playing: function () { return !video.get(0).paused; }
|
||||
};
|
||||
};
|
||||
return Widget;
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user