|
Lines 1-3
Link Here
|
|
|
1 |
/* exported openAuth ExpandField CloneField CloneSubfield UnCloneField CloneItemSubfield CheckMandatorySubfields */ |
| 2 |
|
| 1 |
/* |
3 |
/* |
| 2 |
* Unified file for catalogue edition |
4 |
* Unified file for catalogue edition |
| 3 |
*/ |
5 |
*/ |
|
Lines 52-58
function openAuth(tagsubfieldid,authtype,source) {
Link Here
|
| 52 |
} |
54 |
} |
| 53 |
} |
55 |
} |
| 54 |
mainstring = mainstring.join(' '); |
56 |
mainstring = mainstring.join(' '); |
| 55 |
newin=window.open("../authorities/auth_finder.pl?source="+source+"&authtypecode="+authtype+"&index="+tagsubfieldid+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes'); |
57 |
window.open("../authorities/auth_finder.pl?source="+source+"&authtypecode="+authtype+"&index="+tagsubfieldid+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes'); |
| 56 |
} |
58 |
} |
| 57 |
|
59 |
|
| 58 |
function ExpandField(index) { |
60 |
function ExpandField(index) { |
|
Lines 120-126
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
| 120 |
} |
122 |
} |
| 121 |
|
123 |
|
| 122 |
// settings all subfields |
124 |
// settings all subfields |
| 123 |
for(var i=0,divslen = divs.length ; i<divslen ; i++){ // foreach div/li |
125 |
var divslen = divs.length; |
|
|
126 |
for( i=0; i < divslen ; i++ ){ // foreach div/li |
| 124 |
if(divs[i].getAttribute("id").match(/^subfield/)){ // if it s a subfield |
127 |
if(divs[i].getAttribute("id").match(/^subfield/)){ // if it s a subfield |
| 125 |
|
128 |
|
| 126 |
// set the attribute for the new 'li' subfields |
129 |
// set the attribute for the new 'li' subfields |
|
Lines 128-133
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
| 128 |
|
131 |
|
| 129 |
var inputs = divs[i].getElementsByTagName('input'); |
132 |
var inputs = divs[i].getElementsByTagName('input'); |
| 130 |
var id_input = ""; |
133 |
var id_input = ""; |
|
|
134 |
var olddiv; |
| 135 |
var oldcontrol; |
| 131 |
|
136 |
|
| 132 |
for( j = 0 ; j < inputs.length ; j++ ) { |
137 |
for( j = 0 ; j < inputs.length ; j++ ) { |
| 133 |
if(inputs[j].getAttribute("id") && inputs[j].getAttribute("id").match(/^tag_/) ){ |
138 |
if(inputs[j].getAttribute("id") && inputs[j].getAttribute("id").match(/^tag_/) ){ |
|
Lines 143-149
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
| 143 |
|
148 |
|
| 144 |
inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key); |
149 |
inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key); |
| 145 |
inputs[0].setAttribute('name',inputs[0].getAttribute('name')+new_key); |
150 |
inputs[0].setAttribute('name',inputs[0].getAttribute('name')+new_key); |
| 146 |
var id_input; |
151 |
|
| 147 |
try { |
152 |
try { |
| 148 |
id_input = inputs[1].getAttribute('id')+new_key; |
153 |
id_input = inputs[1].getAttribute('id')+new_key; |
| 149 |
inputs[1].setAttribute('id',id_input); |
154 |
inputs[1].setAttribute('id',id_input); |
|
Lines 162-169
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
| 162 |
} |
167 |
} |
| 163 |
} |
168 |
} |
| 164 |
if( $(inputs[1]).hasClass('framework_plugin') ) { |
169 |
if( $(inputs[1]).hasClass('framework_plugin') ) { |
| 165 |
var olddiv= original.getElementsByTagName('li')[i]; |
170 |
olddiv= original.getElementsByTagName('li')[i]; |
| 166 |
var oldcontrol= olddiv.getElementsByTagName('input')[1]; |
171 |
oldcontrol= olddiv.getElementsByTagName('input')[1]; |
| 167 |
AddEventHandlers( oldcontrol,inputs[1],id_input ); |
172 |
AddEventHandlers( oldcontrol,inputs[1],id_input ); |
| 168 |
} |
173 |
} |
| 169 |
|
174 |
|
|
Lines 203-223
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
| 203 |
// 2 possibilities : |
208 |
// 2 possibilities : |
| 204 |
try{ |
209 |
try{ |
| 205 |
if( $(buttonDot).hasClass('framework_plugin') ) { |
210 |
if( $(buttonDot).hasClass('framework_plugin') ) { |
| 206 |
var olddiv= original.getElementsByTagName('li')[i]; |
211 |
olddiv= original.getElementsByTagName('li')[i]; |
| 207 |
var oldcontrol= olddiv.getElementsByTagName('a')[0]; |
212 |
oldcontrol= olddiv.getElementsByTagName('a')[0]; |
| 208 |
AddEventHandlers(oldcontrol,buttonDot,id_input); |
213 |
AddEventHandlers(oldcontrol,buttonDot,id_input); |
| 209 |
} else { |
|
|
| 210 |
if(buttonDotOnClick.match('Dopop')) { // -2- It's a auth value |
| 211 |
var re1 = /&index=.*',/; |
| 212 |
var re2 = /,.*\)/; |
| 213 |
|
| 214 |
buttonDotOnClick = buttonDotOnClick.replace(re1,"&index="+inputs[1].getAttribute('id')+"',"); |
| 215 |
buttonDotOnClick = buttonDotOnClick.replace(re2,",'"+inputs[1].getAttribute('id')+"')"); |
| 216 |
|
| 217 |
if(buttonDotOnClick){ |
| 218 |
buttonDot.setAttribute('onclick',buttonDotOnClick); |
| 219 |
} |
| 220 |
} |
| 221 |
} |
214 |
} |
| 222 |
try { |
215 |
try { |
| 223 |
// do not copy the script section. |
216 |
// do not copy the script section. |
|
Lines 226-232
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
| 226 |
} catch(e) { |
219 |
} catch(e) { |
| 227 |
// do nothing if there is no script |
220 |
// do nothing if there is no script |
| 228 |
} |
221 |
} |
| 229 |
}catch(e){} |
222 |
} catch(e){ |
|
|
223 |
// |
| 224 |
} |
| 230 |
} |
225 |
} |
| 231 |
} |
226 |
} |
| 232 |
} |
227 |
} |
|
Lines 237-250
function CloneField(index, hideMarc, advancedMARCEditor) {
Link Here
|
| 237 |
// setting a new id for the indicator div |
232 |
// setting a new id for the indicator div |
| 238 |
divs[i].setAttribute('id',divs[i].getAttribute('id')+new_key); |
233 |
divs[i].setAttribute('id',divs[i].getAttribute('id')+new_key); |
| 239 |
|
234 |
|
| 240 |
var inputs = divs[i].getElementsByTagName('input'); |
235 |
inputs = divs[i].getElementsByTagName('input'); |
| 241 |
inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key); |
236 |
inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key); |
| 242 |
inputs[1].setAttribute('id',inputs[1].getAttribute('id')+new_key); |
237 |
inputs[1].setAttribute('id',inputs[1].getAttribute('id')+new_key); |
| 243 |
|
238 |
|
| 244 |
var CloneButtonPlus; |
239 |
var CloneButtonPlus; |
| 245 |
try { |
240 |
try { |
| 246 |
var anchors = divs[i].getElementsByTagName('a'); |
241 |
anchors = divs[i].getElementsByTagName('a'); |
| 247 |
for (var j = 0; j < anchors.length; j++) { |
242 |
for ( j = 0; j < anchors.length; j++) { |
| 248 |
if (anchors[j].getAttribute('class') == 'buttonPlus') { |
243 |
if (anchors[j].getAttribute('class') == 'buttonPlus') { |
| 249 |
anchors[j].setAttribute('onclick',"CloneField('" + new_id + "','" + hideMarc + "','" + advancedMARCEditor + "'); return false;"); |
244 |
anchors[j].setAttribute('onclick',"CloneField('" + new_id + "','" + hideMarc + "','" + advancedMARCEditor + "'); return false;"); |
| 250 |
} else if (anchors[j].getAttribute('class') == 'buttonMinus') { |
245 |
} else if (anchors[j].getAttribute('class') == 'buttonMinus') { |
|
Lines 287-292
function CloneSubfield(index, advancedMARCEditor){
Link Here
|
| 287 |
var selects = clone.getElementsByTagName('select'); |
282 |
var selects = clone.getElementsByTagName('select'); |
| 288 |
var textareas = clone.getElementsByTagName('textarea'); |
283 |
var textareas = clone.getElementsByTagName('textarea'); |
| 289 |
var linkid; |
284 |
var linkid; |
|
|
285 |
var oldcontrol; |
| 290 |
|
286 |
|
| 291 |
// input |
287 |
// input |
| 292 |
var id_input = ""; |
288 |
var id_input = ""; |
|
Lines 302-313
function CloneSubfield(index, advancedMARCEditor){
Link Here
|
| 302 |
|
298 |
|
| 303 |
// Plugin input |
299 |
// Plugin input |
| 304 |
if( $(inputs[1]).hasClass('framework_plugin') ) { |
300 |
if( $(inputs[1]).hasClass('framework_plugin') ) { |
| 305 |
var oldcontrol= original.getElementsByTagName('input')[1]; |
301 |
oldcontrol= original.getElementsByTagName('input')[1]; |
| 306 |
AddEventHandlers( oldcontrol, inputs[1], linkid ); |
302 |
AddEventHandlers( oldcontrol, inputs[1], linkid ); |
| 307 |
} |
303 |
} |
| 308 |
|
304 |
|
| 309 |
// select |
305 |
// select |
| 310 |
for(var i=0,len=selects.length; i<len ; i++ ){ |
306 |
for(i=0,len=selects.length; i<len ; i++ ){ |
| 311 |
id_input = selects[i].getAttribute('id')+new_key; |
307 |
id_input = selects[i].getAttribute('id')+new_key; |
| 312 |
selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key); |
308 |
selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key); |
| 313 |
selects[i].setAttribute('name',selects[i].getAttribute('name')+new_key); |
309 |
selects[i].setAttribute('name',selects[i].getAttribute('name')+new_key); |
|
Lines 315-321
function CloneSubfield(index, advancedMARCEditor){
Link Here
|
| 315 |
} |
311 |
} |
| 316 |
|
312 |
|
| 317 |
// textarea |
313 |
// textarea |
| 318 |
for(var i=0,len=textareas.length; i<len ; i++ ){ |
314 |
for( i=0,len=textareas.length; i<len ; i++ ){ |
| 319 |
id_input = textareas[i].getAttribute('id')+new_key; |
315 |
id_input = textareas[i].getAttribute('id')+new_key; |
| 320 |
textareas[i].setAttribute('id',textareas[i].getAttribute('id')+new_key); |
316 |
textareas[i].setAttribute('id',textareas[i].getAttribute('id')+new_key); |
| 321 |
textareas[i].setAttribute('name',textareas[i].getAttribute('name')+new_key); |
317 |
textareas[i].setAttribute('name',textareas[i].getAttribute('name')+new_key); |
|
Lines 328-334
function CloneSubfield(index, advancedMARCEditor){
Link Here
|
| 328 |
// Handle click event on buttonDot for plugin |
324 |
// Handle click event on buttonDot for plugin |
| 329 |
var links = clone.getElementsByTagName('a'); |
325 |
var links = clone.getElementsByTagName('a'); |
| 330 |
if( $(links[0]).hasClass('framework_plugin') ) { |
326 |
if( $(links[0]).hasClass('framework_plugin') ) { |
| 331 |
var oldcontrol= original.getElementsByTagName('a')[0]; |
327 |
oldcontrol= original.getElementsByTagName('a')[0]; |
| 332 |
AddEventHandlers( oldcontrol, links[0], linkid ); |
328 |
AddEventHandlers( oldcontrol, links[0], linkid ); |
| 333 |
} |
329 |
} |
| 334 |
|
330 |
|
|
Lines 345-351
function CloneSubfield(index, advancedMARCEditor){
Link Here
|
| 345 |
try { |
341 |
try { |
| 346 |
var anchors = clone.getElementsByTagName('a'); |
342 |
var anchors = clone.getElementsByTagName('a'); |
| 347 |
if(anchors.length){ |
343 |
if(anchors.length){ |
| 348 |
for(var i = 0 ,lenanchors = anchors.length ; i < lenanchors ; i++){ |
344 |
for( i = 0 ,len = anchors.length ; i < len ; i++){ |
| 349 |
if(anchors[i].getAttribute('class') == 'buttonPlus'){ |
345 |
if(anchors[i].getAttribute('class') == 'buttonPlus'){ |
| 350 |
anchors[i].setAttribute('onclick',"CloneSubfield('" + new_id + "','" + advancedMARCEditor + "'); return false;"); |
346 |
anchors[i].setAttribute('onclick',"CloneSubfield('" + new_id + "','" + advancedMARCEditor + "'); return false;"); |
| 351 |
} else if (anchors[i].getAttribute('class') == 'buttonMinus') { |
347 |
} else if (anchors[i].getAttribute('class') == 'buttonMinus') { |
|
Lines 385-391
function AddEventHandlers (oldcontrol, newcontrol, newinputid ) {
Link Here
|
| 385 |
} |
381 |
} |
| 386 |
} |
382 |
} |
| 387 |
|
383 |
|
| 388 |
/** |
384 |
/** |
| 389 |
* This function removes or clears unwanted subfields |
385 |
* This function removes or clears unwanted subfields |
| 390 |
*/ |
386 |
*/ |
| 391 |
function UnCloneField(index) { |
387 |
function UnCloneField(index) { |
|
Lines 439-484
function CreateKey(){
Link Here
|
| 439 |
return parseInt(Math.random() * 100000); |
435 |
return parseInt(Math.random() * 100000); |
| 440 |
} |
436 |
} |
| 441 |
|
437 |
|
| 442 |
/** |
|
|
| 443 |
* This function allows to move a subfield up by clickink on the 'up' button . |
| 444 |
*/ |
| 445 |
function upSubfield(index) { |
| 446 |
try{ |
| 447 |
var line = document.getElementById(index); // get the line where the user has clicked. |
| 448 |
} catch(e) { |
| 449 |
return; // this line doesn't exist... |
| 450 |
} |
| 451 |
var tag = line.parentNode; // get the dad of this line. (should be "<div id='tag_...'>") |
| 452 |
|
| 453 |
// getting all visible subfields for this tag |
| 454 |
var subfields = tag.querySelectorAll("div.subfield_line:not( [style*='display:none;'] )"); |
| 455 |
var subfieldsLength = subfields.length; |
| 456 |
|
| 457 |
if(subfieldsLength<=1) return; // nothing to do if there is just one subfield. |
| 458 |
|
| 459 |
// among all subfields |
| 460 |
for(var i=0;i<subfieldsLength;i++){ |
| 461 |
if(subfields[i].getAttribute('id') == index){ //looking for the subfield which is clicked : |
| 462 |
if(i==0){ // if the clicked subfield is on the top |
| 463 |
tag.appendChild(subfields[0]); |
| 464 |
return; |
| 465 |
} else { |
| 466 |
var lineAbove = subfields[i-1]; |
| 467 |
tag.insertBefore(line,lineAbove); |
| 468 |
return; |
| 469 |
} |
| 470 |
} |
| 471 |
} |
| 472 |
} |
| 473 |
|
| 474 |
// FIXME :: is it used ? |
| 475 |
function unHideSubfield(index,labelindex) { |
| 476 |
subfield = document.getElementById(index); |
| 477 |
subfield.style.display = 'block'; |
| 478 |
label = document.getElementById(labelindex); |
| 479 |
label.style.display='none'; |
| 480 |
} |
| 481 |
|
| 482 |
/* Functions developed for additem.tt */ |
438 |
/* Functions developed for additem.tt */ |
| 483 |
|
439 |
|
| 484 |
/** |
440 |
/** |
|
Lines 505-517
function CloneItemSubfield(original){
Link Here
|
| 505 |
} |
461 |
} |
| 506 |
|
462 |
|
| 507 |
// select |
463 |
// select |
| 508 |
for(var i=0,len=selects.length; i<len ; i++ ){ |
464 |
for( i=0,len=selects.length; i<len ; i++ ){ |
| 509 |
id_input = selects[i].getAttribute('id')+new_key; |
465 |
id_input = selects[i].getAttribute('id')+new_key; |
| 510 |
selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key); |
466 |
selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key); |
| 511 |
} |
467 |
} |
| 512 |
|
468 |
|
| 513 |
// textarea |
469 |
// textarea |
| 514 |
for(var i=0,len=textareas.length; i<len ; i++ ){ |
470 |
for( i=0,len=textareas.length; i<len ; i++ ){ |
| 515 |
id_input = textareas[i].getAttribute('id')+new_key; |
471 |
id_input = textareas[i].getAttribute('id')+new_key; |
| 516 |
textareas[i].setAttribute('id',textareas[i].getAttribute('id')+new_key); |
472 |
textareas[i].setAttribute('id',textareas[i].getAttribute('id')+new_key); |
| 517 |
} |
473 |
} |
|
Lines 537-543
function CloneItemSubfield(original){
Link Here
|
| 537 |
*/ |
493 |
*/ |
| 538 |
function CheckMandatorySubfields(p){ |
494 |
function CheckMandatorySubfields(p){ |
| 539 |
var total = 0; |
495 |
var total = 0; |
| 540 |
$(p).find(".subfield_line input[name='mandatory'][value='1']").each(function(i){ |
496 |
$(p).find(".subfield_line input[name='mandatory'][value='1']").each(function(){ |
| 541 |
var editor = $(this).siblings("[name='field_value']"); |
497 |
var editor = $(this).siblings("[name='field_value']"); |
| 542 |
if (!editor.val()) { |
498 |
if (!editor.val()) { |
| 543 |
editor.addClass("missing"); |
499 |
editor.addClass("missing"); |
| 544 |
- |
|
|