/*! * GRT Youtube Popup - jQuery Plugin * Version: 1.0 * Author: GRT107 * * Copyright (c) 2017 GRT107 * Released under the MIT license */ (function ( $ ) { $.fn.grtyoutube = function( options ) { return this.each(function() { // Get video ID var getvideoid = $(this).attr("youtubeid"); // Default options var settings = $.extend({ videoID: getvideoid, autoPlay: true, theme: "dark" }, options ); // Convert some values if(settings.autoPlay === true) { settings.autoPlay = 1 } else if(settings.autoPlay === false) { settings.autoPlay = 0 } if(settings.theme === "dark") { settings.theme = "grtyoutube-dark-theme" } else if(settings.theme === "light") { settings.theme = "grtyoutube-light-theme" } // Initialize on click if(getvideoid) { $(this).on( "click", function() { $("body").append('
'+ '
'+ ''+ ''+ '
'+ '
'); }); } // Close the box on click or escape $(this).on('click', function (event) { event.preventDefault(); $(".grtyoutube-popup-close, .grtyoutube-popup").click(function(){ $(".grtyoutube-popup").remove(); }); }); $(document).keyup(function(event) { if (event.keyCode == 27){ $(".grtyoutube-popup").remove(); } }); }); }; }( jQuery ));