Skip to content
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
9 changes: 4 additions & 5 deletions src/core/hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import getOffset from "../util/getOffset";
import cloneObject from "../util/cloneObject";
import forEach from "../util/forEach";
import DOMEvent from "./DOMEvent";
import setAnchorAsButton from "../util/setAnchorAsButton";
import setHelperLayerPosition from "./setHelperLayerPosition";
import placeTooltip from "./placeTooltip";
import createElement from "../util/createElement";
Expand Down Expand Up @@ -169,10 +168,10 @@ export async function addHints() {
return;
}

const hint = createElement("a", {
const hint = createElement("button", {
className: "introjs-hint",
});
setAnchorAsButton(hint);
hint.setAttribute("type", "button");

hint.onclick = getHintClick(i);

Expand Down Expand Up @@ -333,9 +332,9 @@ export async function showHintDialog(stepId) {
tooltipTextLayer.appendChild(tooltipWrapper);

if (this._options.hintShowButton) {
const closeButton = createElement("a");
const closeButton = createElement("button");
closeButton.className = this._options.buttonClass;
closeButton.setAttribute("role", "button");
closeButton.setAttribute("type", "button");
closeButton.innerHTML = this._options.hintButtonLabel;
closeButton.onclick = hideHint.bind(this, stepId);
tooltipTextLayer.appendChild(closeButton);
Expand Down
40 changes: 20 additions & 20 deletions src/core/showElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import addClass from "../util/addClass";
import scrollTo from "../util/scrollTo";
import exitIntro from "./exitIntro";
import forEach from "../util/forEach";
import setAnchorAsButton from "../util/setAnchorAsButton";
import { nextStep, previousStep } from "./steps";
import setHelperLayerPosition from "./setHelperLayerPosition";
import placeTooltip from "./placeTooltip";
Expand Down Expand Up @@ -73,22 +72,22 @@ function _createBullets(targetElement) {

forEach(this._introItems, ({ step }, i) => {
const innerLi = createElement("li");
const anchorLink = createElement("a");
const anchorButton = createElement("button");

innerLi.setAttribute("role", "presentation");
anchorLink.setAttribute("role", "tab");
anchorButton.setAttribute("type", "button");
anchorButton.setAttribute("role", "tab");

anchorLink.onclick = anchorClick;
anchorButton.onclick = anchorClick;

if (i === targetElement.step - 1) {
anchorLink.className = "active";
anchorButton.className = "active";
}

setAnchorAsButton(anchorLink);
anchorLink.innerHTML = " ";
anchorLink.setAttribute("data-step-number", step);
anchorButton.innerHTML = " ";
anchorButton.setAttribute("data-step-number", step);

innerLi.appendChild(anchorLink);
innerLi.appendChild(anchorButton);
ulContainer.appendChild(innerLi);
});

Expand Down Expand Up @@ -125,10 +124,10 @@ export function _recreateBullets(oldReferenceLayer, targetElement) {
function _updateBullets(oldReferenceLayer, targetElement) {
if (this._options.showBullets) {
oldReferenceLayer.querySelector(
".introjs-bullets li > a.active"
".introjs-bullets li > button.active"
).className = "";
oldReferenceLayer.querySelector(
`.introjs-bullets li > a[data-step-number="${targetElement.step}"]`
`.introjs-bullets li > button[data-step-number="${targetElement.step}"]`
).className = "active";
}
}
Expand Down Expand Up @@ -396,7 +395,7 @@ export default async function _showElement(targetElement) {
referenceLayer.appendChild(tooltipLayer);

//next button
nextTooltipButton = createElement("a");
nextTooltipButton = createElement("button");

nextTooltipButton.onclick = async () => {
if (self._introItems.length - 1 !== self._currentStep) {
Expand All @@ -414,27 +413,24 @@ export default async function _showElement(targetElement) {
}
};

setAnchorAsButton(nextTooltipButton);
nextTooltipButton.innerHTML = this._options.nextLabel;

//previous button
prevTooltipButton = createElement("a");
prevTooltipButton = createElement("button");

prevTooltipButton.onclick = async () => {
if (self._currentStep !== 0) {
await previousStep.call(self);
}
};

setAnchorAsButton(prevTooltipButton);
prevTooltipButton.innerHTML = this._options.prevLabel;

//skip button
skipTooltipButton = createElement("a", {
skipTooltipButton = createElement("button", {
className: "introjs-skipbutton",
});

setAnchorAsButton(skipTooltipButton);
skipTooltipButton.innerHTML = this._options.skipLabel;

skipTooltipButton.onclick = async () => {
Expand Down Expand Up @@ -515,6 +511,7 @@ export default async function _showElement(targetElement) {
prevTooltipButton !== null
) {
prevTooltipButton.className = `${this._options.buttonClass} introjs-prevbutton introjs-disabled`;
prevTooltipButton.setAttribute("disabled", "disabled");
}
}
} else if (
Expand Down Expand Up @@ -555,6 +552,7 @@ export default async function _showElement(targetElement) {
);
} else {
nextTooltipButton.className = `${this._options.buttonClass} introjs-nextbutton introjs-disabled`;
prevTooltipButton.setAttribute("disabled", "disabled");
}
}
}
Expand All @@ -565,24 +563,26 @@ export default async function _showElement(targetElement) {
prevTooltipButton !== null
) {
prevTooltipButton.className = `${this._options.buttonClass} introjs-prevbutton`;
prevTooltipButton.removeAttribute("disabled");
}
if (
typeof nextTooltipButton !== "undefined" &&
nextTooltipButton !== null
) {
nextTooltipButton.className = `${this._options.buttonClass} introjs-nextbutton`;
nextTooltipButton.removeAttribute("disabled");
nextTooltipButton.innerHTML = this._options.nextLabel;
}
}

if (typeof prevTooltipButton !== "undefined" && prevTooltipButton !== null) {
prevTooltipButton.setAttribute("role", "button");
prevTooltipButton.setAttribute("type", "button");
}
if (typeof nextTooltipButton !== "undefined" && nextTooltipButton !== null) {
nextTooltipButton.setAttribute("role", "button");
nextTooltipButton.setAttribute("type", "button");
}
if (typeof skipTooltipButton !== "undefined" && skipTooltipButton !== null) {
skipTooltipButton.setAttribute("role", "button");
skipTooltipButton.setAttribute("type", "button");
}

//Set focus on "next" button, so that hitting Enter always moves you onto the next step
Expand Down
17 changes: 14 additions & 3 deletions src/styles/introjs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ tr.introjs-showElement {

.introjs-arrow {
border: 5px solid transparent;
content: "";
position: absolute;
}

Expand Down Expand Up @@ -234,6 +233,10 @@ tr.introjs-showElement {
}

.introjs-button {
appearance: none;
border: 0;
background: none;
padding: 0;
box-sizing: content-box;
position: relative;
overflow: visible;
Expand Down Expand Up @@ -285,6 +288,10 @@ tr.introjs-showElement {
}

.introjs-skipbutton {
appearance: none;
border: 0;
background: none;
padding: 0;
position: absolute;
top: 0;
right: 0;
Expand Down Expand Up @@ -360,7 +367,11 @@ tr.introjs-showElement {
float: left;
margin: 0 2px;

a {
button {
appearance: none;
border: 0;
background: none;
padding: 0;
transition: width 0.1s ease-in;
box-sizing: content-box;
display: block;
Expand All @@ -380,7 +391,7 @@ tr.introjs-showElement {
}
}

a.active {
button.active {
width: 15px;
background: #999;
}
Expand Down
10 changes: 0 additions & 10 deletions src/util/setAnchorAsButton.js

This file was deleted.

4 changes: 2 additions & 2 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ compareSnapshotCommand({
});

Cypress.Commands.add("nextStep", () => {
cy.get(".introjs-nextbutton").click();
cy.get(".introjs-nextbutton").click({ force: true });
});

Cypress.Commands.add("prevStep", () => {
cy.get(".introjs-prevbutton").click();
cy.get(".introjs-prevbutton").click({ force: true });
});
6 changes: 3 additions & 3 deletions themes/introjs-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ tr.introjs-showElement > th {
float: left;
margin: 0 2px;
}
.introjs-bullets ul li a {
.introjs-bullets ul li button {
display: block;
width: 8px;
height: 8px;
Expand All @@ -228,10 +228,10 @@ tr.introjs-showElement > th {
-webkit-border-radius: 10px;
text-decoration: none;
}
.introjs-bullets ul li a:hover {
.introjs-bullets ul li button:hover {
background: rgba(255,255,255,0.2);
}
.introjs-bullets ul li a.active {
.introjs-bullets ul li button.active {
background: rgba(255,255,255,0.2);
}
.introjsFloatingElement {
Expand Down
6 changes: 3 additions & 3 deletions themes/introjs-nassim.css
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
float: left;
margin: 0 2px;
}
.introjs-bullets ul li a {
.introjs-bullets ul li button {
display: block;
width: 6px;
height: 6px;
Expand All @@ -273,10 +273,10 @@
-webkit-border-radius: 10px;
text-decoration: none;
}
.introjs-bullets ul li a:hover {
.introjs-bullets ul li button:hover {
background: #999;
}
.introjs-bullets ul li a.active {
.introjs-bullets ul li button.active {
background: #999;
}

Expand Down
6 changes: 3 additions & 3 deletions themes/introjs-nazanin.css
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
float: left;
margin: 0 2px;
}
.introjs-bullets ul li a {
.introjs-bullets ul li button {
display: block;
width: 6px;
height: 6px;
Expand All @@ -242,10 +242,10 @@
-webkit-border-radius: 10px;
text-decoration: none;
}
.introjs-bullets ul li a:hover {
.introjs-bullets ul li button:hover {
background: #999;
}
.introjs-bullets ul li a.active {
.introjs-bullets ul li button.active {
background: #999;
}

Expand Down
6 changes: 3 additions & 3 deletions themes/introjs-royal.css
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
float: left;
margin: 0 2px;
}
.introjs-bullets ul li a {
.introjs-bullets ul li button {
display: block;
width: 6px;
height: 6px;
Expand All @@ -259,10 +259,10 @@
-webkit-border-radius: 10px;
text-decoration: none;
}
.introjs-bullets ul li a:hover {
.introjs-bullets ul li button:hover {
background: #999;
}
.introjs-bullets ul li a.active {
.introjs-bullets ul li button.active {
background: #999;
}

Expand Down