mirror of
https://github.com/discourse/discourse.git
synced 2025-05-26 12:05:25 +08:00
PLUGIN: New API for decorating a post with jQuery
This commit is contained in:
12
app/assets/javascripts/discourse/lib/plugin-api.js.es6
Normal file
12
app/assets/javascripts/discourse/lib/plugin-api.js.es6
Normal 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);
|
||||
}
|
Reference in New Issue
Block a user