FIX: LazyYT was not being applied when a post was edited

This commit is contained in:
Robin Ward 2014-12-18 12:28:14 -05:00
parent f21d34df24
commit 2d3a9b334d
2 changed files with 12 additions and 3 deletions

View file

@ -1,11 +1,15 @@
var _decorateId = 0;
function decorate(klass, evt, cb) { function decorate(klass, evt, cb) {
var mixin = {}; var mixin = {};
mixin["_decorate_" + new Date().getTime().toString()] = function($elem) { cb($elem); }.on(evt); mixin["_decorate_" + (_decorateId++)] = function($elem) { cb($elem); }.on(evt);
klass.reopen(mixin); klass.reopen(mixin);
} }
export function decorateCooked(container, cb) { export function decorateCooked(container, cb) {
decorate(Discourse.PostView, 'postViewInserted', cb); var postView = container.lookupFactory('view:post');
decorate(postView, 'postViewInserted', cb);
decorate(postView, 'postViewUpdated', cb);
decorate(container.lookupFactory('view:composer'), 'previewRefreshed', cb); decorate(container.lookupFactory('view:composer'), 'previewRefreshed', cb);
decorate(container.lookupFactory('view:embedded-post'), 'previewRefreshed', cb); decorate(container.lookupFactory('view:embedded-post'), 'previewRefreshed', cb);
decorate(container.lookupFactory('view:user-stream'), 'didInsertElement', cb); decorate(container.lookupFactory('view:user-stream'), 'didInsertElement', cb);

View file

@ -45,9 +45,14 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
// If the cooked content changed, add the quote controls // If the cooked content changed, add the quote controls
cookedChanged: function() { cookedChanged: function() {
Em.run.scheduleOnce('afterRender', this, '_insertQuoteControls'); Em.run.scheduleOnce('afterRender', this, '_cookedWasChanged');
}.observes('post.cooked'), }.observes('post.cooked'),
_cookedWasChanged: function() {
this.trigger('postViewUpdated', this.$());
this._insertQuoteControls();
},
mouseUp: function(e) { mouseUp: function(e) {
if (this.get('controller.multiSelect') && (e.metaKey || e.ctrlKey)) { if (this.get('controller.multiSelect') && (e.metaKey || e.ctrlKey)) {
this.get('controller').toggledSelectedPost(this.get('post')); this.get('controller').toggledSelectedPost(this.get('post'));