aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/media.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2018-06-18 21:41:25 +1000
committerSam Potts <sam@potts.es>2018-06-18 21:41:25 +1000
commitcc3c0b54484e6f5a7b4dba8a36a44f345e462f26 (patch)
tree5fe2838546d9f981b21572dee88ee7a1c3195477 /src/js/media.js
parent4811e3333f1417bc9e14f6cc38afc789e9051c4c (diff)
parent3c9c1b4cdcd0eb9076c3f0bafbabb057ee140c42 (diff)
downloadplyr-cc3c0b54484e6f5a7b4dba8a36a44f345e462f26.tar.lz
plyr-cc3c0b54484e6f5a7b4dba8a36a44f345e462f26.tar.xz
plyr-cc3c0b54484e6f5a7b4dba8a36a44f345e462f26.zip
Merge branch 'develop'
Diffstat (limited to 'src/js/media.js')
-rw-r--r--src/js/media.js33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/js/media.js b/src/js/media.js
index f10bea1f..eb37d441 100644
--- a/src/js/media.js
+++ b/src/js/media.js
@@ -5,7 +5,7 @@
import html5 from './html5';
import vimeo from './plugins/vimeo';
import youtube from './plugins/youtube';
-import utils from './utils';
+import { createElement, toggleClass, wrap } from './utils/elements';
const media = {
// Setup media
@@ -17,50 +17,41 @@ const media = {
}
// Add type class
- utils.toggleClass(this.elements.container, this.config.classNames.type.replace('{0}', this.type), true);
+ toggleClass(this.elements.container, this.config.classNames.type.replace('{0}', this.type), true);
// Add provider class
- utils.toggleClass(this.elements.container, this.config.classNames.provider.replace('{0}', this.provider), true);
+ toggleClass(this.elements.container, this.config.classNames.provider.replace('{0}', this.provider), true);
// Add video class for embeds
// This will require changes if audio embeds are added
if (this.isEmbed) {
- utils.toggleClass(this.elements.container, this.config.classNames.type.replace('{0}', 'video'), true);
+ toggleClass(this.elements.container, this.config.classNames.type.replace('{0}', 'video'), true);
}
// Inject the player wrapper
if (this.isVideo) {
// Create the wrapper div
- this.elements.wrapper = utils.createElement('div', {
+ this.elements.wrapper = createElement('div', {
class: this.config.classNames.video,
});
// Wrap the video in a container
- utils.wrap(this.media, this.elements.wrapper);
+ wrap(this.media, this.elements.wrapper);
// Faux poster container
- this.elements.poster = utils.createElement('div', {
+ this.elements.poster = createElement('div', {
class: this.config.classNames.poster,
});
this.elements.wrapper.appendChild(this.elements.poster);
}
- if (this.isEmbed) {
- switch (this.provider) {
- case 'youtube':
- youtube.setup.call(this);
- break;
-
- case 'vimeo':
- vimeo.setup.call(this);
- break;
-
- default:
- break;
- }
- } else if (this.isHTML5) {
+ if (this.isHTML5) {
html5.extend.call(this);
+ } else if (this.isYouTube) {
+ youtube.setup.call(this);
+ } else if (this.isVimeo) {
+ vimeo.setup.call(this);
}
},
};