3 $( document ).ready(function() {
4 var checkboxes = $("#delete-alert-form input[type='checkbox']");
5 var checkedcheckboxes = 0;
6 checkboxes.on("change",function(){
7 if( $("#delete-alert-form").find("input:checked").length > 0){
9 $("#delete-alerts").removeClass("disabled");
11 checkedcheckboxes = 0;
12 $("#delete-alerts").addClass("disabled");
16 var soundfield = $("#sound");
17 var playsound = $('#play-sound');
19 soundfield.on("change",function(){
20 enablePlayButton($(this).val(),playsound);
23 $(".edit-alert").hide();
24 $("#new-alert-form").hide();
26 $("#newalert").on("click",function(e){
28 $("#new-alert-form").show();
29 $("#toolbar, #delete-alert-form").hide();
32 $('#koha-sounds').on('change', function() {
33 soundfield.val( this.value );
34 enablePlayButton($(this).val(),playsound);
37 playsound.on('click', function(e) {
39 if( soundfield.val() !== '' ){
40 playSound( soundfield.val() );
42 alert( __("Please select or enter a sound.") );
46 $('#cancel-edit').on('click', function(e) {
49 enablePlayButton("",playsound);
51 $("#selector").val("");
53 $("#koha-sounds").val("");
56 $(".edit-alert").hide();
57 $(".create-alert").show();
58 $("#new-alert-form").hide();
59 $("#delete-alert-form").show();
62 $('#delete-alert-form').on('submit', function() {
63 if( checkedcheckboxes == 1 ){
64 return confirm( __("Are you sure you want to delete the selected audio alerts?") );
66 alert( __("Check the box next to the alert you want to delete.") );
71 $(".edit").on("click",function(e){
74 var id = $(this).data("soundid");
75 var precedence = $(this).data("precedence");
76 var selector = $(this).data("selector");
77 var sound = $(this).data("sound");
78 EditAlert( elt, id, precedence, selector, sound );
82 function enablePlayButton(sound_field_value,playbutton){
83 if( sound_field_value !== '' ){
84 playbutton.removeClass("disabled");
86 playbutton.addClass("disabled");
90 function EditAlert( elt, id, precedence, selector, sound ) {
91 $("#new-alert-form").show();
92 $("#delete-alert-form").hide();
94 $(".create-alert").hide();
95 $(".edit-alert").show();
97 $("#selector").val(selector);
98 $("#sound").val(sound);
99 $("#koha-sounds").val(sound);
100 enablePlayButton(sound,$('#play-sound'));