new module:ct-menu /Control(any, container Element)
The Control will be in charge of rendering into the screen any
module:ct-menu/Model. In order to do so, after constructing this class with the appropriate
parameters, call module:ct-menu/Control#render.
This class will be initially used to render module:ct-menu/model/Menu but any implementation of
module:ct-menu/Model can be provided. See module:ct-menu/Control#addGenerator for details
on how to extend the control's functionality.
Parameters:
| Name | Type | Description |
|---|---|---|
any |
module:ct-menu |
instance of Model. |
containerElement |
HTMLElement | Container element. |
Methods
add Generator(generator, type)
This method is used as an extension point to the Control. It will allow you to define
your own generators to render custom items. They will be linked by the item's type returned by
module:ct-menu/Model#getType.
This generators will need to implement module:ct-menu/Generator.
Parameters:
| Name | Type | Description |
|---|---|---|
generator |
module:ct-menu |
Generator class which will render elements of the given type. |
type |
String | String representation of the item type the generator registered will be in charge of rendering. |
Throws:
-
If generator is not an instance of
module:ct-menu/Generator. - Type
-
module:ct-core
/Error
append(any, container Element)
Extracts the DOM representation of the provided model and appends it to a container element. This is done by calling each of the model type generator's create method.
Parameters:
| Name | Type | Description |
|---|---|---|
any |
module:ct-menu |
instance of Model. |
containerElement |
HTMLElement | Container element in which the menu will be rendered to. |
Throws:
-
-
If generator is not an instance of
module:ct-menu/Model. - Type
-
module:ct-core
/Error
-
-
-
If containerElement is not a HTMLElement.
- Type
-
module:ct-core
/Error
-
-
-
If no generator exists for the provided model.
- Type
-
module:ct-core
/Error
-
destroy()
Removes all the children nodes appended to the container and calls destroy in each of the registered controls.
get Model() → {Model}
Returns the current model for the menu.
Returns:
- Type
- Model
render()
Renders any module:ct-menu/Model onto the screen.
set Auto Hide(auto Hide)
Disable or enable the auto-hide functionality.
Parameters:
| Name | Type | Description |
|---|---|---|
autoHide |
Boolean | if true, enable auto-hiding this menu |
set Container Element(container Element)
Allows you to set the container element in which the menu will be rendered.
Parameters:
| Name | Type | Description |
|---|---|---|
containerElement |
HTMLElement | The element in which the menu will be rendered. |
Throws:
-
If containerElement is not a HTMLElement.
- Type
-
module:ct-core
/Error
set Model(model)
Allows you to set the model which will be rendered.
Parameters:
| Name | Type | Description |
|---|---|---|
model |
module:ct-menu |
Model to be rendered. |
Throws:
-
If model is not an instance of
module:ct-menu/Model. - Type
-
module:ct-core
/Error