refactored select_list_move_optgroup.js to handle both, id's and DOM-object, as function argument most of the time

git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1752 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
p.tessenow 14 years ago
parent 16de349e59
commit c2218ae859
  1. 14
      assets/javascripts/select_list_move_optgroup.js

@ -11,7 +11,7 @@ function createOption(theText, theValue, theCategory) {
function addOption(theSel, newOpt, theCategory)
{
var theCategory = newOpt.getAttribute("data-category");
Element.extend(theSel);
theSel = $(theSel);
if (theCategory && (theSel.childElements().length > 0) && theSel.down(0).tagName == "OPTGROUP") { // add the opt to the given category
opt_groups = theSel.childElements();
for (var i=0; i<opt_groups.length; i++)
@ -27,7 +27,7 @@ function addOption(theSel, newOpt, theCategory)
function swapOptions(theSel, index1, index2)
{
Element.extend(theSel);
theSel = $(theSel);
var text, value;
text = theSel.options[index1].text;
value = theSel.options[index1].value;
@ -42,7 +42,7 @@ function swapOptions(theSel, index1, index2)
function deleteOption(theSel, theIndex)
{
Element.extend(theSel);
theSel = $(theSel);
var selLength = theSel.length;
if(selLength>0)
{
@ -52,8 +52,8 @@ function deleteOption(theSel, theIndex)
function moveOptions(theSelFrom, theSelTo)
{
Element.extend(theSelFrom);
Element.extend(theSelTo);
theSelFrom = $(theSelFrom);
theSelTo = $(theSelTo);
var selLength = theSelFrom.length;
var selectedText = new Array();
var selectedValues = new Array();
@ -73,7 +73,7 @@ function moveOptions(theSelFrom, theSelTo)
}
function moveOptionUp(theSel) {
Element.extend(theSel);
theSel = $(theSel);
var index = theSel.selectedIndex;
if (index > 0) {
swapOptions(theSel, index-1, index);
@ -82,7 +82,7 @@ function moveOptionUp(theSel) {
}
function moveOptionDown(theSel) {
Element.extend(theSel);
theSel = $(theSel);
var index = theSel.selectedIndex;
if (index < theSel.length - 1) {
swapOptions(theSel, index, index+1);

Loading…
Cancel
Save