Loading admin_toolbar.install +16 −12 Original line number Diff line number Diff line Loading @@ -51,25 +51,29 @@ function admin_toolbar_update_8004() { /** @var \Drupal\Core\Config\Config $admin_toolbar_tools_config */ $admin_toolbar_tools_config = \Drupal::service('config.factory') ->getEditable('admin_toolbar_tools.settings'); // Define the default values for the added configuration variables. $hoverintent_behavior_config_default = [ 'enabled' => TRUE, 'timeout' => 500, ]; // If there is a value in the old config, move it to the new config. if (!$admin_toolbar_tools_config->isNew()) { $hoverintent_functionality = (bool) $admin_toolbar_tools_config->get('hoverintent_functionality'); // Move 'hoverintent_functionality' to the 'admin_toolbar.settings'. \Drupal::service('config.factory') ->getEditable('admin_toolbar.settings') ->set('enable_hoverintent', $hoverintent_functionality) ->save(TRUE); $hoverintent_behavior_config_default['enabled'] = $hoverintent_functionality; // Remove the 'hoverintent_functionality' configuration from the // 'admin_toolbar_tools.settings'. $admin_toolbar_tools_config->clear('hoverintent_functionality') ->save(TRUE); } else { // If the admin_toolbar_tools config is new, it means that the module was // not installed and therefore had no value for the config. \Drupal::service('config.factory') ->getEditable('admin_toolbar.settings') ->set('enable_hoverintent', TRUE) ->set('hoverintent_behavior', $hoverintent_behavior_config_default) ->save(TRUE); } } admin_toolbar.module +4 −3 Original line number Diff line number Diff line Loading @@ -34,11 +34,12 @@ function admin_toolbar_toolbar_alter(&$items) { default: break; } $enable_hoverintent = $admin_toolbar_config->get('enable_hoverintent'); if ($enable_hoverintent === TRUE) { $hoverintent_behavior = $admin_toolbar_config->get('hoverintent_behavior'); if ($hoverintent_behavior['enabled'] === TRUE) { // Use the hoverIntent plugin library. $items['administration']['#attached']['library'][] = 'admin_toolbar/toolbar.tree.hoverintent'; // Add the configured hoverIntent settings values to the JS of the toolbar. $items['administration']['#attached']['drupalSettings']['hoverIntentTimeout'] = $hoverintent_behavior['timeout']; } else { // Use default Admin Toolbar hover library. Loading config/install/admin_toolbar.settings.yml +3 −1 Original line number Diff line number Diff line menu_depth: 4 enable_hoverintent: true sticky_behavior: 'enabled' hoverintent_behavior: enabled: true timeout: 500 config/schema/admin_toolbar.schema.yml +10 −3 Original line number Diff line number Diff line Loading @@ -5,9 +5,6 @@ admin_toolbar.settings: menu_depth: type: integer label: 'Depth of displayed menu' enable_hoverintent: type: boolean label: 'Enable HoverIntent' sticky_behavior: type: string label: 'Sticky toolbar behavior' Loading @@ -15,3 +12,13 @@ admin_toolbar.settings: enabled: 'Enabled' disabled: 'Disabled' hide_on_scroll_down: 'Disabled: Hide on scroll-down, show on scroll-up' hoverintent_behavior: type: mapping label: 'hoverIntent behavior' mapping: enabled: type: boolean label: 'Enable hoverIntent' timeout: type: integer label: 'hoverIntent timeout' js/admin_toolbar.hoverintent.js +4 −4 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ * Admin Toolbar hoverIntent plugin behavior for the display of the menu. */ (($, once) => { (($, Drupal, once) => { /** * Implements the Admin Toolbar hoverIntent plugin behavior. * Loading @@ -13,7 +13,7 @@ * Attaches the behavior for the display of the menu on hover. */ Drupal.behaviors.adminToolbarHoverIntent = { attach: (context) => { attach: (context, settings) => { if (context !== document) { return; } Loading @@ -33,9 +33,9 @@ out() { $(this).removeClass('hover-intent'); }, timeout: 250, timeout: settings.hoverIntentTimeout, }); }); }, }; })(jQuery, once); })(jQuery, Drupal, once); Loading
admin_toolbar.install +16 −12 Original line number Diff line number Diff line Loading @@ -51,25 +51,29 @@ function admin_toolbar_update_8004() { /** @var \Drupal\Core\Config\Config $admin_toolbar_tools_config */ $admin_toolbar_tools_config = \Drupal::service('config.factory') ->getEditable('admin_toolbar_tools.settings'); // Define the default values for the added configuration variables. $hoverintent_behavior_config_default = [ 'enabled' => TRUE, 'timeout' => 500, ]; // If there is a value in the old config, move it to the new config. if (!$admin_toolbar_tools_config->isNew()) { $hoverintent_functionality = (bool) $admin_toolbar_tools_config->get('hoverintent_functionality'); // Move 'hoverintent_functionality' to the 'admin_toolbar.settings'. \Drupal::service('config.factory') ->getEditable('admin_toolbar.settings') ->set('enable_hoverintent', $hoverintent_functionality) ->save(TRUE); $hoverintent_behavior_config_default['enabled'] = $hoverintent_functionality; // Remove the 'hoverintent_functionality' configuration from the // 'admin_toolbar_tools.settings'. $admin_toolbar_tools_config->clear('hoverintent_functionality') ->save(TRUE); } else { // If the admin_toolbar_tools config is new, it means that the module was // not installed and therefore had no value for the config. \Drupal::service('config.factory') ->getEditable('admin_toolbar.settings') ->set('enable_hoverintent', TRUE) ->set('hoverintent_behavior', $hoverintent_behavior_config_default) ->save(TRUE); } }
admin_toolbar.module +4 −3 Original line number Diff line number Diff line Loading @@ -34,11 +34,12 @@ function admin_toolbar_toolbar_alter(&$items) { default: break; } $enable_hoverintent = $admin_toolbar_config->get('enable_hoverintent'); if ($enable_hoverintent === TRUE) { $hoverintent_behavior = $admin_toolbar_config->get('hoverintent_behavior'); if ($hoverintent_behavior['enabled'] === TRUE) { // Use the hoverIntent plugin library. $items['administration']['#attached']['library'][] = 'admin_toolbar/toolbar.tree.hoverintent'; // Add the configured hoverIntent settings values to the JS of the toolbar. $items['administration']['#attached']['drupalSettings']['hoverIntentTimeout'] = $hoverintent_behavior['timeout']; } else { // Use default Admin Toolbar hover library. Loading
config/install/admin_toolbar.settings.yml +3 −1 Original line number Diff line number Diff line menu_depth: 4 enable_hoverintent: true sticky_behavior: 'enabled' hoverintent_behavior: enabled: true timeout: 500
config/schema/admin_toolbar.schema.yml +10 −3 Original line number Diff line number Diff line Loading @@ -5,9 +5,6 @@ admin_toolbar.settings: menu_depth: type: integer label: 'Depth of displayed menu' enable_hoverintent: type: boolean label: 'Enable HoverIntent' sticky_behavior: type: string label: 'Sticky toolbar behavior' Loading @@ -15,3 +12,13 @@ admin_toolbar.settings: enabled: 'Enabled' disabled: 'Disabled' hide_on_scroll_down: 'Disabled: Hide on scroll-down, show on scroll-up' hoverintent_behavior: type: mapping label: 'hoverIntent behavior' mapping: enabled: type: boolean label: 'Enable hoverIntent' timeout: type: integer label: 'hoverIntent timeout'
js/admin_toolbar.hoverintent.js +4 −4 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ * Admin Toolbar hoverIntent plugin behavior for the display of the menu. */ (($, once) => { (($, Drupal, once) => { /** * Implements the Admin Toolbar hoverIntent plugin behavior. * Loading @@ -13,7 +13,7 @@ * Attaches the behavior for the display of the menu on hover. */ Drupal.behaviors.adminToolbarHoverIntent = { attach: (context) => { attach: (context, settings) => { if (context !== document) { return; } Loading @@ -33,9 +33,9 @@ out() { $(this).removeClass('hover-intent'); }, timeout: 250, timeout: settings.hoverIntentTimeout, }); }); }, }; })(jQuery, once); })(jQuery, Drupal, once);