提交 f76db3e7 编写于 作者: K Kamran Ahmed

Accessibility improvements and refactorign

上级 1d3f002a
...@@ -111,7 +111,7 @@ document.addEventListener("DOMContentLoaded", function () { ...@@ -111,7 +111,7 @@ document.addEventListener("DOMContentLoaded", function () {
document.querySelector('#animated-tour') document.querySelector('#animated-tour')
.addEventListener('click', () => { .addEventListener('click', () => {
if (boringTourDriver.isActivated) { if (boringTourDriver.isActivated) {
boringTourDriver.reset(); boringTourDriver.reset(true);
} }
animatedTourDriver.start(); animatedTourDriver.start();
...@@ -120,7 +120,7 @@ document.addEventListener("DOMContentLoaded", function () { ...@@ -120,7 +120,7 @@ document.addEventListener("DOMContentLoaded", function () {
document.querySelector('#boring-tour') document.querySelector('#boring-tour')
.addEventListener('click', () => { .addEventListener('click', () => {
if (animatedTourDriver.isActivated) { if (animatedTourDriver.isActivated) {
animatedTourDriver.reset(); animatedTourDriver.reset(true);
} }
boringTourDriver.start(); boringTourDriver.start();
......
...@@ -34,10 +34,10 @@ export const POPOVER_HTML = ` ...@@ -34,10 +34,10 @@ export const POPOVER_HTML = `
<div class="${CLASS_POPOVER_TITLE}">Popover Title</div> <div class="${CLASS_POPOVER_TITLE}">Popover Title</div>
<div class="${CLASS_POPOVER_DESCRIPTION}">Popover Description</div> <div class="${CLASS_POPOVER_DESCRIPTION}">Popover Description</div>
<div class="${CLASS_POPOVER_FOOTER}"> <div class="${CLASS_POPOVER_FOOTER}">
<a href="javascript:void(0)" class="${CLASS_CLOSE_BTN}">Close</a> <button class="${CLASS_CLOSE_BTN}">Close</button>
<span class="driver-btn-group"> <span class="driver-btn-group">
<a class="${CLASS_PREV_STEP_BTN}" href="javascript:void(0)">&larr; Previous</a> <button class="${CLASS_PREV_STEP_BTN}">&larr; Previous</button>
<a class="${CLASS_NEXT_STEP_BTN}" href="javascript:void(0)">Next &rarr;</a> <button class="${CLASS_NEXT_STEP_BTN}">Next &rarr;</button>
</span> </span>
</div> </div>
</div>`; </div>`;
......
...@@ -20,6 +20,8 @@ export default class Overlay { ...@@ -20,6 +20,8 @@ export default class Overlay {
this.window = window; this.window = window;
this.document = document; this.document = document;
this.removeNode = this.removeNode.bind(this);
} }
/** /**
...@@ -120,10 +122,11 @@ export default class Overlay { ...@@ -120,10 +122,11 @@ export default class Overlay {
/** /**
* Removes the overlay and cancel any listeners * Removes the overlay and cancel any listeners
*/ */
clear() { clear(immediate = false) {
// Deselect the highlighted element if any // Deselect the highlighted element if any
if (this.highlightedElement) { if (this.highlightedElement) {
this.highlightedElement.onDeselected(true); const hideStage = true;
this.highlightedElement.onDeselected(hideStage);
} }
this.highlightedElement = null; this.highlightedElement = null;
...@@ -136,9 +139,9 @@ export default class Overlay { ...@@ -136,9 +139,9 @@ export default class Overlay {
// Clear any existing timers and remove node // Clear any existing timers and remove node
this.window.clearTimeout(this.hideTimer); this.window.clearTimeout(this.hideTimer);
if (this.options.animate) { if (this.options.animate && !immediate) {
this.node.style.opacity = '0'; this.node.style.opacity = '0';
this.hideTimer = window.setTimeout(this.removeNode, ANIMATION_DURATION_MS); this.hideTimer = this.window.setTimeout(this.removeNode, ANIMATION_DURATION_MS);
} else { } else {
this.removeNode(); this.removeNode();
} }
......
...@@ -56,7 +56,7 @@ div#driver-popover-item { ...@@ -56,7 +56,7 @@ div#driver-popover-item {
clear: both; clear: both;
margin-top: 5px; margin-top: 5px;
a { button {
display: inline-block; display: inline-block;
padding: 3px 10px; padding: 3px 10px;
border: 1px solid #d4d4d4; border: 1px solid #d4d4d4;
...@@ -72,7 +72,7 @@ div#driver-popover-item { ...@@ -72,7 +72,7 @@ div#driver-popover-item {
margin: 10px 0 0; margin: 10px 0 0;
} }
a.driver-disabled { button.driver-disabled {
color: #808080; color: #808080;
cursor: default; cursor: default;
pointer-events: none; pointer-events: none;
......
...@@ -147,10 +147,10 @@ export default class Driver { ...@@ -147,10 +147,10 @@ export default class Driver {
/** /**
* Resets the steps if any and clears the overlay * Resets the steps if any and clears the overlay
*/ */
reset() { reset(immediate = false) {
this.currentStep = 0; this.currentStep = 0;
this.isActivated = false; this.isActivated = false;
this.overlay.clear(); this.overlay.clear(immediate);
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册