From e70f9854a79542b110c8a7ec5e2a602a705d0bd2 Mon Sep 17 00:00:00 2001 From: toins Date: Wed, 27 Sep 2006 14:17:29 +0000 Subject: [PATCH] fix bug in MARC editor, when you have hide_marc=ON and want to repeat a subfield that is the only subfield of the field --- .../default/en/acqui.simple/addbiblio.tmpl | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/default/en/acqui.simple/addbiblio.tmpl b/koha-tmpl/intranet-tmpl/default/en/acqui.simple/addbiblio.tmpl index 4b82bf986e..777604dd75 100644 --- a/koha-tmpl/intranet-tmpl/default/en/acqui.simple/addbiblio.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/acqui.simple/addbiblio.tmpl @@ -308,27 +308,31 @@ function AddField(field,cntrepeatfield) { } function cloneSubfield(index) { - var original = document.getElementById(index); - var clone = original.cloneNode(true); - clone.setAttribute("id", index + index); -// orginput : the value of the original field (in [0] if hide_marc=1, otherwise in [1] -// image : the up button. don't exist is hide_marc=1 - - var orginput = original.getElementsByTagName('input')[0]; - - var orginput = original.getElementsByTagName('input')[1]; - image = clone.getElementsByTagName('img')[0]; - image.setAttribute("onclick","upSubfield('" + index + index + "')"); - - trigger = original.getElementsByTagName('a')[0]; - if (trigger) { - trigger.parentNode.removeChild(trigger); - } - clonetrigger = clone.getElementsByTagName('a')[0]; - clonetrigger.setAttribute("onclick","cloneSubfield('" + index + index + "')"); - clone.setAttribute("tabindex","1"); - orginput.value = ''; - original.parentNode.insertBefore( clone, original.nextSibling); + var original = document.getElementById(index); //original
+ var clone = original.cloneNode(true); + + // set the attribute for the new 'div' subfields + clone.setAttribute('id',index + index);//set another id. + var NumTabIndex; + NumTabIndex = parseInt(original.getAttribute('tabindex')); + if(isNaN(NumTabIndex)) NumTabIndex = 0; + clone.setAttribute('tabindex',NumTabIndex+1); + + var ButtonPlus; + var CloneButtonPlus; + try{ + ButtonPlus = original.getElementsByTagName('a')[0]; // getting the '+ + ButtonPlus.parentNode.removeChild(ButtonPlus); // removing the '+' button + + CloneButtonPlus = clone.getElementsByTagName('a')[0]; + CloneButtonPlus.setAttribute('onclick',"cloneSubfield('" + index + index + "')"); + } + catch(e){ + // do nothig if ButtonPlus & CloneButtonPlus don't exist. + } + + // insert this line on the page + original.parentNode.insertBefore(clone,original.nextSibling); } function upSubfield(index) {