Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
action_menu Class Reference
Inheritance diagram for action_menu:
renderable templatable

Public Member Functions

 __construct (array $actions=array())
 Constructs the action menu with the given items. More...
 
 add ($action)
 Adds an action to this action menu. More...
 
 add_primary_action ($action)
 Adds a primary action to the action menu. More...
 
 add_secondary_action ($action)
 Adds a secondary action to the action menu. More...
 
 do_not_enhance ()
 If you call this method the action menu will be displayed but will not be enhanced. More...
 
 export_for_template (renderer_base $output)
 Export for template. More...
 
 get_primary_actions (core_renderer $output=null)
 Returns the primary actions ready to be rendered. More...
 
 get_secondary_actions ()
 Returns the secondary actions ready to be rendered. More...
 
 initialise_js (moodle_page $page)
 Initialises JS required fore the action menu. More...
 
 is_empty ()
 Return true if there is at least one visible link in the menu. More...
 
 set_action_label ($label)
 Sets the label for the menu trigger. More...
 
 set_alignment ($dialogue, $button)
 Sets the alignment of the dialogue in relation to button used to toggle it. More...
 
 set_constraint ($ancestorselector)
 Sets a constraint for the dialogue. More...
 
 set_menu_trigger ($trigger, $extraclasses='')
 Sets the menu trigger text. More...
 
 set_nowrap_on_items ($value=true)
 Sets nowrap on items. More...
 
 set_owner_selector ($selector)
 Sets the selector that should be used to find the owning node of this menu. More...
 
 will_be_enhanced ()
 Returns true if this action menu will be enhanced. More...
 

Public Attributes

pix_icon $actionicon
 An icon to use for the toggling the secondary menu (dropdown).
 
array $actionlabel = null
 The string to use for the accessible label for the menu.
 
array $actiontext = null
 The string to use next to the icon for the action icon relating to the secondary (dropdown) menu.
 
array $attributes = array()
 An array of attributes added to the container of the action menu. More...
 
array $attributesprimary = array()
 An array of attributes added to the container of the primary actions. More...
 
array $attributessecondary = array()
 An array of attributes added to the container of the secondary actions. More...
 
string $menutrigger = ''
 Any text to use for the toggling the secondary menu (dropdown).
 
bool $prioritise = false
 Place the action menu before all other actions.
 
string $triggerextraclasses = ''
 Any extra classes for toggling to the secondary menu.
 
const BL = 3
 Top right alignment.
 
const BR = 4
 Top right alignment.
 
const TL = 1
 Top right alignment.
 
const TR = 2
 Top right alignment.
 

Protected Member Functions

 get_align_string ($align)
 Returns a string to describe the alignment. More...
 

Protected Attributes

int $instance = 0
 The instance number. More...
 
array $primaryactions = array()
 An array of primary actions. More...
 
array $secondaryactions = array()
 An array of secondary actions. More...
 

Constructor & Destructor Documentation

◆ __construct()

action_menu::__construct ( array  $actions = array())

Constructs the action menu with the given items.

Parameters
array$actionsAn array of actions (action_menu_link|pix_icon|string).

Member Function Documentation

◆ add()

action_menu::add (   $action)

Adds an action to this action menu.

Parameters
action_menu_link | pix_icon | string$action

◆ add_primary_action()

action_menu::add_primary_action (   $action)

Adds a primary action to the action menu.

Parameters
action_menu_link | action_link | pix_icon | string$action

◆ add_secondary_action()

action_menu::add_secondary_action (   $action)

Adds a secondary action to the action menu.

Parameters
action_link | pix_icon | string$action

◆ do_not_enhance()

action_menu::do_not_enhance ( )

If you call this method the action menu will be displayed but will not be enhanced.

By not displaying the menu enhanced all items will be displayed in a single row.

Deprecated:
since Moodle 3.2

◆ export_for_template()

action_menu::export_for_template ( renderer_base  $output)

Export for template.

Parameters
renderer_base$outputThe renderer.
Return values
stdClass

