3 namespace Drupal\superfish\Plugin\Block;
5 use Drupal\system\Plugin\Block\SystemMenuBlock;
6 use Drupal\Core\Menu\InaccessibleMenuLink;
7 use Drupal\Core\Menu\MenuTreeParameters;
8 use Drupal\Core\Form\FormStateInterface;
9 use Drupal\Component\Utility\Html;
12 * Provides a "Superfish" block.
16 * admin_label = @Translation("Superfish"),
18 * category = @Translation("Superfish"),
19 * deriver = "Drupal\system\Plugin\Derivative\SystemMenuBlock"
22 class SuperfishBlock extends SystemMenuBlock {
25 * Overrides \Drupal\block\BlockBase::blockForm().
27 public function blockForm($form, FormStateInterface $form_state) {
28 $form = parent::blockForm($form, $form_state);
29 $defaults = $this->defaultConfiguration();
32 '#title' => $this->t('Block settings'),
35 $form['sf']['superfish_type'] = array(
37 '#title' => $this->t('Menu type'),
38 '#description' => '<em>(' . $this->t('Default') . ': ' . $this->t('Horizontal (single row)') . ')</em>',
39 '#default_value' => $this->configuration['menu_type'],
41 'horizontal' => $this->t('Horizontal (single row)'),
42 'navbar' => $this->t('Horizontal (double row)'),
43 'vertical' => $this->t('Vertical (stack)')
46 $form['sf']['superfish_style'] = array(
48 '#title' => $this->t('Style'),
49 '#description' => '<em>(' . $this->t('Default') . ': ' . $this->t('None') . ')</em>',
50 '#default_value' => $this->configuration['style'],
52 'none' => $this->t('None'),
53 'default' => $this->t('Default'),
54 'black' => $this->t('Black'),
55 'blue' => $this->t('Blue'),
56 'coffee' => $this->t('Coffee'),
57 'white' => $this->t('White')
60 $form['sf']['superfish_arrow'] = array(
61 '#type' => 'checkbox',
62 '#title' => $this->t('Add arrows to parent menus'),
63 '#default_value' => $this->configuration['arrow'],
65 $form['sf']['superfish_shadow'] = array(
66 '#type' => 'checkbox',
67 '#title' => $this->t('Drop shadows'),
68 '#default_value' => $this->configuration['shadow'],
70 $form['sf']['superfish_slide'] = array(
72 '#title' => $this->t('Slide-in effect'),
73 '#description' => '<em>(' . $this->t('Default') . ': ' . $this->t('Vertical') . ')</em><br />' . ((count(superfish_effects()) == 4) ? $this->t('jQuery Easing plugin is not installed.') . '<br />' . $this->t('The plugin provides a handful number of animation effects, they can be used by uploading the \'jquery.easing.js\' file to the libraries directory within the \'easing\' directory (for example: sites/all/libraries/easing/jquery.easing.js). Refresh this page after the plugin is uploaded, this will make more effects available in the above list.') . '<br />' : ''),
74 '#default_value' => $this->configuration['slide'],
75 '#options' => superfish_effects(),
77 $form['sf-plugins'] = array(
79 '#title' => $this->t('Superfish plugins'),
82 $form['sf-plugins']['superfish_supposition'] = array(
83 '#type' => 'checkbox',
84 '#title' => $this->t('jQuery Supposition'),
85 '#description' => $this->t('Relocates sub-menus when they would otherwise appear outside the browser window area.') . ' <em>(' . $this->t('Default') . ': ' . $this->t('enabled') . ')</em>',
86 '#default_value' => $this->configuration['supposition'],
88 $form['sf-plugins']['superfish_hoverintent'] = array(
89 '#type' => 'checkbox',
90 '#title' => $this->t('jQuery hoverIntent'),
91 '#description' => $this->t('Prevents accidental firing of animations by waiting until the user\'s mouse slows down enough, hence determinig user\'s <em>intent</em>.') . ' <em>(' . $this->t('Default') . ': ' . $this->t('enabled') . ')</em>',
92 '#default_value' => $this->configuration['hoverintent'],
94 $form['sf-plugins']['sf-touchscreen'] = array(
96 '#title' => $this->t('sf-Touchscreen'),
97 '#description' => $this->t('<strong>sf-Touchscreen</strong> provides touchscreen compatibility.') . ' <sup>(' . $this->t('The first click on a parent hyperlink shows its children and the second click opens the hyperlink.') . ')</sup>',
100 $form['sf-plugins']['sf-touchscreen']['superfish_touch'] = array(
102 '#default_value' => $this->configuration['touch'],
104 0 => $this->t('Disable') . '. <sup>(' . $this->t('Default') . ')</sup>',
105 1 => $this->t('Enable jQuery sf-Touchscreen plugin for this menu.'),
106 2 => $this->t('Enable jQuery sf-Touchscreen plugin for this menu depending on the user\'s Web browser <strong>window width</strong>.'),
107 3 => $this->t('Enable jQuery sf-Touchscreen plugin for this menu depending on the user\'s Web browser <strong>user agent</strong>.'),
110 $form['sf-plugins']['sf-touchscreen']['superfish_touchbh'] = array(
112 '#title' => 'Select a behaviour',
113 '#description' => $this->t('Using this plugin, the first click or tap will expand the sub-menu, here you can choose what a second click or tap should do.'),
114 '#default_value' => $this->configuration['touchbh'],
116 0 => $this->t('Opening the parent menu item link on the second tap.'),
117 1 => $this->t('Hiding the sub-menu on the second tap.'),
118 2 => $this->t('Hiding the sub-menu on the second tap, adding cloned parent links to the top of sub-menus as well.') . ' <sup>(' . $this->t('Default') . ')</sup>',
121 $form['sf-plugins']['sf-touchscreen']['sf-touchscreen-windowwidth'] = array(
122 '#type' => 'details',
123 '#title' => $this->t('Window width settings'),
124 '#description' => $this->t('sf-Touchscreen will be enabled only if the width of user\'s Web browser window is smaller than the below value.') . '<br /><br />' . $this->t('Please note that in most cases such a meta tag is necessary for this feature to work properly:') . '<br /><code><meta name="viewport" content="width=device-width, initial-scale=1.0" /></code>',
127 $form['sf-plugins']['sf-touchscreen']['sf-touchscreen-windowwidth']['superfish_touchbp'] = array(
128 '#type' => 'textfield',
129 '#description' => $this->t('Also known as "Breakpoint".') . ' <em>(' . $this->t('Default') . ': 768)</em>',
130 '#default_value' => $this->configuration['touchbp'],
131 '#field_suffix' => $this->t('pixels'),
134 $form['sf-plugins']['sf-touchscreen']['sf-touchscreen-useragent'] = array(
135 '#type' => 'details',
136 '#title' => $this->t('User agent settings'),
139 $form['sf-plugins']['sf-touchscreen']['sf-touchscreen-useragent']['superfish_touchua'] = array(
141 '#default_value' => $this->configuration['touchua'],
143 0 => $this->t('Use the pre-defined list of the <strong>user agents</strong>.') . '<sup>(' . $this->t('Default') . ') (' . $this->t('Recommended') . ')</sup>',
144 1 => $this->t('Use the custom list of the <strong>user agents</strong>.'),
147 $form['sf-plugins']['sf-touchscreen']['sf-touchscreen-useragent']['superfish_touchual'] = array(
148 '#type' => 'textfield',
149 '#title' => $this->t('Custom list of the user agents'),
150 '#description' => $this->t('Could be partial or complete. (Asterisk separated)') . ' <em>(' . $this->t('Default') . ': ' . $this->t('empty') . ')</em><br />' . $this->t('Examples') . ':<ul><li>iPhone*Android*iPad <sup>(' . $this->t('Recommended') . ')</sup></li><li>Mozilla/5.0 (webOS/1.4.0; U; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Version/1.0 Safari/532.2 Pre/1.0 * Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405</li></ul>' . ((isset($_SERVER['HTTP_USER_AGENT'])) ? '<br />' . $this->t('<strong>UA string of the current Web browser:</strong>') . ' ' . $_SERVER['HTTP_USER_AGENT'] : ''),
151 '#default_value' => $this->configuration['touchual'],
153 '#maxlength' => 2000,
155 $form['sf-plugins']['sf-touchscreen']['sf-touchscreen-useragent']['superfish_touchuam'] = array(
157 '#title' => $this->t('<strong>User agent</strong> detection method'),
158 '#description' => '<em>(' . $this->t('Default') . ': ' . $this->t('Client-side (JavaScript)') . ')</em>',
159 '#default_value' => $this->configuration['touchuam'],
161 0 => $this->t('Client-side (JavaScript)'),
162 1 => $this->t('Server-side (PHP)')
165 $form['sf-plugins']['sf-smallscreen'] = array(
166 '#type' => 'details',
167 '#title' => $this->t('sf-Smallscreen'),
168 '#description' => $this->t('<strong>sf-Smallscreen</strong> provides small-screen compatibility for your menus.') . ' <sup>(' . $this->t('Converts the dropdown into a <select> element.') . ')</sup>',
171 $form['sf-plugins']['sf-smallscreen']['superfish_small'] = array(
173 '#default_value' => $this->configuration['small'],
175 0 => $this->t('Disable') . '.',
176 1 => $this->t('Enable jQuery sf-Smallscreen plugin for this menu.'),
177 2 => $this->t('Enable jQuery sf-Smallscreen plugin for this menu depending on the user\'s Web browser <strong>window width</strong>.') . ' <sup>(' . $this->t('Default') . ')</sup>',
178 3 => $this->t('Enable jQuery sf-Smallscreen plugin for this menu depending on the user\'s Web browser <strong>user agent</strong>.'),
181 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-windowwidth'] = array(
182 '#type' => 'details',
183 '#title' => $this->t('Window width settings'),
184 '#description' => $this->t('sf-Smallscreen will be enabled only if the width of user\'s Web browser window is smaller than the below value.') . '<br /><br />' . $this->t('Please note that in most cases such a meta tag is necessary for this feature to work properly:') . '<br /><code><meta name="viewport" content="width=device-width, initial-scale=1.0" /></code>',
187 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-windowwidth']['superfish_smallbp'] = array(
188 '#type' => 'textfield',
189 '#description' => $this->t('Also known as "Breakpoint".') . ' <em>(' . $this->t('Default') . ': 768)</em>',
190 '#default_value' => $this->configuration['smallbp'],
191 '#field_suffix' => $this->t('pixels'),
194 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-useragent'] = array(
195 '#type' => 'details',
196 '#title' => $this->t('User agent settings'),
199 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-useragent']['superfish_smallua'] = array(
201 '#default_value' => $this->configuration['smallua'],
203 0 => $this->t('Use the pre-defined list of the <strong>user agents</strong>.') . '<sup>(' . $this->t('Default') . ') (' . $this->t('Recommended') . ')</sup>',
204 1 => $this->t('Use the custom list of the <strong>user agents</strong>.'),
207 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-useragent']['superfish_smallual'] = array(
208 '#type' => 'textfield',
209 '#title' => $this->t('Custom list of the user agents'),
210 '#description' => $this->t('Could be partial or complete. (Asterisk separated)') . ' <em>(' . $this->t('Default') . ': ' . $this->t('empty') . ')</em><br />' . $this->t('Examples') . ':<ul><li>iPhone*Android*iPad <sup>(' . $this->t('Recommended') . ')</sup></li><li>Mozilla/5.0 (webOS/1.4.0; U; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Version/1.0 Safari/532.2 Pre/1.0 * Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405</li></ul>' . ((isset($_SERVER['HTTP_USER_AGENT'])) ? '<br />' . $this->t('<strong>UA string of the current Web browser:</strong>') . ' ' . $_SERVER['HTTP_USER_AGENT'] : ''),
211 '#default_value' => $this->configuration['smallual'],
213 '#maxlength' => 2000,
215 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-useragent']['superfish_smalluam'] = array(
217 '#title' => $this->t('<strong>User agent</strong> detection method'),
218 '#description' => '<em>(' . $this->t('Default') . ': ' . $this->t('Client-side (JavaScript)') . ')</em>',
219 '#default_value' => $this->configuration['smalluam'],
221 0 => $this->t('Client-side (JavaScript)'),
222 1 => $this->t('Server-side (PHP)')
225 $form['sf-plugins']['sf-smallscreen']['superfish_smallact'] = array(
227 '#title' => $this->t('Select a type'),
228 '#default_value' => $this->configuration['smallact'],
230 0 => $this->t('Convert the menu to a <select> element.'),
231 1 => $this->t('Convert the menu to an accordion menu.') . ' <sup>(' . $this->t('Default') . ')</sup>',
234 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-select'] = array(
235 '#type' => 'details',
236 '#title' => $this->t('<select> settings'),
239 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-select']['superfish_smallset'] = array(
240 '#type' => 'textfield',
241 '#title' => $this->t('<select> title'),
242 '#description' => $this->t('By default the first item in the <select> element will be the name of the parent menu or the title of this block, you can change this by setting a custom title.') . ' <em>(' . $this->t('Default') . ': ' . $this->t('empty') . ')</em><br />' . $this->t('Example') . ': <em> - ' . $this->t('Main Menu') . ' - </em>.',
243 '#default_value' => $this->configuration['smallset'],
247 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-select']['superfish_smallasa'] = array(
248 '#type' => 'checkbox',
249 '#title' => $this->t('Add <em>selected</em> attribute to the <option> element with the class <strong>active</strong> .'),
250 '#description' => $this->t('Makes pre-selected the item linked to the active page when the page loads.'),
251 '#default_value' => $this->configuration['smallasa'],
253 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-select']['sf-smallscreen-select-more'] = array(
254 '#type' => 'details',
255 '#title' => $this->t('More'),
258 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-select']['sf-smallscreen-select-more']['superfish_smallcmc'] = array(
259 '#type' => 'checkbox',
260 '#title' => $this->t('Copy the main <ul> classes to the <select>.') . ' <sup><em>(' . $this->t('Default') . ': ' . $this->t('disabled') . ')</em></sup>',
261 '#default_value' => $this->configuration['smallcmc'],
263 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-select']['sf-smallscreen-select-more']['superfish_smallecm'] = array(
264 '#type' => 'textfield',
265 '#title' => $this->t('Exclude these classes from the <select> element'),
266 '#description' => $this->t('Comma separated') . ' <em>(' . $this->t('Default') . ': ' . $this->t('empty') . ')</em>',
267 '#default_value' => $this->configuration['smallecm'],
269 '#maxlength' => 1000,
272 ':input[name="superfish_smallcmc' . '"]' => array('checked' => TRUE),
276 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-select']['sf-smallscreen-select-more']['superfish_smallchc'] = array(
277 '#type' => 'checkbox',
278 '#title' => $this->t('Copy the hyperlink classes to the <option> elements of the <select>.') . ' <sup><em>(' . $this->t('Default') . ': ' . $this->t('disabled') . ')</em></sup>',
279 '#default_value' => $this->configuration['smallchc'],
281 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-select']['sf-smallscreen-select-more']['superfish_smallech'] = array(
282 '#type' => 'textfield',
283 '#title' => $this->t('Exclude these classes from the <option> elements of the <select>'),
284 '#description' => $this->t('Comma separated') . ' <em>(' . $this->t('Default') . ': ' . $this->t('empty') . ')</em>',
285 '#default_value' => $this->configuration['smallech'],
287 '#maxlength' => 1000,
290 ':input[name="superfish_smallchc' . '"]' => array('checked' => TRUE),
294 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-select']['sf-smallscreen-select-more']['superfish_smallicm'] = array(
295 '#type' => 'textfield',
296 '#title' => $this->t('Include these classes in the <select> element'),
297 '#description' => $this->t('Comma separated') . ' <em>(' . $this->t('Default') . ': ' . $this->t('empty') . ')</em>',
298 '#default_value' => $this->configuration['smallicm'],
300 '#maxlength' => 1000,
302 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-select']['sf-smallscreen-select-more']['superfish_smallich'] = array(
303 '#type' => 'textfield',
304 '#title' => $this->t('Include these classes in the <option> elements of the <select>'),
305 '#description' => $this->t('Comma separated') . ' <em>(' . $this->t('Default') . ': ' . $this->t('empty') . ')</em>',
306 '#default_value' => $this->configuration['smallich'],
308 '#maxlength' => 1000,
310 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-accordion'] = array(
311 '#type' => 'details',
312 '#title' => $this->t('Accordion settings'),
315 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-accordion']['superfish_smallamt'] = array(
316 '#type' => 'textfield',
317 '#title' => $this->t('Accordion menu title'),
318 '#description' => $this->t('By default the caption of the accordion toggle switch will be the name of the parent menu or the title of this block, you can change this by setting a custom title.') . ' <em>(' . $this->t('Default') . ': ' . $this->t('empty') . ')</em><br />' . $this->t('Example') . ': <em>' . $this->t('Menu') . '</em>.',
319 '#default_value' => $this->configuration['smallamt'],
323 $form['sf-plugins']['sf-smallscreen']['sf-smallscreen-accordion']['superfish_smallabt'] = array(
325 '#title' => $this->t('Accordion button type'),
326 '#default_value' => $this->configuration['smallabt'],
328 0 => $this->t('Use parent menu items as buttons.'),
329 1 => $this->t('Use parent menu items as buttons, add cloned parent links to sub-menus as well.') . ' <sup>(' . $this->t('Default') . ')</sup>',
330 2 => $this->t('Create new links next to parent menu item links and use them as buttons.'),
333 $form['sf-plugins']['sf-supersubs'] = array(
334 '#type' => 'details',
335 '#title' => $this->t('Supersubs'),
336 '#description' => $this->t('<strong>Supersubs</strong> makes it possible to define custom widths for your menus.'),
339 $form['sf-plugins']['sf-supersubs']['superfish_supersubs'] = array(
340 '#type' => 'checkbox',
341 '#title' => $this->t('Enable Supersubs for this menu.'),
342 '#default_value' => $this->configuration['supersubs'],
344 $form['sf-plugins']['sf-supersubs']['superfish_minwidth'] = array(
345 '#type' => 'textfield',
346 '#title' => $this->t('Minimum width'),
347 '#description' => $this->t('Minimum width for sub-menus, in <strong>em</strong> units.') . ' <em>(' . $this->t('Default') . ': 12)</em>',
348 '#default_value' => $this->configuration['minwidth'],
351 $form['sf-plugins']['sf-supersubs']['superfish_maxwidth'] = array(
352 '#type' => 'textfield',
353 '#title' => $this->t('Maximum width'),
354 '#description' => $this->t('Maximum width for sub-menus, in <strong>em</strong> units.') . ' <em>(' . $this->t('Default') . ': 27)</em>',
355 '#default_value' => $this->configuration['maxwidth'],
358 $form['sf-multicolumn'] = array(
359 '#type' => 'details',
360 '#title' => $this->t('Multi-column sub-menus'),
363 $form['sf-multicolumn']['superfish_multicolumn'] = array(
364 '#type' => 'checkbox',
365 '#title' => $this->t('Enable multi-column sub-menus.'),
366 '#default_value' => $this->configuration['multicolumn'],
368 $form['sf-multicolumn']['superfish_multicolumn_depth'] = array(
370 '#title' => $this->t('Start from depth'),
371 '#description' => $this->t('The depth of the first instance of multi-column sub-menus.') . ' <em>(' . $this->t('Default') . ': 1)</em>',
372 '#default_value' => $this->configuration['multicolumn_depth'],
373 '#options' => array_combine(range(1, 10),range(1, 10)),
375 $form['sf-multicolumn']['superfish_multicolumn_levels'] = array(
377 '#title' => $this->t('Levels'),
378 '#description' => $this->t('The amount of sub-menu levels that will be included in the multi-column sub-menu.') . ' <em>(' . $this->t('Default') . ': 1)</em>',
379 '#default_value' => $this->configuration['multicolumn_levels'],
380 '#options' => array_combine(range(1, 10),range(1, 10)),
382 $form['sf-advanced'] = array(
383 '#type' => 'details',
384 '#title' => $this->t('Advanced settings'),
387 $form['sf-advanced']['sf-settings'] = array(
388 '#type' => 'details',
389 '#title' => $this->t('Superfish'),
392 $form['sf-advanced']['sf-settings']['superfish_speed'] = array(
393 '#type' => 'textfield',
394 '#title' => $this->t('Animation speed'),
395 '#description' => $this->t('The speed of the animation either in <strong>milliseconds</strong> or pre-defined values (<strong>slow, normal, fast</strong>).') . ' <em>(' . $this->t('Default') . ': fast)</em>',
396 '#default_value' => $this->configuration['speed'],
399 $form['sf-advanced']['sf-settings']['superfish_delay'] = array(
401 '#title' => $this->t('Mouse delay'),
402 '#description' => $this->t('The delay in <strong>milliseconds</strong> that the mouse can remain outside a sub-menu without it closing.') . ' <em>(' . $this->t('Default') . ': 800)</em>',
403 '#default_value' => $this->configuration['delay'],
406 $form['sf-advanced']['sf-settings']['superfish_pathlevels'] = array(
408 '#title' => $this->t('Path levels'),
409 '#description' => $this->t('The amount of sub-menu levels that remain open or are restored using the ".active-trail" class.') . ' <em>(' . $this->t('Default') . ': 1)</em><br />' . $this->t('Change this setting <strong>only and only</strong> if you are <strong>totally sure</strong> of what you are doing.'),
410 '#default_value' => $this->configuration['pathlevels'],
411 '#options' => array_combine(range(0, 10),range(0, 10)),
413 $form['sf-advanced']['sf-hyperlinks'] = array(
414 '#type' => 'details',
415 '#title' => $this->t('Hyperlinks'),
418 $form['sf-advanced']['sf-hyperlinks']['superfish_expanded'] = array(
419 '#type' => 'checkbox',
420 '#title' => $this->t('Take "Expanded" option into effect.'),
421 '#description' => $this->t('By enabling this option, only parent menu items with <em>Expanded</em> option enabled will have their submenus appear.') . ' <em>(' . $this->t('Default') . ': ' . $this->t('disabled') . ')</em>',
422 '#default_value' => $this->configuration['expanded'],
424 $form['sf-advanced']['sf-hyperlinks']['superfish_clone_parent'] = array(
425 '#type' => 'checkbox',
426 '#title' => $this->t('Add cloned parent links to the top of sub-menus.') . ' <em>(' . $this->t('Default') . ': ' . $this->t('disabled') . ')</em>',
427 '#default_value' => $this->configuration['clone_parent'],
429 $form['sf-advanced']['sf-hyperlinks']['superfish_hide_linkdescription'] = array(
430 '#type' => 'checkbox',
431 '#title' => $this->t('Disable hyperlink descriptions ("title" attribute)') . ' <em>(' . $this->t('Default') . ': ' . $this->t('disabled') . ')</em>',
432 '#default_value' => $this->configuration['hide_linkdescription'],
434 $form['sf-advanced']['sf-hyperlinks']['superfish_add_linkdescription'] = array(
435 '#type' => 'checkbox',
436 '#title' => $this->t('Insert hyperlink descriptions ("title" attribute) into hyperlink texts.') . ' <em>(' . $this->t('Default') . ': ' . $this->t('disabled') . ')</em>',
437 '#default_value' => $this->configuration['add_linkdescription'],
439 $form['sf-advanced']['sf-hyperlinks']['superfish_itemdepth'] = array(
440 '#type' => 'checkbox',
441 '#title' => $this->t('Add <strong>item depth</strong> class to menu items and their hyperlinks.') . '<em>(sf-depth-1, sf-depth-2, sf-depth-3, ...)</em> <em>(' . $this->t('Default') . ': ' . $this->t('enabled') . ')</em>',
442 '#default_value' => $this->configuration['link_depth_class'],
444 $form['sf-advanced']['sf-custom-classes'] = array(
445 '#type' => 'details',
446 '#title' => $this->t('Custom classes'),
449 $form['sf-advanced']['sf-custom-classes']['superfish_ulclass'] = array(
450 '#type' => 'textfield',
451 '#title' => $this->t('For the main UL'),
452 '#description' => $this->t('(Space separated, without dots)') . ' <em>(' . $this->t('Default') . ': ' . $this->t('empty') . ')</em><br />' . $this->t('Example') . ': top-menu category-science',
453 '#default_value' => $this->configuration['custom_list_class'],
455 '#maxlength' => 1000,
457 $form['sf-advanced']['sf-custom-classes']['superfish_liclass'] = array(
458 '#type' => 'textfield',
459 '#title' => $this->t('For the list items'),
460 '#description' => $this->t('(Space separated, without dots)') . ' <em>(' . $this->t('Default') . ': ' . $this->t('empty') . ')</em><br />' . $this->t('Example') . ': science-sub',
461 '#default_value' => $this->configuration['custom_item_class'],
463 '#maxlength' => 1000,
465 $form['sf-advanced']['sf-custom-classes']['superfish_hlclass'] = array(
466 '#type' => 'textfield',
467 '#title' => $this->t('For the hyperlinks'),
468 '#description' => $this->t('(Space separated, without dots)') . ' <em>(' . $this->t('Default') . ': ' . $this->t('empty') . ')</em><br />' . $this->t('Example') . ': science-link',
469 '#default_value' => $this->configuration['custom_link_class'],
471 '#maxlength' => 1000,
477 * Overrides \Drupal\block\BlockBase::blockValiate().
479 public function blockValidate($form, FormStateInterface $form_state) {
481 // Commented out for now as I couldn't get validation to work, with RC4 at least.
483 $touch = $form_state->getValue(array('sf-plugins', 'sf-touchscreen', 'sf-touchscreen-useragent', 'superfish_touch'));
484 $touchbp = $form_state->getValue(array('sf-plugins', 'sf-touchscreen', 'sf-touchscreen-windowwidth', 'superfish_touchbp'));
485 $touchua = $form_state->getValue(array('sf-plugins', 'sf-touchscreen', 'sf-touchscreen-useragent', 'superfish_touchua'));
486 $touchual = $form_state->getValue(array('sf-plugins', 'sf-touchscreen', 'sf-touchscreen-useragent', 'superfish_touchual'));
487 $small = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-useragent', 'superfish_small'));
488 $smallbp = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-useragent', 'superfish_smallbp'));
489 $smallua = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-useragent', 'superfish_smallua'));
490 $smallual = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-useragent', 'superfish_smallual'));
491 $minwidth = $form_state->getValue(array('sf-plugins', 'sf-supersubs', 'superfish_minwidth'));
492 $maxwidth = $form_state->getValue(array('sf-plugins', 'sf-supersubs', 'superfish_maxwidth'));
493 $speed = $form_state->getValue(array('sf-advanced', 'sf-settings', 'superfish_speed'));
494 $delay = $form_state->getValue(array('sf-advanced', 'sf-settings', 'superfish_delay'));
496 if (!is_numeric($speed) && !in_array($speed, array('slow', 'normal', 'fast'))) {
497 $form_state->setErrorByName('superfish_speed', t('Unacceptable value entered for the "Animation speed" option.'));
499 if (!is_numeric($delay)) {
500 $form_state->setErrorByName('superfish_delay', t('Unacceptable value entered for the "Mouse delay" option.'));
502 if ($touch == 2 && $touchbp == '') {
503 $form_state->setErrorByName('superfish_touchbp', t('"sfTouchscreen Breakpoint" option cannot be empty.'));
505 if (!is_numeric($touchbp)) {
506 $form_state->setErrorByName('superfish_touchbp', t('Unacceptable value enterd for the "sfTouchscreen Breakpoint" option.'));
508 if ($touch == 3 && $touchua == 1 && $touchual == '') {
509 $form_state->setErrorByName('superfish_touchual', t('List of the touch-screen user agents cannot be empty.'));
511 if ($small == 2 && $smallbp == '') {
512 $form_state->setErrorByName('superfish_smallbp', t('"sfSmallscreen Breakpoint" option cannot be empty.'));
514 if (!is_numeric($smallbp)) {
515 $form_state->setErrorByName('superfish_smallbp', t('Unacceptable value entered for the "sfSmallscreen Breakpoint" option.'));
517 if ($small == 3 && $smallua == 1 && $smallual == '') {
518 $form_state->setErrorByName('superfish_smallual', t('List of the small-screen user agents cannot be empty.'));
521 $supersubs_error = FALSE;
522 if (!is_numeric($minwidth)) {
523 $form_state->setErrorByName('superfish_minwidth', t('Unacceptable value entered for the "Supersubs minimum width" option.'));
524 $supersubs_error = TRUE;
526 if (!is_numeric($maxwidth)) {
527 $form_state->setErrorByName('superfish_maxwidth', t('Unacceptable value entered for the "Supersubs maximum width" option.'));
528 $supersubs_error = TRUE;
530 if ($supersubs_error !== TRUE && $minwidth > $maxwidth) {
531 $form_state->setErrorByName('superfish_maxwidth', t('Supersubs "maximum width" has to be bigger than the "minimum width".'));
534 parent::blockValidate($form, $form_state);
539 * Overrides \Drupal\block\BlockBase::blockSubmit().
541 public function blockSubmit($form, FormStateInterface $form_state) {
543 $this->configuration['level'] = $form_state->getValue('level');
544 $this->configuration['depth'] = $form_state->getValue('depth');
545 $this->configuration['menu_type'] = $form_state->getValue(array('sf', 'superfish_type'));
546 $this->configuration['style'] = $form_state->getValue(array('sf', 'superfish_style'));
547 $this->configuration['arrow'] = $form_state->getValue(array('sf', 'superfish_arrow'));
548 $this->configuration['shadow'] = $form_state->getValue(array('sf', 'superfish_shadow'));
549 $this->configuration['slide'] = $form_state->getValue(array('sf', 'superfish_slide'));
551 $this->configuration['supposition'] = $form_state->getValue(array('sf-plugins', 'superfish_supposition'));
552 $this->configuration['hoverintent'] = $form_state->getValue(array('sf-plugins', 'superfish_hoverintent'));
554 $this->configuration['touch'] = $form_state->getValue(array('sf-plugins', 'sf-touchscreen', 'superfish_touch'));
555 $this->configuration['touchbh'] = $form_state->getValue(array('sf-plugins', 'sf-touchscreen', 'superfish_touchbh'));
556 $this->configuration['touchbp'] = $form_state->getValue(array('sf-plugins', 'sf-touchscreen', 'sf-touchscreen-windowwidth', 'superfish_touchbp'));
557 $this->configuration['touchua'] = $form_state->getValue(array('sf-plugins', 'sf-touchscreen', 'sf-touchscreen-useragent', 'superfish_touchua'));
558 $this->configuration['touchual'] = $form_state->getValue(array('sf-plugins', 'sf-touchscreen', 'sf-touchscreen-useragent', 'superfish_touchual'));
559 $this->configuration['touchuam'] = $form_state->getValue(array('sf-plugins', 'sf-touchscreen', 'sf-touchscreen-useragent', 'superfish_touchuam'));
561 $this->configuration['small'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'superfish_small'));
562 $this->configuration['smallact'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'superfish_smallact'));
563 $this->configuration['smallbp'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-windowwidth', 'superfish_smallbp'));
564 $this->configuration['smallua'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-useragent', 'superfish_smallua'));
565 $this->configuration['smallual'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-useragent', 'superfish_smallual'));
566 $this->configuration['smalluam'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-useragent', 'superfish_smalluam'));
567 $this->configuration['smallset'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-select', 'superfish_smallset'));
568 $this->configuration['smallasa'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-select', 'superfish_smallasa'));
569 $this->configuration['smallcmc'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-select', 'sf-smallscreen-select-more', 'superfish_smallcmc'));
570 $this->configuration['smallecm'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-select', 'sf-smallscreen-select-more', 'superfish_smallecm'));
571 $this->configuration['smallchc'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-select', 'sf-smallscreen-select-more', 'superfish_smallchc'));
572 $this->configuration['smallech'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-select', 'sf-smallscreen-select-more', 'superfish_smallech'));
573 $this->configuration['smallicm'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-select', 'sf-smallscreen-select-more', 'superfish_smallicm'));
574 $this->configuration['smallich'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-select', 'sf-smallscreen-select-more', 'superfish_smallich'));
575 $this->configuration['smallamt'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-accordion', 'superfish_smallamt'));
576 $this->configuration['smallabt'] = $form_state->getValue(array('sf-plugins', 'sf-smallscreen', 'sf-smallscreen-accordion', 'superfish_smallabt'));
578 $this->configuration['supersubs'] = $form_state->getValue(array('sf-plugins', 'sf-supersubs', 'superfish_supersubs'));
579 $this->configuration['minwidth'] = $form_state->getValue(array('sf-plugins', 'sf-supersubs', 'superfish_minwidth'));
580 $this->configuration['maxwidth'] = $form_state->getValue(array('sf-plugins', 'sf-supersubs', 'superfish_maxwidth'));
582 $this->configuration['multicolumn'] = $form_state->getValue(array('sf-multicolumn', 'superfish_multicolumn'));
583 $this->configuration['multicolumn_depth'] = $form_state->getValue(array('sf-multicolumn', 'superfish_multicolumn_depth'));
584 $this->configuration['multicolumn_levels'] = $form_state->getValue(array('sf-multicolumn', 'superfish_multicolumn_levels'));
586 $this->configuration['speed'] = $form_state->getValue(array('sf-advanced', 'sf-settings', 'superfish_speed'));
587 $this->configuration['delay'] = $form_state->getValue(array('sf-advanced', 'sf-settings', 'superfish_delay'));
588 $this->configuration['pathlevels'] = $form_state->getValue(array('sf-advanced', 'sf-settings', 'superfish_pathlevels'));
589 $this->configuration['expanded'] = $form_state->getValue(array('sf-advanced', 'sf-hyperlinks', 'superfish_expanded'));
590 $this->configuration['clone_parent'] = $form_state->getValue(array('sf-advanced', 'sf-hyperlinks', 'superfish_clone_parent'));
591 $this->configuration['hide_linkdescription'] = $form_state->getValue(array('sf-advanced', 'sf-hyperlinks', 'superfish_hide_linkdescription'));
592 $this->configuration['add_linkdescription'] = $form_state->getValue(array('sf-advanced', 'sf-hyperlinks', 'superfish_add_linkdescription'));
593 $this->configuration['link_depth_class'] = $form_state->getValue(array('sf-advanced', 'sf-hyperlinks', 'superfish_itemdepth'));
594 $this->configuration['custom_list_class'] = $form_state->getValue(array('sf-advanced', 'sf-custom-classes', 'superfish_ulclass'));
595 $this->configuration['custom_item_class'] = $form_state->getValue(array('sf-advanced', 'sf-custom-classes', 'superfish_liclass'));
596 $this->configuration['custom_link_class'] = $form_state->getValue(array('sf-advanced', 'sf-custom-classes', 'superfish_hlclass'));
600 * Implements \Drupal\block\BlockBase::build().
602 public function build() {
606 // Block settings which will be passed to the Superfish themes.
607 $sfsettings = array();
608 $sfsettings['level'] = $this->configuration['level'];
609 $sfsettings['depth'] = $this->configuration['depth'];
610 $sfsettings['menu_type'] = $this->configuration['menu_type'];
611 $sfsettings['style'] = $this->configuration['style'];
612 $sfsettings['expanded'] = $this->configuration['expanded'];
613 $sfsettings['itemdepth'] = $this->configuration['link_depth_class'];
614 $sfsettings['ulclass'] = $this->configuration['custom_list_class'];
615 $sfsettings['liclass'] = $this->configuration['custom_item_class'];
616 $sfsettings['hlclass'] = $this->configuration['custom_link_class'];
617 $sfsettings['clone_parent'] = $this->configuration['clone_parent'];
618 $sfsettings['hide_linkdescription'] = $this->configuration['hide_linkdescription'];
619 $sfsettings['add_linkdescription'] = $this->configuration['add_linkdescription'];
620 $sfsettings['multicolumn'] = $this->configuration['multicolumn'];
621 $sfsettings['multicolumn_depth'] = ($this->configuration['menu_type'] == 'navbar' && $this->configuration['multicolumn_depth'] == 1) ? 2 : $this->configuration['multicolumn_depth'];
622 $sfsettings['multicolumn_levels'] = $this->configuration['multicolumn_levels'] + $sfsettings['multicolumn_depth'];
624 // jQuery plugin options which will be passed to the Drupal behavior.
625 $sfoptions = array();
626 $sfoptions['pathClass'] = ($sfsettings['menu_type'] == 'navbar') ? 'active-trail' : '';
627 $sfoptions['pathLevels'] = ($this->configuration['pathlevels'] != 1) ? $this->configuration['pathlevels'] : '';
628 $sfoptions['delay'] = ($this->configuration['delay'] != 800) ? $this->configuration['delay'] : '';
629 $sfoptions['animation']['opacity'] = 'show';
630 $slide = $this->configuration['slide'];
631 if (strpos($slide, '_')) {
632 $slide = explode('_', $slide);
635 $sfoptions['animation']['height'] = array('show', $slide[0]);
638 $sfoptions['animation']['width'] = array('show', $slide[0]);
641 $sfoptions['animation']['height'] = array('show', $slide[0]);
642 $sfoptions['animation']['width'] = array('show', $slide[0]);
645 $build['#attached']['library'][] = 'superfish/superfish_easing';
650 $sfoptions['animation']['height'] = 'show';
653 $sfoptions['animation']['width'] = 'show';
656 $sfoptions['animation']['height'] = 'show';
657 $sfoptions['animation']['width'] = 'show';
661 $speed = $this->configuration['speed'];
662 if ($speed != 'normal') {
663 $sfoptions['speed'] = ((is_numeric($speed)) ? (int)$speed : (($speed == ('slow' || 'normal' || 'fast')) ? $speed : ''));
665 $sfoptions['autoArrows'] = ($this->configuration['arrow'] == 0) ? FALSE : '';
666 $sfoptions['dropShadows'] = ($this->configuration['shadow'] == 0) ? FALSE : '';
668 if ($this->configuration['hoverintent']) {
669 $build['#attached']['library'][] = 'superfish/superfish_hoverintent';
672 $sfoptions['disableHI'] = TRUE;
674 $sfoptions = superfish_array_remove_empty($sfoptions);
676 // Options for Superfish sub-plugins.
677 $sfplugins = array();
678 $touchscreen = $this->configuration['touch'];
680 $build['#attached']['library'][] = 'superfish/superfish_touchscreen';
681 $behaviour = $this->configuration['touchbh'];
682 $sfplugins['touchscreen']['behaviour'] = ($behaviour != 2) ? $behaviour : '';
683 switch ($touchscreen) {
685 $sfplugins['touchscreen']['mode'] = 'always_active';
688 $sfplugins['touchscreen']['mode'] = 'window_width';
689 $tsbp = $this->configuration['touchbp'];
690 $sfplugins['touchscreen']['breakpoint'] = ($tsbp != 768) ? (int)$tsbp : '';
693 // Which method to use for UA detection.
694 $tsuam = $this->configuration['touchuam'];
695 $tsua = $this->configuration['touchua'];
701 $sfplugins['touchscreen']['mode'] = 'useragent_predefined';
704 $sfplugins['touchscreen']['mode'] = 'useragent_custom';
705 $tsual = drupal_strtolower($this->configuration['touchual']);
706 if (strpos($tsual, '*')) {
707 $tsual = str_replace('*', '|', $tsual);
709 $sfplugins['touchscreen']['useragent'] = $tsual;
715 if (isset($_SERVER['HTTP_USER_AGENT'])) {
716 $hua = drupal_strtolower($_SERVER['HTTP_USER_AGENT']);
718 // Use the pre-defined list of mobile UA strings.
720 if (preg_match('/(android|bb\d+|meego)|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $hua)) {
721 $sfplugins['touchscreen']['mode'] = 'always_active';
722 if ($behaviour == 2) {
723 $sfsettings['clone_parent'] = 1;
727 // Use the custom list of UA strings.
729 $tsual = drupal_strtolower($this->configuration['touchual']);
731 if (strpos($tsual, '*')) {
732 $tsual = explode('*', $tsual);
733 foreach ($tsual as $ua) {
734 $tsuac[] = (strpos($hua, $ua)) ? 1 : 0;
738 $tsuac[] = (strpos($hua, $tsual)) ? 1 : 0;
740 if (in_array(1, $tsuac)) {
741 $sfplugins['touchscreen']['mode'] = 'always_active';
742 if ($behaviour == 2) {
743 $sfsettings['clone_parent'] = 1;
755 $smallscreen = $this->configuration['small'];
757 $build['#attached']['library'][] = 'superfish/superfish_smallscreen';
758 switch ($smallscreen) {
760 $sfplugins['smallscreen']['mode'] = 'always_active';
763 $sfplugins['smallscreen']['mode'] = 'window_width';
764 $ssbp = $this->configuration['smallbp'];
765 $sfplugins['smallscreen']['breakpoint'] = ($ssbp != 768) ? (int)$ssbp : '';
768 // Which method to use for UA detection.
769 $ssuam = $this->configuration['smalluam'];
770 $ssua = $this->configuration['smallua'];
776 $sfplugins['smallscreen']['mode'] = 'useragent_predefined';
779 $sfplugins['smallscreen']['mode'] = 'useragent_custom';
780 $ssual = drupal_strtolower($this->configuration['smallual']);
781 if (strpos($ssual, '*')) {
782 $ssual = str_replace('*', '|', $ssual);
784 $sfplugins['smallscreen']['useragent'] = $ssual;
791 if (isset($_SERVER['HTTP_USER_AGENT'])) {
792 $hua = drupal_strtolower($_SERVER['HTTP_USER_AGENT']);
794 // Use the pre-defined list of mobile UA strings.
796 if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $hua)) {
797 $sfplugins['smallscreen']['mode'] = 'always_active';
800 // Use the custom list of UA strings.
802 $ssual = drupal_strtolower($this->configuration['smallual']);
804 if (strpos($ssual, '*')) {
805 $ssual = explode('*', $ssual);
806 foreach ($ssual as $ua) {
807 $ssuac[] = (strpos($hua, $ua)) ? 1 : 0;
811 $ssuac[] = (strpos($hua, $ssual)) ? 1 : 0;
813 if (in_array(1, $ssuac)) {
814 $sfplugins['smallscreen']['mode'] = 'always_active';
823 $type = $this->configuration['smallact'];
826 $asa = $this->configuration['smallasa'];
827 $cmc = $this->configuration['smallcmc'];
828 $chc = $this->configuration['smallchc'];
829 $ecm = $this->configuration['smallecm'];
830 $ech = $this->configuration['smallech'];
831 $icm = $this->configuration['smallicm'];
832 $ich = $this->configuration['smallich'];
834 $sfplugins['smallscreen']['type'] = 'select';
835 $sfplugins['smallscreen']['addSelected'] = ($asa == 1) ? TRUE : '';
836 $sfplugins['smallscreen']['menuClasses'] = ($cmc == 1) ? TRUE : '';
837 $sfplugins['smallscreen']['hyperlinkClasses'] = ($chc == 1) ? TRUE : '';
838 $sfplugins['smallscreen']['excludeClass_menu'] = ($cmc == 1 && !empty($ecm)) ? $ecm : '';
839 $sfplugins['smallscreen']['excludeClass_hyperlink'] = ($chc == 1 && !empty($ech)) ? $ech : '';
840 $sfplugins['smallscreen']['includeClass_menu'] = (!empty($icm)) ? $icm : '';
841 $sfplugins['smallscreen']['includeClass_hyperlink'] = (!empty($ich)) ? $ich : '';
844 $ab = $this->configuration['smallabt'];
845 $sfplugins['smallscreen']['accordionButton'] = ($ab != 1) ? $ab : '';
846 $sfplugins['smallscreen']['expandText'] = ($this->t('Expand') != 'Expand') ? $this->t('Expand') : '';
847 $sfplugins['smallscreen']['collapseText'] = ($this->t('Collapse') != 'Collapse') ? $this->t('Collapse') : '';
852 if ($this->configuration['supposition']) {
853 $sfplugins['supposition'] = TRUE;
854 $build['#attached']['library'][] = 'superfish/superfish_supposition';
857 if ($this->configuration['supersubs']) {
858 $build['#attached']['library'][] = 'superfish/superfish_supersubs';
859 $minwidth = $this->configuration['minwidth'];
860 $maxwidth = $this->configuration['maxwidth'];
861 $sfplugins['supersubs']['minWidth'] = ($minwidth != 12) ? $minwidth : '';
862 $sfplugins['supersubs']['maxWidth'] = ($maxwidth != 27) ? $maxwidth : '';
863 if (empty($sfplugins['supersubs']['minWidth']) && empty($sfplugins['supersubs']['maxWidth'])) {
864 $sfplugins['supersubs'] = TRUE;
868 // Attaching the requires JavaScript and CSS files.
869 $build['#attached']['library'][] = 'superfish/superfish';
870 if ($sfsettings['style'] != 'none') {
871 $build['#attached']['library'][] = 'superfish/superfish_style_'. $sfsettings['style'];
874 // Title for the small-screen menu.
879 $title = $this->configuration['smallset'];
882 $title = $this->configuration['smallamt'];
885 $sfplugins['smallscreen']['title'] = $title ? $title : $this->label();
887 $sfplugins = superfish_array_remove_empty($sfplugins);
890 $menu_name = $this->getDerivativeId();
893 $level = $this->configuration['level'];
894 // Menu display depth.
895 $depth = $sfsettings['depth'];
897 // By not setting the any expanded parents we don't limit the loading of the subtrees.
898 // Calling MenuLinkTreeInterface::getCurrentRouteMenuTreeParameters we would be
899 // doing so. We don't actually need the parents expanded as we do different rendering.
900 $parameters = (new MenuTreeParameters())
901 ->setMinDepth($level)
902 ->setMaxDepth($depth ? min($level + ($depth - 1), $this->menuTree->maxDepth()) : NULL)
903 ->setActiveTrail($this->menuActiveTrail->getActiveTrailIds($menu_name))
904 ->onlyEnabledLinks();
906 $tree = $this->menuTree->load($menu_name, $parameters);
907 $manipulators = array(
908 ['callable' => 'menu.default_tree_manipulators:checkAccess'],
909 ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort']
911 $tree = $this->menuTree->transform($tree, $manipulators);
914 $html_id = Html::getUniqueId('superfish-' . $menu_name);
916 // Preparing the Drupal behavior.
917 $build['#attached']['drupalSettings']['superfish'][$html_id]['id'] = $html_id;
918 $build['#attached']['drupalSettings']['superfish'][$html_id]['sf'] = isset($sfoptions) ? $sfoptions : array();
919 if (!empty($sfplugins)) {
920 $build['#attached']['drupalSettings']['superfish'][$html_id]['plugins'] = $sfplugins;
923 // Calling the theme.
924 $build['content'] = array(
925 '#theme' => 'superfish',
926 '#menu_name' => $menu_name,
927 '#html_id' => $html_id,
929 '#settings' => $sfsettings
931 // Build the original menu tree to calculate cache tags and contexts.
932 $treeBuild = $this->menuTree->build($tree);
933 $build['#cache'] = $treeBuild['#cache'];
939 * Overrides \Drupal\block\BlockBase::defaultConfiguration().
941 public function defaultConfiguration() {
942 return parent::defaultConfiguration() + [
945 'menu_type' => 'horizontal',
951 'slide' => 'vertical',
980 'multicolumn_depth' => 1,
981 'multicolumn_levels' => 0,
985 'hide_linkdescription' => 0,
986 'add_linkdescription' => 0,
987 'link_depth_class' => 1,
988 'custom_list_class' => '',
989 'custom_item_class' => '',
990 'custom_link_class' => ''