Namespace: toolbar

toolbar

Manage the toolbar of AskiaPortal.

 portal.toolbar.append({
     tools : [
         {id : "button1", text: "Classic", title: "Button to do one..."},
         {id : "button2", text: "Disabled", title: "Button to do two...", disabled : true},
         {id : "button3", text: "Main action", title: "Button to do the main action...", usePrimaryStyle: true},
         {id : "button4", text: "Open new window", title: "Button to do the open a new window ...", targetUrl: "https://my.url.to.open"},
         {
             id : "button5",
             text: "Drop down menu", 
             title: "Button with drop down menu ...", 
             children : [
                 { id : "button5-subItem1", text : "Classic menu", title: "Classical sub-menu"},
                 { id : "button5-subItem2", text : "Disabled menu", title: "Disabled sub-menu", disabled : true}
             ]
         }
     ]
 }).then(() => {

     // Listen event on the toolbar
     portal.toolbar.addEventListener("click", (event, details) => {
         console.log(`The tool with the id '${details.id}' has been clicked!`);
     });
 });
Dependencies:
  • ./js/portal.channel.js
  • ./js/portal.EventEmitter.js
Mixes In:

Methods

(static) Toolbar#append(options) → {Promise}

Append tools in the toolbar.

Parameters:
Name Type Description
options Object

Options

Properties
Name Type Description
tools Array.<Object>

Tools to append

Properties
Name Type Attributes Default Description
id String

Identifier of the tool.

text String

Text of the tool.

title String

Title of the tool.

disabled Boolean <optional>

Disabled state of the tool.

usePrimaryStyle Boolean <optional>
false

Use the primary color style, for call-to-action.

targetUrl String <optional>

On click open the new browser window with the specified URL.

children Array.<Object> <optional>
null

Children tools that will appear as menu items.

Returns:
Type
Promise

(static) Toolbar#clear() → {Promise}

Remove all tools in the toolbar.

Returns:
Type
Promise

(static) Toolbar#disable(options) → {Promise}

Disable tools in the toolbar.

Parameters:
Name Type Description
options Object

Options

Properties
Name Type Description
ids Array.<String>

Ids of the tools to disable

Returns:
Type
Promise

(static) Toolbar#enable(options) → {Promise}

Enable tools in the toolbar.

Parameters:
Name Type Description
options Object

Options

Properties
Name Type Description
ids Array.<String>

Ids of the tools to enable

Returns:
Type
Promise

(static) Toolbar#remove(options) → {Promise}

Remove tools in the toolbar.

Parameters:
Name Type Description
options Object

Options

Properties
Name Type Description
ids Array.<String>

Ids of the tools to remove

Returns:
Type
Promise

(static) Toolbar#update(options) → {Promise}

Append tools in the toolbar.

Parameters:
Name Type Description
options Object

Options

Properties
Name Type Description
tools Array.<Object>

Tools to append

Properties
Name Type Attributes Default Description
id String

Identifier of the tool.

text String

Text of the tool.

title String

Title of the tool.

disabled Boolean <optional>

Disabled state of the tool.

usePrimaryStyle Boolean <optional>
false

Use the primary color style, for call-to-action.

targetUrl String <optional>

On click open the new browser window with the specified URL.

children Array.<Object> <optional>
null

Children tools that will appear as menu items.

Returns:
Type
Promise

Events

click

When the user click on the tool.

Parameters:
Name Type Description
details Object

Details of the click event

Properties
Name Type Description
id String

Id of the tool that has been clicked