Skip to content

Commit a43ad85

Browse files
committed
add option for custom highlightClass
1 parent 1ab36b3 commit a43ad85

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ introJs().onafterchange(function(targetElement) {
330330
- `data-intro`: The tooltip text of step
331331
- `data-step`: Optionally define the number (priority) of step
332332
- `data-tooltipClass`: Optionally define a CSS class for tooltip
333+
- `data-highlightClass`: Optionally append a CSS class to the helperLayer
333334
- `data-position`: Optionally define the position of tooltip, `top`, `left`, `right`, `bottom`, `bottom-left-aligned` (same as 'bottom'), 'bottom-middle-aligned' and 'bottom-right-aligned'. Default is `bottom`
334335

335336
###Options:
@@ -341,6 +342,7 @@ introJs().onafterchange(function(targetElement) {
341342
- `doneLabel`: Done button label
342343
- `tooltipPosition`: Default tooltip position
343344
- `tooltipClass`: Adding CSS class to all tooltips
345+
- `highlightClass`: Additional CSS class for the helperLayer
344346
- `exitOnEsc`: Exit introduction when pressing Escape button, `true` or `false`
345347
- `exitOnOverlayClick`: Exit introduction when clicking on overlay layer, `true` or `false`
346348
- `showStepNumbers`: Show steps number in the red circle or not, `true` or `false`

intro.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
tooltipPosition: 'bottom',
4343
/* Next CSS class for tooltip boxes */
4444
tooltipClass: '',
45+
/* CSS class that is added to the helperLayer */
46+
highlightClass: '',
4547
/* Close introduction when pressing Escape button? */
4648
exitOnEsc: true,
4749
/* Close introduction when clicking on overlay layer? */
@@ -130,6 +132,7 @@
130132
intro: currentElement.getAttribute('data-intro'),
131133
step: parseInt(currentElement.getAttribute('data-step'), 10),
132134
tooltipClass: currentElement.getAttribute('data-tooltipClass'),
135+
highlightClass: currentElement.getAttribute('data-highlightClass') || this._options.highlightClass,
133136
position: currentElement.getAttribute('data-position') || this._options.tooltipPosition
134137
};
135138
}
@@ -156,6 +159,7 @@
156159
intro: currentElement.getAttribute('data-intro'),
157160
step: nextStep + 1,
158161
tooltipClass: currentElement.getAttribute('data-tooltipClass'),
162+
highlightClass: currentElement.getAttribute('data-highlightClass') || this._options.highlightClass,
159163
position: currentElement.getAttribute('data-position') || this._options.tooltipPosition
160164
};
161165
}
@@ -515,7 +519,7 @@
515519
break;
516520
}
517521
}
518-
522+
519523
/**
520524
* Determines the position of the tooltip based on the position precedence and availability
521525
* of screen space.
@@ -655,8 +659,13 @@
655659
var self = this,
656660
oldHelperLayer = document.querySelector('.introjs-helperLayer'),
657661
oldReferenceLayer = document.querySelector('.introjs-tooltipReferenceLayer'),
662+
highlightClass = 'introjs-helperLayer',
658663
elementPosition = _getOffset(targetElement.element);
659664

665+
if (targetElement.highlightClass) {
666+
highlightClass += (' ' + targetElement.highlightClass);
667+
}
668+
660669
if (oldHelperLayer != null) {
661670
var oldHelperNumberLayer = oldReferenceLayer.querySelector('.introjs-helperNumberLayer'),
662671
oldtooltipLayer = oldReferenceLayer.querySelector('.introjs-tooltiptext'),
@@ -666,6 +675,8 @@
666675
prevTooltipButton = oldReferenceLayer.querySelector('.introjs-prevbutton'),
667676
nextTooltipButton = oldReferenceLayer.querySelector('.introjs-nextbutton');
668677

678+
//update or reset the helper highlight class
679+
oldHelperLayer.className = highlightClass;
669680
//hide the tooltip
670681
oldtooltipContainer.style.opacity = 0;
671682
oldtooltipContainer.style.display = "none";
@@ -727,7 +738,7 @@
727738
bulletsLayer = document.createElement('div'),
728739
buttonsLayer = document.createElement('div');
729740

730-
helperLayer.className = 'introjs-helperLayer';
741+
helperLayer.className = highlightClass;
731742
referenceLayer.className = 'introjs-tooltipReferenceLayer';
732743

733744
//set new position to helper layer

0 commit comments

Comments
 (0)