Bug 42128: Remove event attribute from admin-icon-selection.inc

This patch removes the "onmousedown" event attribute from
admin-icon-selection.inc, an include used in itemtypes.tt and
authorised_values.tt. I took this opportunity to create separate JS
files for both of those templates and added the event handler to the JS.

To test, apply the patch and go to Administration.

- Go to Item types and add or edit an item type.
  - In the icon selection section, select one of the built-in icons.
  - Switch to the "Remove image" tab.
  - Click the text input. The corresponding radio button should be
    selected.
- Go to Authorized values and perform the same test.

Sponsored-by: Athens County Public Libraries
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Owen Leonard 2026-03-18 11:30:30 -04:00 committed by Pedro Amorim
parent b83e2a6fe4
commit 25496bdc4f
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
5 changed files with 86 additions and 84 deletions

View File

@ -74,11 +74,11 @@
<label for="remote_image_check"> Remote image:</label>
[% IF image_location.match('^http') %]
<input type="radio" id="remote_image_check" name="image" value="remoteImage" checked="checked" />
<input type="text" name="remoteImage" size="48" maxlength="200" value="[% image_location | html %]" onmousedown="document.getElementById('remote_image_check').checked = true;" />
<input id="remoteimage" type="text" name="remoteImage" size="48" maxlength="200" value="[% image_location | html %]" />
<img src="[% image_location | html %]" alt="" />
[% ELSE %]
<input type="radio" id="remote_image_check" name="image" value="remoteImage" />
<input type="text" id="remoteImage" name="remoteImage" size="48" maxlength="200" value="" />
<input type="text" id="remoteimage" name="remoteImage" size="48" maxlength="200" value="" />
[% END %]
[% END %]
[% END # /tab_panels %]

View File

@ -403,53 +403,7 @@
[% Asset.js("js/admin-menu.js") | $raw %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'select2.inc' %]
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function () {
$("#categoriest").kohaTable({
order: [[0, "asc"]],
pagingType: "full",
});
if ($("#branches option:selected").length < 1) {
$("#branches option:first").attr("selected", "selected");
}
$(".delete").click(function () {
return confirm(_("Are you sure you want to delete this authorized value?"));
});
$("#category_search").change(function () {
$("#category").submit();
});
$("#delete_category").on("submit", function () {
return confirm(_("Are you sure you want to delete this authorized value category?"));
});
if ($("#icons .tab-pane.active").length < 1) {
$("#icons a:first").tab("show");
}
$("#Aform").submit(function () {
if ($("#authorised_value").length) {
if (!$("#authorised_value").get(0).checkValidity()) {
alert(_("Authorised value should be numeric."));
$("#authorised_value").focus();
return false;
}
}
return true;
});
if ($("#library_limitation").length > 0) {
$("#library_limitation")[0].style.minWidth = "450px";
$("#library_limitation").select2();
}
$("#remoteImage").on("mousedown", function () {
$("#remote_image_check").prop("checked", true);
});
});
</script>
[% Asset.js("js/pages/authorised_values.js") | $raw %]
[% END %]
[% BLOCK category_descriptions %]

View File

@ -554,41 +554,7 @@
table_settings['columns'].shift(); // Remove item type image column from configuration
[% END %]
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function () {
$("#table_item_type").kohaTable(
{
pagingType: "full",
},
table_settings
);
$("#itemtypeentry").validate({
rules: {
itemtype: { required: true },
description: { required: true },
rentalcharge: { number: true },
rentalcharge_hourly: { number: true },
defaultreplacecost: { number: true },
},
});
$("#itemtype").on("blur", function () {
toUC(this);
});
if ($("#icons .tab-pane.active").length < 1) {
$("#icons a:first").tab("show");
}
if ($("#library_limitation").length > 0) {
$("#library_limitation")[0].style.minWidth = "450px";
$("#library_limitation").select2();
}
$("#remoteImage").on("mousedown", function () {
$("#remote_image_check").prop("checked", true);
});
});
</script>
[% Asset.js("js/pages/itemtypes.js") | $raw %]
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]

View File

@ -0,0 +1,50 @@
$(document).ready(function () {
$("#categoriest").kohaTable({
order: [[0, "asc"]],
pagingType: "full",
});
if ($("#branches option:selected").length < 1) {
$("#branches option:first").attr("selected", "selected");
}
$(".delete").click(function () {
return confirm(
__("Are you sure you want to delete this authorized value?")
);
});
$("#category_search").change(function () {
$("#category").submit();
});
$("#delete_category").on("submit", function () {
return confirm(
__(
"Are you sure you want to delete this authorized value category?"
)
);
});
if ($("#icons .tab-pane.active").length < 1) {
$("#icons a:first").tab("show");
}
$("#Aform").submit(function () {
if ($("#authorised_value").length) {
if (!$("#authorised_value").get(0).checkValidity()) {
alert(__("Authorised value should be numeric."));
$("#authorised_value").focus();
return false;
}
}
return true;
});
if ($("#library_limitation").length > 0) {
$("#library_limitation")[0].style.minWidth = "450px";
$("#library_limitation").select2();
}
$("#remoteimage").on("mousedown", function () {
document.getElementById("remote_image_check").checked = true;
});
});

View File

@ -0,0 +1,32 @@
$(document).ready(function () {
$("#table_item_type").kohaTable(
{
pagingType: "full",
},
table_settings
);
$("#itemtypeentry").validate({
rules: {
itemtype: { required: true },
description: { required: true },
rentalcharge: { number: true },
rentalcharge_hourly: { number: true },
defaultreplacecost: { number: true },
},
});
$("#itemtype").on("blur", function () {
toUC(this);
});
if ($("#icons .tab-pane.active").length < 1) {
$("#icons a:first").tab("show");
}
if ($("#library_limitation").length > 0) {
$("#library_limitation")[0].style.minWidth = "450px";
$("#library_limitation").select2();
}
$("#remoteimage").on("mousedown", function () {
document.getElementById("remote_image_check").checked = true;
});
});