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){
7 $("#delete-alerts").removeClass("disabled");
10 $("#delete-alerts").addClass("disabled");
14 var soundfield = $("#sound");
15 var playsound = $('#play-sound');
17 soundfield.on("change",function(){
18 enablePlayButton($(this).val(),playsound);
21 $(".edit-alert").hide();
22 $("#new-alert-form").hide();
24 $("#newalert").on("click",function(e){
26 $("#new-alert-form").show();
27 $("#toolbar, #delete-alert-form").hide();
30 $('#koha-sounds').on('change', function() {
31 soundfield.val( this.value );
32 enablePlayButton($(this).val(),playsound);
35 playsound.on('click', function(e) {
37 if( soundfield.val() !== '' ){
38 playSound( soundfield.val() );
40 alert( MSG_AUDIO_EMPTY_SOUND );
44 $('#cancel-edit').on('click', function(e) {
47 enablePlayButton("",playsound);
49 $("#selector").val("");
51 $("#koha-sounds").val("");
54 $(".edit-alert").hide();
55 $(".create-alert").show();
56 $("#new-alert-form").hide();
57 $("#delete-alert-form").show();
60 $('#delete-alert-form').on('submit', function() {
61 if( checkedcheckboxes == 1 ){
62 return confirm( MSG_AUDIO_CONFIRM_DELETE );
64 alert( MSG_AUDIO_CHECK_CHECKBOXES );
69 $(".edit").on("click",function(e){
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 );
80 function enablePlayButton(sound_field_value,playbutton){
81 if( sound_field_value !== '' ){
82 playbutton.removeClass("disabled");
84 playbutton.addClass("disabled");
88 function EditAlert( elt, id, precedence, selector, sound ) {
89 $("#new-alert-form").show();
90 $("#delete-alert-form").hide();
92 $(".create-alert").hide();
93 $(".edit-alert").show();
95 $("#selector").val(selector);
96 $("#sound").val(sound);
97 $("#koha-sounds").val(sound);
98 enablePlayButton(sound,$('#play-sound'));