-
-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathuitools.js
More file actions
32 lines (29 loc) · 730 Bytes
/
uitools.js
File metadata and controls
32 lines (29 loc) · 730 Bytes
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
function foreach(list, callback) {
for (var idx = 0; idx < list.length; idx++) {
if (callback.apply(list[idx]) === false) {
break;
}
}
}
function getNextSiblingInDom(element) {
var allChildrenOfParent = element.parentNode.children,
nextSibling = false,
foundCurrent = false;
foreach(allChildrenOfParent, function() {
if (this === element) {
foundCurrent = true;
} else {
if (foundCurrent === true) {
nextSibling = this;
return false;
}
}
});
return nextSibling;
}
function addClass(element, className) {
var classes = element.className.split(' ');
if (classes.indexOf(className) !== false) {
element.className += " " + className;
}
}