Loading config/schema/siteimprove.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -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' Loading js/siteimprove.js +11 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 : '/'}); } } }; Loading siteimprove.libraries.yml +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ siteimprove: dependencies: - core/jquery - core/jquery.once - core/jquery.cookie siteimprove.overlay: license: name: GPL-2.0+ Loading siteimprove.module +2 −0 Original line number Diff line number Diff line Loading @@ -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]))) { Loading src/Form/SettingsForm.php +14 −0 Original line number Diff line number Diff line Loading @@ -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']); Loading Loading @@ -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')) Loading Loading
config/schema/siteimprove.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -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' Loading
js/siteimprove.js +11 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 : '/'}); } } }; Loading
siteimprove.libraries.yml +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ siteimprove: dependencies: - core/jquery - core/jquery.once - core/jquery.cookie siteimprove.overlay: license: name: GPL-2.0+ Loading
siteimprove.module +2 −0 Original line number Diff line number Diff line Loading @@ -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]))) { Loading
src/Form/SettingsForm.php +14 −0 Original line number Diff line number Diff line Loading @@ -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']); Loading Loading @@ -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')) Loading