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
(function(a){a.widget("s2j.combobox",{options:{icon:false},_create:function(){this.wrapper=a("").addClass("s2j-combobox").insertAfter(this.element);this.element.hide();this._createAutocomplete();if(this.options.icon===true){this._createShowAllButton()}},_createAutocomplete:function(){var b=this.element.children(":selected"),c=b.val()?b.text():"";this.input=a("").appendTo(this.wrapper).val(c).attr("title","").addClass("s2j-combobox-input").autocomplete({delay:0,minLength:0,source:a.proxy(this,"_source")});this._on(this.input,{autocompleteselect:function(d,e){e.item.option.selected=true;this._trigger("select",d,{item:e.item.option});d.ui=e;if(this.options.onselecttopics){a.each(this.options.onselecttopics.split(","),function(f,g){select.publish(g,{item:e.item},d)})}},autocompletefocus:function(d,e){this._trigger("focus",d,{item:e.item});d.ui=e;if(this.options.onfocustopics){a.each(this.options.onfocustopics.split(","),function(f,g){select.publish(g,{item:e.item},d)})}},autocompletechange:function(e,f){this._removeIfInvalid(e,f);if(!f.item){var g=new RegExp("^"+a.ui.autocomplete.escapeRegex(a(this).val())+"$","i"),d=false;select.children("option").each(function(){if(this.value.match(g)){this.selected=d=true;return false}});if(!d){a(this).val("");select.val("");return false}}this._trigger("change",e,{item:f.item});e.ui=f;if(this.options.oncha){a.each(this.options.oncha.split(","),function(h,j){select.publish(j,{item:f.item},e)})}}})},_createShowAllButton:function(){var b=this.input,c=false;a("").attr("tabIndex",-1).appendTo(this.wrapper).button({icons:{primary:"ui-icon-triangle-1-s"},text:false}).removeClass("ui-corner-all").addClass("s2j-combobox-toggle ui-corner-right").mousedown(function(){c=b.autocomplete("widget").is(":visible")}).click(function(){b.focus();if(c){return}b.autocomplete("search","")})},_source:function(c,b){var d=new RegExp(a.ui.autocomplete.escapeRegex(c.term),"i");b(this.element.children("option").map(function(){var e=a(this).text();if(this.value&&(!c.term||d.test(e))){return{label:e,value:e,option:this}}}))},_removeIfInvalid:function(d,f){if(f.item){return}var e=this.input.val(),b=e.toLowerCase(),c=false;this.element.children("option").each(function(){if(a(this).text().toLowerCase()===b){this.selected=c=true;return false}});if(c){return}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