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

(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt (-71 / +80 lines)
Lines 13-105 Link Here
13
     return s.substring(index + 1);
13
     return s.substring(index + 1);
14
 }
14
 }
15
15
16
// Select the first item available
17
function select_first_available(id){
18
    var radios = $("input:radio[name='checkitem_" + id + "']");
19
    $(radios).first().attr("checked", "checked");
20
}
21
16
 $(document).ready(function() {
22
 $(document).ready(function() {
17
    $('#hold-request-form').preventDoubleFormSubmit();
23
    $('#hold-request-form').preventDoubleFormSubmit();
18
24
19
    var copiesRowId = null;
25
    var copiesRowId = null;
20
    var wasSpecific = false;
26
    var wasSpecific = false;
21
    var lastCopiesRowId = null;
27
    var lastCopiesRowId = null;
22
	$(".checkitem").parent().click(function(e){
28
    $(".checkitem").parent().click(function(e){
23
		if(e.target.tagName.toLowerCase() == 'td'){
29
        if(e.target.tagName.toLowerCase() == 'td'){
24
           $(this).find("input.checkitem").each( function() {
30
           $(this).find("input.checkitem").each( function() {
25
               $(this).attr('checked', !$(this).attr('checked'));
31
               $(this).attr('checked', 'checked');
26
			});
32
            });
27
		}
33
        }
28
	});
34
    });
35
36
    // click on a first td check the confirmjs checkbox
37
    $("td.hold").click(function(e){
38
      if(e.target.tagName.toLowerCase() == 'td'){
39
        $(this).find("input.confirmjs").each( function() {
40
           $(this).attr('checked', !$(this).attr('checked'));
41
           $(this).change();
42
        });
43
      }
44
    });
45
29
    // Hides all 'specific copy' table rows on load.
46
    // Hides all 'specific copy' table rows on load.
30
    $(".copiesrow").hide();
47
    $(".copiesrow").hide();
31
48
32
    $("#place_on_hdr").show();
33
    [% IF OPACItemHolds == '1' %]
34
        $(".place_on_type").show();
35
    [% END %]
36
37
    // Replace non-JS single-selection with multi-selection capability.
49
    // Replace non-JS single-selection with multi-selection capability.
38
    $(".reserve_mode").val("multi");
50
    $(".reserve_mode").val("multi");
39
    $(".confirm_nonjs").remove();
51
    $(".confirm_nonjs").remove();
40
    $(".confirmjs_hold").each(function(){
52
    $(".confirmjs_hold").each(function(){
41
        var bib = $(this).attr("title");
53
        var bib = $(this).attr("title");
42
        var html = "<input type =\"checkbox\" class=\"confirmjs\" checked=\"checked\"";
54
        var html = "<input type =\"checkbox\" class=\"confirmjs\" checked=\"checked\"";
43
        html += "value=\"" + bib + "\"/>";
55
        html += "value=\"" + bib + "\" id=\"" + bib + "\"/>";
44
        $(this).html(html);
45
    });
46
    $(".confirmjs_nohold").each(function(){
47
        var bib = $(this).attr("title");
48
        var html = "<input type =\"checkbox\" class=\"confirmjs\" disabled=\"disabled\"";
49
        html += "value=\"" + bib + "\"/>";
50
        $(this).html(html);
56
        $(this).html(html);
51
    });
57
    });
52
58
53
    // Make sure a specific item was selected where specified
59
    // expand or collapse the copiesrow tr
54
    // before moving on to a new item.
60
    function toggle_copiesrow(biblioNum) {
55
    function changeSelection (newCopiesRowId, isSpecific) {
61
        var checkbox = $("input:checkbox[value='"+biblioNum+"']");
56
        if (copiesRowId && ((copiesRowId != newCopiesRowId) || (wasSpecific != isSpecific))) {
57
            var biblioNum = suffixOf(copiesRowId, "_");
58
59
            // If the 'specific copy' radio button was checked
60
              if (wasSpecific && (copiesRowId != newCopiesRowId)) {
61
                // Find the selected copy
62
                var item = $(".checkitem_" + biblioNum + ":checked");
63
                if ($(item).size() == 0) {
64
                    alert(MSG_NO_COPY_SELECTED);
65
                    return false;
66
                }
67
            }
68
        }
69
        copiesRowId = newCopiesRowId;
70
        wasSpecific = isSpecific;
71
        return true;
72
    }
73
74
    // When 'specific copy' radio button is clicked
75
    $(".selectspecific").click(function() {
76
77
        // Make sure all other specific copy table rows are hidden
78
        biblioNum = suffixOf($(this).attr("id"), "_");
79
        newCopiesRowId = "#copiesrow_" + biblioNum;
62
        newCopiesRowId = "#copiesrow_" + biblioNum;
63
        var select_specific = $("#reqspecific_"+biblioNum).is(":checked");
80
64
81
        if (!changeSelection(newCopiesRowId, true)) {
65
        // If the checkbox is checked AND we want a specific item, we display the items block
82
            return false;
66
        if ( $(checkbox).is(":checked") && select_specific ) {
67
            $(newCopiesRowId).show();
68
        } else {
69
            $(newCopiesRowId).hide();
83
        }
70
        }
84
        $(".copiesrow:not(" + newCopiesRowId + ")").hide();
71
    };
85
72
86
        // Show the specific copy table for this radio button.
73
    $("#place_on_hdr").show();
87
        $(newCopiesRowId).show();
88
    });
89
74
75
    [% IF OPACItemHolds == '1' %]
76
        $(".place_on_type").show();
77
        // onload, selectany is checked
78
        $(".selectany").attr("checked", "checked");
79
    [% END %]
90
80
91
    // When 'first available' radion button is clicked
81
    // If we can choose a specific item, we preselect the first one
92
    $(".selectany").click(function() {
82
    [% IF OPACItemHolds =="1" or OPACItemHolds == 'force' %]
93
        // Make sure all other specific copy table rows are hidden
83
        $("tr.hold").each(function(){
94
        biblioNum = suffixOf($(this).attr("id"), "_");
84
            var id = suffixOf($(this).attr("id"), "_");
95
        newCopiesRowId = "#copiesrow_" + biblioNum;
85
            select_first_available(id);
86
        });
87
    [% END %]
96
88
97
        if (!changeSelection(newCopiesRowId, false)) {
89
    // On confirmsjs change
98
            return false;
90
    $(".confirmjs").change(function(){
91
        var id = suffixOf($(this).attr("id"), "_");
92
        // If I m checked, I enable radio buttons
93
        if ( $(this).is(":checked") ) {
94
            $("#reqspecific_" + id).attr("disabled", false);
95
            $("#reqany_" + id).attr("disabled", false);
99
        }
96
        }
100
97
        // Else its are disabled
101
        // Hide the copies table row
98
        else {
102
        $(".copiesrow").hide();
99
            $("#reqspecific_" + id).attr("disabled", "disabled");
100
            $("#reqany_" + id).attr("disabled", "disabled");
101
        }
102
        // expand or collaspe the items block
103
        toggle_copiesrow(id);
104
   });
105
106
    // When 'specific copy' or 'first available' radio button is clicked
107
    $(".selectspecific, .selectany").click(function() {
108
        var id = suffixOf($(this).attr("id"), "_");
109
        expand_copiesrow(id);
103
    });
110
    });
104
111
105
    // When 'Place Hold' button is clicked
112
    // When 'Place Hold' button is clicked
Lines 236-241 Link Here
236
            <input type="hidden" name="selecteditems" id="selections"/>
243
            <input type="hidden" name="selecteditems" id="selections"/>
237
            <div id="bigloop">
244
            <div id="bigloop">
238
              <table id="bibitemloop">
245
              <table id="bibitemloop">
246
                <thead>
239
                [% UNLESS ( none_available ) %]<tr>
247
                [% UNLESS ( none_available ) %]<tr>
240
                  <th>Hold</th>
248
                  <th>Hold</th>
241
                  <th>Title</th>
249
                  <th>Title</th>
Lines 257-272 Link Here
257
                    <th id="place_on_hdr" style="display:none">Place On</th>
265
                    <th id="place_on_hdr" style="display:none">Place On</th>
258
                  [% END %]
266
                  [% END %]
259
                  [% UNLESS ( singleBranchMode ) %]
267
                  [% UNLESS ( singleBranchMode ) %]
260
		    [% IF ( choose_branch ) %]
268
                    [% IF ( choose_branch ) %]
261
                        <th>Pickup location</th>
269
                        <th>Pickup location</th>
262
		    [% END %]
270
                    [% END %]
263
                  [% END %]
271
                  [% END %]
264
                </tr>[% ELSE %]<tr><th colspan="5">Title</th></tr>[% END %]
272
                </tr>[% ELSE %]<tr><th colspan="5">Title</th></tr>[% END %]
265
273
                </thead>
274
                <tbody>
266
                [% FOREACH bibitemloo IN bibitemloop %]
275
                [% FOREACH bibitemloo IN bibitemloop %]
267
                  <tr>
276
                  <tr id="hold_[% bibitemloo.biblionumber %]" class="hold">
268
                      [% IF ( bibitemloo.holdable ) %]
277
                    [% IF ( bibitemloo.holdable ) %]
269
                                    <td class="hold">
278
                    <td class="hold">
270
                      <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
279
                      <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
271
                      <input class="single_bib" name="single_bib" type="hidden" value="[% bibitemloo.biblionumber %]"/>
280
                      <input class="single_bib" name="single_bib" type="hidden" value="[% bibitemloo.biblionumber %]"/>
272
                        <span class="confirmjs_hold" title="[% bibitemloo.biblionumber %]"></span>
281
                        <span class="confirmjs_hold" title="[% bibitemloo.biblionumber %]"></span>
Lines 277-286 Link Here
277
                                 value="any" />
286
                                 value="any" />
278
                          <label class="confirm_label" for="[% bibitemloo.checkitem_bib %]">Next available copy</label>
287
                          <label class="confirm_label" for="[% bibitemloo.checkitem_bib %]">Next available copy</label>
279
                        </span>
288
                        </span>
280
					</td>
289
                    </td>
281
                      [% ELSE %]
290
                    [% ELSE %]
282
                                      [% UNLESS ( none_available ) %]<td class="hold">&nbsp;</td>[% END %]
291
                      [% UNLESS ( none_available ) %]<td class="hold">&nbsp;</td>[% END %]
283
                      [% END %]
292
                    [% END %]
284
                    [% IF ( bibitemloo.holdable ) %]<td class="title">[% ELSE %]<td class="title" colspan="5">[% END %]
293
                    [% IF ( bibitemloo.holdable ) %]<td class="title">[% ELSE %]<td class="title" colspan="5">[% END %]
285
                      <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% bibitemloo.biblionumber %]">[% bibitemloo.title |html %][% IF ( bibitemloo.subtitle ) %] [% FOREACH subtitl IN bibitemloo.subtitle %][% subtitl.subfield %][% END %][% END %]</a>
294
                      <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% bibitemloo.biblionumber %]">[% bibitemloo.title |html %][% IF ( bibitemloo.subtitle ) %] [% FOREACH subtitl IN bibitemloo.subtitle %][% subtitl.subfield %][% END %][% END %]</a>
286
                      [% IF ( bibitemloo.author ) %],  by [% bibitemloo.author %][% END %]
295
                      [% IF ( bibitemloo.author ) %],  by [% bibitemloo.author %][% END %]
Lines 485-490 Link Here
485
                  [% END %]<!-- bib_available -->
494
                  [% END %]<!-- bib_available -->
486
                  [% END %]<!-- OPACItemHolds -->
495
                  [% END %]<!-- OPACItemHolds -->
487
                [% END %]
496
                [% END %]
497
                </tbody>
488
              </table><!-- bibitemloop -->
498
              </table><!-- bibitemloop -->
489
              [% END %] <!-- if message -->
499
              [% END %] <!-- if message -->
490
            </div><!-- bigloop -->
500
            </div><!-- bigloop -->
491
- 

Return to bug 7825