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 );
70 function enablePlayButton(sound_field_value,playbutton){
71 if( sound_field_value !== '' ){
72 playbutton.removeClass("disabled");
74 playbutton.addClass("disabled");
78 function EditAlert( elt, id, precedence, selector, sound ) {
79 $("#new-alert-form").show();
80 $("#delete-alert-form").hide();
82 $(".create-alert").hide();
83 $(".edit-alert").show();
85 $("#selector").val(selector);
86 $("#sound").val(sound);
87 $("#koha-sounds").val(sound);
88 enablePlayButton(sound,$('#play-sound'));