Difference between revisions of "MediaWiki:Common.js"
From Summertime Saga Wiki
Line 24: | Line 24: | ||
var title = elm.text(); | var title = elm.text(); | ||
− | elm.replaceWith('<a class="vid-embed" href="https://youtube.com/watch?v=' + vidId + '" target="_blank" style="background-image:url(//i.ytimg.com/vi/' + vidId + '/maxresdefault.jpg)"><span class="vid-embed-title">' + title + '</span><span class="vid-embed-play"></span></a>'); | + | elm.replaceWith('<a class="vid-embed" href="https://youtube.com/watch?v=' + vidId + '" target="_blank" style="background-image:url(//i.ytimg.com/vi/' + vidId + '/maxresdefault.jpg)"><span class="vid-embed-title">' + title + '</span><span class="vid-embed-play"><i class="fa fa-play-circle"></i></span></a>'); |
}); | }); | ||
}; | }; | ||
Line 35: | Line 35: | ||
// Load magnificPopup CSS | // Load magnificPopup CSS | ||
headElm.append('<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css"/>'); | headElm.append('<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css"/>'); | ||
+ | |||
+ | // And fontawesome | ||
+ | headElm.append('<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>'); | ||
// Add our own custom CSS, again temporary | // Add our own custom CSS, again temporary | ||
− | headElm.append('<style type="text/css">.vid-embed { position: relative; text-decoration: none; display: inline-block; width: 384px; height: 216px; margin-right: 10px; background-size: cover; background-position: center center; border: 1px solid #000; transition: border-color 0.15s ease-in-out; box-shadow: 0 0 10px 3px #191B26; border-radius: 2px; } .vid-embed:hover { border-color: #777; } .vid-embed:focus { outline: 0; } .vid-embed-title { color: # | + | headElm.append('<style type="text/css">.vid-embed { position: relative; text-decoration: none; display: inline-block; width: 384px; height: 216px; margin-right: 10px; background-size: cover; background-position: center center; border: 1px solid #000; transition: border-color 0.15s ease-in-out; box-shadow: 0 0 10px 3px #191B26; border-radius: 2px; } .vid-embed:hover { border-color: #777; } .vid-embed:focus { outline: 0; } span.vid-embed-title { color: #bbb; text-align: left; margin: 8px 0 0 12px; font-size: 16px; } span.vid-embed-title:hover { text-decoration: none; } .vid-embed-play { position: absolute; top: 0; left: 0; bottom: 0; right: 0; width: 50px; height: 50px; margin: auto; }</style>'); |
// Run our main function | // Run our main function |
Revision as of 10:58, 6 February 2017
/* Any JavaScript here will be loaded for all users on every page load. */ // Test code for youtube embeds -sam9 $(function() { // Click handler $('#content').on('click', '.vid-embed', function(e) { e.preventDefault(); var elm = $(this); $.magnificPopup.open({ items: { src : elm.attr('href'), type : 'iframe' } }); }); // Main parsing function var parseTags = function() { // Loop through our tags $('.vid').each(function(){ var elm = $(this); var vidId = elm.data('link'); var title = elm.text(); elm.replaceWith('<a class="vid-embed" href="https://youtube.com/watch?v=' + vidId + '" target="_blank" style="background-image:url(//i.ytimg.com/vi/' + vidId + '/maxresdefault.jpg)"><span class="vid-embed-title">' + title + '</span><span class="vid-embed-play"><i class="fa fa-play-circle"></i></span></a>'); }); }; // Load magnificPopup if it isn't already if (typeof $.magnificPopup === 'undefined') { // Temporary work around due to lack of server access $.getScript('//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js', function() { var headElm = $('head'); // Load magnificPopup CSS headElm.append('<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css"/>'); // And fontawesome headElm.append('<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>'); // Add our own custom CSS, again temporary headElm.append('<style type="text/css">.vid-embed { position: relative; text-decoration: none; display: inline-block; width: 384px; height: 216px; margin-right: 10px; background-size: cover; background-position: center center; border: 1px solid #000; transition: border-color 0.15s ease-in-out; box-shadow: 0 0 10px 3px #191B26; border-radius: 2px; } .vid-embed:hover { border-color: #777; } .vid-embed:focus { outline: 0; } span.vid-embed-title { color: #bbb; text-align: left; margin: 8px 0 0 12px; font-size: 16px; } span.vid-embed-title:hover { text-decoration: none; } .vid-embed-play { position: absolute; top: 0; left: 0; bottom: 0; right: 0; width: 50px; height: 50px; margin: auto; }</style>'); // Run our main function parseTags(); }); } else { // Run our main function parseTags(); } }());