Loading collapsiblock.libraries.yml +1 −1 Original line number Diff line number Diff line Loading @@ -4,9 +4,9 @@ core: theme/dist/css/collapsiblock.min.css: { weight: 0, minified: true } js: theme/dist/js/collapsiblock.min.js: { weight: 0, minified: true } https://unpkg.com/slide-element@2/dist/index.umd.js: { type: external, minified: true } dependencies: - core/drupal - core/drupalSettings - core/js-cookie - core/once - core/jquery collapsiblock.module +2 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ * Make blocks collapsible. */ use Drupal\collapsiblock\Form\CollapsiblockGlobalSettings; use Drupal\Core\Block\BlockPluginInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\block\BlockInterface; Loading @@ -29,7 +30,6 @@ function collapsiblock_page_attachments_alter(array &$attachments) { $settings = \Drupal::config('collapsiblock.settings'); $collapsiblock = [ 'active_pages' => $settings->get('active_pages'), 'slide_type' => $settings->get('slide_type'), 'slide_speed' => $settings->get('slide_speed'), 'cookie_lifetime' => $settings->get('cookie_lifetime'), ]; Loading @@ -49,7 +49,7 @@ function collapsiblock_form_block_form_alter(&$form, FormStateInterface $form_st // Add the global default to the list of options for the per-block setting. $block = $form_state->getFormObject()->getEntity(); $options = unserialize(COLLAPSIBLOCK_ACTION_OPTIONS); $options = CollapsiblockGlobalSettings::ACTION_OPTIONS; $settings = \Drupal::config('collapsiblock.settings'); $default_action = $options[$settings->get('default_action')]; $options = [0 => 'Global default, currently set to: ' . $default_action] + $options; Loading config/install/collapsiblock.settings.yml +0 −1 Original line number Diff line number Diff line default_action: 1 active_pages: FALSE slide_type: 1 slide_speed: 200 cookie_lifetime: config/schema/collapsiblock.schema.yml +0 −5 Original line number Diff line number Diff line Loading @@ -13,11 +13,6 @@ collapsiblock.settings: label: 'Remember collapsed state on active pages' translatable: false nullable: false slide_type: type: integer label: 'Default animation type' translatable: false nullable: false slide_speed: type: integer label: 'Animation speed' Loading src/Form/CollapsiblockGlobalSettings.php +10 −11 Original line number Diff line number Diff line Loading @@ -12,6 +12,14 @@ use Drupal\Core\Form\FormStateInterface; */ class CollapsiblockGlobalSettings extends ConfigFormBase { const ACTION_OPTIONS = [ 1 => 'None.', 2 => 'Collapsible, expanded by default.', 3 => 'Collapsible, collapsed by default.', 5 => 'Collapsible, expanded all the time.', 4 => 'Collapsible, collapsed all the time.', ]; /** * {@inheritdoc} */ Loading @@ -37,21 +45,13 @@ class CollapsiblockGlobalSettings extends ConfigFormBase { $form['default_action'] = [ '#type' => 'radios', '#title' => t('Default block collapse behavior'), '#options' => unserialize(COLLAPSIBLOCK_ACTION_OPTIONS), '#options' => $this::ACTION_OPTIONS, '#default_value' => $config->get('default_action'), ]; $form['active_pages'] = [ '#type' => 'checkbox', '#title' => t('Remember collapsed state on active pages'), '#title' => t('Allow menu blocks to be collapsed on page load if they have active links'), '#default_value' => $config->get('active_pages'), '#description' => t('Block can collapse even if it contains an active link (such as in menu blocks).'), ]; $form['slide_type'] = [ '#type' => 'radios', '#title' => t('Default animation type'), '#options' => [1 => t('Slide'), 2 => t('Fade and slide')], '#description' => t('Slide is the Drupal default while Fade and slide adds a nice fade effect.'), '#default_value' => $config->get('slide_type'), ]; $options = [ '50', Loading Loading @@ -104,7 +104,6 @@ class CollapsiblockGlobalSettings extends ConfigFormBase { $this->config('collapsiblock.settings') ->set('default_action', $values['default_action']) ->set('active_pages', $values['active_pages']) ->set('slide_type', $values['slide_type']) ->set('slide_speed', $values['slide_speed']) ->set('cookie_lifetime', $values['cookie_lifetime'] ?? NULL) ->save(); Loading Loading
collapsiblock.libraries.yml +1 −1 Original line number Diff line number Diff line Loading @@ -4,9 +4,9 @@ core: theme/dist/css/collapsiblock.min.css: { weight: 0, minified: true } js: theme/dist/js/collapsiblock.min.js: { weight: 0, minified: true } https://unpkg.com/slide-element@2/dist/index.umd.js: { type: external, minified: true } dependencies: - core/drupal - core/drupalSettings - core/js-cookie - core/once - core/jquery
collapsiblock.module +2 −2 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ * Make blocks collapsible. */ use Drupal\collapsiblock\Form\CollapsiblockGlobalSettings; use Drupal\Core\Block\BlockPluginInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\block\BlockInterface; Loading @@ -29,7 +30,6 @@ function collapsiblock_page_attachments_alter(array &$attachments) { $settings = \Drupal::config('collapsiblock.settings'); $collapsiblock = [ 'active_pages' => $settings->get('active_pages'), 'slide_type' => $settings->get('slide_type'), 'slide_speed' => $settings->get('slide_speed'), 'cookie_lifetime' => $settings->get('cookie_lifetime'), ]; Loading @@ -49,7 +49,7 @@ function collapsiblock_form_block_form_alter(&$form, FormStateInterface $form_st // Add the global default to the list of options for the per-block setting. $block = $form_state->getFormObject()->getEntity(); $options = unserialize(COLLAPSIBLOCK_ACTION_OPTIONS); $options = CollapsiblockGlobalSettings::ACTION_OPTIONS; $settings = \Drupal::config('collapsiblock.settings'); $default_action = $options[$settings->get('default_action')]; $options = [0 => 'Global default, currently set to: ' . $default_action] + $options; Loading
config/install/collapsiblock.settings.yml +0 −1 Original line number Diff line number Diff line default_action: 1 active_pages: FALSE slide_type: 1 slide_speed: 200 cookie_lifetime:
config/schema/collapsiblock.schema.yml +0 −5 Original line number Diff line number Diff line Loading @@ -13,11 +13,6 @@ collapsiblock.settings: label: 'Remember collapsed state on active pages' translatable: false nullable: false slide_type: type: integer label: 'Default animation type' translatable: false nullable: false slide_speed: type: integer label: 'Animation speed' Loading
src/Form/CollapsiblockGlobalSettings.php +10 −11 Original line number Diff line number Diff line Loading @@ -12,6 +12,14 @@ use Drupal\Core\Form\FormStateInterface; */ class CollapsiblockGlobalSettings extends ConfigFormBase { const ACTION_OPTIONS = [ 1 => 'None.', 2 => 'Collapsible, expanded by default.', 3 => 'Collapsible, collapsed by default.', 5 => 'Collapsible, expanded all the time.', 4 => 'Collapsible, collapsed all the time.', ]; /** * {@inheritdoc} */ Loading @@ -37,21 +45,13 @@ class CollapsiblockGlobalSettings extends ConfigFormBase { $form['default_action'] = [ '#type' => 'radios', '#title' => t('Default block collapse behavior'), '#options' => unserialize(COLLAPSIBLOCK_ACTION_OPTIONS), '#options' => $this::ACTION_OPTIONS, '#default_value' => $config->get('default_action'), ]; $form['active_pages'] = [ '#type' => 'checkbox', '#title' => t('Remember collapsed state on active pages'), '#title' => t('Allow menu blocks to be collapsed on page load if they have active links'), '#default_value' => $config->get('active_pages'), '#description' => t('Block can collapse even if it contains an active link (such as in menu blocks).'), ]; $form['slide_type'] = [ '#type' => 'radios', '#title' => t('Default animation type'), '#options' => [1 => t('Slide'), 2 => t('Fade and slide')], '#description' => t('Slide is the Drupal default while Fade and slide adds a nice fade effect.'), '#default_value' => $config->get('slide_type'), ]; $options = [ '50', Loading Loading @@ -104,7 +104,6 @@ class CollapsiblockGlobalSettings extends ConfigFormBase { $this->config('collapsiblock.settings') ->set('default_action', $values['default_action']) ->set('active_pages', $values['active_pages']) ->set('slide_type', $values['slide_type']) ->set('slide_speed', $values['slide_speed']) ->set('cookie_lifetime', $values['cookie_lifetime'] ?? NULL) ->save(); Loading