Lines 56-75
function openAuth(tagsubfieldid,authtype,source) {
Link Here
|
56 |
} |
56 |
} |
57 |
|
57 |
|
58 |
function ExpandField(index) { |
58 |
function ExpandField(index) { |
59 |
var original = document.getElementById(index); //original <div> |
59 |
var original = document.getElementById(index); //original <li> |
60 |
var divs = original.getElementsByTagName('div'); |
60 |
var lis = original.getElementsByTagName('li'); |
61 |
for(var i=0,divslen = divs.length ; i<divslen ; i++){ // foreach div |
61 |
for(var i=0,lislen = lis.length ; i<lislen ; i++){ // foreach li |
62 |
if(divs[i].hasAttribute('id') == 0 ) {continue; } // div element is specific to Select2 |
62 |
if(lis[i].hasAttribute('id') == 0 ) {continue; } // li element is specific to Select2 |
63 |
if(divs[i].getAttribute('id').match(/^subfield/)){ // if it s a subfield |
63 |
if(lis[i].getAttribute('id').match(/^subfield/)){ // if it s a subfield |
64 |
if (!divs[i].style.display) { |
64 |
if (!lis[i].style.display) { |
65 |
// first time => show all subfields |
65 |
// first time => show all subfields |
66 |
divs[i].style.display = 'block'; |
66 |
lis[i].style.display = 'block'; |
67 |
} else if (divs[i].style.display == 'none') { |
67 |
} else if (lis[i].style.display == 'none') { |
68 |
// show |
68 |
// show |
69 |
divs[i].style.display = 'block'; |
69 |
lis[i].style.display = 'block'; |
70 |
} else { |
70 |
} else { |
71 |
// hide |
71 |
// hide |
72 |
divs[i].style.display = 'none'; |
72 |
lis[i].style.display = 'none'; |
73 |
} |
73 |
} |
74 |
} |
74 |
} |
75 |
} |
75 |
} |
Lines 101-116
var Select2Utils = {
Link Here
|
101 |
* @param advancedMARCEditor '0' for false, '1' for true |
101 |
* @param advancedMARCEditor '0' for false, '1' for true |
102 |
*/ |
102 |
*/ |
103 |
function CloneField(index, hideMarc, advancedMARCEditor) { |
103 |
function CloneField(index, hideMarc, advancedMARCEditor) { |
104 |
var original = document.getElementById(index); //original <div> |
104 |
var original = document.getElementById(index); //original <li> |
105 |
Select2Utils.removeSelect2(original); |
105 |
Select2Utils.removeSelect2(original); |
106 |
|
106 |
|
107 |
var clone = original.cloneNode(true); |
107 |
var clone = original.cloneNode(true); |
108 |
var new_key = CreateKey(); |
108 |
var new_key = CreateKey(); |
109 |
var new_id = original.getAttribute('id')+new_key; |
109 |
var new_id = original.getAttribute('id')+new_key; |
110 |
|
110 |
|
111 |
clone.setAttribute('id',new_id); // setting a new id for the parent div |
111 |
clone.setAttribute('id',new_id); // setting a new id for the parent li |
112 |
|
112 |
|
113 |
var divs = clone.getElementsByTagName('div'); |
113 |
var divs = Array.from(clone.getElementsByTagName('li')).concat(Array.from(clone.getElementsByTagName('div'))); |
114 |
|
114 |
|
115 |
// if hide_marc, indicators are hidden fields |
115 |
// if hide_marc, indicators are hidden fields |
116 |
// setting a new name for the new indicator |
116 |
// setting a new name for the new indicator |
Lines 120-129
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
120 |
} |
120 |
} |
121 |
|
121 |
|
122 |
// settings all subfields |
122 |
// settings all subfields |
123 |
for(var i=0,divslen = divs.length ; i<divslen ; i++){ // foreach div |
123 |
for(var i=0,divslen = divs.length ; i<divslen ; i++){ // foreach div/li |
124 |
if(divs[i].getAttribute("id").match(/^subfield/)){ // if it s a subfield |
124 |
if(divs[i].getAttribute("id").match(/^subfield/)){ // if it s a subfield |
125 |
|
125 |
|
126 |
// set the attribute for the new 'div' subfields |
126 |
// set the attribute for the new 'li' subfields |
127 |
divs[i].setAttribute('id',divs[i].getAttribute('id')+new_key); |
127 |
divs[i].setAttribute('id',divs[i].getAttribute('id')+new_key); |
128 |
|
128 |
|
129 |
var inputs = divs[i].getElementsByTagName('input'); |
129 |
var inputs = divs[i].getElementsByTagName('input'); |
Lines 162-168
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
162 |
} |
162 |
} |
163 |
} |
163 |
} |
164 |
if( $(inputs[1]).hasClass('framework_plugin') ) { |
164 |
if( $(inputs[1]).hasClass('framework_plugin') ) { |
165 |
var olddiv= original.getElementsByTagName('div')[i]; |
165 |
var olddiv= original.getElementsByTagName('li')[i]; |
166 |
var oldcontrol= olddiv.getElementsByTagName('input')[1]; |
166 |
var oldcontrol= olddiv.getElementsByTagName('input')[1]; |
167 |
AddEventHandlers( oldcontrol,inputs[1],id_input ); |
167 |
AddEventHandlers( oldcontrol,inputs[1],id_input ); |
168 |
} |
168 |
} |
Lines 173-184
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
173 |
labels[0].setAttribute('for',id_input); |
173 |
labels[0].setAttribute('for',id_input); |
174 |
} |
174 |
} |
175 |
|
175 |
|
176 |
if(hideMarc == '0') { |
|
|
177 |
// updating javascript parameters on button up |
178 |
var imgs = divs[i].getElementsByTagName('img'); |
179 |
imgs[0].setAttribute('onclick',"upSubfield(\'"+divs[i].getAttribute('id')+"\');"); |
180 |
} |
181 |
|
182 |
// setting its '+' and '-' buttons |
176 |
// setting its '+' and '-' buttons |
183 |
try { |
177 |
try { |
184 |
var anchors = divs[i].getElementsByTagName('a'); |
178 |
var anchors = divs[i].getElementsByTagName('a'); |
Lines 209-215
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
209 |
// 2 possibilities : |
203 |
// 2 possibilities : |
210 |
try{ |
204 |
try{ |
211 |
if( $(buttonDot).hasClass('framework_plugin') ) { |
205 |
if( $(buttonDot).hasClass('framework_plugin') ) { |
212 |
var olddiv= original.getElementsByTagName('div')[i]; |
206 |
var olddiv= original.getElementsByTagName('li')[i]; |
213 |
var oldcontrol= olddiv.getElementsByTagName('a')[0]; |
207 |
var oldcontrol= olddiv.getElementsByTagName('a')[0]; |
214 |
AddEventHandlers(oldcontrol,buttonDot,id_input); |
208 |
AddEventHandlers(oldcontrol,buttonDot,id_input); |
215 |
} else { |
209 |
} else { |
Lines 236-245
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
236 |
} |
230 |
} |
237 |
} |
231 |
} |
238 |
} |
232 |
} |
239 |
if(hideMarc == '0') { |
|
|
240 |
var buttonUp = divs[i].getElementsByTagName('img')[0]; |
241 |
buttonUp.setAttribute('onclick',"upSubfield('" + divs[i].getAttribute('id') + "')"); |
242 |
} |
243 |
|
233 |
|
244 |
} else { // it's a indicator div |
234 |
} else { // it's a indicator div |
245 |
if(divs[i].getAttribute('id').match(/^div_indicator/)){ |
235 |
if(divs[i].getAttribute('id').match(/^div_indicator/)){ |
Lines 275-280
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
275 |
// insert this line on the page |
265 |
// insert this line on the page |
276 |
original.parentNode.insertBefore(clone,original.nextSibling); |
266 |
original.parentNode.insertBefore(clone,original.nextSibling); |
277 |
|
267 |
|
|
|
268 |
$("ul.sortable_subfield", clone).sortable(); |
269 |
|
278 |
Select2Utils.initSelect2(original); |
270 |
Select2Utils.initSelect2(original); |
279 |
Select2Utils.initSelect2(clone); |
271 |
Select2Utils.initSelect2(clone); |
280 |
} |
272 |
} |
Lines 290-296
function CloneSubfield(index, advancedMARCEditor){
Link Here
|
290 |
Select2Utils.removeSelect2(original); |
282 |
Select2Utils.removeSelect2(original); |
291 |
var clone = original.cloneNode(true); |
283 |
var clone = original.cloneNode(true); |
292 |
var new_key = CreateKey(); |
284 |
var new_key = CreateKey(); |
293 |
// set the attribute for the new 'div' subfields |
285 |
// set the attribute for the new 'li' subfields |
294 |
var inputs = clone.getElementsByTagName('input'); |
286 |
var inputs = clone.getElementsByTagName('input'); |
295 |
var selects = clone.getElementsByTagName('select'); |
287 |
var selects = clone.getElementsByTagName('select'); |
296 |
var textareas = clone.getElementsByTagName('textarea'); |
288 |
var textareas = clone.getElementsByTagName('textarea'); |
Lines 351-358
function CloneSubfield(index, advancedMARCEditor){
Link Here
|
351 |
clone.setAttribute('id',new_id); |
343 |
clone.setAttribute('id',new_id); |
352 |
|
344 |
|
353 |
try { |
345 |
try { |
354 |
var buttonUp = clone.getElementsByTagName('img')[0]; |
|
|
355 |
buttonUp.setAttribute('onclick',"upSubfield('" + new_id + "')"); |
356 |
var anchors = clone.getElementsByTagName('a'); |
346 |
var anchors = clone.getElementsByTagName('a'); |
357 |
if(anchors.length){ |
347 |
if(anchors.length){ |
358 |
for(var i = 0 ,lenanchors = anchors.length ; i < lenanchors ; i++){ |
348 |
for(var i = 0 ,lenanchors = anchors.length ; i < lenanchors ; i++){ |
Lines 500-506
function CloneItemSubfield(original){
Link Here
|
500 |
var clone = original.cloneNode(true); |
490 |
var clone = original.cloneNode(true); |
501 |
var new_key = CreateKey(); |
491 |
var new_key = CreateKey(); |
502 |
|
492 |
|
503 |
// set the attribute for the new 'div' subfields |
493 |
// set the attribute for the new 'li' subfields |
504 |
var inputs = clone.getElementsByTagName('input'); |
494 |
var inputs = clone.getElementsByTagName('input'); |
505 |
var selects = clone.getElementsByTagName('select'); |
495 |
var selects = clone.getElementsByTagName('select'); |
506 |
var textareas = clone.getElementsByTagName('textarea'); |
496 |
var textareas = clone.getElementsByTagName('textarea'); |
507 |
- |
|
|