Documentation
Toolbar
is
Returns: Boolean
Check if the toolbar is running. For example, if the option toolbar
is false, therefore API toolbar.is
also returns false
. The toolbar is not running in this case.
var is = this.toolbar.is();
isAir
Returns: Boolean
Check if the toolbar is running as Air Toolbar.
var air = this.toolbar.isAir();
isFixed
Returns: Boolean
Check if the toolbar is in fixed position when a user scroll the document.
var fixed = this.toolbar.isFixed();
isContextBar
Returns: Boolean
Check if the context bar is opened.
var bar = this.toolbar.isContextBar();
getElement
Returns: Object
Return the Dom object of the toolbar element.
var $toolbar = this.toolbar.getElement();
getWrapper
Returns: Object
Return the Dom object of the toolbar wrapper element.
var $wrapper = this.toolbar.getWrapper();
getDropdown
Returns: Object
Boolean
Return the object of the current opened dropdown or returns false
if no dropdowns are opened.
var dropdown = this.toolbar.getDropdown();
getButton
name | String |
Returns: Object
Boolean
Return the button object by specified name, and false
if the button doesn't exist on the toolbar.
var button = this.toolbar.getButton('bold');
getButtons
Returns: Array
Return the array of all button objects on the toolbar.
var buttons = this.toolbar.getButtons();
getButtonsKeys
Returns: Array
Return the array of all button names on the toolbar.
var keys = this.toolbar.getButtonsKeys();
addButton
name | String | |
data | Object |
Returns: Object
Add a button at the end of the toolbar with name
and the following data object:
- title
String
- the alternative text of button HTML element
- api
String
- the name of API to module or plugin method, for example:
module.block.format
.
- the name of API to module or plugin method, for example:
- message
String
- the name of message which is broadcasting to app when the button is clicked, for example:
mybuttonclicked
.
- the name of message which is broadcasting to app when the button is clicked, for example:
- tooltip
String
- the text for button tooltip when a user moves the cursor to the button. By default the title is shown on the tooltip text.
- args
Mixed
- arguments which will be passed with api method or message.
- observe
String
- module or plugin name that will watch the button.
The method returns the object of the created button.
var data = {
title: 'My button',
api: 'plugin.myplugin.toggle'
};
var button = this.toolbar.addButton('mybutton', data);
With argument:
var data = {
title: 'My button',
api: 'plugin.myplugin.toggle',
args: 'argument'
};
var button = this.toolbar.addButton('mybutton', data);
With arguments:
var data = {
title: 'My button',
api: 'plugin.myplugin.toggle',
args: {
key1: 'value1',
key2: 'value2'
}
};
var button = this.toolbar.addButton('mybutton', data);
addButtonFirst
name | String | |
data | Object |
Returns: Object
Add a button at the start of the toolbar.
var data = {
title: 'My button',
api: 'plugin.myplugin.toggle'
};
var button = this.toolbar.addButtonFirst('mybutton', data);
addButtonAfter
after | String | |
name | String | |
data | Object |
Returns: Object
Add a button after the specified button on the toolbar.
var data = {
title: 'My button',
api: 'plugin.myplugin.toggle'
};
var button = this.toolbar.addButtonAfter('bold', 'mybutton', data);
In this example, the new button will be added after the bold
button. If the specified button doesn't exist the new button will be added at the end of the toolbar.
addButtonBefore
before | String | |
name | String | |
data | Object |
Returns: Object
Add a button before the specified button on the toolbar.
var data = {
title: 'My button',
api: 'plugin.myplugin.toggle'
};
var button = this.toolbar.addButtonBefore('bold', 'mybutton', data);
In this example, the new button will be added before the bold
button. If the specified button doesn't exist the new button will be added at the end of the toolbar.
setButtonsInactive
Set all button on the toolbar is not active.
this.toolbar.setButtonsInactive();
setButtonsActive
Set all button on the toolbar is active.
this.toolbar.setButtonsActive();
disableButtons
Disable all button on the toolbar.
this.toolbar.disableButtons();
enableButtons
Enable all button on the toolbar.
this.toolbar.enableButtons();