Use local var for additionalPanels

This commit is contained in:
James Kiesel
2017-03-29 08:52:50 +09:00
parent c99883cf65
commit 3b55ceffb3
2 changed files with 19 additions and 13 deletions

View File

@ -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);
}
/**