Changed select2 search field for a more convenient

This commit is contained in:
Nikita Khromov
2021-06-02 14:02:12 +03:00
parent bafc970c60
commit da0694dc80
2 changed files with 28 additions and 1 deletions

View File

@ -48,3 +48,6 @@ if (document.currentScript && document.currentScript.src) {
}
// escape and unescape func
!function(e){function n(n){function t(e){return n[e]}var e="(?:"+Object.keys(n).join("|")+")",u=RegExp(e),c=RegExp(e,"g");return function(e){return e=null==e?"":""+e,u.test(e)?e.replace(c,t):e}}escape=n({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"}),unescape=n({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'","&#x60;":"`"}),e.escape=escape,e.unescape=unescape}(window);
// select2 fix search field
var select2_amd,select2_defaults;"undefined"!=typeof jQuery&&void 0!==$.fn.select2&&(select2_amd=$.fn.select2.amd,select2_defaults=$.fn.select2.defaults,select2_amd.define("SearchableSingleSelection",["select2/utils","select2/selection/single","select2/selection/eventRelay","select2/dropdown/search"],function(e,t,n,s){var l=e.Decorate(t,s);(l=e.Decorate(l,n)).prototype.render=function(){var e=s.prototype.render.call(this,t.prototype.render);return this.$searchContainer.hide(),this.$element.siblings(".select2").find(".selection").prepend(this.$searchContainer),e};var r=l.prototype.bind;return l.prototype.bind=function(e){var t=this;r.apply(this,arguments),e.on("open",function(){t.$selection.hide(),t.$searchContainer.show()}),e.on("close",function(){t.$searchContainer.hide(),t.$selection.show()})},l}),select2_amd.define("UnsearchableDropdown",["select2/utils","select2/dropdown","select2/dropdown/attachBody","select2/dropdown/closeOnSelect"],function(e,t,n,s){n=e.Decorate(t,n);return n=e.Decorate(n,s)}),select2_amd.define("jquery.select2_",["jquery","jquery-mousewheel","./select2/core","./select2/defaults","./select2/utils"],function(r,e,c,t,o){var a;return null!=r.fn.select2&&(a=["open","close","destroy"],r.fn.select2=function(t){if((t=t||{}).selectionAdapter=r.fn.select2.amd.require("SearchableSingleSelection"),t.dropdownAdapter=r.fn.select2.amd.require("UnsearchableDropdown"),"object"==typeof t){this.each(function(){var e=r.extend(!0,{},t);new c(r(this),e)});var e=this.next().find(".select2-search.select2-search--dropdown"),n=this.next().find("span.selection").find(".select2-selection__arrow").clone();return r(n[0]).appendTo(e),this}if("string"!=typeof t)throw new Error("Invalid arguments for Select2: "+t);var s,l=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=o.GetData(this,"select2");null==e&&window.console&&console.error&&console.error("The select2('"+t+"') method was called on an element that is not using Select2."),s=e[t].apply(e,l)}),-1<r.inArray(t,a)?this:s}),null==r.fn.select2.defaults&&(r.fn.select2.defaults=t),c}),$.fn.select2.amd.require("jquery.select2_"),$.fn.select2.amd=select2_amd,$.fn.select2.defaults=select2_defaults);

View File

@ -363,6 +363,24 @@ a.aboutlink:active {
transition: transform 0.2s ease;
transform: rotate(-135deg) translate(1px,1px);
}
.select2-container--default .select2-search .select2-selection__arrow b {
width: 4px !important;
height: 4px !important;
margin: -1px 1px !important;
border: solid 1px #404040 !important;
border-bottom: none !important;
border-right: none !important;
background-image: none;
box-sizing: border-box;
transition: transform 0.2s ease;
transform: rotate(-135deg) translate(1px,1px);
left: 50%;
position: absolute;
top: 50%;
}
.select2-search--dropdown {
padding: 0px !important;
}
.select2-container--default.select2-container--open .select2-selection__arrow b{
transform: rotate(45deg);
@ -374,7 +392,13 @@ a.aboutlink:active {
border-radius: 2px;
font-size: 11px;
}
.select2-search.select2-search--dropdown .select2-selection__arrow {
height: 20px;
position: absolute;
top: 1px;
right: 1px;
width: 20px;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
background-color: #d8dadc !important;
}