-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.step.js
38 lines (36 loc) · 930 Bytes
/
jquery.step.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(function (root, factory) {
if (typeof define === "function" && define.amd) {
define([], factory);
} else if (typeof module === "object" && module.exports) {
module.exports = factory();
} else {
root["mu-jquery-step/jquery.step"] = factory();
}
})(this, function () {
function Step(index, element) {
this.index = index;
this.element = element;
}
return function (selector, target, callback) {
var prev;
var step;
var list = Step.prototype = {};
var elements = this
.find(selector)
.map(function (index, element) {
var next = new Step(index, element);
if (prev) {
next.prev = prev;
prev.next = next;
}
else {
list.first = next;
}
if (element === target) {
step = next;
}
return list.last = prev = next;
});
return callback.call(elements, step);
}
});