84c675db83b52d84509c4668b6b1299b9e4e3834
1var selected
2
3function dragOver( e ) {
4 if ( isBefore( selected, e.target ) ) e.target.parentNode.insertBefore( selected, e.target )
5 else e.target.parentNode.insertBefore( selected, e.target.nextSibling )
6}
7
8function dragEnd() {
9 selected = null
10}
11
12function dragStart( e ) {
13 e.dataTransfer.effectAllowed = "move"
14 e.dataTransfer.setData( "text/plain", null )
15 selected = e.target
16}
17
18function isBefore( el1, el2 ) {
19 var cur
20 if ( el2.parentNode === el1.parentNode ) {
21 for ( cur = el1.previousSibling; cur; cur = cur.previousSibling ) {
22 if (cur === el2) return true
23 }
24 } else return false;
25}