Implements templatable.

◆ get_align_string()

action_menu::get_align_string (   $align)
protected

Returns a string to describe the alignment.

Parameters
int$alignOne of action_menu::TL, action_menu::TR, action_menu::BL, action_menu::BR.
Return values
string

◆ get_primary_actions()

action_menu::get_primary_actions ( core_renderer  $output = null)

Returns the primary actions ready to be rendered.

Parameters
core_renderer$outputThe renderer to use for getting icons.
Return values
array

◆ get_secondary_actions()

action_menu::get_secondary_actions ( )

Returns the secondary actions ready to be rendered.

Return values
array

◆ initialise_js()

action_menu::initialise_js ( moodle_page  $page)

Initialises JS required fore the action menu.

The JS is only required once as it manages all action menu's on the page.

Parameters
moodle_page$page

◆ is_empty()

action_menu::is_empty ( )

Return true if there is at least one visible link in the menu.

Return values
bool

◆ set_action_label()

action_menu::set_action_label (   $label)

Sets the label for the menu trigger.

Parameters
string$labelThe text

◆ set_alignment()

action_menu::set_alignment (   $dialogue,
  $button 
)

Sets the alignment of the dialogue in relation to button used to toggle it.

Parameters
int$dialogueOne of action_menu::TL, action_menu::TR, action_menu::BL, action_menu::BR.
int$buttonOne of action_menu::TL, action_menu::TR, action_menu::BL, action_menu::BR.

◆ set_constraint()

action_menu::set_constraint (   $ancestorselector)

Sets a constraint for the dialogue.

The constraint is applied when the dialogue is shown and limits the display of the dialogue to within the element the constraint identifies.

This is required whenever the action menu is displayed inside any CSS element with the .no-overflow class (flexible_table and any of it's child classes are a likely candidate).

Parameters
string$ancestorselectorA snippet of CSS used to identify the ancestor to contrain the dialogue to.

◆ set_menu_trigger()

action_menu::set_menu_trigger (   $trigger,
  $extraclasses = '' 
)

Sets the menu trigger text.

Parameters
string$triggerThe text
string$extraclassesExtra classes to style the secondary menu toggle.

◆ set_nowrap_on_items()

action_menu::set_nowrap_on_items (   $value = true)

Sets nowrap on items.

If true menu items should not wrap lines if they are longer than the available space.

This property can be useful when the action menu is displayed within a parent element that is either floated or relatively positioned. In that situation the width of the menu is determined by the width of the parent element which may not be large enough for the menu items without them wrapping. This disables the wrapping so that the menu takes on the width of the longest item.

Parameters
bool$valueIf true nowrap gets set, if false it gets removed. Defaults to true.

◆ set_owner_selector()

action_menu::set_owner_selector (   $selector)

Sets the selector that should be used to find the owning node of this menu.

Parameters
string$selectorA CSS/YUI selector to identify the owner of the menu.

◆ will_be_enhanced()

action_menu::will_be_enhanced ( )

Returns true if this action menu will be enhanced.

Return values
bool

Member Data Documentation

◆ $attributes

array action_menu::$attributes = array()

An array of attributes added to the container of the action menu.

Initialised with defaults during construction.

◆ $attributesprimary

array action_menu::$attributesprimary = array()

An array of attributes added to the container of the primary actions.

Initialised with defaults during construction.

◆ $attributessecondary

array action_menu::$attributessecondary = array()

An array of attributes added to the container of the secondary actions.

Initialised with defaults during construction.

◆ $instance

int action_menu::$instance = 0
protected

The instance number.

This is unique to this instance of the action menu.

◆ $primaryactions

array action_menu::$primaryactions = array()
protected

An array of primary actions.

Please use action_menu::add_primary_action() to add actions.

◆ $secondaryactions

array action_menu::$secondaryactions = array()
protected

An array of secondary actions.

Please use action_menu::add_secondary_action() to add actions.


The documentation for this class was generated from the following file: