Bug 25727: Do not open options on clear

We want to restore the previous behaviour and keep the options closed when
clear is clicked

https://github.com/select2/select2/issues/3320#issuecomment-621662039

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2020-08-17 12:58:10 +00:00
parent 18139a8d4a
commit 46e6df4d22
6 changed files with 17 additions and 16 deletions

View File

@ -31,5 +31,17 @@
removeAllItems:function(){return _("Remove all items")},
removeItem:function(){return _("Remove item")}
});
$(document).ready(function(){
$(".select2").select2();
$(".select2").on("select2:clear", function (evt) {
$(this).on("select2:opening.cancelOpen", function (evt) {
evt.preventDefault();
$(this).off("select2:opening.cancelOpen");
});
});
});
</script>
<!-- / select2.inc -->

View File

@ -168,11 +168,6 @@ function confirmnotdup(redirect){
[% Asset.css("css/addbiblio.css") | $raw %]
[% INCLUDE 'select2.inc' %]
<script>
$(document).ready(function() {
$('.subfield_line select').select2();
});
</script>
</head>
<body id="auth_authorities" class="auth">
@ -375,7 +370,7 @@ function confirmnotdup(redirect){
[% SET mv = subfield_loo.marc_value %]
[% IF ( mv.type == 'select' ) %]
<select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor" id="[%- mv.id | html -%]">
<select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
[% FOREACH aval IN mv.values %]
[% IF aval == mv.default %]
<option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>

View File

@ -483,11 +483,6 @@
[% Asset.css("css/addbiblio.css") | $raw %]
[% INCLUDE 'select2.inc' %]
<script>
$(document).ready(function() {
$('.subfield_line select').select2();
});
</script>
</head>
<body id="cat_addbiblio" class="cat">
@ -852,7 +847,7 @@
[% ELSIF ( mv.type == 'textarea' ) %]
<textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1">[%- mv.value | html -%]</textarea>
[% ELSIF ( mv.type == 'select' ) %]
<select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor" id="[%- mv.id | html -%]">
<select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
[% FOREACH aval IN mv.values %]
[% IF aval == mv.default %]
<option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>

View File

@ -158,9 +158,9 @@
<input type="hidden" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]">
[% ELSIF ( mv.type == 'select' ) %]
[% IF ( mv.readonly || ite.IS_RETURN_CLAIM ) %]
<select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled">
<select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor select2" readonly="readonly" disabled="disabled">
[% ELSE %]
<select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor">
<select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor select2">
[% END %]
[% FOREACH aval IN mv.values %]
[% IF aval == mv.default %]

View File

@ -234,7 +234,7 @@ $(document).ready(function() {
<label>[% iteminformatio.subfield | html %] - [% iteminformatio.marc_lib | $raw %]</label>
[% END %]
[% IF ( iteminformatio.marc_value.type == 'select' ) %]
<select name="field_value" size="1">
<select name="field_value" size="1" class="select2">
[% FOREACH value IN iteminformatio.marc_value.values %]
[% IF ( value == iteminformatio.marc_value.default ) %]
<option value="[% value | html %]" selected="selected">[% iteminformatio.marc_value.labels.$value | html %]</option>

View File

@ -69,7 +69,6 @@ $(document).ready(function(){
multiCopyControl.toggle();
});
$('.subfield_line select').select2();
});
function Check(f) {