Commit 3e9dd6b6 authored by marcheing's avatar marcheing

Add videojs share button javascript files

parent 3c332c43
((vjs) ->
# define some reasonable defaults
defaults = {
destination: '#',
id: '0',
title: ''
}
# plugin initializer
shareButton = (options) ->
settings = videojs.mergeOptions(defaults, options)
player = @
link = document.createElement("a")
share_translation = $('input[name=share_translation]').val()
share_instructions_translation = $('input[name=share_instructions_translation]').val()
link.id = "vjs-share-button-image-destination"
link.className += "vjs-control-bar"
link.target = "_self"
link.innerHTML += '<span data-tooltip aria-haspopup="true" class="has-tip left ic-share" data-disable-hover="false" tabindex=1 title="'+ share_translation + '" onClick="document.getElementById(\'share-box-video-'+settings.id+'\').style.display=\'block\';this.blur();"></span>'
shareBox = document.createElement('div')
shareBox.id = "share-box-video-"+settings.id
shareBox.className = "vjs-share-box"
shareBox.innerHTML += '<div class="share-links-group">'+
'<h3>' + share_translation + '</h3>'+
'<a class="share-facebook fa-stack fa-1x" target="_blank" href="javascript:window.open(%22http://www.facebook.com/sharer.php?u=%22+encodeURIComponent(%22'+settings.destination+'%22)+%22&#38;t=%22+encodeURIComponent(%22'+settings.title+'%22))" title="Facebook">'+
'<i class="fa fa-square fa-stack-2x"></i>'+
'<i class="fa fa-facebook fa-stack-1x fa-inverse"></i>'+
'</a>'+
'<a class="share-twitter fa-stack fa-1x" target="_blank" href="javascript:window.open(%22https://twitter.com/share?url=%22+encodeURIComponent(%22'+settings.destination+'%22)+%22&text=%22+encodeURIComponent(%22'+settings.title+'%22))" title="Twitter">'+
'<i class="fa fa-square fa-stack-2x"></i>'+
'<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>'+
'</a>'+
'<a class="share-google-plus fa-stack fa-1x" target="_blank" href="javascript:window.open(%22https://plus.google.com/share?url=%22+encodeURIComponent(%22'+settings.destination+'%22))" title="Google +">'+
'<i class="fa fa-square fa-stack-2x"></i>'+
'<i class="fa fa-google-plus fa-stack-1x fa-inverse"></i>'+
'<a onClick="document.getElementById(\'share-link-modal-video-'+settings.id+'\').style.display=\'block\';" class="fa-stack fa-1x">'+
'<i class="fa fa-square fa-stack-2x"></i>'+
'<i class="fa fa-link fa-stack-1x fa-inverse"></i>'+
'</a>'+
'<div class="share-link-modal" id="share-link-modal-video-'+settings.id+'">'+
'<p>' + share_instructions_translation + '</p>'+
'<input type="text" value="'+settings.destination+'">'+
'<button class="close-button" aria-label="Close modal" type="button" onClick="document.getElementById(\'share-link-modal-video-'+settings.id+'\').style.display=\'none\';">'+
'<span aria-hidden="true">&times;</span>'+
'</button>'+
'</div>'+
'<button class="close-button" aria-label="Close modal" type="button" onClick="document.getElementById(\'share-box-video-'+settings.id+'\').style.display=\'none\';">'+
'<span aria-hidden="true">&times;</span>'+
'</button>'+
'</div>'
player.el().appendChild(link)
player.el().appendChild(shareBox)
@loadImage = (src) ->
$('#vjs-share-button-image').src = src
@setDestination = (href) ->
$('#vjs-share-button-image-destination').href = href
@
# register the plugin with video.js
vjs.plugin('shareButton', shareButton)
$(document).ready ->
$('div[id^=video]').each((index, el) ->
video = videojs(el.id)
video.shareButton({id: el.id, destination: $('#video_link').val()})
)
) videojs
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment