Bug 12283: Disable autocomplete for patron search inputs
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / audio_alerts.js
1 $( document ).ready(function() {
2     var checkboxes = $("#delete-alert-form input[type='checkbox']");
3     var checkedcheckboxes = 0;
4     checkboxes.on("change",function(){
5         if( $("#delete-alert-form").find("input:checked").length > 0){
6             checkedcheckboxes = 1;
7             $("#delete-alerts").removeClass("disabled");
8         } else {
9             checkedcheckboxes = 0;
10             $("#delete-alerts").addClass("disabled");
11         }
12     });
13
14     var soundfield = $("#sound");
15     var playsound = $('#play-sound');
16
17     soundfield.on("change",function(){
18         enablePlayButton($(this).val(),playsound);
19     });
20
21     $(".edit-alert").hide();
22     $("#new-alert-form").hide();
23
24     $("#newalert").on("click",function(e){
25         e.preventDefault();
26         $("#new-alert-form").show();
27         $("#toolbar, #delete-alert-form").hide();
28     });
29
30     $('#koha-sounds').on('change', function() {
31         soundfield.val( this.value );
32         enablePlayButton($(this).val(),playsound);
33     });
34
35     playsound.on('click', function(e) {
36         e.preventDefault();
37         if( soundfield.val() !== '' ){
38             playSound( soundfield.val() );
39         } else {
40             alert( MSG_AUDIO_EMPTY_SOUND );
41         }
42     });
43
44     $('#cancel-edit').on('click', function(e) {
45         e.preventDefault();
46
47         enablePlayButton("",playsound);
48         $("#id").val("");
49         $("#selector").val("");
50         soundfield.val("");
51         $("#koha-sounds").val("");
52
53         $("#toolbar").show();
54         $(".edit-alert").hide();
55         $(".create-alert").show();
56         $("#new-alert-form").hide();
57         $("#delete-alert-form").show();
58     });
59
60     $('#delete-alert-form').on('submit', function() {
61         if( checkedcheckboxes == 1 ){
62             return confirm( MSG_AUDIO_CONFIRM_DELETE );
63         } else {
64             alert( MSG_AUDIO_CHECK_CHECKBOXES );
65             return false;
66         }
67     });
68
69     $(".edit").on("click",function(e){
70         e.preventDefault();
71         var elt = this;
72         var id = $(this).data("soundid");
73         var precedence = $(this).data("precedence");
74         var selector = $(this).data("selector");
75         var sound = $(this).data("sound");
76         EditAlert( elt, id, precedence, selector, sound );
77     });
78 });
79
80 function enablePlayButton(sound_field_value,playbutton){
81     if( sound_field_value !== '' ){
82         playbutton.removeClass("disabled");
83     } else {
84         playbutton.addClass("disabled");
85     }
86 }
87
88 function EditAlert( elt, id, precedence, selector, sound ) {
89     $("#new-alert-form").show();
90     $("#delete-alert-form").hide();
91     $("#toolbar").hide();
92     $(".create-alert").hide();
93     $(".edit-alert").show();
94     $("#id").val(id);
95     $("#selector").val(selector);
96     $("#sound").val(sound);
97     $("#koha-sounds").val(sound);
98     enablePlayButton(sound,$('#play-sound'));
99 }