From fdc176c361f154eaf5f47481709abd7da8b4a623 Mon Sep 17 00:00:00 2001 From: Kyle M Hall <kyle@bywatersolutions.com> Date: Thu, 19 Jun 2014 08:12:45 -0400 Subject: [PATCH] [SIGNED OFF] Bug 11431 [1] - Replace existing system with no change in functionality This patch set adds the ability to select which sounds are used for Koha's audio alerts, and which elements trigger those audio alerts. Test Plan: 1) Apply this patch set 2) Run updatedatabase.pl 3) Enable the AudioAlerts system preference 4) Test existing sounds 5) Set the various OverrideAudioAlert preferences to different sounds 6) Retest, verify new sounds play 7) Add/remove selectors from the AudioAlertSelector system preferences 8) Observe the difference in audio alert behavior based on your selections Signed-off-by: Nick Clemens <nick@quecheelibrary.org> --- .../prog/en/includes/doc-head-close.inc | 51 +++++++++++++++----- .../prog/en/includes/intranet-bottom.inc | 1 + koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js | 17 +++++++ .../prog/en/modules/circ/circulation.tt | 13 ++--- .../intranet-tmpl/prog/en/modules/circ/returns.tt | 41 +++------------- 5 files changed, 68 insertions(+), 55 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc index f6269de..d9f9171 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc @@ -1,13 +1,13 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon %][% ELSE %][% interface %]/[% theme %]/img/favicon.ico[% END %]" type="image/x-icon" /> + <link rel="stylesheet" type="text/css" href="[% interface %]/lib/jquery/jquery-ui.css" /> <link rel="stylesheet" type="text/css" href="[% interface %]/lib/bootstrap/bootstrap.min.css" /> <link rel="stylesheet" type="text/css" media="print" href="[% themelang %]/css/print.css" /> [% INCLUDE intranetstylesheet.inc %] -[% IF ( bidi ) %] - <link rel="stylesheet" type="text/css" href="[% themelang %]/css/right-to-left.css" /> -[% END %] +[% IF ( bidi ) %]<link rel="stylesheet" type="text/css" href="[% themelang %]/css/right-to-left.css" />[% END %] [% IF ( IntranetUserCSS ) %]<style type="text/css">[% IntranetUserCSS %]</style>[% END %] + <script type="text/javascript" src="[% interface %]/lib/jquery/jquery.js"></script> <script type="text/javascript" src="[% interface %]/lib/jquery/jquery-ui.js"></script> <script type="text/javascript" src="[% interface %]/lib/shortcut/shortcut.js"></script> @@ -22,14 +22,17 @@ <!-- koha core js --> <script type="text/javascript" src="[% themelang %]/js/staff-global.js"></script> + [% INCLUDE 'validator-strings.inc' %] + [% IF ( intranetuserjs ) %] <script type="text/javascript"> - //<![CDATA[ - [% intranetuserjs %] - //]]> + //<![CDATA[ + [% intranetuserjs %] + //]]> </script> [% END %] + [% IF ( virtualshelves || intranetbookbag ) %] <script type="text/javascript"> //<![CDATA[ @@ -46,13 +49,35 @@ var MSG_NON_RESERVES_SELECTED = _("One or more selected items cannot be reserved."); //]]> </script> -<script type="text/javascript" src="[% themelang %]/js/basket.js"></script> + + <script type="text/javascript" src="[% themelang %]/js/basket.js"></script> [% END %] + [% IF LocalCoverImages %] -<script type="text/javascript" src="[% themelang %]/js/localcovers.js"></script> -<script type="text/javascript"> -//<![CDATA[ -var NO_LOCAL_JACKET = _("No cover image available"); -//]]> -</script> + <script type="text/javascript" src="[% themelang %]/js/localcovers.js"></script> + <script type="text/javascript"> + //<![CDATA[ + var NO_LOCAL_JACKET = _("No cover image available"); + //]]> + </script> +[% END %] + +[% IF soundon %] + <script type="text/javascript"> + //<![CDATA[ + var TMPL_SOUND_PATH = "[% interface %]/[% theme %]/sound/"; + //]]> + + $( document ).ready(function() { + if ( $(".audio-alert-action").length ) { + playSoundAction(); + } + else if ( $(".audio-alert-warning").length ) { + playSoundWarning(); + } + else if ( $(".audio-alert-success").length ) { + playSoundSuccess(); + } + }); + </script> [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc index d937656..f9103ce 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc @@ -65,5 +65,6 @@ </div> [% END %] [% END %] + <span id="audio-alert"></span> </body> </html> diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js index fa75b44..bfd8e1e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js @@ -122,3 +122,20 @@ function toUC(f) { function confirmDelete(message) { return (confirm(message) ? true : false); } + +function playSound( sound ) { + sound = TMPL_SOUND_PATH + sound; + document.getElementById("audio-alert").innerHTML = "<embed src='" + sound + "' hidden='true' autostart='true' loop='false' />"; +} + +function playSoundWarning() { + playSound( 'critical.ogg' ); +} + +function playSoundAction() { + playSound( 'opening.ogg' ); +} + +function playSoundSuccess() { + playSound( 'beep.ogg' ); +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 9734c0f..ca24508 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -143,7 +143,7 @@ $(document).ready(function() { [% IF ( NEEDSCONFIRMATION ) %] <div class="yui-g"> -<div id="circ_needsconfirmation" class="dialog alert"> +<div id="circ_needsconfirmation" class="dialog alert audio-alert-action"> [% IF CAN_user_circulate_force_checkout %] <h3>Please confirm checkout</h3> [% ELSE %] @@ -308,12 +308,8 @@ $(document).ready(function() { [% IF ( IMPOSSIBLE ) %] -[% IF ( soundon ) %] -<audio src="[% interface %]/[% theme %]/sound/critical.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio> -[% END %] - <div class="yui-g"> -<div id="circ_impossible" class="dialog alert"> +<div id="circ_impossible" class="dialog alert audio-alert-warning"> <!-- RESULT OF ISSUING REQUEST --> <ul> [% IF ( STATS ) %] @@ -416,11 +412,10 @@ $(document).ready(function() { </div></div> [% ELSE %] -[% IF ( soundon ) %] -<audio src="[% interface %]/[% theme %]/sound/beep.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio> -[% END %] [% END %] <!-- /impossible --> +<span class="audio-alert-success"></span> + [% IF ( issued ) %] <p>Item checked out</p> [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index 068f710..363f6c1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -89,6 +89,7 @@ $(document).ready(function () { </script> </head> <body id="circ_returns" class="circ"> +<span class="audio-alert-success"></span> [% INCLUDE 'header.inc' %] [% INCLUDE 'checkin-search.inc' %] @@ -172,11 +173,7 @@ $(document).ready(function () { [% IF ( waiting ) %] <!-- waiting --> -[% IF ( soundon ) %] -<audio src="[% interface %]/[% theme %]/sound/ending.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio> -[% END %] - -<div id="hold-found1" class="dialog message"> + <div id="hold-found1" class="dialog message audio-alert-action"> <h3>Hold found (item is already waiting): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% itembiblionumber %]">[% title |html %]</a></h3> [% IF ( reservenotes ) %]<h4>Notes: [% reservenotes %]</h4>[% END %] <h4>Hold for:</h4> @@ -215,10 +212,7 @@ $(document).ready(function () { [% IF ( diffbranch ) %] <!-- diffbranch --> - [% IF ( soundon ) %] - <audio src="[% interface %]/[% theme %]/sound/opening.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio> - [% END %] - <div id="transfer-needed" class="dialog message"> + <div id="transfer-needed" class="dialog message audio-alert-action"> <h3>Hold needing transfer found: <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% itembiblionumber %]">[% title |html %]</a></h3> <h4>Hold for: </h4> <ul> @@ -255,20 +249,14 @@ $(document).ready(function () { [% IF ( transfer ) %] <!-- transfer: item with no reservation, must be returned to its home library --> - <div id="return1" class="dialog message"> + <div id="return1" class="dialog message audio-alert-action"> <h3>Please return <a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&biblionumber=[% itembiblionumber %]">[% title or "item" |html %]</a> to [% homebranchname %]<br/>( <a href="#" onclick="Dopop('transfer-slip.pl?transferitem=[% itemnumber %]&branchcode=[% homebranch %]&op=slip'); return true;">Print slip</a> )</h3> </div> - [% IF ( soundon ) %] - <audio src="[% interface %]/[% theme %]/sound/opening.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio> - [% END %] [% END %] [% IF ( needstransfer ) %] <!-- needstransfer --> - [% IF ( soundon ) %] - <audio src="[% interface %]/[% theme %]/sound/opening.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio> - [% END %] - <div id="item-transfer" class="dialog message"><h3> This item needs to be transferred to [% homebranchname %]</h3> + <div id="item-transfer" class="dialog message audio-alert-action"><h3> This item needs to be transferred to [% homebranchname %]</h3> Transfer now?<br /> <form method="post" action="returns.pl" name="mainform" id="mainform"> [% IF itemnumber %] @@ -291,10 +279,7 @@ $(document).ready(function () { [% IF ( diffbranch ) %] <!-- diffbranch --> - [% IF ( soundon ) %] - <audio src="[% interface %]/[% theme %]/sound/opening.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio> - [% END %] - <h3>Item consigned:</h3> + <h3 class="audio-alert-action">Item consigned:</h3> <table> <caption><a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&biblionumber=[% itembiblionumber %]">[% title |html %]</a></caption> <tr> @@ -319,11 +304,7 @@ $(document).ready(function () { [% IF ( reserved ) %] <!-- reserved --> - [% IF ( soundon ) %] - <audio src="[% interface %]/[% theme %]/sound/opening.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio> - [% END %] - - <div id="hold-found2" class="dialog message"> + <div id="hold-found2" class="dialog message audio-alert-action"> <h3>Hold found: <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% itembiblionumber %]">[% title |html %]</a></h3> [% IF ( reservenotes ) %]<h4>Notes: [% reservenotes %]</h4>[% END %] <h5>Hold for:</h5> @@ -369,7 +350,7 @@ $(document).ready(function () { [% END %] [% IF ( errmsgloop ) %] - <div class="dialog alert"> + <div class="dialog alert audio-alert-warning"> <h3>Check in message</h3> [% FOREACH errmsgloo IN errmsgloop %] [% IF ( errmsgloo.NotForLoanStatusUpdated ) %] @@ -424,13 +405,7 @@ $(document).ready(function () { <p class="problem"><b>Reminder: </b>Patron was earlier restricted until [% errmsgloo.prevdebarred | $KohaDates %]</p> [% END %] [% END %] -[% IF ( soundon ) %] -<audio src="[% interface %]/[% theme %]/sound/critical.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio> -[% END %] [% ELSE %] -[% IF ( soundon ) %] -<audio src="[% interface %]/[% theme %]/sound/beep.ogg" autoplay="autoplay" autobuffer="autobuffer"></audio> -[% END %] [% END %] </div> -- 1.7.10.4