Last active
October 12, 2020 03:29
-
-
Save HoundstoothSTL/5631366 to your computer and use it in GitHub Desktop.
Revisions
-
HoundstoothSTL revised this gist
May 22, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ <!-- usage in HTML --> <div id="testVideo2" data-video="58834399" data-js="embedTrigger"> <img src="http://placehold.it/640x400"> <!-- Uses placeholder image --> </div> -
HoundstoothSTL revised this gist
May 22, 2013 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ <!-- usage in HTML --> <div id="testVideo2" data-video="58834399" data-js="embedTrigger"> <img src="http://placehold.it/640x350"> <!-- Uses placeholder image --> </div> -
HoundstoothSTL created this gist
May 22, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ var Embed = { config : { elementId : 'embed', trigger: document.querySelectorAll('[data-js="embedTrigger"]'), videoId : 7100569, autoplay : true, vidWidth: 640, vidHeight: 400 }, trigger : function() { // Move trigger here if wanted }, put : function(video) { var el = document.getElementById(this.config.elementId); el.innerHTML = unescape(video.html); }, init : function(options) { if( typeof options === "object" ) { this.config = options; } var js = document.createElement('script'), callback = 'Embed.put', endpoint = 'http://www.vimeo.com/api/oembed.json', videoUrl = encodeURIComponent("http://www.vimeo.com/" + this.config.videoId), w = this.config.vidWidth, h = this.config.vidHeight, autoplay = this.config.autoplay, url = endpoint + '?url=' + videoUrl + '&width=' + w + '&autoplay=' + autoplay + '&callback=' + callback; js.setAttribute('type', 'text/javascript'); js.setAttribute('src', url); js.setAttribute('async', true); document.getElementsByTagName('head').item(0).appendChild(js); } }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ /* --- Just your general app file --*/ (function(){ var triggers = document.querySelectorAll('[data-js="embedTrigger"]'); [].forEach.call( triggers, function(element) { element.addEventListener('click', function() { Embed.init({ elementId: this.id, videoId : this.getAttribute('data-video'), autoplay : true, vidWidth: 640, vidHeight: 400 }); }, false); }); }());