Skip to content

Commit 1b83ed1

Browse files
authored
Merge pull request #6 from nxmndr/skip-empty-elements
feat: skip null elements
2 parents e43f49b + 8b68649 commit 1b83ed1

File tree

9 files changed

+20
-6
lines changed

9 files changed

+20
-6
lines changed

extend.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
(new Extend\Settings())
5353
->serializeToForum('datlechin-simple-tour-guide.showProgress', 'datlechin-simple-tour-guide.show_progress', 'boolval')
5454
->serializeToForum('datlechin-simple-tour-guide.allowDismiss', 'datlechin-simple-tour-guide.allow_dismiss', 'boolval')
55+
->serializeToForum('datlechin-simple-tour-guide.skipNullElements', 'datlechin-simple-tour-guide.skip_null_elements', 'boolval')
5556
->serializeToForum('datlechin-simple-tour-guide.steps', 'datlechin-simple-tour-guide.steps'),
5657

5758
(new Extend\Event())

js/dist/admin.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dist/admin.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dist/forum.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dist/forum.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/src/admin/components/SettingsPage.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ export default class SettingsPage extends ExtensionPage {
3939
label: app.translator.trans('datlechin-simple-tour-guide.admin.settings.allow_close_label'),
4040
help: app.translator.trans('datlechin-simple-tour-guide.admin.settings.allow_close_help'),
4141
})}
42+
{this.buildSettingComponent({
43+
setting: 'datlechin-simple-tour-guide.skip_null_elements',
44+
type: 'boolean',
45+
label: app.translator.trans('datlechin-simple-tour-guide.admin.settings.skip_null_elements_label'),
46+
help: app.translator.trans('datlechin-simple-tour-guide.admin.settings.skip_null_elements_help'),
47+
})}
4248
<div className="Form-group">
4349
<Button className="Button" icon="fas fa-plus" onclick={() => app.modal.show(EditTourGuideStepModal)}>
4450
{app.translator.trans('datlechin-simple-tour-guide.admin.add_step')}

js/src/forum/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,19 @@ app.initializers.add('datlechin/flarum-simple-tour-guide', () => {
6464
current: '{{current}}',
6565
total: '{{total}}',
6666
}),
67-
showButtons: ['next', 'previous'],
67+
showButtons: getSetting('skipNullElements') ? ['next'] : ['next', 'previous'],
6868
nextBtnText: getTranslation('next_btn_text'),
6969
prevBtnText: getTranslation('prev_btn_text'),
7070
doneBtnText: getTranslation('done_btn_text'),
7171
steps: getSteps(),
7272
onDestroyed: () => {
7373
dismissTour();
7474
},
75+
onHighlightStarted(element) {
76+
if (!element && getSetting('skipNullElements')) {
77+
setTimeout(() => driverObj.moveNext(), 10);
78+
}
79+
},
7580
});
7681

7782
driverObj.drive();

locale/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ datlechin-simple-tour-guide:
55
show_progress_help: This will show the current step and total steps at the top of the popover.
66
allow_close_label: Allow close
77
allow_close_help: Allow users closing the popover by click on the backdrop.
8+
skip_null_elements_label: Skip null elements
9+
skip_null_elements_help: Skip steps whose target matches no HTML element. You can use this to target languages with 'html[lang="es"] my-selector'. This also hides Prev button for coherence, and you should hide progress.
810

911
permissions:
1012
reset_tour_guide: Reset tour guide

src/TourGuideStepValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class TourGuideStepValidator extends AbstractValidator
99
protected $rules = [
1010
'title' => ['required', 'string'],
1111
'description' => ['required', 'string'],
12-
'target' => ['required', 'string', 'regex:/^[.#]?[a-zA-Z]+[\w-]*$/'],
12+
'target' => ['required', 'string', 'max:255', 'not_regex:/[\n\r]/'],
1313
'is_trigger_click' => ['required', 'boolean'],
1414
];
1515
}

0 commit comments

Comments
 (0)