From da0694dc80149c13430161044566866314a638d4 Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Wed, 2 Jun 2021 14:02:12 +0300 Subject: [PATCH] Changed select2 search field for a more convenient --- sdkjs-plugins/v1/plugins-ui.js | 3 +++ sdkjs-plugins/v1/plugins.css | 26 +++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/sdkjs-plugins/v1/plugins-ui.js b/sdkjs-plugins/v1/plugins-ui.js index 5d8208ca..33fa0618 100644 --- a/sdkjs-plugins/v1/plugins-ui.js +++ b/sdkjs-plugins/v1/plugins-ui.js @@ -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({"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"}),unescape=n({"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"}),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