Class: StatusBar

Granite.author.ui. StatusBar

Loads and displays statuses about the current editor content and provides simple interaction with them.

Statuses can be loaded from the server (Granite.author.ui.StatusBar#loadStatuses) or added and removed manually (Granite.author.ui.StatusBar#addStatus and Granite.author.ui.StatusBar#removeStatus).

Statuses can display actions, which are rendered as clickable links. A client library can implement an action by listening to clicks on elements of class editor-StatusBar-action and with the attribute data-status-action-id equals to the desired action id. The following data is associated with the link elements, and can be retrieved inside the event handler using $(this).data(key):

  • statusType: the status type
  • statusId: the status id
  • statusActionId: the status action id
  • statusData: the status object containing all status data


new StatusBar()

Creates a StatusBar instance.

Source:
ui/ui.StatusBar.js

Members


loaded

Flag indicating if the statuses of the current resource have already been loaded.

Source:
ui/ui.StatusBar.js

Methods


addStatus(type, title, message [, shortMessage] [, priority] [, variant] [, icon] [, data] [, actions])

Adds a new status to the status bar. The status will be inserted into the list of existing statuses according to its priority. The status bar will be made visible if it is hidden.

This method must only be called after the statuses of the current resource have been loaded, i.e. when Granite.author.ui.StatusBar#hasLoaded returns true or after Document#event:cq-editor-statusbar-loaded has been fired.

Parameters:
Name Type Argument Default Description
type string

the status type

title string

the status title describing the module or feature the status is associated with

message string

the status message

shortMessage string <optional>

a short message to be displayed in the popover list

priority number <optional>

the status priority (if omitted, a default is assumed based on the variant)

variant string <optional>
info

the status variant, in line with Coral.Alert variants ('success', 'info', 'warning' or 'error')

icon string <optional>

the name of a CoralUI icon (if omitted, a default is assumed based on the variant)

data Object <optional>

additional data to be associated with this status (e.g. to implement an action)

actions Array.<Object> <optional>

actions to act upon the status

actions[].id string

the id of the action

actions[].label string

the label of the action

Source:
ui/ui.StatusBar.js
Returns:

the status id

Type
number

hasLoaded()

Checks if the statuses of the current resource have already been loaded.

Source:
ui/ui.StatusBar.js
Returns:

true if the statuses have been loaded, false otherwise

Type
boolean

hide()

Hides the status bar.

Source:
ui/ui.StatusBar.js

loadStatuses(path)

Retrieves the statuses for a given resource and adds them to the status bar. Current statuses are reset and the status bar will be shown if it is hidden.

Parameters:
Name Type Description
path string

the path to a resource for which to load the statuses

Source:
ui/ui.StatusBar.js
Fires:

removeStatus(id)

Removes the status with the specified id from the status bar. The status bar will be hidden if no more statuses are present after the removal.

Parameters:
Name Type Description
id number

the id of the status to remove

Source:
ui/ui.StatusBar.js

show()

Shows the status bar.

Source:
ui/ui.StatusBar.js

showNextStatus()

Shows the status next to the one currently displayed (having equal or lower priority).

Source:
ui/ui.StatusBar.js

showPreviousStatus()

Shows the status previous to the one currently displayed (having equal or higher priority).

Source:
ui/ui.StatusBar.js

showStatus(id)

Shows the status with the specified id. The status bar will be made visible if it is hidden.

Parameters:
Name Type Description
id number

the status id

Source:
ui/ui.StatusBar.js