From cfbeb31918e92e3c66025b07eeadfdadf2d09fb7 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] 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 --- .../prog/en/includes/doc-head-close.inc | 79 +++++++++++++------- .../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, 82 insertions(+), 69 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 11f6f38..25d14e2 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,37 +22,62 @@ <!-- 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[ - var MSG_BASKET_EMPTY = _("Your cart is currently empty"); - var MSG_RECORD_IN_BASKET = _("This item is already in your cart"); - var MSG_RECORD_ADDED = _("This item has been added to your cart"); - var MSG_NRECORDS_ADDED = _(" item(s) added to your cart"); - var MSG_NRECORDS_IN_BASKET = _("already in your cart"); - var MSG_NO_RECORD_SELECTED = _("No item was selected"); - var MSG_NO_RECORD_ADDED = _("No item was added to your cart"); - var MSG_CONFIRM_DEL_BASKET = _("Are you sure you want to empty your cart?"); - var MSG_CONFIRM_DEL_RECORDS = _("Are you sure you want to remove the selected items?"); - var MSG_IN_YOUR_CART = _("Items in your cart: "); - var MSG_NON_RESERVES_SELECTED = _("One or more selected items cannot be reserved."); - //]]> + <script type="text/javascript"> + //<![CDATA[ + var MSG_BASKET_EMPTY = _("Your cart is currently empty"); + var MSG_RECORD_IN_BASKET = _("This item is already in your cart"); + var MSG_RECORD_ADDED = _("This item has been added to your cart"); + var MSG_NRECORDS_ADDED = _(" item(s) added to your cart"); + var MSG_NRECORDS_IN_BASKET = _("already in your cart"); + var MSG_NO_RECORD_SELECTED = _("No item was selected"); + var MSG_NO_RECORD_ADDED = _("No item was added to your cart"); + var MSG_CONFIRM_DEL_BASKET = _("Are you sure you want to empty your cart?"); + var MSG_CONFIRM_DEL_RECORDS = _("Are you sure you want to remove the selected items?"); + var MSG_IN_YOUR_CART = _("Items in your cart: "); + 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 442a7bb..a71642b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc @@ -52,5 +52,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 c553a6d..97fdd7a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js @@ -117,3 +117,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 6805126..12ecb20 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -186,7 +186,7 @@ var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); [% 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 %] @@ -351,12 +351,8 @@ var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); [% 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 ) %] @@ -459,11 +455,10 @@ var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); </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 72f9ee3..09cab8c 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.2.5