|
1139 | 1139 | return true;
|
1140 | 1140 | };
|
1141 | 1141 |
|
| 1142 | + /** |
| 1143 | + * Removes open hint (tooltip hint) |
| 1144 | + * |
| 1145 | + * @api private |
| 1146 | + * @method _removeHintTooltip |
| 1147 | + */ |
| 1148 | + function _removeHintTooltip() { |
| 1149 | + var tooltip = this._targetElement.querySelector('.introjs-hintTooltip'); |
| 1150 | + |
| 1151 | + if (tooltip) { |
| 1152 | + tooltip.parentNode.removeChild(tooltip); |
| 1153 | + } |
| 1154 | + }; |
1142 | 1155 |
|
1143 | 1156 | /**
|
1144 | 1157 | * Start parsing hint items
|
|
1184 | 1197 | }
|
1185 | 1198 |
|
1186 | 1199 | _addHints.call(this);
|
| 1200 | + |
| 1201 | + if (window.addEventListener) { |
| 1202 | + window.addEventListener('click', _removeHintTooltip.bind(this), true); |
| 1203 | + //for window resize |
| 1204 | + //window.addEventListener('resize', this._onResize, true); |
| 1205 | + } else if (document.attachEvent) { //IE |
| 1206 | + //for window resize |
| 1207 | + document.attachEvent('onclick', _removeHintTooltip.bind(this)); |
| 1208 | + //document.attachEvent('onresize', self._onResize); |
| 1209 | + } |
| 1210 | + }; |
| 1211 | + |
| 1212 | + /** |
| 1213 | + * Remove single hint from the page |
| 1214 | + * |
| 1215 | + * @api private |
| 1216 | + * @method _removeHint |
| 1217 | + */ |
| 1218 | + function _removeHint(stepId) { |
| 1219 | + _removeHintTooltip.call(this); |
| 1220 | + var hint = this._targetElement.querySelector('.introjs-hint[data-step="' + stepId + '"]'); |
| 1221 | + |
| 1222 | + if (hint) { |
| 1223 | + hint.parentNode.removeChild(hint); |
| 1224 | + } |
1187 | 1225 | };
|
1188 | 1226 |
|
1189 | 1227 | /**
|
|
1203 | 1241 | hint.href = "javascript:void(0);";
|
1204 | 1242 |
|
1205 | 1243 | // when user clicks on the hint element
|
1206 |
| - hint.onclick = _hintClick.bind(this, hint, item); |
| 1244 | + hint.onclick = _hintClick.bind(this, hint, item, i); |
1207 | 1245 |
|
1208 | 1246 | hint.className = 'introjs-hint';
|
1209 | 1247 | var hintDot = document.createElement('div');
|
|
1266 | 1304 | * @method _hintClick
|
1267 | 1305 | * @param {Object} hintElement
|
1268 | 1306 | * @param {Object} item
|
| 1307 | + * @param {Number} stepId |
1269 | 1308 | */
|
1270 |
| - function _hintClick(hintElement, item) { |
| 1309 | + function _hintClick(hintElement, item, stepId) { |
| 1310 | + _removeHintTooltip.call(this); |
| 1311 | + |
1271 | 1312 | var tooltipLayer = document.createElement('div');
|
1272 | 1313 | var tooltipTextLayer = document.createElement('div');
|
1273 | 1314 | var arrowLayer = document.createElement('div');
|
|
1283 | 1324 | var closeButton = document.createElement('a');
|
1284 | 1325 | closeButton.className = 'introjs-button';
|
1285 | 1326 | closeButton.innerHTML = this._options.hintButtonLabel;
|
| 1327 | + closeButton.onclick = _removeHint.bind(this, stepId); |
1286 | 1328 |
|
1287 | 1329 | tooltipTextLayer.appendChild(tooltipWrapper);
|
1288 | 1330 | tooltipTextLayer.appendChild(closeButton);
|
|
0 commit comments