Bug 34711: Remove use of onclick for opac-privacy.pl

This change removes the "onclick" attribute for the buttons
on opac-privacy.pl.

Note: The Javascript is placed in a separate file, which is
the preferred way for Javascript to be handled by
Content-Security-Policy

Test plan:
0. Apply the patch
1. Go to http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=OPACPrivacy
2. Set syspref to "Allow"
3. Go to http://localhost:8080/cgi-bin/koha/opac-privacy.pl
4. The confirmation modal appears and "OK" and "Cancel" buttons work as
   expected

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
David Cook 2023-09-05 04:58:52 +00:00 committed by Tomas Cohen Arazi
parent bc8a062001
commit c997fe863f
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 11 additions and 4 deletions

View file

@ -175,7 +175,7 @@
<td colspan=7>Immediately delete my checkout history. This action cannot be undone.</td>
<td colspan=1>
<fieldset class="action">
<input type="submit" value="Delete checkout history" form="opac-privacy-delete-checkouts" class="btn btn-danger btn-block" onclick="return confirmDelete(MSG_CONFIRM_AGAIN);" />
<input type="submit" value="Delete checkout history" form="opac-privacy-delete-checkouts" class="btn btn-danger btn-block privacy-confirm-delete" />
</fieldset>
</td>
</tr>
@ -183,7 +183,7 @@
<td colspan=7>Immediately delete my hold history. This action cannot be undone.</td>
<td colspan=1>
<fieldset class="action">
<input type="submit" value="Delete hold history" form="opac-privacy-delete-holds" class="btn btn-danger btn-block" onclick="return confirmDelete(MSG_CONFIRM_AGAIN);" />
<input type="submit" value="Delete hold history" form="opac-privacy-delete-holds" class="btn btn-danger btn-block privacy-confirm-delete" />
</fieldset>
</td>
</tr>
@ -191,7 +191,7 @@
<td colspan=7>Immediately delete my checkout history & my hold history. This action cannot be undone.</td>
<td colspan=1>
<fieldset class="action">
<input type="submit" value="Delete checkout and hold history" form="opac-privacy-delete-all" class="btn btn-danger btn-block" onclick="return confirmDelete(MSG_CONFIRM_AGAIN);" />
<input type="submit" value="Delete checkout and hold history" form="opac-privacy-delete-all" class="btn btn-danger btn-block privacy-confirm-delete" />
</fieldset>
</td>
</tr>
@ -208,4 +208,6 @@
</div> <!-- / .main -->
[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %][% END %]
[% BLOCK jsinclude %]
[% Asset.js('js/privacy.js') | $raw %]
[% END %]

View file

@ -0,0 +1,5 @@
$(document).ready(function(){
$('.privacy-confirm-delete').on('click',function(){
return confirmDelete(MSG_CONFIRM_AGAIN);
});
});