FIX: Don't stop youtube videos from playing on cloak

This commit is contained in:
Robin Ward 2016-02-26 16:48:41 -05:00
parent ef1ff113a3
commit 65d7103bdc
3 changed files with 15 additions and 4 deletions

View File

@ -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) {

View File

@ -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;
@ -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 }));

View File

@ -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'); }
@ -397,6 +404,8 @@ export default createWidget('post', {
},
html(attrs) {
if (attrs.cloaked) { return 'cloaked'; }
return this.attach('post-article', attrs);
},