View | Details | Raw Unified | Return to bug 15886
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/js/audio_alerts.js (+89 lines)
Line 0 Link Here
1
$( document ).ready(function() {
2
    var checkboxes = $("#delete-alert-form input[type='checkbox']");
3
    var checkedcheckboxes = 0;
4
    checkboxes.on("change",function(){
5
        if( $(checkboxes+":checked").length > 0){
6
            checkedcheckboxes = 1;
7
            $("#delete-alerts").removeClass("disabled");
8
        } else {
9
            checkedcheckboxes = 0;
10
            $("#delete-alerts").addClass("disabled");
11
        }
12
    });
13
14
    var soundfield = $("#sound");
15
    var playsound = $('#play-sound');
16
17
    soundfield.on("change",function(){
18
        enablePlayButton($(this).val(),playsound);
19
    });
20
21
    $(".edit-alert").hide();
22
    $("#new-alert-form").hide();
23
24
    $("#newalert").on("click",function(e){
25
        e.preventDefault();
26
        $("#new-alert-form").show();
27
        $("#toolbar, #delete-alert-form").hide();
28
    });
29
30
    $('#koha-sounds').on('change', function() {
31
        soundfield.val( this.value );
32
        enablePlayButton($(this).val(),playsound);
33
    });
34
35
    playsound.on('click', function(e) {
36
        e.preventDefault();
37
        if( soundfield.val() !== '' ){
38
            playSound( soundfield.val() );
39
        } else {
40
            alert( MSG_AUDIO_EMPTY_SOUND );
41
        }
42
    });
43
44
    $('#cancel-edit').on('click', function(e) {
45
        e.preventDefault();
46
47
        enablePlayButton("",playsound);
48
        $("#id").val("");
49
        $("#selector").val("");
50
        soundfield.val("");
51
        $("#koha-sounds").val("");
52
53
        $("#toolbar").show();
54
        $(".edit-alert").hide();
55
        $(".create-alert").show();
56
        $("#new-alert-form").hide();
57
        $("#delete-alert-form").show();
58
    });
59
60
    $('#delete-alert-form').on('submit', function() {
61
        if( checkedcheckboxes == 1 ){
62
            return confirm( MSG_AUDIO_CONFIRM_DELETE );
63
        } else {
64
            alert( MSG_AUDIO_CHECK_CHECKBOXES );
65
            return false;
66
        }
67
    });
68
});
69
70
function enablePlayButton(sound_field_value,playbutton){
71
    if( sound_field_value !== '' ){
72
        playbutton.removeClass("disabled");
73
    } else {
74
        playbutton.addClass("disabled");
75
    }
76
}
77
78
function EditAlert( elt, id, precedence, selector, sound ) {
79
    $("#new-alert-form").show();
80
    $("#delete-alert-form").hide();
81
    $("#toolbar").hide();
82
    $(".create-alert").hide();
83
    $(".edit-alert").show();
84
    $("#id").val(id);
85
    $("#selector").val(selector);
86
    $("#sound").val(sound);
87
    $("#koha-sounds").val(sound);
88
    enablePlayButton(sound,$('#play-sound'));
89
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/audio_alerts.tt (-108 / +62 lines)
Lines 1-76 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Administration &rsaquo; Audio alerts</title>
2
<title>Koha &rsaquo; Administration &rsaquo; Audio alerts</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
5
<script type="text/javascript">
4
<script type="text/javascript">
6
$( document ).ready(function() {
5
    var MSG_AUDIO_EMPTY_SOUND = _("Please select or enter a sound.");
7
    $(".edit-alert").hide();
6
    var MSG_AUDIO_CONFIRM_DELETE = _("Are you sure you want to delete the selected audio alerts?");
8
7
    var MSG_AUDIO_CHECK_CHECKBOXES = _("Check the box next to the alert you want to delete.")
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>
8
</script>
69
9
<script type="text/javascript" src="[% themelang %]/js/audio_alerts.js"></script>
70
</head>
10
</head>
11
71
<body id="admin_audio_alerts" class="admin">
12
<body id="admin_audio_alerts" class="admin">
72
[% INCLUDE 'header.inc' %]
13
[% INCLUDE 'header.inc' %]
73
[% INCLUDE 'patrons-admin-search.inc' %]
14
[% INCLUDE 'cat-search.inc' %]
74
15
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>
16
<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
17
Lines 78-126 function EditAlert( elt, id, precedence, selector, sound ) { Link Here
78
    <div id="bd">
19
    <div id="bd">
79
        <div id="yui-main">
20
        <div id="yui-main">
80
            <div class="yui-b">
21
            <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
22
91
                        <br/>
23
                <div id="toolbar" class="btn-toolbar">
24
                    <a class="btn btn-small" id="newalert" href="/cgi-bin/koha/admin/audio_alerts.pl"><i class="fa fa-plus"></i> New alert</a>
25
                </div>
92
26
93
                        <select id="koha-sounds">
27
                <form id="new-alert-form" action="audio_alerts.pl" method="post" class="validated">
94
                            <option value="">Select built-in sound</option>
28
                    <fieldset class="rows">
95
                            <option value="beep.ogg">beep.ogg</option>
29
                        <legend><span class="create-alert">Add new alert</span><span class="edit-alert">Edit alert</span></legend>
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
30
115
                        <p>
31
                        <input id="id" name="id" type="hidden" value="" />
116
                            <button id="save-alert" type="submit" class="btn create-alert"><i class="icon-hdd"></i> Save alert</button>
32
                        <ol>
117
                            <button id="save-edit" type="submit" class="btn edit-alert save-edit"><i class="icon-hdd"></i> Update alert</button>
33
                            <li>
118
                            <a id="cancel-edit" class="btn edit-alert cancel-edit"><i class="icon icon-remove-circle"></i> Cancel edit</a>
34
                                <label for="selector" class="required">Selector: </label>
119
                        </p>
35
                                <input id="selector" name="selector" type="text" class="required input-large" placeholder="selector" />
36
                                <span class="required">Required</span>
37
                            </li>
38
                            <li>
39
                                <label for="sound" class="required">Sound: </label>
40
                                <input id="sound" name="sound" type="text" class="required input-large" placeholder="sound" />
41
                                <button id="play-sound" class="btn btn-mini disabled"><i class="icon-play"></i> Play sound</button>
42
                                 <span class="required">Required</span>
43
                            </li>
44
                            <li>
45
                                <label for="koha-sounds">Select a built-in sound: </label>
46
                                <select id="koha-sounds">
47
                                    <option value=""> -- Choose one -- </option>
48
                                    <option value="beep.ogg">beep.ogg</option>
49
                                    <option value="call.ogg">call.ogg</option>
50
                                    <option value="critical.ogg">critical.ogg</option>
51
                                    <option value="device_connect.ogg">device_connect.ogg</option>
52
                                    <option value="device_disconnect.ogg">device_disconnect.ogg</option>
53
                                    <option value="ending.ogg">ending.ogg</option>
54
                                    <option value="fail.ogg">fail.ogg</option>
55
                                    <option value="IM_notification.ogg">IM_notification.ogg</option>
56
                                    <option value="incoming_call.ogg">incoming_call.ogg</option>
57
                                    <option value="loading.ogg">loading.ogg</option>
58
                                    <option value="loading_2.ogg">loading_2.ogg</option>
59
                                    <option value="maximize.ogg">maximize.ogg</option>
60
                                    <option value="minimize.ogg">minimize.ogg</option>
61
                                    <option value="new_mail_notification.ogg">new_mail_notification.ogg</option>
62
                                    <option value="opening.ogg">opening.ogg</option>
63
                                    <option value="panic.ogg">panic.ogg</option>
64
                                    <option value="popup.ogg">popup.ogg</option>
65
                                    <option value="warning.ogg">warning.ogg</option>
66
                                </select>
67
                            </li>
68
                        </ol>
69
                    </fieldset>
70
                    <fieldset class="action">
71
                            <input id="save-alert" type="submit" value="Submit" />
72
                            <a href="#" id="cancel-edit" class="cancel cancel-edit">Cancel</a>
120
                    </fieldset>
73
                    </fieldset>
121
                </form>
74
                </form>
122
75
123
                <form id="delete-alert-form" action="audio_alerts.pl" method="post">
76
                <form id="delete-alert-form" action="audio_alerts.pl" method="post">
77
                    <h3>Audio alerts</h3>
124
                    <table id="audio-alerts-table">
78
                    <table id="audio-alerts-table">
125
                        <thead id="audio-alerts-table-head">
79
                        <thead id="audio-alerts-table-head">
126
                            <tr>
80
                            <tr>
Lines 140-158 function EditAlert( elt, id, precedence, selector, sound ) { Link Here
140
                                    <td>[% a.precedence %]</td>
94
                                    <td>[% a.precedence %]</td>
141
                                    <td style="white-space:nowrap;">
95
                                    <td style="white-space:nowrap;">
142
                                        <a title="Move alert up" href="audio_alerts.pl?action=move&amp;where=up&amp;id=[% a.id %]">
96
                                        <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" />
97
                                            <img src="[% interface %]/[% theme %]/img/go-up.png" alt="Move alert up" />
144
                                        </a>
98
                                        </a>
145
99
146
                                        <a title="Move alert to top" href="audio_alerts.pl?action=move&amp;where=top&amp;id=[% a.id %]">
100
                                        <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" />
101
                                            <img src="[% interface %]/[% theme %]/img/go-top.png" alt="Move alert to top" />
148
                                        </a>
102
                                        </a>
149
103
150
                                        <a title="Move alert to bottom" href="audio_alerts.pl?action=move&amp;where=bottom&amp;id=[% a.id %]">
104
                                        <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" />
105
                                            <img src="[% interface %]/[% theme %]/img/go-bottom.png" alt="Move alert to bottom" />
152
                                        </a>
106
                                        </a>
153
107
154
                                        <a title="Move alert down" href="audio_alerts.pl?action=move&amp;where=down&amp;id=[% a.id %]">
108
                                        <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" />
109
                                            <img src="[% interface %]/[% theme %]/img/go-down.png" alt="Move alert down" />
156
                                        </a>
110
                                        </a>
157
                                    </td>
111
                                    </td>
158
                                    <td>[% a.selector %]</td>
112
                                    <td>[% a.selector %]</td>
Lines 163-170 function EditAlert( elt, id, precedence, selector, sound ) { Link Here
163
                        </tbody>
117
                        </tbody>
164
                    </table>
118
                    </table>
165
119
166
                    <p/>
120
                    <p>
167
                    <button id="delete-alerts" type="submit" class="btn"><i class="icon-trash"></i> Delete selected alerts</button>
121
                        <button id="delete-alerts" type="submit" class="btn disabled"><i class="icon-trash"></i> Delete selected alerts</button>
122
                    </p>
168
                </form>
123
                </form>
169
            </div>
124
            </div>
170
        </div>
125
        </div>
171
- 

Return to bug 15886