Skip to content
Bibliofile edited this page Oct 18, 2019 · 5 revisions

This is out of date, for the 7.x bot see here

Provides an interface for interacting with the page easily. These functions can be accessed through extension.ui.<function>.

ui.notify(text, displayTime = 2)

Sends a notification to the user which is automatically dismissed after displayTime seconds. The text parameter will be HTML escaped.

ui.alert(text, buttons = [{text: 'OK'}])

Creates a notification which requires the user's account. The buttons parameter follows this format: [{text: 'Text', style:'success', action: function(){}, thisArg: undefined, dismiss: true}]. Only the text option is required. The style option may be any of the following: success, danger, warning, info. At least one button must correctly have dismiss set to true. The text parameter of the function will be set as HTML.

ui.buildContentFromTemplate(templateSelector, targetSelector, rules = [])

Clones the template found by the templateSelector and walks through each rule. The rules array must follow this format: [{selector: '.class', value: ''}]. Each rule must have a selector property. If a text or html property is provided, then the textContent or innerHTML will be set on the selector. Any other properties will be set with setAttribute.

ui.addMessageToConsole(message, name = '', nameClass = '') - DEPRECATED since 6.2.0

Adds a message to the console.

ui.addTab(tabText, groupName = 'main')

Adds a tab to the navigation, if groupName is provided, the tab will be added to the specified group. By default, only the group messages and main exist. Returns a <div> which the tab content should be placed within.

ui.addTabGroup(text, groupName)

Creates a new tab. The groupName can then be used in ui.addTab.

ui.removeTab(tabContent)

Removes a tab from the navigation and the page. tabContent should be the div returned by ui.addTab.

ui.removeTabGroup(groupName)

Removes a group and all child tabs from the page and navigation.