|
155 | 155 |
|
156 | 156 | if (currentItem.element !== null) {
|
157 | 157 | introItems.push(currentItem);
|
158 |
| - } |
| 158 | + } |
159 | 159 | }.bind(this));
|
160 | 160 |
|
161 | 161 | } else {
|
162 | 162 | //use steps from data-* annotations
|
163 | 163 | var elmsLength = allIntroSteps.length;
|
164 | 164 | var disableInteraction;
|
165 |
| - |
| 165 | + |
166 | 166 | //if there's no element to intro
|
167 | 167 | if (elmsLength < 1) {
|
168 | 168 | return false;
|
169 | 169 | }
|
170 | 170 |
|
171 | 171 | _forEach(allIntroSteps, function (currentElement) {
|
172 |
| - |
| 172 | + |
173 | 173 | // PR #80
|
174 | 174 | // start intro for groups of elements
|
175 | 175 | if (group && (currentElement.getAttribute("data-intro-group") !== group)) {
|
|
208 | 208 | var nextStep = 0;
|
209 | 209 |
|
210 | 210 | _forEach(allIntroSteps, function (currentElement) {
|
211 |
| - |
| 211 | + |
212 | 212 | // PR #80
|
213 | 213 | // start intro for groups of elements
|
214 | 214 | if (group && (currentElement.getAttribute("data-intro-group") !== group)) {
|
215 | 215 | return;
|
216 | 216 | }
|
217 |
| - |
| 217 | + |
218 | 218 | if (currentElement.getAttribute('data-step') === null) {
|
219 | 219 |
|
220 | 220 | while (true) {
|
|
223 | 223 | } else {
|
224 | 224 | nextStep++;
|
225 | 225 | }
|
226 |
| - } |
| 226 | + } |
227 | 227 |
|
228 | 228 | if (typeof (currentElement.getAttribute('data-disable-interaction')) !== 'undefined') {
|
229 | 229 | disableInteraction = !!currentElement.getAttribute('data-disable-interaction');
|
|
250 | 250 | for (var z = 0; z < introItems.length; z++) {
|
251 | 251 | if (introItems[z]) {
|
252 | 252 | // copy non-falsy values to the end of the array
|
253 |
| - tempIntroItems.push(introItems[z]); |
254 |
| - } |
| 253 | + tempIntroItems.push(introItems[z]); |
| 254 | + } |
255 | 255 | }
|
256 | 256 |
|
257 | 257 | introItems = tempIntroItems;
|
|
307 | 307 | if (code === null) {
|
308 | 308 | code = (e.charCode === null) ? e.keyCode : e.charCode;
|
309 | 309 | }
|
310 |
| - |
| 310 | + |
311 | 311 | if ((code === 'Escape' || code === 27) && this._options.exitOnEsc === true) {
|
312 | 312 | //escape key pressed, exit the intro
|
313 | 313 | //check if exit callback is defined
|
|
631 | 631 | currentTooltipPosition = this._introItems[this._currentStep].position;
|
632 | 632 |
|
633 | 633 | // Floating is always valid, no point in calculating
|
634 |
| - if (currentTooltipPosition !== "floating") { |
| 634 | + if (currentTooltipPosition !== "floating") { |
635 | 635 | currentTooltipPosition = _determineAutoPosition.call(this, targetElement, tooltipLayer, currentTooltipPosition);
|
636 | 636 | }
|
637 | 637 |
|
|
812 | 812 | var calculatedPosition = "floating";
|
813 | 813 |
|
814 | 814 | /*
|
815 |
| - * auto determine position |
| 815 | + * auto determine position |
816 | 816 | */
|
817 | 817 |
|
818 | 818 | // Check for space below
|
|
884 | 884 | winWidth = Math.min(windowSize.width, window.screen.width),
|
885 | 885 | possibleAlignments = ['-left-aligned', '-middle-aligned', '-right-aligned'],
|
886 | 886 | calculatedAlignment = '';
|
887 |
| - |
| 887 | + |
888 | 888 | // valid left must be at least a tooltipWidth
|
889 | 889 | // away from right side
|
890 | 890 | if (winWidth - offsetLeft < tooltipWidth) {
|
891 | 891 | _removeEntry(possibleAlignments, '-left-aligned');
|
892 | 892 | }
|
893 | 893 |
|
894 |
| - // valid middle must be at least half |
| 894 | + // valid middle must be at least half |
895 | 895 | // width away from both sides
|
896 |
| - if (offsetLeft < halfTooltipWidth || |
| 896 | + if (offsetLeft < halfTooltipWidth || |
897 | 897 | winWidth - offsetLeft < halfTooltipWidth) {
|
898 | 898 | _removeEntry(possibleAlignments, '-middle-aligned');
|
899 | 899 | }
|
|
913 | 913 | calculatedAlignment = possibleAlignments[0];
|
914 | 914 | }
|
915 | 915 | } else {
|
916 |
| - // if screen width is too small |
917 |
| - // for ANY alignment, middle is |
| 916 | + // if screen width is too small |
| 917 | + // for ANY alignment, middle is |
918 | 918 | // probably the best for visibility
|
919 | 919 | calculatedAlignment = '-middle-aligned';
|
920 | 920 | }
|
|
963 | 963 | widthHeightPadding = 0;
|
964 | 964 | }
|
965 | 965 |
|
| 966 | + var helperLayerMinTop = Math.max(0, (elementPosition.top - widthHeightPadding / 2)); |
| 967 | + var helperLayerMaxHeight = Math.min(Math.max(document.documentElement.clientHeight, window.innerHeight || 0), elementPosition.height + widthHeightPadding); |
| 968 | + |
966 | 969 | //set new position to helper layer
|
967 | 970 | helperLayer.style.cssText = 'width: ' + (elementPosition.width + widthHeightPadding) + 'px; ' +
|
968 |
| - 'height:' + (elementPosition.height + widthHeightPadding) + 'px; ' + |
969 |
| - 'top:' + (elementPosition.top - widthHeightPadding / 2) + 'px;' + |
| 971 | + 'height:' + helperLayerMaxHeight + 'px; ' + |
| 972 | + 'top:' + helperLayerMinTop + 'px;' + |
970 | 973 | 'left: ' + (elementPosition.left - widthHeightPadding / 2) + 'px;';
|
971 | 974 |
|
972 | 975 | }
|
|
1036 | 1039 | oldtooltipLayer = oldReferenceLayer.querySelector('.introjs-tooltiptext'),
|
1037 | 1040 | oldArrowLayer = oldReferenceLayer.querySelector('.introjs-arrow'),
|
1038 | 1041 | oldtooltipContainer = oldReferenceLayer.querySelector('.introjs-tooltip');
|
1039 |
| - |
| 1042 | + |
1040 | 1043 | skipTooltipButton = oldReferenceLayer.querySelector('.introjs-skipbutton');
|
1041 | 1044 | prevTooltipButton = oldReferenceLayer.querySelector('.introjs-prevbutton');
|
1042 | 1045 | nextTooltipButton = oldReferenceLayer.querySelector('.introjs-nextbutton');
|
|
1072 | 1075 | _forEach(fixParents, function (parent) {
|
1073 | 1076 | _removeClass(parent, /introjs-fixParent/g);
|
1074 | 1077 | });
|
1075 |
| - |
| 1078 | + |
1076 | 1079 | //remove old classes if the element still exist
|
1077 | 1080 | _removeShowElement();
|
1078 | 1081 |
|
|
1168 | 1171 | _forEach(this._introItems, function (item, i) {
|
1169 | 1172 | var innerLi = document.createElement('li');
|
1170 | 1173 | var anchorLink = document.createElement('a');
|
1171 |
| - |
| 1174 | + |
1172 | 1175 | innerLi.setAttribute('role', 'presentation');
|
1173 | 1176 | anchorLink.setAttribute('role', 'tab');
|
1174 | 1177 |
|
1175 | 1178 | anchorLink.onclick = anchorClick;
|
1176 | 1179 |
|
1177 | 1180 | if (i === (targetElement.step-1)) {
|
1178 | 1181 | anchorLink.className = 'active';
|
1179 |
| - } |
| 1182 | + } |
1180 | 1183 |
|
1181 | 1184 | _setAnchorAsButton(anchorLink);
|
1182 | 1185 | anchorLink.innerHTML = " ";
|
|
1390 | 1393 | * @param {Object} tooltipLayer
|
1391 | 1394 | */
|
1392 | 1395 | function _scrollTo(scrollTo, targetElement, tooltipLayer) {
|
1393 |
| - if (scrollTo === 'off') return; |
| 1396 | + if (scrollTo === 'off') return; |
1394 | 1397 | var rect;
|
1395 | 1398 |
|
1396 | 1399 | if (!this._options.scrollToElement) return;
|
|
1518 | 1521 | var _stamp = (function () {
|
1519 | 1522 | var keys = {};
|
1520 | 1523 | return function stamp (obj, key) {
|
1521 |
| - |
| 1524 | + |
1522 | 1525 | // get group key
|
1523 | 1526 | key = key || 'introjs-stamp';
|
1524 | 1527 |
|
|
1546 | 1549 | var DOMEvent = (function () {
|
1547 | 1550 | function DOMEvent () {
|
1548 | 1551 | var events_key = 'introjs_event';
|
1549 |
| - |
| 1552 | + |
1550 | 1553 | /**
|
1551 | 1554 | * Gets a unique ID for an event listener
|
1552 | 1555 | *
|
|
1867 | 1870 |
|
1868 | 1871 | _addHints.call(this);
|
1869 | 1872 |
|
1870 |
| - /* |
| 1873 | + /* |
1871 | 1874 | todo:
|
1872 |
| - these events should be removed at some point |
| 1875 | + these events should be removed at some point |
1873 | 1876 | */
|
1874 | 1877 | DOMEvent.on(document, 'click', _removeHintTooltip, this, false);
|
1875 | 1878 | DOMEvent.on(window, 'resize', _reAlignHints, this, true);
|
|
1910 | 1913 | */
|
1911 | 1914 | function _hideHint(stepId) {
|
1912 | 1915 | var hint = _hintQuerySelectorAll('.introjs-hint[data-step="' + stepId + '"]')[0];
|
1913 |
| - |
| 1916 | + |
1914 | 1917 | _removeHintTooltip.call(this);
|
1915 | 1918 |
|
1916 | 1919 | if (hint) {
|
|
2018 | 2021 |
|
2019 | 2022 | /**
|
2020 | 2023 | * Returns an event handler unique to the hint iteration
|
2021 |
| - * |
| 2024 | + * |
2022 | 2025 | * @param {Integer} i
|
2023 | 2026 | * @return {Function}
|
2024 | 2027 | */
|
2025 | 2028 | var getHintClick = function (i) {
|
2026 | 2029 | return function(e) {
|
2027 | 2030 | var evt = e ? e : window.event;
|
2028 |
| - |
| 2031 | + |
2029 | 2032 | if (evt.stopPropagation) {
|
2030 | 2033 | evt.stopPropagation();
|
2031 | 2034 | }
|
|
2258 | 2261 | var overflowRegex = /(auto|scroll)/;
|
2259 | 2262 |
|
2260 | 2263 | if (style.position === "fixed") return document.body;
|
2261 |
| - |
| 2264 | + |
2262 | 2265 | for (var parent = element; (parent = parent.parentElement);) {
|
2263 | 2266 | style = window.getComputedStyle(parent);
|
2264 | 2267 | if (excludeStaticParent && style.position === "static") {
|
|
0 commit comments