rizzo-next
Version:
The next generation of Lonely Planet's style guide and pattern library.
120 lines (94 loc) • 4.8 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _video_player = require("./video_player");
var _video_player2 = _interopRequireDefault(_video_player);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var File = function (_VideoPlayer) {
_inherits(File, _VideoPlayer);
function File() {
_classCallCheck(this, File);
return _possibleConstructorReturn(this, (File.__proto__ || Object.getPrototypeOf(File)).apply(this, arguments));
}
_createClass(File, [{
key: "initialize",
value: function initialize(options) {
this.player = null;
_get(File.prototype.__proto__ || Object.getPrototypeOf(File.prototype), "initialize", this).call(this, options);
}
}, {
key: "setup",
value: function setup() {
var _this2 = this;
if (this.videoId) {
var html = "<video preload='auto' src='" + this.videoId + "' ";
if (this.cover) {
html += "class='video__cover' ";
}
if (this.controls) {
html += "controls ";
}
if (this.muted) {
html += "muted ";
}
if (this.playsInline) {
html += "playsinline webkit-playsinline ";
}
if (this.autoplay) {
html += "autoplay ";
}
if (this.poster) {
html += "poster='" + this.poster + "' ";
}
html += "></video>";
this.$el.html(html);
if (this.cover) {
this.$el.addClass("video__cover--container");
}
this.player = this.el.getElementsByTagName("video")[0];
this.player.onplaying = function () {
_this2.trigger("started");
};
this.player.onended = function () {
_this2.trigger("ended");
};
}
_get(File.prototype.__proto__ || Object.getPrototypeOf(File.prototype), "setup", this).call(this);
}
}, {
key: "play",
value: function play() {
_get(File.prototype.__proto__ || Object.getPrototypeOf(File.prototype), "play", this).call(this);
if (this.player) {
var promise = this.player.play();
if (promise) {
promise.catch(function (reason) {
return console.log("VIDEOJS:", reason);
}).then(function () {});
}
}
}
}, {
key: "pause",
value: function pause() {
_get(File.prototype.__proto__ || Object.getPrototypeOf(File.prototype), "pause", this).call(this);
if (this.player) {
this.player.pause();
}
}
}, {
key: "dispose",
value: function dispose() {
this.$el.html("");
_get(File.prototype.__proto__ || Object.getPrototypeOf(File.prototype), "dispose", this).call(this);
}
}]);
return File;
}(_video_player2.default);
exports.default = File;