Better documentation for getHeadingButtons
This commit is contained in:
parent
0a07cad2cb
commit
3c2eda4a1d
|
@ -48,6 +48,19 @@ export default class ChatHeading extends CustomElement {
|
||||||
*/
|
*/
|
||||||
getHeadingButtons () {
|
getHeadingButtons () {
|
||||||
const buttons = [
|
const buttons = [
|
||||||
|
/**
|
||||||
|
* @typedef { Object } HeadingButtonAttributes
|
||||||
|
* An object representing a chat heading button
|
||||||
|
* @property { Boolean } standalone
|
||||||
|
* True if shown on its own, false if it must be in the dropdown menu.
|
||||||
|
* @property { Function } handler
|
||||||
|
* A handler function to be called when the button is clicked.
|
||||||
|
* @property { String } a_class - HTML classes to show on the button
|
||||||
|
* @property { String } i18n_text - The user-visiible name of the button
|
||||||
|
* @property { String } i18n_title - The tooltip text for this button
|
||||||
|
* @property { String } icon_class - What kind of CSS class to use for the icon
|
||||||
|
* @property { String } name - The internal name of the button
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
'a_class': 'show-user-details-modal',
|
'a_class': 'show-user-details-modal',
|
||||||
'handler': ev => this.showUserDetailsModal(ev),
|
'handler': ev => this.showUserDetailsModal(ev),
|
||||||
|
@ -69,25 +82,34 @@ export default class ChatHeading extends CustomElement {
|
||||||
'standalone': api.settings.get('view_mode') === 'overlayed'
|
'standalone': api.settings.get('view_mode') === 'overlayed'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
const el = _converse.chatboxviews.get(this.getAttribute('jid'));
|
||||||
* *Hook* which allows plugins to add more buttons to a chat's heading.
|
if (el) {
|
||||||
* @event _converse#getHeadingButtons
|
/**
|
||||||
* @example
|
* *Hook* which allows plugins to add more buttons to a chat's heading.
|
||||||
* api.listen.on('getHeadingButtons', (view, buttons) => {
|
*
|
||||||
* buttons.push({
|
* Note: This hook is fired for both 1 on 1 chats and groupchats.
|
||||||
* 'i18n_title': __('Foo'),
|
* If you only care about one, you need to add a check in your code.
|
||||||
* 'i18n_text': __('Foo Bar'),
|
*
|
||||||
* 'handler': ev => alert('Foo!'),
|
* @event _converse#getHeadingButtons
|
||||||
* 'a_class': 'toggle-foo',
|
* @param { HTMLElement } el
|
||||||
* 'icon_class': 'fa-foo',
|
* The `converse-chat` (or `converse-muc`) DOM element that represents the chat
|
||||||
* 'name': 'foo'
|
* @param { Array.<HeadingButtonAttributes> }
|
||||||
* });
|
* An array of the existing buttons. New buttons may be added,
|
||||||
* return buttons;
|
* and existing ones removed or modified.
|
||||||
* });
|
* @example
|
||||||
*/
|
* api.listen.on('getHeadingButtons', (el, buttons) => {
|
||||||
const chatview = _converse.chatboxviews.get(this.getAttribute('jid'));
|
* buttons.push({
|
||||||
if (chatview) {
|
* 'i18n_title': __('Foo'),
|
||||||
return _converse.api.hook('getHeadingButtons', chatview, buttons);
|
* 'i18n_text': __('Foo Bar'),
|
||||||
|
* 'handler': ev => alert('Foo!'),
|
||||||
|
* 'a_class': 'toggle-foo',
|
||||||
|
* 'icon_class': 'fa-foo',
|
||||||
|
* 'name': 'foo'
|
||||||
|
* });
|
||||||
|
* return buttons;
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
return _converse.api.hook('getHeadingButtons', el, buttons);
|
||||||
} else {
|
} else {
|
||||||
return buttons; // Happens during tests
|
return buttons; // Happens during tests
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user