From 98eac4924c37161a37da7a5f6cd134bff022b5c4 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 27 Dec 2016 11:38:14 -0500 Subject: [PATCH] FIX: If an audio file is playing, don't cloak it --- .../discourse/initializers/post-decorations.js.es6 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/assets/javascripts/discourse/initializers/post-decorations.js.es6 b/app/assets/javascripts/discourse/initializers/post-decorations.js.es6 index df6e8d8bc27..d17b2087acd 100644 --- a/app/assets/javascripts/discourse/initializers/post-decorations.js.es6 +++ b/app/assets/javascripts/discourse/initializers/post-decorations.js.es6 @@ -8,6 +8,18 @@ export default { withPluginApi('0.1', api => { api.decorateCooked(highlightSyntax); api.decorateCooked(lightbox); + + api.decorateCooked($elem => { + const players = $('audio', $elem); + if (players.length) { + players.on('play', () => { + const postId = parseInt($elem.closest('article').data('post-id')); + if (postId) { + api.preventCloak(postId); + } + }); + } + }); }); } };