Skip to content

Commit 4d0cd9f

Browse files
committed
Added setStepIndex
1 parent 70dd162 commit 4d0cd9f

File tree

8 files changed

+48
-11
lines changed

8 files changed

+48
-11
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ git clone http://github.com/oguzhanoya/jquery-steps.git
2525
```
2626
CDN
2727
```html
28-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.steps@1.1.0/dist/jquery-steps.min.css">
29-
<script src="https://cdn.jsdelivr.net/npm/jquery.steps@1.1.0/dist/jquery-steps.min.js"></script>
28+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery.steps@1.1.1/dist/jquery-steps.min.css">
29+
<script src="https://cdn.jsdelivr.net/npm/jquery.steps@1.1.1/dist/jquery-steps.min.js"></script>
3030
```
3131

3232
## Setup
@@ -102,6 +102,7 @@ Init plugin with choosen options.
102102
|finish|Trigger the onFinish event.|
103103
|getStepIndex|Gets the current step index.(start from 0)|
104104
|getMaxStepIndex|Gets the max step index.|
105+
|setStepIndex|Sets the step index.|
105106

106107
## License
107108

dist/jquery-steps.js

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery-steps.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery-steps.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/api.html

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
<button id="btnGetStepIndex">Current Step Index</button>
4343
<button id="btnGetMaxStepIndex">Max Step Index</button>
4444
<hr>
45+
<button id="btnGoToFirstStep">First Step</button>
46+
<button id="btnGoToStep2">Go to Step 2</button>
47+
<button id="btnGoToLastStep">Last Step</button>
48+
<hr>
4549
<button id="btnDestroy">Destroy</button>
4650

4751
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
@@ -53,6 +57,7 @@
5357
alert('Wizard Completed');
5458
}
5559
});
60+
5661
steps_api = steps.data('plugin_Steps');
5762

5863
$('#btnPrev').on('click', function () {
@@ -64,15 +69,28 @@
6469
});
6570

6671
$('#btnGetStepIndex').on('click', function () {
67-
const idx = steps_api.getStepIndex();
72+
var idx = steps_api.getStepIndex();
6873
alert(idx);
6974
});
7075

7176
$('#btnGetMaxStepIndex').on('click', function () {
72-
const idx = steps_api.getMaxStepIndex();
77+
var idx = steps_api.getMaxStepIndex();
7378
alert(idx);
7479
});
7580

81+
$('#btnGoToFirstStep').on('click', function () {
82+
steps_api.setStepIndex(0);
83+
});
84+
85+
$('#btnGoToStep2').on('click', function () {
86+
steps_api.setStepIndex(1);
87+
});
88+
89+
$('#btnGoToLastStep').on('click', function () {
90+
var maxIdx = steps_api.getMaxStepIndex();
91+
steps_api.setStepIndex(maxIdx);
92+
});
93+
7694
$('#btnDestroy').on('click', function () {
7795
steps_api.destroy();
7896
});

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery.steps",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "A simple, lightweight jQuery step wizard plugin.",
55
"main": "./dist/jquery-steps.js",
66
"repository": {

src/Steps.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ class Steps {
168168
}
169169
}
170170

171+
setStepIndex(idx) {
172+
const maxIndex = this.getMaxStepIndex();
173+
if (idx <= maxIndex) {
174+
const stepIndex = this.getStepIndex();
175+
this.setActiveStep(stepIndex, idx);
176+
}
177+
}
178+
171179
next() {
172180
const stepIndex = this.getStepIndex();
173181
const maxIndex = this.getMaxStepIndex();

0 commit comments

Comments
 (0)