mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FIX: Don't cloak videos once they begin playing
This commit is contained in:
@ -4,7 +4,15 @@ export default {
|
||||
name: "apply-lazyYT",
|
||||
initialize() {
|
||||
withPluginApi('0.1', api => {
|
||||
api.decorateCooked($elem => $('.lazyYT', $elem).lazyYT());
|
||||
api.decorateCooked($elem => $('.lazyYT', $elem).lazyYT({
|
||||
onPlay(e, $el) {
|
||||
// don't cloak posts that have playing videos in them
|
||||
const postId = parseInt($el.closest('article').data('post-id'));
|
||||
if (postId) {
|
||||
api.preventCloak(postId);
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -6,9 +6,12 @@
|
||||
* Contributors: https://github.com/tylerpearson/lazyYT/graphs/contributors || https://github.com/daugilas/lazyYT/graphs/contributors
|
||||
*
|
||||
* Usage: <div class="lazyYT" data-youtube-id="laknj093n" data-parameters="rel=0">loading...</div>
|
||||
*
|
||||
* Note: Discourse has forked this from the original, beware when updating the file.
|
||||
*
|
||||
*/
|
||||
|
||||
;(function ($) {
|
||||
(function ($) {
|
||||
'use strict';
|
||||
|
||||
function setUp($el, settings) {
|
||||
@ -100,10 +103,15 @@
|
||||
.addClass('lazyYT-image-loaded')
|
||||
.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!$el.hasClass('lazyYT-video-loaded') && $thumb.hasClass('lazyYT-image-loaded')) {
|
||||
$el.html('<iframe src="//www.youtube.com/embed/' + id + '?autoplay=1&' + youtube_parameters + '" frameborder="0" allowfullscreen></iframe>')
|
||||
.addClass('lazyYT-video-loaded');
|
||||
}
|
||||
|
||||
if (settings.onPlay) {
|
||||
settings.onPlay(e, $el);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@ -122,4 +130,4 @@
|
||||
});
|
||||
};
|
||||
|
||||
}(jQuery));
|
||||
})(jQuery);
|
||||
|
Reference in New Issue
Block a user