Skip to content

Commit

Permalink
FIX: Don't stop youtube videos from playing on cloak
Browse files Browse the repository at this point in the history
  • Loading branch information
eviltrout committed Feb 26, 2016
1 parent ef1ff11 commit 65d7103
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const icons = {
};

export default createWidget('post-small-action', {
buildKey: attrs => `post-small-act-${attrs.id}`,
tagName: 'div.small-action.onscreen-post.clearfix',

buildId(attrs) {
Expand Down
9 changes: 5 additions & 4 deletions app/assets/javascripts/discourse/widgets/post-stream.js.es6
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createWidget } from 'discourse/widgets/widget';
import transformPost from 'discourse/lib/transform-post';
import { Placeholder } from 'discourse/lib/posts-with-placeholders';
import { h } from 'virtual-dom';
import { addWidgetCleanCallback } from 'discourse/components/mount-widget';

const CLOAKING_ENABLED = !window.inTestEnv;
Expand Down Expand Up @@ -86,9 +85,11 @@ export default createWidget('post-stream', {

const height = _cloaked[post.id];
if (height) {
result.push(h('div.cloaked-post', { id: `post_${post.post_number}`,
attributes: { style: `height: ${height}px` } }));
} else if (transformed.isSmallAction) {
transformed.cloaked = true;
transformed.height = height;
}

if (transformed.isSmallAction) {
result.push(this.attach('post-small-action', transformed, { model: post }));
} else {
result.push(this.attach('post', transformed, { model: post }));
Expand Down
9 changes: 9 additions & 0 deletions app/assets/javascripts/discourse/widgets/post.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,14 @@ export default createWidget('post', {
buildKey: attrs => `post-${attrs.id}`,
shadowTree: true,

buildAttributes(attrs) {
if (attrs.cloaked) {
return { style: `height: ${attrs.height}px` };
}
},

buildClasses(attrs) {
if (attrs.cloaked) { return 'cloaked-post'; }
const classNames = ['topic-post', 'clearfix'];

if (attrs.selected) { classNames.push('selected'); }
Expand All @@ -397,6 +404,8 @@ export default createWidget('post', {
},

html(attrs) {
if (attrs.cloaked) { return 'cloaked'; }

return this.attach('post-article', attrs);
},

Expand Down

0 comments on commit 65d7103

Please sign in to comment.