|
64 | 64 | var skipButton = targetElm.querySelector(".introjs-skipbutton"),
|
65 | 65 | nextStepButton = targetElm.querySelector(".introjs-nextbutton");
|
66 | 66 |
|
67 |
| - targetElm.onkeydown = function(e) { |
| 67 | + window.onkeydown = function(e) { |
68 | 68 | if (e.keyCode == 27) {
|
69 | 69 | //escape key pressed, exit the intro
|
70 | 70 | _exitIntro.call(self, targetElm);
|
|
96 | 96 | if((this._introItems.length) <= this._currentStep) {
|
97 | 97 | //end of the intro
|
98 | 98 | //check if any callback is defined
|
99 |
| - if (this._introCompleteCallback != undefined){ |
| 99 | + if (this._introCompleteCallback != undefined) { |
100 | 100 | this._introCompleteCallback.call(this);
|
101 | 101 | }
|
102 | 102 | _exitIntro.call(this, this._targetElement);
|
|
113 | 113 | * @method _nextStep
|
114 | 114 | */
|
115 | 115 | function _previousStep() {
|
116 |
| - if (this._currentStep == 0){ |
| 116 | + if (this._currentStep == 0) { |
117 | 117 | return false;
|
118 | 118 | }
|
119 | 119 |
|
|
150 | 150 | //clean listeners
|
151 | 151 | targetElement.onkeydown = null;
|
152 | 152 | //check if any callback is defined
|
153 |
| - if (this._introExitCallback != undefined){ |
| 153 | + if (this._introExitCallback != undefined) { |
154 | 154 | this._introExitCallback.call(this);
|
155 | 155 | }
|
156 | 156 | }
|
|
215 | 215 | oldtooltipContainer = oldHelperLayer.querySelector(".introjs-tooltip")
|
216 | 216 |
|
217 | 217 | //set new position to helper layer
|
218 |
| - oldHelperLayer.setAttribute("style", "width: " + (elementPosition.width + 10) + "px; " + |
219 |
| - "height:" + (elementPosition.height + 10) + "px; " + |
220 |
| - "top:" + (elementPosition.top - 5) + "px;" + |
221 |
| - "left: " + (elementPosition.left - 5) + "px;"); |
| 218 | + oldHelperLayer.setAttribute("style", "width: " + (elementPosition.width + 10) + "px; " + |
| 219 | + "height:" + (elementPosition.height + 10) + "px; " + |
| 220 | + "top:" + (elementPosition.top - 5) + "px;" + |
| 221 | + "left: " + (elementPosition.left - 5) + "px;"); |
222 | 222 | //set current step to the label
|
223 | 223 | oldHelperNumberLayer.innerHTML = targetElement.getAttribute("data-step");
|
224 | 224 | //set current tooltip text
|
|
237 | 237 | tooltipLayer = document.createElement("div");
|
238 | 238 |
|
239 | 239 | helperLayer.className = "introjs-helperLayer";
|
240 |
| - helperLayer.setAttribute("style", "width: " + (elementPosition.width + 10) + "px; " + |
| 240 | + helperLayer.setAttribute("style", "width: " + (elementPosition.width + 10) + "px; " + |
241 | 241 | "height:" + (elementPosition.height + 10) + "px; " +
|
242 |
| - "top:" + (elementPosition.top - 5) + "px;" + |
243 |
| - "left: " + (elementPosition.left - 5) + "px;"); |
| 242 | + "top:" + (elementPosition.top - 5) + "px;" + |
| 243 | + "left: " + (elementPosition.left - 5) + "px;"); |
| 244 | + |
| 245 | + //add helper layer to target element |
| 246 | + this._targetElement.appendChild(helperLayer); |
244 | 247 |
|
245 |
| - document.body.appendChild(helperLayer); |
246 |
| - |
247 | 248 | helperNumberLayer.className = "introjs-helperNumberLayer";
|
248 | 249 | arrowLayer.className = 'introjs-arrow';
|
249 | 250 | tooltipLayer.className = "introjs-tooltip";
|
|
282 | 283 | }
|
283 | 284 |
|
284 | 285 | //scroll the page to the element position
|
285 |
| - if(typeof(targetElement.scrollIntoViewIfNeeded) === "function") { |
| 286 | + if (typeof(targetElement.scrollIntoViewIfNeeded) === "function") { |
286 | 287 | //awesome method guys: https://bugzilla.mozilla.org/show_bug.cgi?id=403510
|
287 | 288 | //but I think this method has some problems with IE < 7.0, I should find a proper failover way
|
288 | 289 | targetElement.scrollIntoViewIfNeeded();
|
|
304 | 305 | //set css class name
|
305 | 306 | overlayLayer.className = "introjs-overlay";
|
306 | 307 |
|
307 |
| - //set overlay layer position |
308 |
| - var elementPosition = _getOffset(targetElm); |
309 |
| - if(elementPosition) { |
310 |
| - styleText += "width: " + elementPosition.width + "px; height:" + elementPosition.height + "px; top:" + elementPosition.top + "px;left: " + elementPosition.left + "px;"; |
| 308 | + //check if the target element is body, we should calculate the size of overlay layer in a better way |
| 309 | + if (targetElm.tagName.toLowerCase() == "body") { |
| 310 | + styleText += "top: 0;bottom: 0; left: 0;right: 0;position: fixed;"; |
311 | 311 | overlayLayer.setAttribute("style", styleText);
|
| 312 | + } else { |
| 313 | + //set overlay layer position |
| 314 | + var elementPosition = _getOffset(targetElm); |
| 315 | + if(elementPosition) { |
| 316 | + styleText += "width: " + elementPosition.width + "px; height:" + elementPosition.height + "px; top:" + elementPosition.top + "px;left: " + elementPosition.left + "px;"; |
| 317 | + overlayLayer.setAttribute("style", styleText); |
| 318 | + } |
312 | 319 | }
|
313 | 320 |
|
314 | 321 | targetElm.appendChild(overlayLayer);
|
|
0 commit comments