|
230 | 230 | };
|
231 | 231 |
|
232 | 232 | this.setTarget = function(element){
|
| 233 | + untrackElementChange(targetElement); |
233 | 234 | targetElement = $(element);
|
| 235 | + trackElementChange(targetElement); |
234 | 236 | };
|
235 | 237 |
|
236 | 238 | this.setPosition = function(position){
|
|
246 | 248 | };
|
247 | 249 |
|
248 | 250 | this.destroy = function(){
|
249 |
| - untrackElementChange(this.element); |
| 251 | + untrackElementChange(that.element); |
250 | 252 | untrackElementChange(tooltip);
|
251 | 253 | this.element.remove();
|
252 | 254 | tooltip.remove();
|
|
361 | 363 |
|
362 | 364 | function showStep(step){
|
363 | 365 | var _showStep = function(){
|
| 366 | + var selectedElement; |
364 | 367 | var intro;
|
365 | 368 | hint = hint || new Hint();
|
366 | 369 | backdrop = backdrop || createBackdrop();
|
|
370 | 373 | }else{
|
371 | 374 | intro = step.intro;
|
372 | 375 | }
|
373 |
| - if(step.element){ |
374 |
| - $(step.element).get(0).scrollIntoView(false); |
| 376 | + if(step.dynamicElement){ |
| 377 | + if(typeof step.dynamicElementCounter === 'undefined'){ |
| 378 | + step.dynamicElementCounter = 0; |
| 379 | + } |
| 380 | + if($(step.element).length - 1 === step.dynamicElementCounter){ |
| 381 | + step.dynamicElementCounter = 0; |
| 382 | + } |
| 383 | + selectedElement = $(step.element).eq(step.dynamicElementCounter); |
| 384 | + }else if(step.element){ |
| 385 | + selectedElement = $(step.element); |
375 | 386 | }
|
376 |
| - hint.setTarget(step.element || $('body')); |
| 387 | + |
| 388 | + $(selectedElement).get(0).scrollIntoView(false); |
| 389 | + |
| 390 | + hint.setTarget(selectedElement || $('body')); |
377 | 391 | hint.setPosition(step.hintPosition);
|
378 | 392 | hint.setTooltipPosition(step.tooltipPosition);
|
379 | 393 | hint.setContent(intro);
|
380 | 394 |
|
381 |
| - highlightElement(step.element, base.options.highlightInteractivity); |
| 395 | + if(step.dynamicElement){ |
| 396 | + if(typeof step.dynamicElementCounter === 'undefined'){ |
| 397 | + step.dynamicElementCounter = 0; |
| 398 | + } |
| 399 | + if($(step.element).length - 1 === step.dynamicElementCounter){ |
| 400 | + step.dynamicElementCounter = 0; |
| 401 | + } |
| 402 | + highlightElement(selectedElement, base.options.highlightInteractivity); |
| 403 | + step.dynamicElementCounter++; |
| 404 | + }else{ |
| 405 | + highlightElement(selectedElement, base.options.highlightInteractivity); |
| 406 | + } |
| 407 | + |
382 | 408 | if(_.isArray(step.highlightElements)){
|
383 | 409 | _.each(step.highlightElements, function(element){
|
384 | 410 | highlightElement(element, base.options.highlightInteractivity);
|
|
405 | 431 | });
|
406 | 432 |
|
407 | 433 | base.nextStep = function(){
|
408 |
| - hideStep(base.currentStep); |
409 |
| - currentStepIndex = currentStepIndex + 1; |
410 |
| - showStep(base.currentStep); |
| 434 | + base.goToStep(currentStepIndex + 1); |
411 | 435 | };
|
412 | 436 |
|
413 | 437 | base.previousStep = function(){
|
|
417 | 441 | };
|
418 | 442 |
|
419 | 443 | base.goToStep = function(stepIndex) {
|
| 444 | + hideStep(base.currentStep); |
420 | 445 | currentStepIndex = stepIndex;
|
421 | 446 | showStep(base.currentStep);
|
422 | 447 | };
|
|
0 commit comments