Bug 18545: Remove use of onclick from OPAC cart
authorAleisha Amohia <aleishaamohia@hotmail.com>
Fri, 5 May 2017 03:58:49 +0000 (03:58 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 24 Jul 2017 17:12:33 +0000 (14:12 -0300)
To test:
1) Apply patch and add one or more items to your cart
2) Confirm that clicking the following things still works as expected:
 - more details
 - brief display
 - send
 - download
 - print
 - select all
 - clear all
 - selecting by clicking checkbox
 - remove title
 - add title to list
 - place hold
 - add tag
 - empty and close

Sponsored-by: Catalyst IT
Followed test plan, works as expected. Resolves issue with two
print dialogues from Bug 18544.
Signed-off-by: Marc VĂ©ron <veron@veron.ch>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt

index fa7e496..d1b137b 100644 (file)
                         [% UNLESS ( print_basket ) %]
                             <div id="toolbar" class="toolbar">
                                 [% IF ( verbose ) %]
-                                    <a href="opac-basket.pl" class="brief" onclick="showLess(); return false;">Brief display</a>
+                                    <a href="opac-basket.pl" class="brief">Brief display</a>
                                 [% ELSE %]
-                                    <a href="opac-basket.pl" class="detail" onclick="showMore(); return false;">More details</a>
+                                    <a href="opac-basket.pl" class="detail">More details</a>
                                 [% END %]
                                 [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
-                                    <a class="send" href="opac-basket.pl" onclick="sendBasket(); return false;">Send</a>
+                                    <a class="send" href="opac-basket.pl">Send</a>
                                 [% END %]
-                                <a class="download" href="opac-basket.pl" onclick="downloadBasket(); return false;">Download</a>
-                                <a class="print-large" href="opac-basket.pl" onclick="printBasket(); return false;">Print</a>
-                                <a class="empty" href="opac-basket.pl" onclick="delBasket(); return false;">Empty and close</a>
+                                <a class="download" href="opac-basket.pl">Download</a>
+                                <a class="print-large" href="opac-basket.pl">Print</a>
+                                <a class="empty" href="opac-basket.pl">Empty and close</a>
                                 <a class="hide close" href="opac-basket.pl">Hide window</a>
                             </div>
 
                                 <span class="sep">|</span>
                                 <span class="links" id="tag_hides">
                                     <span id="selections">Select titles to: </span>
-                                    <a href="#" class="deleteshelf disabled" onclick="delSelRecords(); return false;">Remove</a>
+                                    <a href="#" class="deleteshelf disabled">Remove</a>
                                     [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) %]
                                         [% IF ( ( Koha.Preference( 'virtualshelves' ) == 1 ) && loggedinusername ) %]
-                                            <a href="#" class="newshelf disabled" onclick="addSelToShelf(); return false;">Add to a list</a>
+                                            <a href="#" class="newshelf disabled">Add to a list</a>
                                         [% END %]
                                         [% IF ( Koha.Preference( 'RequestOnOpac' ) == 1 ) %]
-                                            <a href="#" class="hold disabled" onclick="holdSel(); return false;">Place hold</a>
+                                            <a href="#" class="hold disabled">Place hold</a>
                                         [% END %]
                                         [% IF ( TagsInputEnabled && loggedinusername ) %]
