Porting additems.tmpl changes to serials-edit (serialsadditems enabled)
Signed-off-by: Chris Cormack <crc@liblime.com> Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
parent
e04586d2f6
commit
6abe110d8a
1 changed files with 77 additions and 6 deletions
|
@ -73,6 +73,70 @@ function HideItems(index,labelindex) {
|
|||
label = document.getElementById(labelindex);
|
||||
label.style.display='block';
|
||||
}
|
||||
function CloneSubfield(index){
|
||||
var original = document.getElementById(index); //original <div>
|
||||
var clone = original.cloneNode(true);
|
||||
var new_key = CreateKey();
|
||||
var old_id = original.getAttribute('id');
|
||||
old_id=old_id.substr(12);
|
||||
var new_id = old_id+new_key;
|
||||
|
||||
// set the attribute for the new 'div' subfields
|
||||
var inputs = clone.getElementsByTagName('input');
|
||||
var selects = clone.getElementsByTagName('select');
|
||||
var textareas = clone.getElementsByTagName('textarea');
|
||||
|
||||
// input
|
||||
var id_input = "";
|
||||
for(var i=0,len=inputs.length; i<len ; i++ ){
|
||||
id_input = inputs[i].getAttribute('id')+new_key;
|
||||
inputs[i].setAttribute('id',id_input);
|
||||
inputs[i].setAttribute('name',inputs[i].getAttribute('name'));
|
||||
}
|
||||
|
||||
// select
|
||||
for(var i=0,len=selects.length; i<len ; i++ ){
|
||||
id_input = selects[i].getAttribute('id')+new_key;
|
||||
selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key);
|
||||
selects[i].setAttribute('name',selects[i].getAttribute('name'));
|
||||
}
|
||||
|
||||
// textarea
|
||||
for(var i=0,len=textareas.length; i<len ; i++ ){
|
||||
id_input = textareas[i].getAttribute('id')+new_key;
|
||||
textareas[i].setAttribute('id',textareas[i].getAttribute('id')+new_key);
|
||||
textareas[i].setAttribute('name',textareas[i].getAttribute('name'));
|
||||
}
|
||||
|
||||
<!-- TMPL_UNLESS NAME='advancedMARCEditor' -->
|
||||
// when cloning a subfield, reset its label too.
|
||||
var label = clone.getElementsByTagName('label')[0];
|
||||
label.setAttribute('for',id_input);
|
||||
<!-- /TMPL_UNLESS -->
|
||||
|
||||
// setting a new if for the parent div
|
||||
clone.setAttribute('id',new_id);
|
||||
|
||||
var CloneButtonPlus;
|
||||
try {
|
||||
var spans = clone.getElementsByTagName('span');
|
||||
if(spans.length){
|
||||
for(var i = 0 ,lenspans = spans.length ; i < lenspans ; i++){
|
||||
if(spans[i].getAttribute('class') == 'buttonPlus'){
|
||||
CloneButtonPlus = spans[i];
|
||||
CloneButtonPlus.setAttribute('onclick',"CloneSubfield('" + new_id + "')");
|
||||
var buttonUp = clone.getElementsByTagName('img')[0];
|
||||
buttonUp.setAttribute('onclick',"upSubfield('" + new_id + "')");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
// do nothig if ButtonPlus & CloneButtonPlus don't exist.
|
||||
}
|
||||
// insert this line on the page
|
||||
original.parentNode.insertBefore(clone,original.nextSibling);
|
||||
}
|
||||
<!--/TMPL_IF>
|
||||
//]]>
|
||||
</script>
|
||||
|
@ -199,16 +263,20 @@ Error : Barcode Not Unique For serialseq <!--TMPL_VAR Name="errserialseq"-->
|
|||
<!-- TMPL_LOOP NAME="items" -->
|
||||
<div id="item<!-- TMPL_VAR NAME="serialid" --><!-- TMPL_VAR NAME="countitems" -->" class="items">
|
||||
<!-- TMPL_LOOP NAME="iteminformation" -->
|
||||
<p>
|
||||
<div id="subfield<!-- TMPL_VAR NAME="serialid" --><!-- TMPL_VAR NAME="countitems" --><!-- TMPL_VAR NAME="countsubfield" -->" class="subfield"> <label><!-- TMPL_VAR NAME="subfield" --> - <!-- TMPL_IF name="mandatory" --><b><!-- /TMPL_IF --><!-- TMPL_VAR NAME="marc_lib" --><!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF --></label>
|
||||
<div name="line" class="subfield_line" style="<!-- TMPL_VAR NAME='visibility' -->;" id="subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->">
|
||||
|
||||
<label><!-- TMPL_VAR NAME="subfield" --> - <!-- TMPL_IF name="mandatory" --><b><!-- /TMPL_IF --><!-- TMPL_VAR NAME="marc_lib" --><!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF --></label>
|
||||
<!-- TMPL_VAR NAME="marc_value" -->
|
||||
<input type="hidden" name="itemid" value="<!-- TMPL_VAR NAME="itemid" -->" />
|
||||
<input type="hidden" name="kohafield" value="<!-- TMPL_VAR NAME="kohafield" -->" />
|
||||
<input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
|
||||
<input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
|
||||
<input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
|
||||
<!-- TMPL_IF NAME="repeatable" -->
|
||||
<span class="buttonPlus" onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')">+</span>
|
||||
<!-- /TMPL_IF -->
|
||||
|
||||
</div>
|
||||
</p>
|
||||
<!-- /tmpl_loop -->
|
||||
|
||||
<input type="hidden" name="moditem" value="" />
|
||||
|
@ -298,16 +366,19 @@ Error : Barcode Not Unique For serialseq <!--TMPL_VAR Name="errserialseq"-->
|
|||
<div id="cataloguing_additem_itemlist">
|
||||
<div id="item<!-- TMPL_VAR NAME="serialid" --><!-- TMPL_VAR NAME="countitems" -->" class="items">
|
||||
<!-- TMPL_LOOP NAME="iteminformation" -->
|
||||
<p>
|
||||
<div id="subfield<!-- TMPL_VAR NAME="serialid" --><!-- TMPL_VAR NAME="countitems" --><!-- TMPL_VAR NAME="countsubfield" -->" class="subfield"> <label><!-- TMPL_VAR NAME="subfield" --> - <!-- TMPL_IF name="mandatory" --><b><!-- /TMPL_IF --><!-- TMPL_VAR NAME="marc_lib" --><!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF --></label>
|
||||
<div name="line" class="subfield_line" style="<!-- TMPL_VAR NAME='visibility' -->;" id="subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->">
|
||||
|
||||
<label><!-- TMPL_VAR NAME="subfield" --> - <!-- TMPL_IF name="mandatory" --><b><!-- /TMPL_IF --><!-- TMPL_VAR NAME="marc_lib" --><!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF --></label>
|
||||
<!-- TMPL_VAR NAME="marc_value" -->
|
||||
<input type="hidden" name="itemid" value="<!-- TMPL_VAR NAME="itemid" -->" />
|
||||
<input type="hidden" name="kohafield" value="<!-- TMPL_VAR NAME="kohafield" -->" />
|
||||
<input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
|
||||
<input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
|
||||
<input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
|
||||
<!-- TMPL_IF NAME="repeatable" -->
|
||||
<span class="buttonPlus" onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')">+</span>
|
||||
<!-- /TMPL_IF -->
|
||||
</div>
|
||||
</p>
|
||||
<!-- /tmpl_loop -->
|
||||
|
||||
<input type="hidden" name="moditem" value="" />
|
||||
|
|
Loading…
Reference in a new issue