1 (function( $ ) { 2 $.widget( "custom.combobox", { 3 _create: function() { 4 this.wrapper = $( "<span>" ) 5 .addClass( "custom-combobox" ) 6 .insertAfter( this.element ); 7 this.element.hide(); 8 this._createAutocomplete(); 9 this._createShowAllButton(); 10 }, 11 _createAutocomplete: function() { 12 var selected = this.element.children( ":selected" ), 13 value = selected.val() ? selected.text() : ""; 14 this.input = $( "<input>" ) 15 .appendTo( this.wrapper ) 16 .val( value ) 17 .attr( "title", "" ) 18 .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" ) 19 .autocomplete({ 20 delay: 0, 21 minLength: 0, 22 source: $.proxy( this, "_source" ), 23 select: function (event, ui) { 24 qwiz_combobox_callback (ui.item.label, 'class_by_name', this); 25 } 26 }) 27 /* 28 .tooltip({ 29 tooltipClass: "ui-state-highlight" 30 }); 31 */ 32 this._on( this.input, { 33 autocompleteselect: function( event, ui ) { 34 ui.item.option.selected = true; 35 this._trigger( "select", event, { 36 item: ui.item.option 37 }); 38 }, 39 autocompletechange: "_removeIfInvalid" 40 }); 41 }, 42 _createShowAllButton: function() { 43 var input = this.input, 44 wasOpen = false; 45 $( "<a>" ) 46 .attr( "tabIndex", -1 ) 47 .attr( "title", "Show all items" ) 48 .appendTo( this.wrapper ) 49 .button({ 50 icons: { 51 primary: "ui-icon-triangle-1-s" 52 }, 53 text: false 54 }) 55 .removeClass( "ui-corner-all" ) 56 .addClass( "custom-combobox-toggle ui-corner-right" ) 57 .mousedown(function() { 58 wasOpen = input.autocomplete( "widget" ).is( ":visible" ); 59 }) 60 .click(function() { 61 input.focus(); 62 if ( wasOpen ) { 63 return; 64 } 65 input.autocomplete( "search", "" ); 66 }); 67 }, 68 _source: function( request, response ) { 69 var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); 70 response( this.element.children( "option" ).map(function() { 71 var text = $( this ).text(); 72 if ( this.value && ( !request.term || matcher.test(text) ) ) 73 return { 74 label: text, 75 value: text, 76 option: this 77 }; 78 }) ); 79 }, 80 _removeIfInvalid: function( event, ui ) { 81 if ( ui.item ) { 82 return; 83 } 84 var value = this.input.val(), 85 valueLowerCase = value.toLowerCase(), 86 valid = false; 87 this.element.children( "option" ).each(function() { 88 if ( $( this ).text().toLowerCase() === valueLowerCase ) { 89 this.selected = valid = true; 90 return false; 91 } 92 }); 93 if ( valid ) { 94 return; 95 } 96 /* 97 this.input 98 .val( "" ) 99 .attr( "title", value + " didn't match any item" ) 100 .tooltip( "open" ); 101 this._delay(function() { 102 this.input.tooltip( "close" ).attr( "title", "" ); 103 }, 2500 ); 104 */ 105 this.element.val( "" ); 106 this.input.autocomplete( "instance" ).term = ""; 107 }, 108 _destroy: function() { 109 this.wrapper.remove(); 110 this.element.show(); 111 } 112 }); 113 })( jQuery ); 114 /* 115 $(function() { 116 $( "#combobox" ).combobox(); 117 $( "#toggle" ).click(function() { 118 $( "#combobox" ).toggle(); 119 }); 120 }); 121 */
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.