Skip to content

Commit 0f2cd06

Browse files
committed
adding remove hint and remove hints methods to destory all hint elements on the page
1 parent 88b8826 commit 0f2cd06

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

intro.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,39 @@
14701470
}
14711471
};
14721472

1473+
/**
1474+
* Removes all hint elements on the page
1475+
* Useful when you want to destroy the elements and add them again (e.g. a modal or popup)
1476+
*
1477+
* @api private
1478+
* @method _removeHints
1479+
*/
1480+
function _removeHints() {
1481+
var hints = this._targetElement.querySelectorAll('.introjs-hint');
1482+
1483+
if (hints && hints.length > 0) {
1484+
for (var i = 0; i < hints.length; i++) {
1485+
_removeHint.call(this, hints[i].getAttribute('data-step'));
1486+
}
1487+
}
1488+
};
1489+
1490+
/**
1491+
* Remove one single hint element from the page
1492+
* Useful when you want to destroy the element and add them again (e.g. a modal or popup)
1493+
* Use removeHints if you want to remove all elements.
1494+
*
1495+
* @api private
1496+
* @method _removeHint
1497+
*/
1498+
function _removeHint(stepId) {
1499+
var hint = this._targetElement.querySelector('.introjs-hint[data-step="' + stepId + '"]');
1500+
1501+
if (hint) {
1502+
hint.parentNode.removeChild(hint);
1503+
}
1504+
};
1505+
14731506
/**
14741507
* Add all available hints to the page
14751508
*
@@ -1917,6 +1950,14 @@
19171950
showHints: function () {
19181951
_showHints.call(this);
19191952
return this;
1953+
},
1954+
removeHints: function () {
1955+
_removeHints.call(this);
1956+
return this;
1957+
},
1958+
removeHint: function (stepId) {
1959+
_removeHint.call(this, stepId);
1960+
return this;
19201961
}
19211962
};
19221963

0 commit comments

Comments
 (0)