From a55efd15c5db3538440df9832a91a1ff3974ac72 Mon Sep 17 00:00:00 2001 From: Owen Leonard <oleonard@myacpl.org> Date: Thu, 10 Dec 2020 11:48:43 +0000 Subject: [PATCH] Bug 27124: JS error "select2Width is not defined" This patch changes the default width paramter passed to the select2 plugin. This allows the basic MARC editor's Select2 widgets to be styled differently than on other pages. To test, apply the patch and view various pages where the select2 plugin is used: - Basic MARC editor - Items edit - Batch item edit - Authority editor In each case check that the Select2 plugin works correctly to style fields like collection code and home library. On the basic MARC editor page these <select>s should have a width that adjusts as the browser window changes. On other pages the width should be fixed. Check the browser console and confirm that there are no JavaScript errors. Update: Thanks to Julian for the suggested optimization --- koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt | 4 ++-- koha-tmpl/intranet-tmpl/prog/js/select2.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index 38b3ab8ca8..32aeac779d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -5,11 +5,11 @@ <title>Koha › Cataloging › [% IF ( biblionumber ) %]Editing [% title | html %] (Record number [% biblionumber | html %])[% ELSE %]Add MARC record[% END %]</title> [% INCLUDE 'doc-head-close.inc' %] [% Asset.js("lib/hc-sticky.js") | $raw %] +[% INCLUDE 'select2.inc' %] <script> var CAN_user_parameters_manage_auth_values = "[% CAN_user_parameters_manage_auth_values | html %]"; - var select2Width = "100%"; + $.fn.select2.defaults.set("width", "100%" ); </script> -[% INCLUDE 'select2.inc' %] [% Asset.js("js/cataloging.js") | $raw %] [% Asset.js("js/browser.js") | $raw %] <script> diff --git a/koha-tmpl/intranet-tmpl/prog/js/select2.js b/koha-tmpl/intranet-tmpl/prog/js/select2.js index a5c07fe12a..0b68c3fd28 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/select2.js +++ b/koha-tmpl/intranet-tmpl/prog/js/select2.js @@ -1,7 +1,7 @@ /* global __ */ $.fn.select2.defaults.set("allowClear", true); $.fn.select2.defaults.set("placeholder", ""); -$.fn.select2.defaults.set("width", select2Width || "element" ); +$.fn.select2.defaults.set("width", "element" ); // Internationalization $.fn.select2.defaults.set("language", { -- 2.11.0