summaryrefslogtreecommitdiff
path: root/www/wiki/resources/src/mediawiki/htmlform/autocomplete.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/resources/src/mediawiki/htmlform/autocomplete.js')
-rw-r--r--www/wiki/resources/src/mediawiki/htmlform/autocomplete.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/www/wiki/resources/src/mediawiki/htmlform/autocomplete.js b/www/wiki/resources/src/mediawiki/htmlform/autocomplete.js
new file mode 100644
index 00000000..81579755
--- /dev/null
+++ b/www/wiki/resources/src/mediawiki/htmlform/autocomplete.js
@@ -0,0 +1,25 @@
+/*
+ * HTMLForm enhancements:
+ * Set up autocomplete fields.
+ */
+( function ( mw, $ ) {
+
+ mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
+ var $autocomplete = $root.find( '.mw-htmlform-autocomplete' );
+ if ( $autocomplete.length ) {
+ mw.loader.using( 'jquery.suggestions', function () {
+ $autocomplete.suggestions( {
+ fetch: function ( val ) {
+ var $el = $( this );
+ $el.suggestions( 'suggestions',
+ $.grep( $el.data( 'autocomplete' ), function ( v ) {
+ return v.indexOf( val ) === 0;
+ } )
+ );
+ }
+ } );
+ } );
+ }
+ } );
+
+}( mediaWiki, jQuery ) );