discourse/plugins/lazyYT/assets/javascripts/initializers/lazyYT.js.es6

19 lines
488 B
Plaintext
Raw Normal View History

2016-04-01 05:33:25 +08:00
import { withPluginApi } from 'discourse/lib/plugin-api';
2014-07-22 10:39:32 +08:00
export default {
name: "apply-lazyYT",
2016-04-01 05:33:25 +08:00
initialize() {
withPluginApi('0.1', api => {
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);
}
}
}));
2014-07-22 10:39:32 +08:00
});
}
};