Skip to content

Commit c4cd16b

Browse files
committed
Quick fix for set() method
1 parent a3745fa commit c4cd16b

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

index.html

+3-13
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,16 @@
1313
</video>
1414
<ul>
1515
<li><a href="test/">Run unit tests in browser.</a></li>
16-
16+
1717
</ul>
18-
18+
1919
<script src="node_modules/video.js/dist/video.js"></script>
2020
<script src="dist/videojs-social-share-overlay.js"></script>
2121
<script>
2222
(function(window, videojs) {
2323
var player = window.player = videojs('videojs-social-share-overlay-player');
24-
player.socialShareOverlay({
25-
url: 'https://google.com/extra-long-url-with/wrap-that-should-be-cut-off-by-elipsis/page-1',
26-
image: 'http://lorempixel.com/g/800/800',
27-
title: 'Shared Video Title',
28-
description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
29-
platforms: ['twitter','facebook','email','link'],
30-
emailBody: "Check this out on github.com:",
31-
via: 'wwe'
32-
});
24+
player.socialShareOverlay();
3325
player.on('ended', function(){
34-
35-
console.log('firing');
3626
player.socialShareOverlay.set({
3727
url: 'https://google.com/2',
3828
image: 'http://lorempixel.com/g/800/800',

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "videojs-social-share-overlay",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "Social share overlay for videojs",
55
"main": "dist/videojs-social-share-overlay.cjs.js",
66
"module": "dist/videojs-social-share-overlay.es.js",

src/plugin.js

+14-9
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ class SocialShareOverlayPlugin {
7474
const concreteButtonInstance = player.controlBar.addChild(this._socialShareButton, {componentClass: 'socialShare'}, placementIndex)
7575
concreteButtonInstance.addClass('vjs-social-share')
7676
concreteButtonInstance.addClass('vjs-icon-share')
77-
concreteButtonInstance.removeClass('vjs-hidden')
77+
if(!this.options.url) {
78+
concreteButtonInstance.addClass('vjs-hidden')
79+
}
7880

81+
if(!this.shareOverlayEl) {
82+
this.createOverlayEl();
83+
}
84+
this.populateShareOverlay();
7985
};
8086

8187
createOverlayEl () {
@@ -124,13 +130,17 @@ class SocialShareOverlayPlugin {
124130

125131
set(config){
126132
this.options = config;
127-
this.populateShareOverlay;
133+
this.populateShareOverlay();
128134
}
129135

130136
populateShareOverlay () {
131137
if(!this.shareOverlayEl) {
132138
return;
133139
}
140+
if(!this.options.url) {
141+
return this._socialShareButton.addClass('vjs-hidden');
142+
}
143+
this._socialShareButton.removeClass('vjs-hidden');
134144
const title = this.shareOverlayEl.querySelector('.vjs-share-overlay-title')
135145
const desc = this.shareOverlayEl.querySelector('.vjs-share-overlay-description')
136146
const link = this.shareOverlayEl.querySelector('.vjs-share-overlay-link')
@@ -152,10 +162,6 @@ class SocialShareOverlayPlugin {
152162
}
153163

154164
showShareOverlay() {
155-
if(!this.shareOverlayEl) {
156-
this.createOverlayEl();
157-
}
158-
this.populateShareOverlay();
159165
this.onSharePausedState = this.player.paused();
160166
this.player.pause();
161167
this.player.addClass("vjs-social-share-overlay-open");
@@ -207,8 +213,7 @@ class SocialShareOverlayPlugin {
207213

208214
attachClipboard (){
209215
if(typeof Clipboard !== 'undefined') {
210-
let clip = new Clipboard('.vjs-share-overlay-button.copy-link');
211-
console.log('attached', clip);
216+
new Clipboard('.vjs-share-overlay-button.copy-link');
212217
}
213218
}
214219

@@ -222,7 +227,7 @@ class SocialShareOverlayPlugin {
222227
}
223228

224229

225-
getTwitterShareLink (title, url){
230+
getTwitterShareLink (title, url){
226231

227232
const link = 'https://twitter.com/intent/tweet?';
228233

0 commit comments

Comments
 (0)