-                                            <a href="#" id="tagsel_tag" class="disabled" onclick="tagSelected(); return false;">Tag</a>
+                                            <a href="#" id="tagsel_tag" class="disabled">Tag</a>
                                         [% END %]
                                     [% END # / IF opacuserlogin %]
                                 </span>
@@ -54,8 +54,8 @@
                                 <span id="tagsel_form" style="display:none">
                                     <label for="tagsel_new">New tag:</label>
                                     <input name="tagsel_new" id="tagsel_new" maxlength="100" />
-                                    <input id="tagsel_button" name="tagsel_button" class="input tagsel_button" title="Add" type="submit" value="Add" onclick="tagAdded(); return false;" />
-                                    <a href="#" id="tagsel_cancel" onclick="tagCanceled(); return false;">Cancel</a>
+                                    <input id="tagsel_button" name="tagsel_button" class="input tagsel_button" title="Add" type="submit" value="Add">
+                                    <a href="#" id="tagsel_cancel">Cancel</a>
                                 </span>
                                 [% END %]
                             </div>
@@ -70,7 +70,7 @@
                                                 [% IF ( BIBLIO_RESULT.subtitle ) %] [% FOREACH subtitl IN BIBLIO_RESULT.subtitle %] [% subtitl.subfield |html %] [% END %][% END %]
                                                 [% IF ( BIBLIO_RESULT.author ) %] [% BIBLIO_RESULT.author |html %][% END %]
                                         [% ELSE %]
-                                                <input type="checkbox" class="cb" value="[% BIBLIO_RESULT.biblionumber %]" name="bib[% BIBLIO_RESULT.biblionumber %]" id="bib[% BIBLIO_RESULT.biblionumber %]" onclick="selRecord(value,checked)" />
+                                                <input type="checkbox" class="cb" value="[% BIBLIO_RESULT.biblionumber %]" name="bib[% BIBLIO_RESULT.biblionumber %]" id="bib[% BIBLIO_RESULT.biblionumber %]">
                                                 [% BIBLIO_RESULT.title |html %]
                                                 [% IF ( BIBLIO_RESULT.subtitle ) %] [% FOREACH subtitl IN BIBLIO_RESULT.subtitle %] [% subtitl.subfield |html %] [% END %][% END %]
                                                 [% IF ( BIBLIO_RESULT.author ) %] [% BIBLIO_RESULT.author |html %][% END %]
                                         <tr>
                                             [% UNLESS ( print_basket ) %]
                                                 <td>
-                                                <input type="checkbox" class="cb" value="[% BIBLIO_RESULT.biblionumber %]" name="bib[% BIBLIO_RESULT.biblionumber %]" id="bib[% BIBLIO_RESULT.biblionumber %]" onclick="selRecord(value,checked);" />
+                                                <input type="checkbox" class="cb" value="[% BIBLIO_RESULT.biblionumber %]" name="bib[% BIBLIO_RESULT.biblionumber %]" id="bib[% BIBLIO_RESULT.biblionumber %]">
                                                 </td>
                                             [% END %]
                                             <td>
             [% END # / TagsInputEnabled && loggedinusername %]
 
             $(document).ready(function(){
+                $(".brief").click(function(){
+                    showLess();
+                    return false;
+                });
+
+                $(".detail").click(function(){
+                    showMore();
+                    return false;
+                });
+
+                $(".send").click(function(){
+                    sendBasket();
+                    return false;
+                });
+
+                $(".download").click(function(){
+                    downloadBasket();
+                    return false;
+                });
+
+                $(".print-large").click(function(){
+                    e.preventDefault();
+                    printBasket();
+                    return false;
+                });
+
+                $(".empty").click(function(){
+                    delBasket();
+                    return false;
+                });
+
+                $(".deleteshelf").click(function(){
+                    delSelRecords();
+                    return false;
+                });
+
+                $(".newshelf").click(function(){
+                    addSelToShelf();
+                    return false;
+                });
+
+                $(".hold").click(function(){
+                    holdSel();
+                    return false;
+                });
+
+                $("#tagsel_tag").click(function(){
+                    tagSelected();
+                    return false;
+                });
+
+                $("#tagsel_button").click(function(){
+                    tagAdded();
+                    return false;
+                });
+
+                $("#tagsel_cancel").click(function(){
+                    tagCanceled();
+                    return false;
+                });
+
                 $("#CheckAll").click(function(){
                     var checked = [];
                     $(".checkboxed").checkCheckboxes("*", true).each(
                     ]
                 }));
 
-                $(".cb").click(function(){
+                $(".cb").change(function(){
+                    if ($(this).prop("checked")){
+                        selRecord($(this).val(), true);
+                    }
                     enableCheckboxActions();
+                    return false;
                 });
-                enableCheckboxActions();
             });
 
             function enableCheckboxActions(){