diff options
author | rtz12 <koenig@fagott.pw> | 2016-02-14 18:29:11 (UTC) |
---|---|---|
committer | rtz12 <koenig@fagott.pw> | 2016-02-14 18:29:11 (UTC) |
commit | 889adc748ec9a723bca605dcba45d974ec362999 (patch) | |
tree | 934f516a4202b273bb4e982ca5186e4012e54a83 /assets_src/js/lib | |
parent | 200f90f73e26c1e9bbd64889dfe5dbd1e70ae5fc (diff) |
Grils koennen nun sortiert und geloescht werden.
TODO: backend
Diffstat (limited to 'assets_src/js/lib')
-rw-r--r-- | assets_src/js/lib/dom.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/assets_src/js/lib/dom.js b/assets_src/js/lib/dom.js index 33845af..bfbeea7 100644 --- a/assets_src/js/lib/dom.js +++ b/assets_src/js/lib/dom.js | |||
@@ -5,10 +5,42 @@ export function ready(fn) { | |||
5 | } | 5 | } |
6 | 6 | ||
7 | export function closest(el, fn) { | 7 | export function closest(el, fn) { |
8 | if (!el) { | ||
9 | return null; | ||
10 | } | ||
8 | while (el) { | 11 | while (el) { |
9 | if (fn(el)) { | 12 | if (fn(el)) { |
10 | return el; | 13 | return el; |
11 | } | 14 | } |
12 | el = el.parentNode | 15 | el = el.parentNode |
13 | } | 16 | } |
17 | return null; | ||
18 | } | ||
19 | |||
20 | export function next(el, fn) { | ||
21 | if (!el) { | ||
22 | return null; | ||
23 | } | ||
24 | el = el.nextSibling; | ||
25 | while (el) { | ||
26 | if (fn(el)) { | ||
27 | return el; | ||
28 | } | ||
29 | el = el.nextSibling; | ||
30 | } | ||
31 | return null; | ||
32 | } | ||
33 | |||
34 | export function previous(el, fn) { | ||
35 | if (!el) { | ||
36 | return null; | ||
37 | } | ||
38 | el = el.previousSibling; | ||
39 | while (el) { | ||
40 | if (fn(el)) { | ||
41 | return el; | ||
42 | } | ||
43 | el = el.previousSibling; | ||
44 | } | ||
45 | return null; | ||
14 | } | 46 | } |