@@ -, +, @@ --- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 3 +- .../prog/en/includes/doc-head-close.inc | 29 +++++++++++++++----- koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js | 2 +- .../en/modules/admin/preferences/circulation.pref | 19 +++++++++++++ 5 files changed, 45 insertions(+), 9 deletions(-) --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -40,6 +40,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AnonSuggestions','0',NULL,'Set to enable Anonymous suggestions to AnonymousPatron borrowernumber','YesNo'), ('AnonymousPatron','0',NULL,'Set the identifier (borrowernumber) of the anonymous patron. Used for Suggestion and reading history privacy',''), ('AudioAlerts','0','','Enable circulation sounds during checkin and checkout in the staff interface. Not supported by all web browsers yet.','YesNo'), +( 'AudioAlertsCustom', '', NULL, 'Custom audio alert triggers in json associative array format', 'free' ), ( 'AudioAlertSelectorWarning', '.audio-alert-warning', NULL, 'List of jQuery selectors that should trigger warning alert', 'free' ), ( 'AudioAlertSelectorAction', '.audio-alert-action', NULL, 'List of jQuery selectors that should trigger action alert', 'free' ), ( 'AudioAlertSelectorSuccess', '.audio-alert-success', NULL, 'List of jQuery selectors that should trigger successs alert', 'free' ), --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -8566,6 +8566,7 @@ if ( CheckVersion($DBversion) ) { $dbh->do(q{ INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES + ( 'AudioAlertsCustom', '', NULL, 'Custom audio alert triggers in json associative array format', 'free' ), ( 'OverrideAudioAlertWarning', '', NULL, 'URL to an audio file to replace the default warning sound.', 'free' ), ( 'OverrideAudioAlertAction', '', NULL, 'URL to an audio file to replace the default "action required" sound.', 'free' ), ( 'OverrideAudioAlertSuccess', '', NULL, 'URL to an audio file to replace the default success sound.', 'free' ), @@ -8574,7 +8575,7 @@ if ( CheckVersion($DBversion) ) { ( 'AudioAlertSelectorSuccess', '.audio-alert-success', NULL, 'List of jQuery selectors that should trigger successs alert', 'free' ) }); - print "Upgrade to $DBversion done (Bug 11169 - Add OPACAcquisitionDetails syspref)\n"; + print "Upgrade to $DBversion done (Bug 11431 - Add additional sound options for warnings)\n"; SetVersion($DBversion); } --- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc @@ -1,4 +1,5 @@ [% USE Koha %] +[% USE String %] @@ -73,17 +74,31 @@ var AUDIO_ALERT_SELECTOR_ACTION = '[% Koha.Preference("AudioAlertSelectorAction") | replace( "'", "\\'" ) %]'; var AUDIO_ALERT_SELECTOR_WARNING = '[% Koha.Preference("AudioAlertSelectorWarning") | replace( "'", "\\'" ) %]'; var AUDIO_ALERT_SELECTOR_SUCCESS = '[% Koha.Preference("AudioAlertSelectorSuccess") | replace( "'", "\\'" ) %]'; + var AUDIO_ALERT_SELECTOR_CUSTOM = JSON.parse( '{ [% String.new( Koha.Preference("AudioAlertsCustom") ).collapse | replace( "'", "\\'" ) %] }' ); //]]> $( document ).ready(function() { - if ( $( AUDIO_ALERT_SELECTOR_ACTION ).length ) { - playSoundAction(); + var no_sound_played = true; + if ( Object.keys(AUDIO_ALERT_SELECTOR_CUSTOM) ) { + for ( var k in AUDIO_ALERT_SELECTOR_CUSTOM ) { + if ( $(k).length ) { + playSound( AUDIO_ALERT_SELECTOR_CUSTOM[k] ); + no_sound_played = false; + break; + } + } } - else if ( $( AUDIO_ALERT_SELECTOR_WARNING ).length ) { - playSoundWarning(); - } - else if ( $( AUDIO_ALERT_SELECTOR_SUCCESS ).length ) { - playSoundSuccess(); + + if ( no_sound_played ) { + if ( $( AUDIO_ALERT_SELECTOR_ACTION ).length ) { + playSoundAction(); + } + else if ( $( AUDIO_ALERT_SELECTOR_WARNING ).length ) { + playSoundWarning(); + } + else if ( $( AUDIO_ALERT_SELECTOR_SUCCESS ).length ) { + playSoundSuccess(); + } } }); --- a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js +++ a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js @@ -123,7 +123,7 @@ function playSound( sound ) { if ( ! ( sound.charAt(4) == ':' && sound.charAt(5) == '/' && sound.charAt(6) == '/' ) ) { sound = AUDIO_ALERT_PATH + sound; } - document.getElementById("audio-alert").innerHTML = ""; + document.getElementById("audio-alert").innerHTML = ''; } function playSoundWarning() { --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -656,3 +656,22 @@ Circulation: - pref: AudioAlertSelectorSuccess class: url - (This should be a list of jQuery selectors, separated by commas) + - + - Use the following jQuery selectors to trigger the assigned sounds. + - pref: AudioAlertsCustom + type: textarea + class: code + - This should be a list of jQuery selectors, separated by commas, with the sound file name or url afterword, demarcated by ':' + -
+ - 'For example:' + -
+ - '".class1 .class2": "IM_notification.ogg",' + -
+ - '".class1 #id1": "http://domain.com/path/to/sound2.mp3"' + -
+ - would play Koha's internal IM_notification.ogg if any elements with classes of class1 or class2 are found on the page, + - and sound2.mp3 would play if any element with both the id "id1" and class "class1". + -
+ - The priority is from top to bottom. The sound that matches first will be played. + -
+ - If no match is found, Koha will fall back to the system preferences for the alert, action, and warning sounds. --