Commit 315dae02 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

Switch youtube embed to invidio.us

parent 90054835
......@@ -16,4 +16,4 @@
*
* This header is generated by licensify (https://github.com/twada/licensify)
*/
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.ModalVideo=e()}}(function(){return function e(t,n,o){function i(l,a){if(!n[l]){if(!t[l]){var u="function"==typeof require&&require;if(!a&&u)return u(l,!0);if(r)return r(l,!0);var d=new Error("Cannot find module '"+l+"'");throw d.code="MODULE_NOT_FOUND",d}var s=n[l]={exports:{}};t[l][0].call(s.exports,function(e){var n=t[l][1][e];return i(n||e)},s,s.exports,e,t,n,o)}return n[l].exports}for(var r="function"==typeof require&&require,l=0;l<o.length;l++)i(o[l]);return i}({1:[function(e,t,n){"use strict";function o(e,t){if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var n=Object(e),o=1;o<arguments.length;o++){var i=arguments[o];if(void 0!==i&&null!==i)for(var r=Object.keys(Object(i)),l=0,a=r.length;l<a;l++){var u=r[l],d=Object.getOwnPropertyDescriptor(i,u);void 0!==d&&d.enumerable&&(n[u]=i[u])}}return n}function i(){Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:o})}t.exports={assign:o,polyfill:i}},{}],2:[function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),r=e("../lib/util"),l=e("es6-object-assign").assign,a={channel:"youtube",youtube:{autoplay:1,cc_load_policy:1,color:null,controls:1,disablekb:0,enablejsapi:0,end:null,fs:1,h1:null,iv_load_policy:1,list:null,listType:null,loop:0,modestbranding:null,origin:null,playlist:null,playsinline:null,rel:0,showinfo:1,start:0,wmode:"transparent",theme:"dark"},ratio:"16:9",vimeo:{api:!1,autopause:!0,autoplay:!0,byline:!0,callback:null,color:null,height:null,loop:!1,maxheight:null,maxwidth:null,player_id:null,portrait:!0,title:!0,width:null,xhtml:!1},allowFullScreen:!0,animationSpeed:300,classNames:{modalVideo:"modal-video",modalVideoClose:"modal-video-close",modalVideoBody:"modal-video-body",modalVideoInner:"modal-video-inner",modalVideoIframeWrap:"modal-video-movie-wrap",modalVideoCloseBtn:"modal-video-close-btn"},aria:{openMessage:"You just openned the modal video",dismissBtnMessage:"Close the modal by clicking here"}},u=function(){function e(t,n){var i=this;o(this,e);var u=l({},a,n),d="string"==typeof t?document.querySelectorAll(t):t,s=document.querySelector("body"),c=u.classNames,f=u.animationSpeed;[].forEach.call(d,function(e){e.addEventListener("click",function(){var t=e.dataset.videoId,n=(0,r.getUniqId)(),o=i.getHtml(u,t,n);(0,r.append)(s,o);var l=document.querySelector("#"+n),a=l.querySelector(".js-modal-video-dismiss-btn");l.focus(),l.addEventListener("click",function(){(0,r.addClass)(l,c.modalVideoClose),setTimeout(function(){(0,r.remove)(l),e.focus()},f)}),l.addEventListener("keydown",function(e){9===e.which&&(e.preventDefault(),document.activeElement===l?a.focus():(l.setAttribute("aria-label",""),l.focus()))}),a.addEventListener("click",function(){(0,r.triggerEvent)(l,"click")})})})}return i(e,[{key:"getPadding",value:function(e){var t=e.split(":"),n=Number(t[0]);return 100*Number(t[1])/n+"%"}},{key:"getQueryString",value:function(e){var t="";return Object.keys(e).forEach(function(n){t+=n+"="+e[n]+"&"}),t.substr(0,t.length-1)}},{key:"getVideoUrl",value:function(e,t){return"youtube"===e.channel?this.getYoutubeUrl(e.youtube,t):"vimeo"===e.channel?this.getVimeoUrl(e.vimeo,t):""}},{key:"getVimeoUrl",value:function(e,t){return"//player.vimeo.com/video/"+t+"?"+this.getQueryString(e)}},{key:"getYoutubeUrl",value:function(e,t){return"//www.youtube.com/embed/"+t+"?"+this.getQueryString(e)}},{key:"getHtml",value:function(e,t,n){var o=this.getVideoUrl(e,t),i=this.getPadding(e.ratio),r=e.classNames;return'\n <div class="'+r.modalVideo+'" tabindex="-1" role="dialog" aria-label="'+e.aria.openMessage+'" id="'+n+'">\n <div class="'+r.modalVideoBody+'">\n <div class="'+r.modalVideoInner+'">\n <div class="'+r.modalVideoIframeWrap+'" style="padding-bottom:'+i+'">\n <button class="'+r.modalVideoCloseBtn+' js-modal-video-dismiss-btn" aria-label="'+e.aria.dismissBtnMessage+"\"></button>\n <iframe width='460' height='230' src=\""+o+"\" frameborder='0' allowfullscreen="+e.allowFullScreen+' tabindex="-1"/>\n </div>\n </div>\n </div>\n </div>\n '}}]),e}();n.default=u,t.exports=n.default},{"../lib/util":4,"es6-object-assign":1}],3:[function(e,t,n){"use strict";t.exports=e("./core/")},{"./core/":2}],4:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.append=function(e,t){var n=new DOMParser,o=n.parseFromString(t,"text/html");e.appendChild(o.querySelector("body").childNodes[0])},n.prepend=function(e,t){var n=new DOMParser,o=n.parseFromString(t,"text/html");e.insertBefore(o.querySelector("body").childNodes[0],e.firstChild)},n.getUniqId=function(){return(Date.now().toString(36)+Math.random().toString(36).substr(2,5)).toUpperCase()},n.remove=function(e){e&&e.parentNode&&e.parentNode.removeChild(e)},n.addClass=function(e,t){e.classList?e.classList.add(t):e.className+=" "+t},n.triggerEvent=function(e,t,n){var o=void 0;window.CustomEvent?o=new CustomEvent(t,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(t,!1,!1,n)),e.dispatchEvent(o)}},{}]},{},[3])(3)});
\ No newline at end of file
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.ModalVideo=e()}}(function(){return function e(t,n,o){function i(l,a){if(!n[l]){if(!t[l]){var u="function"==typeof require&&require;if(!a&&u)return u(l,!0);if(r)return r(l,!0);var d=new Error("Cannot find module '"+l+"'");throw d.code="MODULE_NOT_FOUND",d}var s=n[l]={exports:{}};t[l][0].call(s.exports,function(e){var n=t[l][1][e];return i(n||e)},s,s.exports,e,t,n,o)}return n[l].exports}for(var r="function"==typeof require&&require,l=0;l<o.length;l++)i(o[l]);return i}({1:[function(e,t,n){"use strict";function o(e,t){if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var n=Object(e),o=1;o<arguments.length;o++){var i=arguments[o];if(void 0!==i&&null!==i)for(var r=Object.keys(Object(i)),l=0,a=r.length;l<a;l++){var u=r[l],d=Object.getOwnPropertyDescriptor(i,u);void 0!==d&&d.enumerable&&(n[u]=i[u])}}return n}function i(){Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:o})}t.exports={assign:o,polyfill:i}},{}],2:[function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),r=e("../lib/util"),l=e("es6-object-assign").assign,a={channel:"youtube",youtube:{autoplay:1,cc_load_policy:1,color:null,controls:1,disablekb:0,enablejsapi:0,end:null,fs:1,h1:null,iv_load_policy:1,list:null,listType:null,loop:0,modestbranding:null,origin:null,playlist:null,playsinline:null,rel:0,showinfo:1,start:0,wmode:"transparent",theme:"dark"},ratio:"16:9",vimeo:{api:!1,autopause:!0,autoplay:!0,byline:!0,callback:null,color:null,height:null,loop:!1,maxheight:null,maxwidth:null,player_id:null,portrait:!0,title:!0,width:null,xhtml:!1},allowFullScreen:!0,animationSpeed:300,classNames:{modalVideo:"modal-video",modalVideoClose:"modal-video-close",modalVideoBody:"modal-video-body",modalVideoInner:"modal-video-inner",modalVideoIframeWrap:"modal-video-movie-wrap",modalVideoCloseBtn:"modal-video-close-btn"},aria:{openMessage:"You just openned the modal video",dismissBtnMessage:"Close the modal by clicking here"}},u=function(){function e(t,n){var i=this;o(this,e);var u=l({},a,n),d="string"==typeof t?document.querySelectorAll(t):t,s=document.querySelector("body"),c=u.classNames,f=u.animationSpeed;[].forEach.call(d,function(e){e.addEventListener("click",function(){var t=e.dataset.videoId,n=(0,r.getUniqId)(),o=i.getHtml(u,t,n);(0,r.append)(s,o);var l=document.querySelector("#"+n),a=l.querySelector(".js-modal-video-dismiss-btn");l.focus(),l.addEventListener("click",function(){(0,r.addClass)(l,c.modalVideoClose),setTimeout(function(){(0,r.remove)(l),e.focus()},f)}),l.addEventListener("keydown",function(e){9===e.which&&(e.preventDefault(),document.activeElement===l?a.focus():(l.setAttribute("aria-label",""),l.focus()))}),a.addEventListener("click",function(){(0,r.triggerEvent)(l,"click")})})})}return i(e,[{key:"getPadding",value:function(e){var t=e.split(":"),n=Number(t[0]);return 100*Number(t[1])/n+"%"}},{key:"getQueryString",value:function(e){var t="";return Object.keys(e).forEach(function(n){t+=n+"="+e[n]+"&"}),t.substr(0,t.length-1)}},{key:"getVideoUrl",value:function(e,t){return"youtube"===e.channel?this.getYoutubeUrl(e.youtube,t):"vimeo"===e.channel?this.getVimeoUrl(e.vimeo,t):""}},{key:"getVimeoUrl",value:function(e,t){return"//player.vimeo.com/video/"+t+"?"+this.getQueryString(e)}},{key:"getYoutubeUrl",value:function(e,t){return"//invidio.us/embed/"+t+"?"+this.getQueryString(e)}},{key:"getHtml",value:function(e,t,n){var o=this.getVideoUrl(e,t),i=this.getPadding(e.ratio),r=e.classNames;return'\n <div class="'+r.modalVideo+'" tabindex="-1" role="dialog" aria-label="'+e.aria.openMessage+'" id="'+n+'">\n <div class="'+r.modalVideoBody+'">\n <div class="'+r.modalVideoInner+'">\n <div class="'+r.modalVideoIframeWrap+'" style="padding-bottom:'+i+'">\n <button class="'+r.modalVideoCloseBtn+' js-modal-video-dismiss-btn" aria-label="'+e.aria.dismissBtnMessage+"\"></button>\n <iframe width='460' height='230' src=\""+o+"\" frameborder='0' allowfullscreen="+e.allowFullScreen+' tabindex="-1"/>\n </div>\n </div>\n </div>\n </div>\n '}}]),e}();n.default=u,t.exports=n.default},{"../lib/util":4,"es6-object-assign":1}],3:[function(e,t,n){"use strict";t.exports=e("./core/")},{"./core/":2}],4:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.append=function(e,t){var n=new DOMParser,o=n.parseFromString(t,"text/html");e.appendChild(o.querySelector("body").childNodes[0])},n.prepend=function(e,t){var n=new DOMParser,o=n.parseFromString(t,"text/html");e.insertBefore(o.querySelector("body").childNodes[0],e.firstChild)},n.getUniqId=function(){return(Date.now().toString(36)+Math.random().toString(36).substr(2,5)).toUpperCase()},n.remove=function(e){e&&e.parentNode&&e.parentNode.removeChild(e)},n.addClass=function(e,t){e.classList?e.classList.add(t):e.className+=" "+t},n.triggerEvent=function(e,t,n){var o=void 0;window.CustomEvent?o=new CustomEvent(t,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(t,!1,!1,n)),e.dispatchEvent(o)}},{}]},{},[3])(3)});
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