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( 0, function(){
29 $("#selector").focus();
31 $("#toolbar, #delete-alert-form").hide();
34 $('#koha-sounds').on('change', function() {
35 soundfield.val( this.value );
36 enablePlayButton($(this).val(),playsound);
39 playsound.on('click', function(e) {
41 if( soundfield.val() !== '' ){
42 playSound( soundfield.val() );
44 alert( __("Please select or enter a sound.") );
48 $('#cancel-edit').on('click', function(e) {
51 enablePlayButton("",playsound);
53 $("#selector").val("");
55 $("#koha-sounds").val("");
58 $(".edit-alert").hide();
59 $(".create-alert").show();
60 $("#new-alert-form").hide();
61 $("#delete-alert-form").show();
64 $('#delete-alert-form').on('submit', function() {
65 if( checkedcheckboxes == 1 ){
66 return confirm( __("Are you sure you want to delete the selected audio alerts?") );
68 alert( __("Check the box next to the alert you want to delete.") );
73 $(".edit").on("click",function(e){
76 var id = $(this).data("soundid");
77 var precedence = $(this).data("precedence");
78 var selector = $(this).data("selector");
79 var sound = $(this).data("sound");
80 EditAlert( elt, id, precedence, selector, sound );
84 function enablePlayButton(sound_field_value,playbutton){
85 if( sound_field_value !== '' ){
86 playbutton.removeClass("disabled");
88 playbutton.addClass("disabled");
92 function EditAlert( elt, id, precedence, selector, sound ) {
93 $("#new-alert-form").show();
94 $("#delete-alert-form").hide();
96 $(".create-alert").hide();
97 $(".edit-alert").show();
99 $("#selector").val(selector);
100 $("#sound").val(sound);
101 $("#koha-sounds").val(sound);
102 enablePlayButton(sound,$('#play-sound'));