diff options
author | cash <cash.costello@gmail.com> | 2011-10-06 22:27:33 -0400 |
---|---|---|
committer | cash <cash.costello@gmail.com> | 2011-10-06 22:27:33 -0400 |
commit | 28da2f9dcb560687d4904e7629ad38049ed3188a (patch) | |
tree | cc91a2192752458884c262cf762753ff4557c086 /vendors/jquery | |
parent | 41256f644b02bf4dcb2bc3798bdf470fa93515da (diff) | |
download | elgg-28da2f9dcb560687d4904e7629ad38049ed3188a.tar.gz elgg-28da2f9dcb560687d4904e7629ad38049ed3188a.tar.bz2 |
using html extension to jquery.ui autocomplete
Diffstat (limited to 'vendors/jquery')
-rw-r--r-- | vendors/jquery/jquery.ui.autocomplete.html.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/vendors/jquery/jquery.ui.autocomplete.html.js b/vendors/jquery/jquery.ui.autocomplete.html.js new file mode 100644 index 000000000..a3ed2ee4b --- /dev/null +++ b/vendors/jquery/jquery.ui.autocomplete.html.js @@ -0,0 +1,40 @@ +/* + * jQuery UI Autocomplete HTML Extension + * + * Copyright 2010, Scott González (http://scottgonzalez.com) + * Dual licensed under the MIT or GPL Version 2 licenses. + * + * http://github.com/scottgonzalez/jquery-ui-extensions + */ +(function( $ ) { + +var proto = $.ui.autocomplete.prototype, + initSource = proto._initSource; + +function filter( array, term ) { + var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" ); + return $.grep( array, function(value) { + return matcher.test( $( "<div>" ).html( value.label || value.value || value ).text() ); + }); +} + +$.extend( proto, { + _initSource: function() { + if ( this.options.html && $.isArray(this.options.source) ) { + this.source = function( request, response ) { + response( filter( this.options.source, request.term ) ); + }; + } else { + initSource.call( this ); + } + }, + + _renderItem: function( ul, item) { + return $( "<li></li>" ) + .data( "item.autocomplete", item ) + .append( $( "<a></a>" )[ this.options.html ? "html" : "text" ]( item.label ) ) + .appendTo( ul ); + } +}); + +})( jQuery );
\ No newline at end of file |