mirror of
https://github.com/discourse/discourse.git
synced 2025-05-26 04:11:26 +08:00
Use local var for additionalPanels
This commit is contained in:
@ -18,7 +18,8 @@ import { addTagsHtmlCallback } from 'discourse/lib/render-tags';
|
||||
import { addUserMenuGlyph } from 'discourse/widgets/user-menu';
|
||||
import { addPostClassesCallback } from 'discourse/widgets/post';
|
||||
import { addPostTransformCallback } from 'discourse/widgets/post-stream';
|
||||
import { queryRegistry } from 'discourse/widgets/widget';
|
||||
import { attachAdditionalPanel } from 'discourse/widgets/header';
|
||||
|
||||
|
||||
// If you add any methods to the API ensure you bump up this number
|
||||
const PLUGIN_API_VERSION = '0.8.6';
|
||||
@ -340,14 +341,18 @@ class PluginApi {
|
||||
* takes a widget name, a value to toggle on, and a function which returns the attrs for the widget
|
||||
* Example:
|
||||
* ```javascript
|
||||
* api.addHeaderPanel('widget-name', 'widgetVisible', function(attrs, state) { return {}; });
|
||||
* api.addHeaderPanel('widget-name', 'widgetVisible', function(attrs, state) {
|
||||
* return { name: attrs.name, description: state.description };
|
||||
* });
|
||||
* ```
|
||||
* note that 'toggle' is an attribute on the state of the header widget,
|
||||
* and the attrFn receives the current attrs and state of the header as arguments,
|
||||
* and returns a hash of attrs to pass to the widget
|
||||
* 'toggle' is an attribute on the state of the header widget,
|
||||
*
|
||||
* 'transformAttrs' is a function which is passed the current attrs and state of the widget,
|
||||
* and returns a hash of values to pass to attach
|
||||
*
|
||||
**/
|
||||
addHeaderPanel(name, toggle, attrFn) {
|
||||
queryRegistry('header').prototype.attachAdditionalPanel(name, toggle, attrFn);
|
||||
addHeaderPanel(name, toggle, transformAttrs) {
|
||||
attachAdditionalPanel(name, toggle, transformAttrs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user