|
Lines 73-78
function ExpandField(index) {
Link Here
|
| 73 |
} |
73 |
} |
| 74 |
} |
74 |
} |
| 75 |
} |
75 |
} |
|
|
76 |
|
| 77 |
var Select2Utils = { |
| 78 |
removeSelect2: function(element) { |
| 79 |
var selects = element.getElementsByTagName('select'); |
| 80 |
for (var i=0; i < selects.length; i++) { |
| 81 |
$(selects[i]).select2('destroy'); |
| 82 |
} |
| 83 |
}, |
| 84 |
|
| 85 |
initSelect2: function(element) { |
| 86 |
var selects = element.getElementsByTagName('select'); |
| 87 |
for (var i=0; i < selects.length; i++) { |
| 88 |
$(selects[i]).select2(); |
| 89 |
} |
| 90 |
} |
| 91 |
}; |
| 92 |
|
| 76 |
/** |
93 |
/** |
| 77 |
* To clone a field |
94 |
* To clone a field |
| 78 |
* @param hideMarc '0' for false, '1' for true |
95 |
* @param hideMarc '0' for false, '1' for true |
|
Lines 80-85
function ExpandField(index) {
Link Here
|
| 80 |
*/ |
97 |
*/ |
| 81 |
function CloneField(index, hideMarc, advancedMARCEditor) { |
98 |
function CloneField(index, hideMarc, advancedMARCEditor) { |
| 82 |
var original = document.getElementById(index); //original <div> |
99 |
var original = document.getElementById(index); //original <div> |
|
|
100 |
Select2Utils.removeSelect2(original); |
| 101 |
|
| 83 |
var clone = original.cloneNode(true); |
102 |
var clone = original.cloneNode(true); |
| 84 |
var new_key = CreateKey(); |
103 |
var new_key = CreateKey(); |
| 85 |
var new_id = original.getAttribute('id')+new_key; |
104 |
var new_id = original.getAttribute('id')+new_key; |
|
Lines 244-251
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
| 244 |
|
263 |
|
| 245 |
// insert this line on the page |
264 |
// insert this line on the page |
| 246 |
original.parentNode.insertBefore(clone,original.nextSibling); |
265 |
original.parentNode.insertBefore(clone,original.nextSibling); |
|
|
266 |
|
| 267 |
Select2Utils.initSelect2(original); |
| 268 |
Select2Utils.initSelect2(clone); |
| 247 |
} |
269 |
} |
| 248 |
|
270 |
|
|
|
271 |
|
| 249 |
/** |
272 |
/** |
| 250 |
* To clone a subfield |
273 |
* To clone a subfield |
| 251 |
* @param index |
274 |
* @param index |
|
Lines 253-258
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
| 253 |
*/ |
276 |
*/ |
| 254 |
function CloneSubfield(index, advancedMARCEditor){ |
277 |
function CloneSubfield(index, advancedMARCEditor){ |
| 255 |
var original = document.getElementById(index); //original <div> |
278 |
var original = document.getElementById(index); //original <div> |
|
|
279 |
Select2Utils.removeSelect2(original); |
| 256 |
var clone = original.cloneNode(true); |
280 |
var clone = original.cloneNode(true); |
| 257 |
var new_key = CreateKey(); |
281 |
var new_key = CreateKey(); |
| 258 |
// set the attribute for the new 'div' subfields |
282 |
// set the attribute for the new 'div' subfields |
|
Lines 327-334
function CloneSubfield(index, advancedMARCEditor){
Link Here
|
| 327 |
} |
351 |
} |
| 328 |
// insert this line on the page |
352 |
// insert this line on the page |
| 329 |
original.parentNode.insertBefore(clone,original.nextSibling); |
353 |
original.parentNode.insertBefore(clone,original.nextSibling); |
|
|
354 |
|
| 355 |
//Restablish select2 for the cloned elements. |
| 356 |
Select2Utils.initSelect2(original); |
| 357 |
Select2Utils.initSelect2(clone); |
| 358 |
|
| 330 |
// delete data of cloned subfield |
359 |
// delete data of cloned subfield |
| 331 |
document.getElementById(linkid).value = ""; |
360 |
clone.querySelectorAll('input.input_marceditor').value = ""; |
| 332 |
} |
361 |
} |
| 333 |
|
362 |
|
| 334 |
function AddEventHandlers (oldcontrol, newcontrol, newinputid ) { |
363 |
function AddEventHandlers (oldcontrol, newcontrol, newinputid ) { |
|
Lines 413-420
function upSubfield(index) {
Link Here
|
| 413 |
} |
442 |
} |
| 414 |
var tag = line.parentNode; // get the dad of this line. (should be "<div id='tag_...'>") |
443 |
var tag = line.parentNode; // get the dad of this line. (should be "<div id='tag_...'>") |
| 415 |
|
444 |
|
| 416 |
// getting all subfields for this tag |
445 |
// getting all visible subfields for this tag |
| 417 |
var subfields = tag.getElementsByTagName('div'); |
446 |
var subfields = tag.querySelectorAll("div.subfield_line"); |
| 418 |
var subfieldsLength = subfields.length; |
447 |
var subfieldsLength = subfields.length; |
| 419 |
|
448 |
|
| 420 |
if(subfieldsLength<=1) return; // nothing to do if there is just one subfield. |
449 |
if(subfieldsLength<=1) return; // nothing to do if there is just one subfield. |
|
Lines 422-429
function upSubfield(index) {
Link Here
|
| 422 |
// among all subfields |
451 |
// among all subfields |
| 423 |
for(var i=0;i<subfieldsLength;i++){ |
452 |
for(var i=0;i<subfieldsLength;i++){ |
| 424 |
if(subfields[i].getAttribute('id') == index){ //looking for the subfield which is clicked : |
453 |
if(subfields[i].getAttribute('id') == index){ //looking for the subfield which is clicked : |
| 425 |
if(i==1){ // if the clicked subfield is on the top |
454 |
if(i==0){ // if the clicked subfield is on the top |
| 426 |
tag.appendChild(subfields[1]); |
455 |
tag.appendChild(subfields[0]); |
| 427 |
return; |
456 |
return; |
| 428 |
} else { |
457 |
} else { |
| 429 |
var lineAbove = subfields[i-1]; |
458 |
var lineAbove = subfields[i-1]; |
|
Lines 449-454
function unHideSubfield(index,labelindex) {
Link Here
|
| 449 |
* @param original subfield div to clone |
478 |
* @param original subfield div to clone |
| 450 |
*/ |
479 |
*/ |
| 451 |
function CloneItemSubfield(original){ |
480 |
function CloneItemSubfield(original){ |
|
|
481 |
Select2Utils.removeSelect2(original); |
| 452 |
var clone = original.cloneNode(true); |
482 |
var clone = original.cloneNode(true); |
| 453 |
var new_key = CreateKey(); |
483 |
var new_key = CreateKey(); |
| 454 |
|
484 |
|
|
Lines 488-493
function CloneItemSubfield(original){
Link Here
|
| 488 |
|
518 |
|
| 489 |
// insert this line on the page |
519 |
// insert this line on the page |
| 490 |
original.parentNode.insertBefore(clone,original.nextSibling); |
520 |
original.parentNode.insertBefore(clone,original.nextSibling); |
|
|
521 |
Select2Utils.initSelect2(original); |
| 522 |
Select2Utils.initSelect2(clone); |
| 491 |
} |
523 |
} |
| 492 |
|
524 |
|
| 493 |
/** |
525 |
/** |
| 494 |
- |
|
|