Skip to content

Commit

Permalink
Bug 25727: Do not open options on clear
Browse files Browse the repository at this point in the history
We want to restore the previous behaviour and keep the options closed when
clear is clicked

select2/select2#3320 (comment)

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
  • Loading branch information
joubu committed Aug 24, 2020
1 parent 18139a8 commit 46e6df4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
12 changes: 12 additions & 0 deletions koha-tmpl/intranet-tmpl/prog/en/includes/select2.inc
Expand Up @@ -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 -->
Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down
Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down
Expand Up @@ -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 %]
Expand Down
Expand Up @@ -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>
Expand Down
1 change: 0 additions & 1 deletion koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js
Expand Up @@ -69,7 +69,6 @@ $(document).ready(function(){
multiCopyControl.toggle();
});

$('.subfield_line select').select2();
});

function Check(f) {
Expand Down

0 comments on commit 46e6df4

Please sign in to comment.