View | Details | Raw Unified | Return to bug 7883
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/css/addbiblio.css (-1 / +5 lines)
Lines 1-7 Link Here
1
#addbibliotabs {
1
#addbibliotabs {
2
	margin-top : 1em;
2
	margin-top : 1em;
3
}
3
}
4
4
ul li.tag {
5
    list-style-type:none;
6
    padding:0 0 0 25px;
7
    background: url("../../img/cursor_split_16.png") no-repeat left bottom;
8
}
5
#addbibliotabs .ui-tabs-panel {
9
#addbibliotabs .ui-tabs-panel {
6
	float : left;
10
	float : left;
7
}
11
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-22 / +386 lines)
Lines 8-17 Link Here
8
//<![CDATA[
8
//<![CDATA[
9
9
10
	 $(document).ready(function() {
10
	 $(document).ready(function() {
11
        $('#addbibliotabs').tabs().bind('show.ui-tabs', function(e, ui) {
11
             var $tabs = $('#addbibliotabs').tabs();
12
			$("#"+ui.panel.id+" input:eq(0)").focus();
12
	     $( "ul.sortable_field", $tabs ).sortable().disableSelection();
13
		});
13
	     $( "ul.sortable_subfield", $tabs ).sortable().disableSelection();
14
14
15
        $('.tag').each(function() {
16
            var field_id = this.getAttribute('id').substring(0, 7);
17
            if (field_id in fields_in_use) {
18
                fields_in_use[field_id]++;
19
            } else {
20
                fields_in_use[field_id] = 1;
21
            }
22
        });
23
        $('.subfield_line').each(function() {
24
            var field_id = this.getAttribute('id').substring(0, 12);
25
            if (field_id in fields_in_use) {
26
                fields_in_use[field_id]++;
27
            } else {
28
                fields_in_use[field_id] = 1;
29
            }
30
        });
15
		/* check cookie to hide/show marcdocs*/
31
		/* check cookie to hide/show marcdocs*/
16
		if($.cookie("marcdocs_[% borrowernumber %]") == 'false'){
32
		if($.cookie("marcdocs_[% borrowernumber %]") == 'false'){
17
			hideMARCdocLinks();
33
			hideMARCdocLinks();
Lines 245-250 function Changefwk(FwkList) { Link Here
245
    f.submit();
261
    f.submit();
246
}
262
}
247
263
264
// returns the subfieldcode based upon subfieldid writing
265
function getSubfieldcode(tagsubfieldid){
266
    // 3 : tag +3 : tagnumber +4 : number of _ +8 subfield -1 begins at 0  
267
    return tagsubfieldid.substr(3+3+4+8-1,1);
268
}
269
270
// Take the base of tagsubfield information (removing the subfieldcodes and subfieldindexes)
271
// returns the filter
272
function getTagInputnameFilter(tagsubfieldid){
273
    var tagsubfield=tagsubfieldid.substr(0,tagsubfieldid.lastIndexOf("_"));  
274
    var tagcode=tagsubfield.substr(tagsubfield.lastIndexOf("_"));
275
    tagsubfield=tagsubfield.substr(0,tagsubfield.lastIndexOf("_"));
276
    tagsubfield=tagsubfield.substr(0,tagsubfield.lastIndexOf("_"));
277
    tagsubfield=tagsubfield+"_."+tagcode;
278
    return tagsubfield;  
279
}
280
281
function openAuth(tagsubfieldid,authtype) {
282
    // let's take the base of tagsubfield information (removing the indexes and the codes
283
    var element=document.getElementById(tagsubfieldid);
284
    var tagsubfield=getTagInputnameFilter(tagsubfieldid);
285
    var elementsubfcode=getSubfieldcode(element.name);
286
    var mainmainstring=element.value;
287
    var mainstring="";  
288
    var inputs = element.parentNode.parentNode.getElementsByTagName("input");
289
290
    for (var myindex =0; myindex<inputs.length;myindex++){
291
        if (inputs[myindex].name && inputs[myindex].name.match(tagsubfield)){
292
            var subfieldcode=getSubfieldcode(inputs[myindex].name);
293
            if (isNaN(parseInt(subfieldcode)) && inputs[myindex].value != "" && subfieldcode!=elementsubfcode){
294
                mainstring=inputs[myindex].value+" "+mainstring;
295
            }      
296
        }
297
    }           
298
	newin=window.open("../authorities/auth_finder.pl?authtypecode="+  authtype+ "&index="+tagsubfieldid+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes');
299
}
300
301
302
function ExpandField(index) {
303
    var original = document.getElementById(index); //original <div>
304
    var divs = original.getElementsByTagName('div');
305
    for(var i=0,divslen = divs.length ; i<divslen ; i++){      // foreach div
306
        if(divs[i].getAttribute('id').match(/^subfield/)){  // if it s a subfield
307
            if (divs[i].style.display == 'block') {
308
                divs[i].style.display = 'none';
309
            } else {
310
                divs[i].style.display = 'block';
311
            }
312
        }
313
    }
314
}
315
316
/**
317
 * To clone a field or a subfield by clicking on '+' button
318
 */ 
319
function CloneField(index) {
320
    var original = document.getElementById(index); //original <div>
321
    fields_in_use[index.substr(0, 7)]++;
322
    var clone = original.cloneNode(true);
323
    var new_key = CreateKey();
324
    var new_id  = original.getAttribute('id')+new_key;
325
    
326
    clone.setAttribute('id',new_id); // setting a new id for the parent div
327
    
328
    var divs = clone.getElementsByTagName('div');
329
    
330
    [% UNLESS ( hide_marc ) %] // No indicator if hide_marc
331
        // setting a new name for the new indicator
332
        for(var i=0; i < 2; i++) {
333
            var indicator = clone.getElementsByTagName('input')[i];
334
            indicator.setAttribute('name',indicator.getAttribute('name')+new_key);
335
        }
336
    [% END %]
337
        
338
    // settings all subfields
339
    for(var i=0,divslen = divs.length ; i<divslen ; i++){      // foreach div
340
        if(divs[i].getAttribute("id").match(/^subfield/)){  // if it s a subfield
341
            
342
            // set the attribute for the new 'div' subfields
343
            divs[i].setAttribute('id',divs[i].getAttribute('id')+new_key);
344
            
345
            var inputs   = divs[i].getElementsByTagName('input');
346
            var id_input = "";
347
            
348
            for( j = 0 ; j < inputs.length ; j++ ) {
349
            	if(inputs[j].getAttribute("id") && inputs[j].getAttribute("id").match(/^tag_/) ){
350
            		inputs[j].value = "";
351
            	}
352
            }
353
            
354
            inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key);
355
            inputs[0].setAttribute('name',inputs[0].getAttribute('name')+new_key);
356
            var id_input;
357
            try {
358
            	id_input = inputs[1].getAttribute('id')+new_key;
359
                inputs[1].setAttribute('id',id_input);
360
                inputs[1].setAttribute('name',inputs[1].getAttribute('name')+new_key);
361
            } catch(e) {
362
            	try{ // it s a select if it is not an input
363
                    var selects = divs[i].getElementsByTagName('select');
364
                    id_input = selects[0].getAttribute('id')+new_key;
365
                    selects[0].setAttribute('id',id_input);
366
                    selects[0].setAttribute('name',selects[0].getAttribute('name')+new_key);
367
                }catch(e2){ // it is a textarea if it s not a select or an input
368
                	var textaeras = divs[i].getElementsByTagName('textarea');
369
                	id_input = textaeras[0].getAttribute('id')+new_key;
370
                	textaeras[0].setAttribute('id',id_input);
371
                    textaeras[0].setAttribute('name',textaeras[0].getAttribute('name')+new_key);
372
                }
373
            }
374
            
375
            [% UNLESS ( advancedMARCEditor ) %]
376
            // when cloning a subfield, re set its label too.
377
            var labels = divs[i].getElementsByTagName('label');
378
            labels[0].setAttribute('for',id_input);
379
            [% END %]
380
            
381
            [% UNLESS ( hide_marc ) %]
382
                // updating javascript parameters on button up
383
                var imgs = divs[i].getElementsByTagName('img');
384
                imgs[0].setAttribute('onclick',"upSubfield(\'"+divs[i].getAttribute('id')+"\');");
385
            [% END %]
386
            
387
            // setting its '+' and '-' buttons
388
            try {
389
                var anchors = divs[i].getElementsByTagName('a');
390
                for (var j = 0; j < anchors.length; j++) {
391
                    if(anchors[j].getAttribute('class') == 'buttonPlus'){
392
                        anchors[j].setAttribute('onclick',"CloneSubfield('" + divs[i].getAttribute('id') + "')");
393
                    } else if (anchors[j].getAttribute('class') == 'buttonMinus') {
394
                        anchors[j].setAttribute('onclick',"UnCloneField('" + divs[i].getAttribute('id') + "')");
395
                    }
396
                }
397
            }
398
            catch(e){
399
                // do nothig if ButtonPlus & CloneButtonPlus don t exist.
400
            }
401
            
402
            // button ...
403
            var spans=0;
404
            try {
405
                spans = divs[i].getElementsByTagName('a');
406
            } catch(e) {
407
                // no spans
408
            }
409
            if(spans){
410
                var buttonDot;
411
                if(!CloneButtonPlus){ // it s impossible to have  + ... (buttonDot AND buttonPlus)
412
                    buttonDot = spans[0];
413
                    if(buttonDot){
414
                        // 2 possibilities :
415
                        try{
416
                            var buttonDotOnClick = buttonDot.getAttribute('onclick');
417
                            if(buttonDotOnClick.match('Clictag')){   // -1- It s a plugin
418
                                var re = /\('.*'\)/i;
419
                                buttonDotOnClick = buttonDotOnClick.replace(re,"('"+inputs[1].getAttribute('id')+"')");
420
                                if(buttonDotOnClick){
421
                                    buttonDot.setAttribute('onclick',buttonDotOnClick);
422
                                }
423
                            } else {
424
                                if(buttonDotOnClick.match('Dopop')) {  // -2- It's a auth value
425
                                    var re1 = /&index=.*',/;
426
                                    var re2 = /,.*\)/;
427
428
                                    buttonDotOnClick = buttonDotOnClick.replace(re1,"&index="+inputs[1].getAttribute('id')+"',");
429
                                    buttonDotOnClick = buttonDotOnClick.replace(re2,",'"+inputs[1].getAttribute('id')+"')");
430
                                    
431
                                    if(buttonDotOnClick){
432
                                            buttonDot.setAttribute('onclick',buttonDotOnClick);
433
                                    }
434
                                }
435
                            }
436
                            try {
437
                            	// do not copy the script section.
438
                            	var script = spans[0].getElementsByTagName('script')[0];
439
                            	spans[0].removeChild(script);
440
                            } catch(e) {
441
                            	// do nothing if there is no script
442
                            }
443
                    	}catch(e){}
444
                	}
445
                }
446
            }
447
            [% UNLESS ( hide_marc ) %]
448
                var buttonUp = divs[i].getElementsByTagName('img')[0];
449
                buttonUp.setAttribute('onclick',"upSubfield('" + divs[i].getAttribute('id') + "')");
450
            [% END %]
451
            
452
        } else { // it's a indicator div
453
            if(divs[i].getAttribute('id').match(/^div_indicator/)){
454
                var inputs = divs[i].getElementsByTagName('input');
455
                inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key);
456
                inputs[1].setAttribute('id',inputs[1].getAttribute('id')+new_key);
457
                
458
                var CloneButtonPlus;
459
                try {
460
                    var anchors = divs[i].getElementsByTagName('a');
461
                    for (var j = 0; j < anchors.length; j++) {
462
                        if (anchors[j].getAttribute('class') == 'buttonPlus') {
463
                            anchors[j].setAttribute('onclick',"CloneField('" + new_id + "')");
464
                        } else if (anchors[j].getAttribute('class') == 'buttonMinus') {
465
                            anchors[j].setAttribute('onclick',"UnCloneField('" + new_id + "')");
466
                        } else if (anchors[j].getAttribute('class') == 'expandfield') {
467
                            anchors[j].setAttribute('onclick',"ExpandField('" + new_id + "')");
468
                        }
469
                    }
470
                }
471
                catch(e){
472
                    // do nothig CloneButtonPlus doesn't exist.
473
                }
474
475
            }
476
        }
477
    }
478
    
479
    // insert this line on the page
480
    original.parentNode.insertBefore(clone,original.nextSibling);
481
}
482
483
function CloneSubfield(index){
484
    var original = document.getElementById(index); //original <div>
485
    fields_in_use[index.substr(0, 12)]++;
486
    var clone = original.cloneNode(true);
487
    var new_key = CreateKey();
488
    var new_id  = original.getAttribute('id')+new_key;
489
    // set the attribute for the new 'div' subfields
490
    var inputs     = clone.getElementsByTagName('input');
491
    var selects    = clone.getElementsByTagName('select');
492
    var textareas  = clone.getElementsByTagName('textarea');
493
    var linkid;
494
495
    // input
496
    var id_input = "";
497
    for(var i=0,len=inputs.length; i<len ; i++ ){
498
        id_input = inputs[i].getAttribute('id')+new_key;
499
        inputs[i].setAttribute('id',id_input);
500
        inputs[i].setAttribute('name',inputs[i].getAttribute('name')+new_key);
501
	linkid = id_input;
502
    }
503
    
504
    // select 
505
    for(var i=0,len=selects.length; i<len ; i++ ){
506
        id_input = selects[i].getAttribute('id')+new_key;
507
        selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key);
508
        selects[i].setAttribute('name',selects[i].getAttribute('name')+new_key);
509
    }
510
    
511
    // textarea
512
    for(var i=0,len=textareas.length; i<len ; i++ ){
513
        id_input = textareas[i].getAttribute('id')+new_key;
514
        textareas[i].setAttribute('id',textareas[i].getAttribute('id')+new_key);
515
        textareas[i].setAttribute('name',textareas[i].getAttribute('name')+new_key);
516
    }
517
518
    // Changing the "..." link's onclick attribute for plugin callback
519
    var links  = clone.getElementsByTagName('a');
520
    var link = links[0];
521
    var buttonDotOnClick = link.getAttribute('onclick');
522
    if(buttonDotOnClick.match('Clictag')){   // -1- It s a plugin
523
	var re = /\('.*'\)/i;
524
        buttonDotOnClick = buttonDotOnClick.replace(re,"('"+linkid+"')");
525
        if(buttonDotOnClick){
526
	    link.setAttribute('onclick',buttonDotOnClick);
527
        }
528
    }
529
530
531
    [% UNLESS ( advancedMARCEditor ) %]
532
    // when cloning a subfield, reset its label too.
533
    var label = clone.getElementsByTagName('label')[0];
534
    label.setAttribute('for',id_input);
535
    [% END %]
536
    
537
    // setting a new id for the parent div
538
    clone.setAttribute('id',new_id);
539
    
540
    try {
541
        var buttonUp = clone.getElementsByTagName('img')[0];
542
        buttonUp.setAttribute('onclick',"upSubfield('" + new_id + "')");
543
        var anchors = clone.getElementsByTagName('a');
544
        if(anchors.length){
545
            for(var i = 0 ,lenanchors = anchors.length ; i < lenanchors ; i++){
546
                if(anchors[i].getAttribute('class') == 'buttonPlus'){
547
                    anchors[i].setAttribute('onclick',"CloneSubfield('" + new_id + "')");
548
                } else if (anchors[i].getAttribute('class') == 'buttonMinus') {
549
                    anchors[i].setAttribute('onclick',"UnCloneField('" + new_id + "')");
550
                }
551
            }
552
        }
553
    }
554
    catch(e){
555
        // do nothig if ButtonPlus & CloneButtonPlus don't exist.
556
    }
557
    // insert this line on the page
558
    original.parentNode.insertBefore(clone,original.nextSibling);
559
}
560
561
 /**
562
 * This function removes or clears unwanted subfields
563
 */
564
function UnCloneField(index) {
565
    var original = document.getElementById(index);
566
    var field_id;
567
    if (index.match("tag")) {
568
        field_id = index.substr(0, 7);
569
    } else {
570
        field_id = index.substr(0, 12);
571
    }
572
    if (1 == fields_in_use[field_id]) {
573
        // clear inputs, but don't delete
574
        $(":input.input_marceditor", original).each(function(){
575
            // thanks to http://www.learningjquery.com/2007/08/clearing-form-data for
576
            // hint about clearing selects correctly
577
            var type = this.type;
578
            var tag = this.tagName.toLowerCase();
579
            if (type == 'text' || type == 'password' || tag == 'textarea') {
580
                this.value = "";
581
            } else if (type == 'checkbox' || type == 'radio') {
582
                this.checked = false;
583
            } else if (tag == 'select') {
584
                this.selectedIndex = -1;
585
            }
586
        });
587
        $(":input.indicator", original).val("");
588
    } else {
589
        original.parentNode.removeChild(original);
590
        fields_in_use[field_id]--;
591
    }
592
}
593
594
/**
595
 * This function create a random number
596
 */
597
function CreateKey(){
598
    return parseInt(Math.random() * 100000);
599
}
600
601
602
function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
603
    subfield = document.getElementById(index);
604
    subfield.style.display = 'block';
605
    label = document.getElementById(labelindex);
606
    label.style.display='none';	
607
}
248
//]]>
608
//]]>
249
</script>
609
</script>
250
<link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
610
<link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
Lines 420-430 function Changefwk(FwkList) { Link Here
420
    </ul>
780
    </ul>
421
781
422
[% FOREACH BIG_LOO IN BIG_LOOP %]
782
[% FOREACH BIG_LOO IN BIG_LOOP %]
423
    <div id="tab[% BIG_LOO.number %]XX">
783
<!-- hide every tab except the 1st -->
784
[% IF ( BIG_LOO.number ) %]
785
    <ul id="tab[% BIG_LOO.number %]XX" class="sortable_field">
786
[% ELSE %]
787
    <ul id="tab[% BIG_LOO.number %]XX" class="sortable_field">
788
[% END %]
789
424
    
790
    
425
    [% FOREACH innerloo IN BIG_LOO.innerloop %]
791
    [% FOREACH innerloo IN BIG_LOO.innerloop %]
426
    [% IF ( innerloo.tag ) %]
792
        [% IF ( innerloo.tag ) %]
427
    <div class="tag" id="tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]">
793
	<li class="tag" id="tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]">
428
        <div class="tag_title" id="div_indicator_tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]">
794
        <div class="tag_title" id="div_indicator_tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]">
429
        [% UNLESS hide_marc %]
795
        [% UNLESS hide_marc %]
430
            [% IF advancedMARCEditor %]
796
            [% IF advancedMARCEditor %]
Lines 504-513 function Changefwk(FwkList) { Link Here
504
                </span>
870
                </span>
505
871
506
        </div>
872
        </div>
507
873
	<ul class="sortable_subfield">
508
        [% FOREACH subfield_loo IN innerloo.subfield_loop %]
874
        [% FOREACH subfield_loo IN innerloo.subfield_loop %]
509
            <!--  One line on the marc editor -->
875
            <!--  One line on the marc editor -->
510
            <div class="subfield_line" style="[% subfield_loo.visibility %]" id="subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]">
876
            <li class="subfield_line" style="[% subfield_loo.visibility %]; float: left; clear: left; width: 100%;" id="subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]">
511
            
877
            
512
                [% UNLESS advancedMARCEditor %]
878
                [% UNLESS advancedMARCEditor %]
513
                    [% IF ( subfield_loo.fixedfield ) %]<label for="tag_[% subfield_loo.tag %]_subfield_[% subfield_loo.subfield %]_[% subfield_loo.index %]_[% subfield_loo.index_subfield %]" style="display:none;" class="labelsubfield">
879
                    [% IF ( subfield_loo.fixedfield ) %]<label for="tag_[% subfield_loo.tag %]_subfield_[% subfield_loo.subfield %]_[% subfield_loo.index %]_[% subfield_loo.index_subfield %]" style="display:none;" class="labelsubfield">
Lines 516-526 function Changefwk(FwkList) { Link Here
516
                [% END %]
882
                [% END %]
517
                
883
                
518
                [% UNLESS hide_marc %]
884
                [% UNLESS hide_marc %]
519
                <span class="subfieldcode">
885
                <span class="subfieldcode">[% IF ( subfield_loo.fixedfield ) %] 
520
                    [% IF ( subfield_loo.fixedfield ) %]
886
                        <img class="buttonUp" style="display:none;" src="[% themelang %]/../img/cursor_split_16.png" alt="Move" title="Move" />
521
                        <img class="buttonUp" style="display:none;" src="/intranet-tmpl/prog/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]')" alt="Move Up" title="Move Up" />
522
                    [% ELSE %]
887
                    [% ELSE %]
523
                        <img class="buttonUp" src="/intranet-tmpl/prog/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]')" alt="Move Up" title="Move Up" />
888
                        <img class="buttonUp" src="[% themelang %]/../img/cursor_split_16.png" alt="Move" title="Move" />
889
524
                    [% END %]
890
                    [% END %]
525
                        <input type="text"
891
                        <input type="text"
526
                            title="[% subfield_loo.marc_lib_plain %]"
892
                            title="[% subfield_loo.marc_lib_plain %]"
Lines 559-575 function Changefwk(FwkList) { Link Here
559
                [% END %]
925
                [% END %]
560
                </span>
926
                </span>
561
                
927
                
562
            </div>
928
            </li>
563
            <!-- End of the line -->
929
            <!-- End of the line -->
564
        [% END %]
930
        [% END %]
565
931
        </ul>
566
    </div>
932
        [% END %]<!-- tag -->
567
    [% END %]<!-- if innerloo.tag -->
933
    [% END %]
568
    [% END %]<!-- BIG_LOO.innerloop -->
934
    </li>
569
    </div>
935
</ul>
570
[% END %]<!-- BIG_LOOP -->
936
[% END %]
571
572
</div><!-- tabs -->
573
937
574
<!-- Fields for fast add cataloguing -->
938
<!-- Fields for fast add cataloguing -->
575
<input type="hidden" name="barcode" value="[% barcode %]" />
939
<input type="hidden" name="barcode" value="[% barcode %]" />

Return to bug 7883