diff --git a/js/jquery.combobox.js b/js/jquery.combobox.js index f12d1d7d..d9959eb6 100644 --- a/js/jquery.combobox.js +++ b/js/jquery.combobox.js @@ -23,16 +23,16 @@ minLength: 0, source: function( request, response ) { var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); - response( select.children( "option" ).map(function() { + response( select.children('option').map(function() { var text = $( this ).text(); if ( this.value && ( !request.term || matcher.test(text) ) ) return { label: text.replace( new RegExp( - "(?![^&;]+;)(?!<[^<>]*)(" + + '(?![^&;]+;)(?!<[^<>]*)(' + $.ui.autocomplete.escapeRegex(request.term) + - ")(?![^<>]*>)(?![^&;]+;)", "gi" - ), "$1" ), + ')(?![^<>]*>)(?![^&;]+;)', 'gi' + ), '$1'), value: text, option: this }; @@ -42,17 +42,17 @@ self.input.val($(ui.item.option).text()); self.input.trigger('change'); ui.item.option.selected = true; - self._trigger( "selected", event, { + self._trigger('selected', event, { item: ui.item.option }); }, change: function( event, ui ) { if ( !ui.item ) { - var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ), + var matcher = new RegExp( '^' + $.ui.autocomplete.escapeRegex( $(this).val() ) + '$', 'i' ), valid = false; self.input.val($(this).val()); //self.input.trigger('change'); - select.children( "option" ).each(function() { + select.children('option').each(function() { if ( $( this ).text().match( matcher ) ) { this.selected = valid = true; return false; @@ -62,36 +62,41 @@ // remove invalid value, as it didn't match anything $( this ).val( "" ); select.val( "" ); - input.data( "autocomplete" ).term = ""; + input.data('autocomplete').term = ''; return false; } } } }) - .addClass( "ui-widget ui-widget-content ui-corner-left" ); + .addClass('ui-widget ui-widget-content ui-corner-left'); - input.data( "autocomplete" )._renderItem = function( ul, item ) { - return $( "
" ) - .data( "item.autocomplete", item ) - .append( "" + item.label + "" ) + input.data('autocomplete')._renderItem = function( ul, item ) { + return $('') + .data('item.autocomplete', item ) + .append('' + item.label + '') .appendTo( ul ); }; $.each(this.options, function(key, value) { self._setOption(key, value); }); + input.dblclick(function() { + // pass empty string as value to search for, displaying all results + input.autocomplete('search', ''); + }); + if(this.options['showButton']) { - this.button = $( "" ) - .attr( "tabIndex", -1 ) - .attr( "title", "Show All Items" ) + this.button = $('') + .attr('tabIndex', -1 ) + .attr('title', 'Show All Items') .insertAfter( input ) .addClass('svg') .addClass('action') .addClass('combo-button') .click(function() { // close if already visible - if ( input.autocomplete( "widget" ).is( ":visible" ) ) { - input.autocomplete( "close" ); + if ( input.autocomplete('widget').is(':visible') ) { + input.autocomplete('close'); return; } @@ -99,7 +104,7 @@ $( this ).blur(); // pass empty string as value to search for, displaying all results - input.autocomplete( "search", "" ); + input.autocomplete('search', ''); input.focus(); }); }