Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added hideSkip option #1608

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/docs/intro/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ permalink: /intro/options/
- `doneLabel`: Done button label
- `hidePrev`: Hide previous button in the first step? Otherwise, it will be disabled button.
- `hideNext`: Hide next button in the last step? Otherwise, it will be disabled button.
- `hideSkip`: Hide the skip button.
- `tooltipPosition`: Default tooltip position
- `tooltipClass`: Adding CSS class to all tooltips
- `highlightClass`: Additional CSS class for the helperLayer
Expand Down
10 changes: 10 additions & 0 deletions src/core/showElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,16 @@ export default function _showElement(targetElement) {
_disableInteraction.call(self);
}

// hide skip button
if (this._options.hideSkip === true) {
afshinm marked this conversation as resolved.
Show resolved Hide resolved
if (
typeof skipTooltipButton !== "undefined" &&
skipTooltipButton !== null
) {
skipTooltipButton.className = "".concat("introjs-skipbutton introjs-hidden");
}
}

// when it's the first step of tour
if (this._currentStep === 0 && this._introItems.length > 1) {
if (
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ function IntroJs(obj) {
hidePrev: false,
/* Hide next button in the last step? Otherwise, it will be disabled button (note: this will also hide the "Done" button) */
hideNext: false,
/* Hide the skip button */
hideSkip: false,
/* Change the Next button to Done in the last step of the intro? otherwise, it will render a disabled button */
nextToDone: true,
/* Default tooltip box position */
Expand Down
47 changes: 47 additions & 0 deletions tests/core/hideSkip.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import introJs from "../../src";

describe("hideSkip", () => {

test("shold show the skip button by default", () => {
const targetElement = document.createElement("div");
document.body.appendChild(targetElement);

const intro = introJs(targetElement).setOptions({
steps: [
{
intro: "hello world"
}
]
})

intro.start();

const skipbutton = document.querySelectorAll(".introjs-skipbutton");

expect(intro._options.hideSkip).toBe(false);
expect(skipbutton.length).toBe(1);
expect(skipbutton[0].className).toBe('introjs-skipbutton')
})

test("should hide the skip button", () => {
const targetElement = document.createElement("div");
document.body.appendChild(targetElement);

const intro = introJs(targetElement).setOptions({
hideSkip: true,
steps: [
{
intro: "hello world"
}
]
})

intro.start();

const skipbutton = document.querySelectorAll(".introjs-skipbutton");

expect(intro._options.hideSkip).toBe(true);
expect(skipbutton.length).toBe(1);
expect(skipbutton[0].className).toBe('introjs-skipbutton introjs-hidden')
});
})