Class: LayerManager

Granite.author. LayerManager

The LayerManager is defined per Editor and manages the different Layers including their registration and activation.
It stores the list of the all the registered Layers, provide access to the current active Layer and also handles the Layer Selector element (dropdown element that allows to select the current Layer).

Initialized on Document#event:cq-editor-loaded


new LayerManager(config)

Instantiates a new Layer Manager with the given config.

Parameters:
Name Type Description
config LayerManagerConfig

The LayerManager Configuration object.

Source:
layers/LayerManager.js

Members


config :LayerManagerConfig

The default LayerManager Configuration properties (order of the Layers, default Layer).

Type:
Source:
layers/LayerManager.js

Methods


activateLayer(name)

Activates a Layer from its name

Parameters:
Name Type Description
name string

Name of the layer

Source:
layers/LayerManager.js
Fires:

focus()

Focuses the first button of the Layer buttons (current layer)

Source:
layers/LayerManager.js

getCurrentLayerName()

Returns the name of the current active Layer.

Source:
layers/LayerManager.js
Returns:
Type
string

getDefaultLayer()

Returns the name of the default Layer

Source:
layers/LayerManager.js
Returns:
  • Name of the default layer
Type
string

getLayers()

Returns all the registred Layers.

Source:
layers/LayerManager.js
Returns:
Type
Object.<Granite.author.Layer>

init()

Initializes the LayerManager; called on Document#event:cq-editor-loaded
It first initializes the Layer Selector, and then activates the default Layer.

Source:
layers/LayerManager.js

registerLayer(layer [, position])

Registers a Layer.
The first Layer to be registered will also be activated

Parameters:
Name Type Argument Description
layer Granite.author.Layer

A Layer object

position number <optional>

Position in the list of the Layer already registered

Source:
layers/LayerManager.js

setCurrentLayer(layerName)

Sets the current active Layer.

Parameters:
Name Type Description
layerName string

Name of the layer to be set as the current one

Source:
layers/LayerManager.js

toggle()

Toggles between Preview and the current Layer
NB: This one is only called when switching from the current Layer and preview using the keyboard shortcut (see key mapping defined in Granite.author.keys.layers)

Source:
layers/LayerManager.js

updateLayerSelector()

Rebuilds the Layer selector (UI element that allows to select the current Layer) by iterating over the registered Layers and adding all that are currently available

Source:
layers/LayerManager.js