1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Enable reordering table columns

This commit is contained in:
Jeremy Stretch
2020-04-28 14:27:27 -04:00
parent 3442ec77a7
commit f51e7519dc
5 changed files with 41 additions and 8 deletions

View File

@@ -448,4 +448,29 @@ $(document).ready(function() {
$('a.image-preview').on('mouseout', function() {
$('#image-preview-window').fadeOut('fast');
});
// Rearrange options within a <select> list
$('#move-option-up').bind('click', function() {
var select_id = '#' + $(this).attr('data-target');
$(select_id + ' option:selected').each(function () {
var newPos = $(select_id + ' option').index(this) - 1;
if (newPos > -1) {
$(select_id + ' option').eq(newPos).before("<option value='" + $(this).val() + "' selected='selected'>" + $(this).text() + "</option>");
$(this).remove();
}
});
});
$('#move-option-down').bind('click', function() {
var select_id = '#' + $(this).attr('data-target');
var countOptions = $(select_id + ' option').length;
var countSelectedOptions = $(select_id + ' option:selected').length;
$(select_id + ' option:selected').each(function () {
var newPos = $(select_id + ' option').index(this) + countSelectedOptions;
if (newPos < countOptions) {
$(select_id + ' option').eq(newPos).after("<option value='" + $(this).val() + "' selected='selected'>" + $(this).text() + "</option>");
$(this).remove();
}
});
});
});