Commit 0a7a2c78 authored by bartvig's avatar bartvig
Browse files

Issue #3255035 by billdaff, j-barnes, bartvig: Siteimprove Overlay collapse config

parent 4aa86e86
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@ siteimprove.settings:
      type: sequence
      sequence:
        - type: string
    widget_default_collapse:
      type: boolean
      label: 'Siteimprove widget collapse'
siteimprove.domain.single.settings:
  type: config_object
  label: 'Siteimprove Single Domain settings'
+11 −2
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@
  if (typeof NodeList !== 'undefined' && NodeList.prototype && !NodeList.prototype.forEach) {
    NodeList.prototype.forEach = Array.prototype.forEach;
  }

  var siteimprove = {
    input: function () {
      this.url = drupalSettings.siteimprove.input.url;
@@ -174,7 +173,17 @@
        }

      });

      // We want to check if we are using the config
      // If not we want to check if the cookie is already set
      // If it doesn't exist we set to '6' to collapse.
      var OVERLAY_COLLAPSED = '6';
      if (drupalSettings.siteimprove.overlay_default_collapse) {
        if(!$.cookie('sicmsplugin') || $.cookie('sicmsplugin') !== OVERLAY_COLLAPSED){
          $.cookie('sicmsplugin', OVERLAY_COLLAPSED, { domain: document.domain , path : '/'});
        }
      } else if ($.cookie('sicmsplugin')) {
        $.cookie('sicmsplugin', '', { domain: document.domain , path : '/'});
      }
    }
  };

+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ siteimprove:
  dependencies:
    - core/jquery
    - core/jquery.once
    - core/jquery.cookie
siteimprove.overlay:
  license:
    name: GPL-2.0+
+2 −0
Original line number Diff line number Diff line
@@ -61,6 +61,8 @@ function siteimprove_toolbar() {
    'entity.taxonomy_term.latest_version',
  ];
  $current_route_name = \Drupal::routeMatch()->getRouteName();
  // Set overlay collapse value for js.
  $toolbar_items['siteimprove_toolbar']['tray']['#attached']['drupalSettings']['siteimprove']['overlay_default_collapse'] = $config->get('overlay_default_collapse');

  // Prepublish should be available for an enabled taxonomy or content type.
  if ($prepublish_enabled && in_array($current_route_name, $enabled_route_names) && (($node && $enabled_content_types[$bundle]) || ($taxonomy && $enabled_taxonomies[$bundle]))) {
+14 −0
Original line number Diff line number Diff line
@@ -310,7 +310,20 @@ class SettingsForm extends ConfigFormBase {
      '#title' => $this->t('Select prepublish check enabled taxonomies'),
      '#description' => $this->t('Select which taxonomies Siteimprove Prepublish check is enabled for'),
    ];
    $form['overlay'] = [
      '#title' => $this->t('Siteimprove Overlay'),
      '#type' => 'fieldset',
    ];

    $form['overlay']['description'] = [
      '#markup' => "<p>" . $this->t('Siteimprove overlay settings.') . "</p>",
    ];

    $form['overlay']['overlay_default_collapse'] = [
      '#title' => $this->t('Collapse overlay by default'),
      '#type' => 'checkbox',
      '#default_value' => $config->get('overlay_default_collapse'),
    ];
    // Invalidate siteimprove_toolbar cache tag to ensure that the toolbar's
    // cache is properly invalidated.
    Cache::invalidateTags(['siteimprove_toolbar']);
@@ -384,6 +397,7 @@ class SettingsForm extends ConfigFormBase {
      ->set('token', $form_state->getValue('token'))
      ->set('domain_plugin_id', $domain_plugin)
      ->set('prepublish_enabled', $form_state->getValue('prepublish_enabled'))
      ->set('overlay_default_collapse', $form_state->getValue('overlay_default_collapse'))
      ->set('api_username', $form_state->getValue('api_username'))
      ->set('api_key', $form_state->getValue('api_key'))
      ->set('enabled_content_types', $form_state->getValue('enabled_content_types'))