Uses icon font for column order selection

pull/934/head
Hagen Schink 11 years ago
parent df1d34842d
commit a60f4a2234
  1. 37
      app/assets/javascripts/select_list_move.js
  2. 12
      app/views/queries/_columns.html.erb

@ -26,17 +26,6 @@
// See doc/COPYRIGHT.rdoc for more details.
//++
function swapOptions(theSel, index1, index2)
{
var text, value;
text = theSel.options[index1].text;
value = theSel.options[index1].value;
theSel.options[index1].text = theSel.options[index2].text;
theSel.options[index1].value = theSel.options[index2].value;
theSel.options[index2].text = text;
theSel.options[index2].value = value;
}
function moveOptions(sourceId, destId) {
var sourceSelection = jQuery('#' + sourceId);
var destSelection = jQuery('#' + destId);
@ -52,20 +41,24 @@ function moveOptions(sourceId, destId) {
});
}
function moveOptionUp(theSel) {
var index = theSel.selectedIndex;
if (index > 0) {
swapOptions(theSel, index-1, index);
theSel.selectedIndex = index-1;
function swapOptions(option1, option2) {
if (option1.length == 1 && option2.length == 1) {
option2.after(option1);
}
}
function moveOptionDown(theSel) {
var index = theSel.selectedIndex;
if (index < theSel.length - 1) {
swapOptions(theSel, index, index+1);
theSel.selectedIndex = index+1;
}
function moveOptionUp(selectionId) {
var selection = jQuery('#' + selectionId);
var selectedOptions = selection.find('option:selected');
swapOptions(selectedOptions.prev(), selectedOptions);
}
function moveOptionDown(selectionId) {
var selection = jQuery('#' + selectionId);
var selectedOptions = selection.find('option:selected');
swapOptions(selectedOptions, selectedOptions.next());
}
function selectAllOptions(id)

@ -54,10 +54,14 @@ See doc/COPYRIGHT.rdoc for more details.
:id => 'selected_columns', :multiple => true, :size => 10, :style => "width:150px" %>
</td>
<td class="table-buttons" align="center" valign="middle">
<input type="button" value="&#8593;" onclick="moveOptionUp(this.form.selected_columns);"
title="<%= l(:label_sort_higher) %>" /><br />
<input type="button" value="&#8595;" onclick="moveOptionDown(this.form.selected_columns);"
title="<%= l(:label_sort_lower) %>" />
<%= link_to icon_wrapper('icon icon-arrow-right5-3', l(:label_sort_higher)), {},
{ title: l(:label_sort_higher),
onclick: "moveOptionUp('selected_columns'); return false;" } %>
<br />
<%= link_to icon_wrapper('icon icon-arrow-right5-2', l(:label_sort_lower)), {},
{ title: l(:label_sort_lower),
style: "margin-right: 3px",
onclick: "moveOptionDown('selected_columns'); return false;" } %>
</td>
</tr>
</table>

Loading…
Cancel
Save