Merge remote-tracking branch 'origin/new/bug_7016'
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / authorities / blinddetail-biblio-search.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Authority details</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4 <script type="text/javascript">
5 //<![CDATA[
6     $(document).ready(function(){
7         var index_start = "[% index %]";
8         var whichfield;
9         try {
10             whichfield = opener.opener.document.getElementById(index_start);
11         } catch(e) {
12             return;
13         }
14
15         var field_start = whichfield.parentNode.parentNode;
16       
17         // browse all its subfields (clear and $9)
18         var subfields = field_start.getElementsByTagName('input');
19         var re = /^tag_\d*_code_/;
20         for(var i=0, len = subfields.length ; i< len ; i++) { // browse all subfields
21             if(subfields[i].getAttribute('name').match(re)){ // it s a subfield
22                 var code     = subfields[i];   // code is the first input 
23                 var subfield = subfields[i+1]; // subfield the second
24
25             [% IF ( clear ) %]
26                 if (subfield){subfield.value="" ;}
27             [% ELSE %]
28                 if(code.value=='9'){
29                     subfield.value = "[% authid |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
30                 }
31             [% END %]
32             }
33         }
34
35         // Sets the good number of form fields for the specified subfield
36         // Returns false if the cloning failed
37         function SetSubfieldNumber(subfield_name, nb) {
38             // Nothing to do if we only have one value
39             if(nb <= 1) {
40                 return true;
41             }
42             
43             // Find the subfield we want to clone
44             var re = new RegExp('^subfield' + subfield_name,'g');
45             var subfields = $(field_start).children('div').filter( function() {
46                 return this.id.match(re);
47             });
48
49             // Try to add as many clones as needed
50             try {
51                 for(var i=0; i<nb-subfields.length; i++) {
52                     window.opener.opener.CloneSubfield(subfields[0].getAttribute('id'));
53                 }
54             }
55             catch(err) {
56                 return false;
57             }
58             return true;
59         }
60
61         // Fills the subfield with the values entered in argument
62         function SetSubfieldValues() {
63             // Get the arguments
64             var subfield_name = arguments[0];
65             var values = new Array();
66             for(var i=1; i<arguments.length; i++) {
67                 values.push(arguments[i]);
68             }
69
70             // Create the correct number of form fields for all values
71             // If the field cloning failed, only the first value will be added to the form.
72             SetSubfieldNumber(subfield_name, values.length);
73             
74             // Find the subfields where we will add the new values
75             var re = new RegExp('^subfield' + subfield_name,'g');
76             var subfields = $(field_start).children('div').filter( function() {
77                 return this.id.match(re);
78             });
79
80             // Add the new values to those subfields, empty the additional fields
81             var i=0;
82             subfields.each(function() {
83                 if(i in values) {
84                     this.getElementsByTagName('input')[1].value = values[i];
85                 }
86                 else {
87                     this.getElementsByTagName('input')[1].value = "";
88                 }
89                 i++;
90             });
91         }
92
93         [% FOREACH SUBFIELD_LOO IN SUBFIELD_LOOP %]
94             SetSubfieldValues(
95                 "[% tag_number |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %][% SUBFIELD_LOO.marc_subfield |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
96             [% FOREACH marc_value IN SUBFIELD_LOO.marc_values %]
97                 ,"[% marc_value |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
98             [% END %]
99             );
100         [% END %]
101
102         opener.close();
103         window.close();
104             
105         return false;
106     });
107 //]]>
108 </script>
109 </head>
110 <body id="auth_blinddetail-biblio-search" class="auth">
111
112 <div id="doc" class="yui-t7">
113    <div id="bd">
114         <div class="yui-g">
115
116
117
118 </div>
119 </div>
120 </div>
121
122 [% INCLUDE 'popup-bottom.inc' %]