RibbonMenu

RibbonMenu

RibbonMenu class for managing ribbon menus in the UI.

Constructor

new RibbonMenu()

Source:

Extends

Members

container :jQuery

Description:
  • Container element for the ribbon menu.

Source:

Container element for the ribbon menu.

Type:
  • jQuery

lastSelected :string

Description:
  • ID of the last selected ribbon.

Source:

ID of the last selected ribbon.

Type:
  • string

ribbons :Object.<string, Object>

Description:
  • Collection of ribbon configurations.

Source:

Collection of ribbon configurations.

Type:
  • Object.<string, Object>

Methods

add(id, options) → {Object}

Description:
  • Adds a new ribbon to the menu.

Source:
Parameters:
Name Type Description
id string

The ID of the ribbon.

options Object

The options for the ribbon.

Properties
Name Type Attributes Default Description
title string <optional>

The title of the ribbon.

icon string <optional>

The icon class for the ribbon.

permanent boolean <optional>
false

Whether the ribbon is permanent.

onClick function <optional>

The onClick event handler.

onBlur function <optional>

The onBlur event handler.

toolbar ui.Toolbar <optional>

The toolbar associated with the ribbon.

Returns:

The added ribbon configuration.

Type
Object

clear()

Description:
  • Clears all non-permanent ribbons from the menu.

Source:

defaultClickEvt()

Description:
  • Default click event handler for ribbons.

Source:

init()

Description:
  • Initializes the ribbon menu.

Source:

isExist(id) → {boolean}

Description:
  • Checks if a ribbon with the given ID exists.

Source:
Parameters:
Name Type Description
id string

The ID of the ribbon.

Returns:

True if the ribbon exists, false otherwise.

Type
boolean

off(evt, fn)

Description:
  • Removes an event
    Equal to $(document).off()

Source:
Since:
  • 4.3.20
Overrides:
Example
trans.off('transLoaded', (e, opt)=> {
	// do something
})
Parameters:
Name Type Description
evt String

Event name

fn function

Function to trigger

on(evt, fn)

Description:
  • Create a new event with JQuery eventing convenience
    Equal to $(document).on()

Source:
Since:
  • 4.3.20 trans.on('transLoaded', (e, opt)=> { // do something })
Overrides:
Parameters:
Name Type Description
evt String

Event name

fn function

Function to trigger

onReady(fn)

Description:
  • Executes a function when the DOM is ready.

Source:
Parameters:
Name Type Description
fn function

The function to execute.

one(evt, fn)

Description:
  • Run the event once
    Trigger an event and immediately removes it
    Equal to $(document).one()

Source:
Since:
  • 4.3.20
Overrides:
Parameters:
Name Type Description
evt String

Event name

fn function

Function to trigger

processWith(processName, value) → {*}

Description:
  • Add a custom process to a value.

Source:
Overrides:
Parameters:
Name Type Description
processName String

Name of the process

value *

Value to be processed

Returns:
  • By default will return value as is
Type
*

rejectState(state, erroropt)

Description:
  • Reject a state

Source:
Overrides:
Parameters:
Name Type Attributes Description
state String

State name

error String <optional>

Error message

remove(id)

Description:
  • Removes a ribbon from the menu.

Source:
Parameters:
Name Type Description
id string

The ID of the ribbon to remove.

resolveState(state, argopt)

Description:
  • Resolve a state

Source:
Overrides:
Parameters:
Name Type Attributes Description
state String

State name

arg * <optional>

Arguments to be passed to until

select($ribbon, triggeropt)

Description:
  • Selects a ribbon and triggers its onClick event.

Source:
Parameters:
Name Type Attributes Default Description
$ribbon jQuery | string

The ribbon element or its ID.

trigger boolean <optional>
true

Whether to trigger the onClick event.

trigger(evt, fn)

Description:
  • Trigger an event
    Equal to $(document).trigger()

Source:
Since:
  • 4.3.20
Overrides:
Parameters:
Name Type Description
evt String

Event name

fn function

Function to trigger

(async) until(state) → {Promise.<*>}

Description:
  • State monitor. Wait until a state is resolved.
    Will wait until resolveState is called.
    Will immidiately executed if resolveState is already called

Source:
Since:
  • 4.12.4
Overrides:
Examples

Basic usage

await basicEventHandler.until("ready");

Asynchronous chaining

basicEventHandler.until("ready")
.then((result) = >{
	console.log(result);
})

basicEventHandler.resolveState("ready", "Hello world");
// prints: Hello world

Immidiately executed if `resolveState` with the same state has already been called

basicEventHandler.resolveState("ready", "App is ready");

var msg = await basicEventHandler.until("ready");
console.log(msg);
//immidately prints "App is ready"
Parameters:
Name Type Description
state String

State name

Returns:
  • Returns any variables passed on resolveState
Type
Promise.<*>

Type Definitions

Event

Description:
  • BasicEventHandler's event. This itself extends the standard Event API for html element. So, you can use the default element's event such as click, focus, blur, etc.
    Methods that uses Event are: on(), off(), one(), trigger()

Source:
Overrides:
See:

BasicEventHandler's event. This itself extends the standard Event API for html element. So, you can use the default element's event such as click, focus, blur, etc.
Methods that uses Event are: on(), off(), one(), trigger()

Type:
  • Event

State

Description:
  • Javascript's Promise type event handler.
    The state will switch from off to on once. And after that, it will stay in that state forever, so any further until() call will be resolved immidiately.
    Methods that uses Event are: until(), resolveState(), rejectState()

Source:
Since:
  • 4.12.1
Overrides:

Javascript's Promise type event handler.
The state will switch from off to on once. And after that, it will stay in that state forever, so any further until() call will be resolved immidiately.
Methods that uses Event are: until(), resolveState(), rejectState()

Type:
  • Promise

Events

active

Description:
  • Event triggered when a ribbon is active.

Source:

beforeSelect

Description:
  • Event triggered before a ribbon is selected.

Source:

ready

Description:
  • Event triggered when the ribbon menu is ready.

Source:

select

Description:
  • Event triggered when a ribbon is selected.

Source:
Properties:
Name Type Description
id string

The ID of the selected ribbon.

Type:
  • string