Fandom

Wikia Developers Wiki

MiniComplete

823pages on
this wiki
Add New Page
Talk7 Share
Nuvola apps kservices This article is about a system or feature that is no longer in use.
  • The page is retained for historical reasons.

MiniComplete is an autocomplete for Special:Upload and Special:MultipleUpload descriptions. It works by detecting when you've opened a brackets for a link [[ or a template {{ and suggests options you might be looking for based on what you typed after those opening brackets.

It is designed to look and function the same as the autocomplete when editing pages. If there is a feature that the editor autocomplete has, but this does not, please request it on the talk page.

Demo

Installing

To install this script add the following to your global.js on Community Central or MediaWiki:Common.js on your wiki:

importArticles( {
    type: 'script',
    articles: [
        // ...
        'u:dev:MiniComplete/code.js',
        // ...
    ]
} );
importArticles — Best Practices for installing JavaScript on Fandom
The importArticles statement is designed to combine multiple HTTP requests into a single data transfer, allowing multiple scripts to load and execute faster. If you've been installing several different scripts, your JavaScript file has probably accumulated unnecessary import statements. Click "Expand" to learn how to efficiently batch import scripts to speed up performance and make your code look cleaner. One other approach is by using the MediaWiki:ImportJS.
If your JavaScript file has several lines of code that say importScript, importScriptPage, or importArticles, you may be able to combine them! By batch importing a collection of scripts with a single import, your JavaScript code will load faster and look cleaner. Consider the example below. On the left is an example of what your JavaScript file might currently look like. On the right is how you could improve that code.
Multiple imports — messy and slow One import — clean and efficient
importScriptPage('AjaxRC/code.js','dev');
 
importScript('MediaWiki:localScript.js');
 
importArticle({
  type: 'script',
  article: 'u:dev:FloatingToc/code.js'
});
 
importScriptPage('page1.js', 'wikiname');
 
importScriptPage('page2.js', 'wikiname');
importArticles({
    type: 'script',
    articles: [
        'u:dev:AjaxRC/code.js',
        'MediaWiki:localScript.js',
        'u:dev:FloatingToc/code.js',
        'u:wikiname:page1.js',
        'u:wikiname:page2.js'
    ]
});
Note: In this example, pay close attention to the placement of commas and other punctuation. For people who aren't familiar with programming (and even those who are!), a common mistake when writing code is to accidentally delete, forget, or misplace critical symbols like commas or quotation marks. This can cause a syntax error that breaks the code. Carefully follow the convention shown here when using importArticles.
But there's much more to importArticles than just this! For more examples and advanced usage, see the help page at Help:Including additional JavaScript and CSS.

Use in other scripts

This script can be used in almost any other script where an autocomplete is wanted for a textarea element. You will need to load the script and register the module containing it's dependencies and then pass the a selector to a function from this script.

The following is an example used for the demo of this script:

// load the module
mw.loader.implement( 'minicomplete', [ '/load.php?debug=false&lang=en&mode=articles&skin=oasis&missingCallback=importArticleMissing&articles=u%3Acamtest%3AMediaWiki%3ATextareaHelper.js%7Cu%3Adev%3AColors%2Fcode.js%7Cu%3Adev%3AMiniComplete%2Fcode.js&only=scripts' ], {}, {} );
 
// insert the textarea
$( '#minicomplete-demo' )
// empty the element first in case of loading twice or more
.empty()
.append(
    $( '<textarea>' )
    .attr( {
        id: 'minicomplete-textarea',
        placeholder: 'Try the MiniComplete demo here!'
    } )
    .css( {
        resize: 'none',
        height: '80px',
        width: '98.3%',
        padding: '2px 5px'
    } )
);
 
// call the modules we need and execute the script in the callback
mw.loader.using( [ 'mediawiki.api', 'minicomplete' ], function () {
    dev.minicomplete.load( '#minicomplete-textarea' );
} );

It is recommended to use the id of the textarea, as I've done in this example, as the selector to pass to dev.minicomplete.load(). If for some reason this cannot be done, you can use any selector you might use in CSS.

To do list

  • Allow users to turn this script on and off at their preference, as users can turn the normal editor autocomplete on and off in Special:Preferences.
  • Allow custom styling of the autocomplete options for wikis with themes not based on Special:ThemeDesigner.

Updates

This only documents major updates, so may not correlate with the latest update in the infobox.

6th February 2015 (diff)
  • Remove Message Wall, Special:Forum and Article Comment support due to support being added by Wikia.
15th February 2014 (diff)
  • Changed to use factory method to stop unnecessary globals from being accessed.
9th November 2013 (diff)
  • Fixed for Article comments, Special:Forum posts and Message Wall comments.
31st October 2013 (diff)
  • Added support for using in other scripts.
  • Loaded non-standard dependencies in a single http request using ResourceLoader.
28th October 2013
  • Script published.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.