PLUGIN: New API for decorating a post with jQuery

This commit is contained in:
Robin Ward 2014-07-21 11:38:38 -04:00
parent 7c898f2e61
commit 59c3ca7e7b
1 changed files with 12 additions and 0 deletions

View File

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