Lines 1756-1782
Link Here
|
1756 |
}); |
1756 |
}); |
1757 |
var prev_rank_request; |
1757 |
var prev_rank_request; |
1758 |
$("select[name=rank-request]").on("focus", function() { |
1758 |
$("select[name=rank-request]").on("focus", function() { |
1759 |
prev_rank_request = $(this).val(); |
1759 |
prev_rank_request = parseInt($(this).val()); |
1760 |
var row = $(this).parents("tr:first"); |
|
|
1761 |
}).change(function() { |
1760 |
}).change(function() { |
1762 |
var row = $(this).parents("tr:first"); |
1761 |
var this_rank = $(this); |
1763 |
var value = parseInt($(this).val()); |
1762 |
var new_rank = parseInt(this_rank.val()); |
1764 |
var found_holds = $("select[name='rank-request'][disabled='disabled']").length ; //Count how many are found |
1763 |
var old_rank = prev_rank_request; |
1765 |
if( !isNaN(value) ) { //If moved to 'del' |
1764 |
|
1766 |
var after = row.parent().find(`tr:nth-child(${value+found_holds})`); //Go to the row 1 after the new value (and skip found holds) |
1765 |
if ( isNaN( old_rank ) ) { |
1767 |
if (prev_rank_request > value) { |
1766 |
$("select[name=rank-request]").not('[disabled]').not(this_rank).each(function() { |
1768 |
row.insertBefore(after); |
1767 |
var current_rank = parseInt($(this).val()); |
1769 |
} else { |
1768 |
if ( !isNaN(current_rank) && current_rank >= new_rank ) { |
1770 |
row.insertAfter(after); |
1769 |
$(this).val(current_rank + 1); |
|
|
1770 |
} |
1771 |
}); |
1772 |
prev_rank_request = new_rank; |
1773 |
return; |
1774 |
} |
1775 |
|
1776 |
if ( isNaN( new_rank ) ) { |
1777 |
if ( !isNaN( old_rank ) ) { |
1778 |
$("select[name=rank-request]").not('[disabled]').not(this).each(function() { |
1779 |
var current_rank = parseInt($(this).val()); |
1780 |
if ( !isNaN(current_rank) && current_rank > old_rank ) { |
1781 |
$(this).val(current_rank - 1); |
1782 |
} |
1783 |
}); |
1771 |
} |
1784 |
} |
|
|
1785 |
prev_rank_request = NaN; |
1786 |
return; |
1772 |
} |
1787 |
} |
1773 |
|
1788 |
|
1774 |
var next_priority = 1; |
1789 |
//if new rank is old rank, don't continue |
1775 |
$("select[name=rank-request]").each(function () { |
1790 |
if ( new_rank === old_rank ) return; |
1776 |
if( isNaN( $(this).val() ) ){ return true; } //Don't reset found or del holds |
1791 |
|
1777 |
$(this).val(next_priority); |
1792 |
// Adjust ranks |
1778 |
next_priority++; |
1793 |
$("select[name=rank-request]").not('[disabled]').not(this).each(function() { |
|
|
1794 |
var current_rank = parseInt($(this).val()); |
1795 |
//if current_rank is NaN, bail |
1796 |
if ( isNaN( current_rank ) ) return; |
1797 |
|
1798 |
if ( old_rank > new_rank ) { |
1799 |
if ( current_rank >= new_rank && current_rank < old_rank ) { |
1800 |
$(this).val(current_rank + 1); |
1801 |
} |
1802 |
} else { |
1803 |
if ( current_rank > old_rank && current_rank <= new_rank ) { |
1804 |
$(this).val(current_rank - 1); |
1805 |
} |
1806 |
} |
1779 |
}); |
1807 |
}); |
|
|
1808 |
|
1809 |
prev_rank_request = new_rank; |
1780 |
}); |
1810 |
}); |
1781 |
|
1811 |
|
1782 |
$(".clear-date").on("click",function(e){ |
1812 |
$(".clear-date").on("click",function(e){ |
1783 |
- |
|
|