From d8f16da1802357ad5935d0db91a07a2013865249 Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Tue, 14 Sep 2010 11:02:42 -0400 Subject: [PATCH] Bug 4867 - cannot clone subfields in marc editor, other clone/unclone weirdness When the clone/unclone plus/minus were replaced with images the tags were inadvertantly deleted causing the js to loose its ability to identify the clone/unclone links and properly udpate the indexes. The resulting incorrect indexes caused various weirdnesses to result when one attempted to clone/unclone subfields. This patch simply adds classes to the two links and updates the js to identify the links based on class. Thanks to owen for his help in chasing this down. Signed-off-by: Owen Leonard Signed-off-by: Galen Charlton --- .../en/modules/cataloguing/addbiblio.tmpl | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl index e722afbe39..3e510c5ede 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl @@ -324,12 +324,12 @@ function CloneField(index) { // setting its '+' and '-' buttons try { - var spans = divs[i].getElementsByTagName('span'); - for (var j = 0; j < spans.length; j++) { - if(spans[j].getAttribute('class') == 'buttonPlus'){ - spans[j].setAttribute('onclick',"CloneSubfield('" + divs[i].getAttribute('id') + "')"); - } else if (spans[j].getAttribute('class') == 'buttonMinus') { - spans[j].setAttribute('onclick',"UnCloneField('" + divs[i].getAttribute('id') + "')"); + var anchors = divs[i].getElementsByTagName('a'); + for (var j = 0; j < anchors.length; j++) { + if(anchors[j].getAttribute('class') == 'buttonPlus'){ + anchors[j].setAttribute('onclick',"CloneSubfield('" + divs[i].getAttribute('id') + "')"); + } else if (anchors[j].getAttribute('class') == 'buttonMinus') { + anchors[j].setAttribute('onclick',"UnCloneField('" + divs[i].getAttribute('id') + "')"); } } } @@ -479,19 +479,19 @@ function CloneSubfield(index){ label.setAttribute('for',id_input); - // setting a new if for the parent div + // setting a new id for the parent div clone.setAttribute('id',new_id); try { var buttonUp = clone.getElementsByTagName('img')[0]; buttonUp.setAttribute('onclick',"upSubfield('" + new_id + "')"); - var spans = clone.getElementsByTagName('span'); - if(spans.length){ - for(var i = 0 ,lenspans = spans.length ; i < lenspans ; i++){ - if(spans[i].getAttribute('class') == 'buttonPlus'){ - spans[i].setAttribute('onclick',"CloneSubfield('" + new_id + "')"); - } else if (spans[i].getAttribute('class') == 'buttonMinus') { - spans[i].setAttribute('onclick',"UnCloneField('" + new_id + "')"); + var anchors = clone.getElementsByTagName('a'); + if(anchors.length){ + for(var i = 0 ,lenanchors = anchors.length ; i < lenanchors ; i++){ + if(anchors[i].getAttribute('class') == 'buttonPlus'){ + anchors[i].setAttribute('onclick',"CloneSubfield('" + new_id + "')"); + } else if (anchors[i].getAttribute('class') == 'buttonMinus') { + anchors[i].setAttribute('onclick',"UnCloneField('" + new_id + "')"); } } } @@ -810,8 +810,8 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ? - '); return false;">Clone - '); return false;">Delete + '); return false;">Clone + '); return false;">Delete -- 2.39.5