mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 08:42:44 +08:00
EXTENSIBILITY: allow registration of custom post menu items
This commit is contained in:
parent
6de7e7e161
commit
e81f122a3f
|
@ -44,7 +44,7 @@ Button.prototype.render = function(buffer) {
|
||||||
|
|
||||||
var hiddenButtons;
|
var hiddenButtons;
|
||||||
|
|
||||||
export default Discourse.View.extend(StringBuffer, {
|
var PostMenuView = Discourse.View.extend(StringBuffer, {
|
||||||
tagName: 'section',
|
tagName: 'section',
|
||||||
classNames: ['post-menu-area', 'clearfix'],
|
classNames: ['post-menu-area', 'clearfix'],
|
||||||
|
|
||||||
|
@ -141,6 +141,13 @@ export default Discourse.View.extend(StringBuffer, {
|
||||||
visibleButtons.splice(visibleButtons.length - 1, 0, this.buttonForShowMoreActions(post));
|
visibleButtons.splice(visibleButtons.length - 1, 0, this.buttonForShowMoreActions(post));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var callbacks = PostMenuView._registerButtonCallbacks;
|
||||||
|
if (callbacks) {
|
||||||
|
_.each(callbacks, function(callback) {
|
||||||
|
callback.apply(self, [visibleButtons]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
buffer.push('<div class="actions">');
|
buffer.push('<div class="actions">');
|
||||||
visibleButtons.forEach(function (b) {
|
visibleButtons.forEach(function (b) {
|
||||||
b.render(buffer);
|
b.render(buffer);
|
||||||
|
@ -374,3 +381,12 @@ export default Discourse.View.extend(StringBuffer, {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
PostMenuView.reopenClass({
|
||||||
|
registerButton: function(callback){
|
||||||
|
this._registerButtonCallbacks = this._registerButtonCallbacks || [];
|
||||||
|
this._registerButtonCallbacks.push(callback);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default PostMenuView;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user