function drag_update(e, u) {
    var this_select = u.item.find('select')[0];
    var rownum = 0;
    read_rows();
    var i;
    var selected;
    for (i = 0; i < num_choices; i++) {
        if (selector(rows[i]) == this_select) {
            selected = i;
        }
    }
    selector(rows[selected]).selectedIndex = selected;
    i = selected-1;
    var last_dest = selected;
    var last_src = -1;

    while (i >= 0) {
        // three cases: 1. rank[i] is the same as the rank of the
        // previous one. In this case map it to last_dest.
        // 2. Or it is less than last_dest, in which keep it the same.
        // 3. Otherwise map it to last_used - 1;
        if (rank[i] != last_src) {
            last_src = rank[i];
            if (rank[i]-1 < last_dest) break;
            else last_dest--;
        }
        selector(rows[i]).selectedIndex = last_dest;
        i--;
    }
    i = selected+1;
    last_src = -1;
    last_dest = selected;
    while (i < num_choices) {
        if (rank[i] != last_src) {
            last_src = rank[i];
            if (rank[i]-1 > last_dest) break;
            else last_dest++;
        }
        selector(rows[i]).selectedIndex = last_dest;
        i++;
    }
    read_rows();
    set_row_borders();
}
// Correct the ranks of the rows after a row is dragged.
Correct the ranks of the rows after a row is dragged.
Correct the ranks of the rows after a row is dragged .
function drag_update(e, u) {
    var this_select = u.item.find('select')[0];
    var rownum = 0;
    read_rows();
    var i;
    var selected;
    for (i = 0; i < num_choices; i++) {
        if (selector(rows[i]) == this_select) {
            selected = i;
        }
    }
    selector(rows[selected]).selectedIndex = selected;
    i = selected-1;
    var last_dest = selected;
    var last_src = -1;
    while (i >= 0) {
        if (rank[i] != last_src) {
            last_src = rank[i];
            if (rank[i]-1 < last_dest) break;
            else last_dest--;
        }
        selector(rows[i]).selectedIndex = last_dest;
        i--;
    }
    i = selected+1;
    last_src = -1;
    last_dest = selected;
    while (i < num_choices) {
        if (rank[i] != last_src) {
            last_src = rank[i];
            if (rank[i]-1 > last_dest) break;
            else last_dest++;
        }
        selector(rows[i]).selectedIndex = last_dest;
        i++;
    }
    read_rows();
    set_row_borders();
}
function drag_update ( e , u ) { var this_select = u . item . find ( 'select' ) [ 0 ] ; var rownum = 0 ; read_rows ( ) ; var i ; var selected ; for ( i = 0 ; i < num_choices ; i ++ ) { if ( selector ( rows [ i ] ) == this_select ) { selected = i ; } } selector ( rows [ selected ] ) . selectedIndex = selected ; i = selected - 1 ; var last_dest = selected ; var last_src = - 1 ; while ( i >= 0 ) { if ( rank [ i ] != last_src ) { last_src = rank [ i ] ; if ( rank [ i ] - 1 < last_dest ) break ; else last_dest -- ; } selector ( rows [ i ] ) . selectedIndex = last_dest ; i -- ; } i = selected + 1 ; last_src = - 1 ; last_dest = selected ; while ( i < num_choices ) { if ( rank [ i ] != last_src ) { last_src = rank [ i ] ; if ( rank [ i ] - 1 > last_dest ) break ; else last_dest ++ ; } selector ( rows [ i ] ) . selectedIndex = last_dest ; i ++ ; } read_rows ( ) ; set_row_borders ( ) ; }
Correct the ranks of the rows after a row is dragged.
Correct the ranks of the rows after a row is dragged .
// three cases: 1. rank[i] is the same as the rank of the // previous one. In this case map it to last_dest. // 2. Or it is less than last_dest, in which keep it the same. // 3. Otherwise map it to last_used - 1;