Bug 15735: Audio Alerts editor broken by use of of single quotes in editor
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / audio_alerts.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Administration &rsaquo; Audio alerts</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4
5 <script type="text/javascript">
6 $( document ).ready(function() {
7     $(".edit-alert").hide();
8
9     $('#koha-sounds').on('change', function() {
10         $('#sound').val( this.value );
11     });
12
13     $('#koha-sounds').on('change', function() {
14         $('#sound').val( this.value );
15     });
16
17     $('#play-sound').on('click', function() {
18         playSound( $('#sound').val() );
19         return false;
20     });
21
22     $('#cancel-edit').on('click', function() {
23         $("#id").val("");
24         $("#selector").val("");
25         $("#sound").val("");
26
27         $(".edit-alert").hide();
28         $(".create-alert").show();
29
30         $("#audio-alerts-table").find("td").each(function (i) {
31             $(this).removeClass('highlighted-row');
32         });
33         return false;
34     });
35
36     $('#new-alert-form').on('submit', function() {
37         if ( ! $('#selector').val() ) {
38             alert(_("You must enter a selector!"));
39             return false;
40         } else if ( ! $('#sound').val() ) {
41             alert(_("You must choose a sound!"));
42             return false;
43         } else {
44             return true;
45         }
46     });
47
48     $('#delete-alert-form').on('submit', function() {
49         return confirm(_("Are you sure you want to delete the selected audio alerts?"));
50     });
51 });
52
53 function EditAlert( elt, id, precedence, selector, sound ) {
54     $("#audio-alerts-table").find("td").each(function (i) {
55         $(this).removeClass('highlighted-row');
56     });
57
58     $(".create-alert").hide();
59     $(".edit-alert").show();
60
61     $(elt).parent().parent().find("td").each(function (i) {
62         $(this).addClass('highlighted-row');
63     });
64     $("#id").val(id);
65     $("#selector").val(selector);
66     $("#sound").val(sound);
67 }
68 </script>
69
70 </head>
71 <body id="admin_audio_alerts" class="admin">
72 [% INCLUDE 'header.inc' %]
73 [% INCLUDE 'patrons-admin-search.inc' %]
74
75 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Audio alerts</div>
76
77 <div id="doc3" class="yui-t2">
78     <div id="bd">
79         <div id="yui-main">
80             <div class="yui-b">
81                 <form id="new-alert-form" action="audio_alerts.pl" method="post">
82                     <fieldset class="form-inline">
83                         <legend><span class="create-alert">Add new alert</span><span class="edit-alert">Edit alert</span></legend>
84
85                         <input id="id" name="id" type="hidden" value="" />
86                         <input id="selector" name="selector" type="text" class="input-large" placeholder="selector" />
87                         <input id="sound" name="sound" type="text" class="input-large" placeholder="sound" />
88
89                         <button id="play-sound" class="btn"><i class="icon-play"></i> Play sound</button>
90
91                         <br/>
92
93                         <select id="koha-sounds">
94                             <option value="">Select built-in sound</option>
95                             <option value="beep.ogg">beep.ogg</option>
96                             <option value="call.ogg">call.ogg</option>
97                             <option value="critical.ogg">critical.ogg</option>
98                             <option value="device_connect.ogg">device_connect.ogg</option>
99                             <option value="device_disconnect.ogg">device_disconnect.ogg</option>
100                             <option value="ending.ogg">ending.ogg</option>
101                             <option value="fail.ogg">fail.ogg</option>
102                             <option value="IM_notification.ogg">IM_notification.ogg</option>
103                             <option value="incoming_call.ogg">incoming_call.ogg</option>
104                             <option value="loading.ogg">loading.ogg</option>
105                             <option value="loading_2.ogg">loading_2.ogg</option>
106                             <option value="maximize.ogg">maximize.ogg</option>
107                             <option value="minimize.ogg">minimize.ogg</option>
108                             <option value="new_mail_notification.ogg">new_mail_notification.ogg</option>
109                             <option value="opening.ogg">opening.ogg</option>
110                             <option value="panic.ogg">panic.ogg</option>
111                             <option value="popup.ogg">popup.ogg</option>
112                             <option value="warning.ogg">warning.ogg</option>
113                         </select>
114
115                         <p>
116                             <button id="save-alert" type="submit" class="btn create-alert"><i class="icon-hdd"></i> Save alert</button>
117                             <button id="save-edit" type="submit" class="btn edit-alert save-edit"><i class="icon-hdd"></i> Update alert</button>
118                             <a id="cancel-edit" class="btn edit-alert cancel-edit"><i class="icon icon-remove-circle"></i> Cancel edit</a>
119                         </p>
120                     </fieldset>
121                 </form>
122
123                 <form id="delete-alert-form" action="audio_alerts.pl" method="post">
124                     <table id="audio-alerts-table">
125                         <thead id="audio-alerts-table-head">
126                             <tr>
127                                 <th>&nbsp;</th>
128                                 <th>Precedence</th>
129                                 <th>&nbsp;</th>
130                                 <th>Selector</th>
131                                 <th>Sound</th>
132                                 <th>&nbsp;</th>
133                             </tr>
134                         </thead>
135
136                         <tbody id="audio-alerts-table-body">
137                             [% FOREACH a IN audio_alerts %]
138                                 <tr>
139                                     <td><input type="checkbox" name="delete" value="[% a.id %]" /></td>
140                                     <td>[% a.precedence %]</td>
141                                     <td style="white-space:nowrap;">
142                                         <a title="Move alert up" href="audio_alerts.pl?action=move&amp;where=up&amp;id=[% a.id %]">
143                                             <img src="[% interface %]/[% theme %]/img/go-up.png" border="0" alt="Go up" />
144                                         </a>
145
146                                         <a title="Move alert to top" href="audio_alerts.pl?action=move&amp;where=top&amp;id=[% a.id %]">
147                                             <img src="[% interface %]/[% theme %]/img/go-top.png" border="0" alt="Go top" />
148                                         </a>
149
150                                         <a title="Move alert to bottom" href="audio_alerts.pl?action=move&amp;where=bottom&amp;id=[% a.id %]">
151                                             <img src="[% interface %]/[% theme %]/img/go-bottom.png" border="0" alt="Go bottom" />
152                                         </a>
153
154                                         <a title="Move alert down" href="audio_alerts.pl?action=move&amp;where=down&amp;id=[% a.id %]">
155                                             <img src="[% interface %]/[% theme %]/img/go-down.png" border="0" alt="Go down" />
156                                         </a>
157                                     </td>
158                                     <td>[% a.selector %]</td>
159                                     <td>[% a.sound %]</td>
160                                     <td><a class="btn btn-small" onclick="EditAlert( this, '[% a.id %]','[% a.precedence %]', '[% a.selector | replace( "'", "\\'" ) | html %]', '[% a.sound %]' )" ><i class="icon-pencil"></i> Edit</a></td>
161                                 </tr>
162                             [% END %]
163                         </tbody>
164                     </table>
165
166                     <p/>
167                     <button id="delete-alerts" type="submit" class="btn"><i class="icon-trash"></i> Delete selected alerts</button>
168                 </form>
169             </div>
170         </div>
171     <div class="yui-b">
172 [% INCLUDE 'admin-menu.inc' %]
173 </div>
174 </div>
175 [% INCLUDE 'intranet-bottom.inc' %]