Bug 24201: (follow-up) add desk choice with library choice
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / desk_selection.js
1 $(document).ready(function() {
2     $("#desk_id").children().each(function() {
3         var selectedBranch = $("#branch"). children("option:selected"). val();
4         if ($(this).attr('id') === "nodesk") { //set no desk by default, should be first element
5             $(this).prop("selected", true);
6             $(this).prop("disabled", false);
7             $(this).show();
8         }
9         else if ($(this).hasClass(selectedBranch)) {
10             $('#nodesk').prop("disabled", true); // we have desk, no need for nodesk option
11             $('#nodesk').hide();
12             $(this).prop("disabled", false);
13             $(this).show();
14             $(this).prop("selected", true)
15         } else {
16             $(this).prop("disabled", true);
17             $(this).hide();
18         }
19     });
20
21     $("#branch").on("change", function() {
22
23         $("#desk_id").children().each(function() {
24             var selectedBranch = $("#branch"). children("option:selected"). val();
25             if ($(this).attr('id') === "nodesk") { //set no desk by default, should be first element
26                 $(this).prop("selected", true);
27                 $(this).prop("disabled", false);
28                 $(this).show();
29             }
30             else if ($(this).hasClass(selectedBranch)) {
31                 $('#nodesk').prop("disabled", true); // we have desk, no need for nodesk option
32                 $('#nodesk').hide();
33                 $(this).prop("disabled", false);
34                 $(this).show();
35                 $(this).prop("selected", true)
36             } else {
37                 $(this).prop("disabled", true);
38                 $(this).hide();
39             }
40         });
41     });
42 }) ;