|
50 | 50 | * @returns {Boolean} Success or not?
|
51 | 51 | */
|
52 | 52 | function _introForElement(targetElm) {
|
53 |
| - var allIntroSteps = targetElm.querySelectorAll('*[data-intro]'), |
54 |
| - introItems = [], |
| 53 | + var introItems = [], |
55 | 54 | self = this;
|
56 | 55 |
|
57 |
| - if(this._options.steps) { |
58 |
| - // use steps passed programmatically |
59 |
| - allIntroSteps = []; |
60 |
| - |
61 |
| - for(var i = 0; i < this._options.steps.length; i++){ |
62 |
| - this._options.steps[i].step = i+1; //set the step |
63 |
| - introItems.push(this._options.steps[i]); |
| 56 | + if (this._options.steps) { |
| 57 | + //use steps passed programmatically |
| 58 | + var allIntroSteps = []; |
| 59 | + |
| 60 | + for (var i = 0, stepsLength = this._options.steps.length; i < stepsLength; i++) { |
| 61 | + var currentItem = this._options.steps[i]; |
| 62 | + //set the step |
| 63 | + currentItem.step = i + 1; |
| 64 | + //grab the element with given selector from the page |
| 65 | + currentItem.element = document.querySelector(currentItem.element); |
| 66 | + introItems.push(currentItem); |
64 | 67 | }
|
65 | 68 |
|
66 | 69 | } else {
|
67 |
| - // use steps from data-* annotations |
| 70 | + //use steps from data-* annotations |
68 | 71 |
|
| 72 | + var allIntroSteps = targetElm.querySelectorAll('*[data-intro]'); |
69 | 73 | //if there's no element to intro
|
70 |
| - if(allIntroSteps.length < 1) { |
| 74 | + if (allIntroSteps.length < 1) { |
71 | 75 | return false;
|
72 | 76 | }
|
73 | 77 |
|
|
424 | 428 | skipTooltipButton.innerHTML = this._options.skipLabel;
|
425 | 429 |
|
426 | 430 | skipTooltipButton.onclick = function() {
|
| 431 | + if (self._introItems.length - 1 == self._currentStep && typeof (self._introCompleteCallback) === 'function') { |
| 432 | + self._introCompleteCallback.call(self); |
| 433 | + } |
427 | 434 | _exitIntro.call(self, self._targetElement);
|
428 | 435 | };
|
429 | 436 |
|
|
0 commit comments