class MultiLevelPushMenu in Responsive Menus 8
Defines the "mlpm" plugin.
Plugin annotation
@ResponsiveMenus(
id = "mlpm",
label = @Translation("Multi Level Push Menu"),
library = "responsive_menus/mlpm"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\Core\Field\PluginSettingsBase implements DependentPluginInterface, PluginSettingsInterface
- class \Drupal\responsive_menus\ResponsiveMenusPluginBase implements ResponsiveMenusPluginInterface
- class \Drupal\responsive_menus\Plugin\ResponsiveMenus\MultiLevelPushMenu implements ResponsiveMenusPluginInterface
- class \Drupal\responsive_menus\ResponsiveMenusPluginBase implements ResponsiveMenusPluginInterface
- class \Drupal\Core\Field\PluginSettingsBase implements DependentPluginInterface, PluginSettingsInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of MultiLevelPushMenu
File
- src/
Plugin/ ResponsiveMenus/ MultiLevelPushMenu.php, line 18
Namespace
Drupal\responsive_menus\Plugin\ResponsiveMenusView source
class MultiLevelPushMenu extends ResponsiveMenusPluginBase implements ResponsiveMenusPluginInterface {
/**
* {@inheritdoc}
*/
public static function getSelectorInfo() {
return t('Parent of the @ul. Example: Given <code>@code</code> you would use @use', [
'@ul' => '<ul>',
'@code' => '<div id="parent-div"> <ul class="menu"> </ul> </div>',
'@use' => '<strong>#parent-div</strong>',
]);
}
/**
* {@inheritdoc}
*/
public static function defaultSettings() {
return [
'responsive_menus_mlpm_css_selectors' => '#main-menu',
'responsive_menus_mlpm_media_size' => 768,
'responsive_menus_mlpm_move_to' => '#page-wrapper',
'responsive_menus_mlpm_nav_block' => 1,
'responsive_menus_mlpm_nav_block_name' => 'mlpm-menu',
'responsive_menus_mlpm_push' => '#page',
'responsive_menus_mlpm_menu_height' => '100%',
'responsive_menus_mlpm_direction' => 'ltr',
'responsive_menus_mlpm_mode' => 'overlap',
'responsive_menus_mlpm_collapsed' => 1,
'responsive_menus_mlpm_full_collapse' => 0,
'responsive_menus_mlpm_swipe' => 'both',
'responsive_menus_mlpm_decoration' => [
'font_awesome' => 1,
'google_fonts' => 1,
'back_text' => 'Back',
'back_class' => 'backItemClass',
'back_icon' => 'fa fa-angle-right',
'group_icon' => 'fa fa-angle-left',
],
'responsive_menus_mlpm_toggle' => [
'container' => '',
'text' => '',
'off_menu' => '',
],
];
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
$form['responsive_menus_mlpm_css_selectors'] = [
'#type' => 'textfield',
'#title' => $this
->t('CSS selectors for which menu to responsify'),
'#default_value' => $this
->getSetting('responsive_menus_mlpm_css_selectors'),
'#description' => $this
->t('Enter CSS/jQuery selector of menus to responsify.'),
];
$form['responsive_menus_mlpm_media_size'] = [
'#type' => 'textfield',
'#title' => $this
->t('Screen width to respond to'),
'#size' => 5,
'#default_value' => $this
->getSetting('responsive_menus_mlpm_media_size'),
'#description' => $this
->t('Width in pixels when we swap out responsive menu e.g. 768 (0 means the responsive menu will always show)'),
];
$form['responsive_menus_mlpm_move_to'] = [
'#type' => 'textfield',
'#title' => $this
->t('CSS selector to move menu to'),
'#default_value' => $this
->getSetting('responsive_menus_mlpm_move_to'),
'#description' => $this
->t("Enter a CSS/JQuery selector of the container the nav menu will be moved to. This is useful when using a theme you don't want to alter."),
];
$form['responsive_menus_mlpm_nav_block'] = [
'#type' => 'select',
'#title' => $this
->t('Add nav block?'),
'#options' => [
1 => $this
->t('Yes'),
0 => $this
->t('No'),
],
'#default_value' => $this
->getSetting('responsive_menus_mlpm_nav_block'),
'#description' => $this
->t("MLPM requires a nav block to be in place. This can be added using javascript if you don't want to alter your theme."),
];
$form['responsive_menus_mlpm_nav_block_name'] = [
'#type' => 'textfield',
'#title' => $this
->t('Id for nav block'),
'#default_value' => $this
->getSetting('responsive_menus_mlpm_nav_block_name'),
'#description' => $this
->t('Enter the id of nav block.'),
];
$form['responsive_menus_mlpm_push'] = [
'#type' => 'textarea',
'#title' => $this
->t('CSS selectors of containers to push'),
'#default_value' => $this
->getSetting('responsive_menus_mlpm_push'),
'#description' => $this
->t('CSS/jQuery selectors of the elements that need to be pushed when expading the MLPM (one per line)'),
];
$form['responsive_menus_mlpm_menu_height'] = [
'#type' => 'textfield',
'#title' => 'Menu height',
'#description' => "Menu height (integer, '%', 'px', 'em').",
'#default_value' => $this
->getSetting('responsive_menus_mlpm_menu_height'),
];
$form['responsive_menus_mlpm_direction'] = [
'#type' => 'select',
'#title' => $this
->t('Sliding direction'),
'#options' => [
'ltr' => $this
->t('Left to right'),
'rtl' => $this
->t('Right to left'),
],
'#description' => '',
'#default_value' => $this
->getSetting('responsive_menus_mlpm_direction'),
];
$form['responsive_menus_mlpm_mode'] = [
'#type' => 'select',
'#title' => $this
->t('Menu sliding mode'),
'#options' => [
'overlap' => $this
->t('Overlap'),
'cover' => $this
->t('Cover'),
],
'#description' => '',
'#default_value' => $this
->getSetting('responsive_menus_mlpm_mode'),
];
$form['responsive_menus_mlpm_collapsed'] = [
'#type' => 'select',
'#title' => $this
->t('How to load the menu'),
'#options' => [
1 => $this
->t('Collapsed'),
0 => $this
->t('Expanded'),
],
'#description' => 'Initialize menu in collapsed/expanded mode',
'#default_value' => $this
->getSetting('responsive_menus_mlpm_collapsed'),
];
$form['responsive_menus_mlpm_full_collapse'] = [
'#type' => 'select',
'#title' => $this
->t('Full collapse'),
'#options' => [
1 => $this
->t('Yes'),
0 => $this
->t('No'),
],
'#description' => 'Do you want to fully hide base level holder when collapsed?',
'#default_value' => $this
->getSetting('responsive_menus_mlpm_full_collapse'),
];
$form['responsive_menus_mlpm_swipe'] = [
'#type' => 'select',
'#title' => $this
->t('Swipe mode'),
'#options' => [
'both' => $this
->t('Both'),
'desktop' => $this
->t('Desktop'),
'touchscreen' => $this
->t('Touchscreen'),
],
'#description' => '',
'#default_value' => $this
->getSetting('responsive_menus_mlpm_swipe'),
];
$form['responsive_menus_mlpm_decoration'] = [
'#type' => 'details',
'#title' => $this
->t('Menu decoration'),
'#open' => FALSE,
];
$style = $this
->getSetting('responsive_menus_mlpm_decoration');
$form['responsive_menus_mlpm_decoration']['font_awesome'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Include font awesome'),
'#description' => $this
->t('By default font awesome is used for the menu icons'),
'#default_value' => $style['font_awesome'],
];
$form['responsive_menus_mlpm_decoration']['google_fonts'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Include google fonts'),
'#description' => $this
->t('By default google fonts are used to style this menu.'),
'#default_value' => $style['google_fonts'],
];
$form['responsive_menus_mlpm_decoration']['back_text'] = [
'#type' => 'textfield',
'#title' => $this
->t('Back text'),
'#description' => $this
->t('The text that will appear on the back links leading you to previous levels of the menu.'),
'#default_value' => $style['back_text'],
];
$form['responsive_menus_mlpm_decoration']['back_class'] = [
'#type' => 'textfield',
'#title' => $this
->t('Back item class'),
'#description' => $this
->t('The class of the back link that leads to the pervious levels of the menu.'),
'#default_value' => $style['back_class'],
];
$form['responsive_menus_mlpm_decoration']['back_icon'] = [
'#type' => 'textfield',
'#title' => $this
->t('Back item icon'),
'#description' => $this
->t('The icon used for the back link that leads to previous levels of the menu (default requires font awesome).'),
'#default_value' => $style['back_icon'],
];
$form['responsive_menus_mlpm_decoration']['group_icon'] = [
'#type' => 'textfield',
'#title' => $this
->t('Group icon'),
'#description' => $this
->t('The icon used on menu links that lead into new layers of the menu (default requires font awesome).'),
'#default_value' => $style['group_icon'],
];
$form['responsive_menus_mlpm_toggle'] = [
'#type' => 'details',
'#title' => $this
->t('Toggle control'),
'#open' => FALSE,
];
$toggle = $this
->getSetting('responsive_menus_mlpm_toggle');
$form['responsive_menus_mlpm_toggle']['container'] = [
'#type' => 'textfield',
'#title' => $this
->t('Menu toggle control container'),
'#description' => $this
->t('The CSS/jQuery selector you would like an anchor tag that will toggle the menu open and closed (leave blank for no control).'),
'#default_value' => $toggle['container'],
];
$form['responsive_menus_mlpm_toggle']['text'] = [
'#type' => 'textarea',
'#title' => $this
->t('Menu toggle control text'),
'#description' => $this
->t('The text/filtered html you would like inside the toggle control'),
'#default_value' => $toggle['text'],
];
$form['responsive_menus_mlpm_toggle']['off_menu'] = [
'#type' => 'textfield',
'#title' => $this
->t('Container to detect off menu clicks'),
'#description' => $this
->t('The CSS/jQuery selector that will close the menu when clicked. This is useful for when you want to be able to close the menu by clicking off of the menu.'),
'#default_value' => $toggle['off_menu'],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function getJsSettings() {
$toggle = $this
->getSetting('responsive_menus_mlpm_toggle');
$style = $this
->getSetting('responsive_menus_mlpm_decoration');
$js_settings = [
'selectors' => $this
->getSetting('responsive_menus_mlpm_css_selectors'),
'media_size' => $this
->getSetting('responsive_menus_mlpm_media_size'),
'move_to' => $this
->getSetting('responsive_menus_mlpm_move_to'),
'nav_block' => $this
->getSetting('responsive_menus_mlpm_nav_block'),
'nav_block_name' => $this
->getSetting('responsive_menus_mlpm_nav_block_name'),
'push' => explode("\n", $this
->getSetting('responsive_menus_mlpm_push')),
'menu_height' => $this
->getSetting('responsive_menus_mlpm_menu_height'),
'direction' => $this
->getSetting('responsive_menus_mlpm_direction'),
'mode' => $this
->getSetting('responsive_menus_mlpm_mode'),
'collapsed' => $this
->getSetting('responsive_menus_mlpm_collapsed'),
'full_collapse' => $this
->getSetting('responsive_menus_mlpm_full_collapse'),
'swipe' => $this
->getSetting('responsive_menus_mlpm_swipe'),
'toggle_container' => $toggle['container'],
'toggle_text' => isset($toggle['text']) ? check_markup($toggle['text'], 'filtered_html') : '',
'off_menu' => $toggle['off_menu'],
'back_text' => $style['back_text'],
'back_class' => $style['back_class'],
'back_icon' => $style['back_icon'],
'group_icon' => $style['group_icon'],
];
return $js_settings;
}
/**
* Gets this plugin's configuration.
*
* @return array
* An array of this plugin's configuration.
*/
public function getConfiguration() {
// TODO: Implement getConfiguration() method.
}
/**
* Sets the configuration for this plugin instance.
*
* @param array $configuration
* An associative array containing the plugin's configuration.
*/
public function setConfiguration(array $configuration) {
// TODO: Implement setConfiguration() method.
}
/**
* Gets default configuration for this plugin.
*
* @return array
* An associative array with the default configuration.
*/
public function defaultConfiguration() {
// TODO: Implement defaultConfiguration() method.
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
MultiLevelPushMenu:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
|
MultiLevelPushMenu:: |
public static | function |
Defines the default settings for this plugin. Overrides PluginSettingsBase:: |
|
MultiLevelPushMenu:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
MultiLevelPushMenu:: |
public | function |
Get Drupal Javscript settings array. Overrides ResponsiveMenusPluginBase:: |
|
MultiLevelPushMenu:: |
public static | function |
Provide UI with plugins selector information. Overrides ResponsiveMenusPluginBase:: |
|
MultiLevelPushMenu:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
MultiLevelPushMenu:: |
public | function |
Form constructor. Overrides ResponsiveMenusPluginBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginSettingsBase:: |
protected | property | Whether default settings have been merged into the current $settings. | |
PluginSettingsBase:: |
protected | property | The plugin settings. | 2 |
PluginSettingsBase:: |
protected | property | The plugin settings injected by third party modules. | |
PluginSettingsBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
6 |
PluginSettingsBase:: |
public | function |
Returns the value of a setting, or its default value if absent. Overrides PluginSettingsInterface:: |
|
PluginSettingsBase:: |
public | function |
Returns the array of settings, including defaults for missing settings. Overrides PluginSettingsInterface:: |
|
PluginSettingsBase:: |
public | function |
Gets the list of third parties that store information. Overrides ThirdPartySettingsInterface:: |
|
PluginSettingsBase:: |
public | function |
Gets the value of a third-party setting. Overrides ThirdPartySettingsInterface:: |
|
PluginSettingsBase:: |
public | function |
Gets all third-party settings of a given module. Overrides ThirdPartySettingsInterface:: |
|
PluginSettingsBase:: |
protected | function | Merges default settings values into $settings. | |
PluginSettingsBase:: |
public | function |
Informs the plugin that some configuration it depends on will be deleted. Overrides PluginSettingsInterface:: |
3 |
PluginSettingsBase:: |
public | function |
Sets the value of a setting for the plugin. Overrides PluginSettingsInterface:: |
|
PluginSettingsBase:: |
public | function |
Sets the settings for the plugin. Overrides PluginSettingsInterface:: |
|
PluginSettingsBase:: |
public | function |
Sets the value of a third-party setting. Overrides ThirdPartySettingsInterface:: |
|
PluginSettingsBase:: |
public | function |
Unsets a third-party setting. Overrides ThirdPartySettingsInterface:: |
|
ResponsiveMenusPluginBase:: |
protected | function | Return array of selectors for JS settings. | |
ResponsiveMenusPluginBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |