From cd7d9a62626c59bb7d84b13213d0398c263d3846 Mon Sep 17 00:00:00 2001 From: Youyou Cheng Date: Tue, 15 Mar 2022 14:09:31 +1030 Subject: [PATCH 1/2] added hideSkip option --- docs/docs/intro/options.md | 1 + src/core/showElement.js | 10 ++++++++++ src/index.js | 2 ++ 3 files changed, 13 insertions(+) diff --git a/docs/docs/intro/options.md b/docs/docs/intro/options.md index 197442612..ce9906eb7 100644 --- a/docs/docs/intro/options.md +++ b/docs/docs/intro/options.md @@ -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 diff --git a/src/core/showElement.js b/src/core/showElement.js index 16b10b2e5..3c51b9e84 100644 --- a/src/core/showElement.js +++ b/src/core/showElement.js @@ -458,6 +458,16 @@ export default function _showElement(targetElement) { _disableInteraction.call(self); } + // hide skip button + if (this._options.hideSkip === true) { + 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 ( diff --git a/src/index.js b/src/index.js index 9d3ef5328..6e5c336f7 100644 --- a/src/index.js +++ b/src/index.js @@ -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 */ From b2c57b6b431aeeb4358317d7c055a5e0bf367e65 Mon Sep 17 00:00:00 2001 From: Youyou Cheng Date: Tue, 5 Apr 2022 11:19:43 +0930 Subject: [PATCH 2/2] add tests for hideSkip option --- tests/core/hideSkip.test.js | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/core/hideSkip.test.js diff --git a/tests/core/hideSkip.test.js b/tests/core/hideSkip.test.js new file mode 100644 index 000000000..80097fd9b --- /dev/null +++ b/tests/core/hideSkip.test.js @@ -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') + }); +}) \ No newline at end of file