|
16 | 16 | * - Loading Animation (Spinner)
|
17 | 17 | * - Implement slideLeft animation
|
18 | 18 | * - Fix bugs in insert and remove methods (add works fine)
|
19 |
| - * a. Refresh ids higher than new index |
20 |
| - * b. The step button is not inserted right (still added at the end) |
21 |
| - * c. Add tests for add, insert and remove |
| 19 | + * a. Add tests for add, insert and remove |
22 | 20 | *
|
23 | 21 | * Planed Features:
|
24 | 22 | * - Progress bar
|
25 | 23 | * - Advanced Accessibility support (WAI-ARIA)
|
26 | 24 | * - Implement preloadContent for async and iframe content types.
|
27 | 25 | * - Implement functionality to skip a certain amount of steps
|
28 | 26 | * - Dynamic settings change
|
| 27 | + * - Dynamic step update |
29 | 28 | *
|
30 | 29 | */
|
31 | 30 |
|
|
362 | 361 | options = wizard.data("options"),
|
363 | 362 | state = wizard.data("state");
|
364 | 363 |
|
365 |
| - if (index < 0 || index > state.Count || state.currentIndex === index) |
| 364 | + // Index out of range and try deleting current item will return false. |
| 365 | + if (index < 0 || index > state.stepCount || state.currentIndex === index) |
366 | 366 | {
|
367 | 367 | return false;
|
368 | 368 | }
|
369 | 369 |
|
370 | 370 | var contentContainer = wizard.children(".content");
|
371 |
| - contentContainer.children(".title:eq(" + index + ")").remove(); |
372 |
| - contentContainer.children(".body:eq(" + index + ")").remove(); |
| 371 | + $(".title:eq(" + index + ")", contentContainer).remove(); |
| 372 | + $(".body:eq(" + index + ")", contentContainer).remove(); |
| 373 | + $(".steps > ol > li:eq(" + index + ")", wizard).remove(); |
373 | 374 |
|
374 | 375 | if (index === 0)
|
375 | 376 | {
|
376 |
| - contentContainer.children(".title:first").addClass("first"); |
| 377 | + $(".title:first", contentContainer).addClass("first"); |
377 | 378 | }
|
378 | 379 |
|
379 | 380 | // Reset state values
|
380 | 381 | if (state.currentIndex >= index)
|
381 | 382 | {
|
382 | 383 | state.currentIndex = state.currentIndex + 1;
|
383 | 384 | }
|
384 |
| - state.stepCount = contentContainer.children(".body").length; |
| 385 | + state.stepCount = $(".body", contentContainer).length; |
385 | 386 | state.currentStep = getStepProperties(wizard, state.currentIndex);
|
386 | 387 |
|
| 388 | + updateIdentifiers(wizard, index); |
387 | 389 | refreshActionState(wizard);
|
388 | 390 |
|
389 | 391 | return true;
|
|
467 | 469 | state.stepCount = contentContainer.children(".body").length;
|
468 | 470 | state.currentStep = getStepProperties(wizard, state.currentIndex);
|
469 | 471 |
|
| 472 | + updateIdentifiers(wizard, index); |
470 | 473 | refreshActionState(wizard);
|
471 | 474 |
|
472 | 475 | return wizard;
|
|
762 | 765 | {
|
763 | 766 | stepItem.addClass("disabled");
|
764 | 767 | }
|
765 |
| - |
766 |
| - $(".steps > ol", wizard).append(stepItem); |
| 768 | + |
| 769 | + var stepCollection = $(".steps > ol", wizard); |
| 770 | + if (index === 0) |
| 771 | + { |
| 772 | + stepCollection.prepend(stepItem); |
| 773 | + } |
| 774 | + else |
| 775 | + { |
| 776 | + $("li:eq(" + (index - 1) + ")", stepCollection).after(stepItem); |
| 777 | + } |
767 | 778 | }
|
768 | 779 |
|
769 | 780 | /**
|
|
802 | 813 | }
|
803 | 814 | }
|
804 | 815 |
|
| 816 | + /** |
| 817 | + * Updates identifiers for step buttons and their related titles. |
| 818 | + * |
| 819 | + * @private |
| 820 | + * @method updateIdentifiers |
| 821 | + * @param wizard A jQuery wizard object |
| 822 | + * @param index The start point for updating ids |
| 823 | + */ |
| 824 | + function updateIdentifiers(wizard, index) |
| 825 | + { |
| 826 | + for (var i = index; i < wizard.data("state").stepCount; i++) |
| 827 | + { |
| 828 | + $(".steps > ol > li:eq(" + i + ") > a", wizard).attr("href", "#" + getUniqueId(wizard) + "-" + i); |
| 829 | + $(".content > .title:eq(" + i + ")", wizard).attr("id", getUniqueId(wizard) + "-" + i); |
| 830 | + } |
| 831 | + } |
| 832 | + |
805 | 833 | /**
|
806 | 834 | * Refreshs the action navigation.
|
807 | 835 | *
|
808 | 836 | * @private
|
809 | 837 | * @method refreshActionState
|
| 838 | + * @param wizard A jQuery wizard object |
810 | 839 | */
|
811 | 840 | function refreshActionState(wizard)
|
812 | 841 | {
|
|
0 commit comments