All Downloads are FREE. Search and download functionalities are using the official Maven repository.

template.js.plugins.jquery.combobox.min.js Maven / Gradle / Ivy

There is a newer version: 5.0.5
Show newest version
'use strict';(function(c){c.widget("s2j.combobox",{options:{icon:!1},_create:function(){this.wrapper=c("\x3cspan\x3e").addClass("s2j-combobox").insertAfter(this.element);this.element.hide();this._createAutocomplete();!0===this.options.icon&&this._createShowAllButton()},_createAutocomplete:function(){var e=this.element,b=this.element.children(":selected"),b=b.val()?b.text():"";this.input=c("\x3cinput\x3e").appendTo(this.wrapper).val(b).attr("title","").addClass("s2j-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left").autocomplete({delay:0,
minLength:0,source:c.proxy(this,"_source")}).tooltip({classes:{"ui-tooltip":"ui-state-highlight"}});this._on(this.input,{autocompleteselect:function(d,a){a.item.option.selected=!0;this._trigger("select",d,{item:a.item.option});d.ui=a;this.options.onselecttopics&&c.each(this.options.onselecttopics.split(","),function(c,b){e.publish(b,{item:a.item},d)})},autocompletefocus:function(d,a){this._trigger("focus",d,{item:a.item});d.ui=a;this.options.onfocustopics&&c.each(this.options.onfocustopics.split(","),
function(c,b){e.publish(b,{item:a.item},d)})},autocompletechange:function(d,a){this._removeIfInvalid(d,a);if(!a.item){var b=new RegExp("^"+c.ui.autocomplete.escapeRegex(this.input.val())+"$","i"),f=!1;e.children("option").each(function(){if(this.value.match(b))return this.selected=f=!0,!1});if(!f)return c(this).val(""),e.val(""),!1}this._trigger("change",d,{item:a.item});d.ui=a;this.options.oncha&&c.each(this.options.oncha.split(","),function(b,c){e.publish(c,{item:a.item},d)})}})},_createShowAllButton:function(){var e=
this.input,b=!1;c("\x3ca\x3e").attr("tabIndex",-1).appendTo(this.wrapper).button({icons:{primary:"ui-icon-triangle-1-s"},text:!1}).removeClass("ui-corner-all").addClass("s2j-combobox-toggle ui-corner-right").mousedown(function(){b=e.autocomplete("widget").is(":visible")}).click(function(){e.focus();b||e.autocomplete("search","")})},_source:function(e,b){var d=new RegExp(c.ui.autocomplete.escapeRegex(e.term),"i");b(this.element.children("option").map(function(){var a=c(this).text();if(this.value&&
(!e.term||d.test(a)))return{label:a,value:a,option:this}}))},_removeIfInvalid:function(e,b){if(!b.item){var d=this.input.val().toLowerCase(),a=!1;this.element.children("option").each(function(){if(c(this).text().toLowerCase()===d)return this.selected=a=!0,!1});a||(this.input.val(""),this.element.val(""),this.input.data("ui-autocomplete").term="")}},_destroy:function(){this.wrapper.remove();this.element.show()}})})(jQuery);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy