diff --git a/config/install/page_load_progress.settings.yml b/config/install/page_load_progress.settings.yml index aa0ecf6..3a6b377 100644 --- a/config/install/page_load_progress.settings.yml +++ b/config/install/page_load_progress.settings.yml @@ -1,3 +1,5 @@ page_load_progress_time: 10 page_load_progress_elements: '.form-submit' +page_load_progress_request_path: '' +page_load_progress_request_path_negate_condition: false page_load_progress_esc_key: true diff --git a/config/schema/page_load_progress.schema.yml b/config/schema/page_load_progress.schema.yml index 1e0b5fd..cf97360 100644 --- a/config/schema/page_load_progress.schema.yml +++ b/config/schema/page_load_progress.schema.yml @@ -8,6 +8,12 @@ page_load_progress.settings: page_load_progress_elements: type: text label: 'Time to wait before showing the image lock' + page_load_progress_request_path: + type: string + label: 'Lists of paths to include or exclude' + page_load_progress_request_path_negate_condition: + type: boolean + label: 'Negate request path condition' page_load_progress_esc_key: type: boolean - label: 'Allow ESC key to kill the throbber' + label: 'Allow ESC key to kill the throbber' \ No newline at end of file diff --git a/page_load_progress.module b/page_load_progress.module index 77b9922..1c866b8 100644 --- a/page_load_progress.module +++ b/page_load_progress.module @@ -9,6 +9,7 @@ * Implements hook_page_attachments(). */ function page_load_progress_page_attachments(array &$attachments) { + // @todo Insert logic for page_load_progress_request_path if (\Drupal::currentUser()->hasPermission('use page load progress') && !strpos(\Drupal::service('path.current')->getPath(), 'admin/structure/views/')) { diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php index cfd75a8..f66decd 100644 --- a/src/Form/SettingsForm.php +++ b/src/Form/SettingsForm.php @@ -53,6 +53,25 @@ class SettingsForm extends ConfigFormBase { '#default_value' => $page_load_progress_config->get('page_load_progress_elements'), ]; + $form['page_load_progress_request_path'] = [ + '#type' => 'textarea', + '#title' => $this->t('Visibility conditions'), + '#default_value' => $page_load_progress_config->get('page_load_progress_request_path'), + '#description' => $this->t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. An example path is %user-wildcard for every user page. %front is the front page.", [ + '%user-wildcard' => '/user/*', + '%front' => '', + ]), + ]; + + $form['page_load_progress_request_path_negate_condition'] = [ + '#type' => 'radios', + '#default_value' => (int) $page_load_progress_config->get('page_load_progress_request_path_negate_condition'), + '#options' => [ + $this->t('Show for the listed pages'), + $this->t('Hide for the listed pages'), + ] + ]; + $form['page_load_progress_esc_key'] = [ '#type' => 'checkbox', '#title' => $this->t('Allow ESC key to kill the throbber'), @@ -70,6 +89,8 @@ class SettingsForm extends ConfigFormBase { $this->config('page_load_progress.settings') ->set('page_load_progress_time', $form_state->getValue('page_load_progress_time')) ->set('page_load_progress_elements', $form_state->getValue('page_load_progress_elements')) + ->set('page_load_progress_request_path', $form_state->getValue('page_load_progress_request_path')) + ->set('page_load_progress_request_path_negate_condition', $form_state->getValue('page_load_progress_request_path_negate_condition')) ->set('page_load_progress_esc_key', $form_state->getValue('page_load_progress_esc_key')) ->save();