Merge "Add tablesUsed to RevisionStoreDbTest"
[lhc/web/wiklou.git] / resources / src / mediawiki / htmlform / autoinfuse.js
1 /*
2 * HTMLForm enhancements:
3 * Infuse some OOUI HTMLForm fields (those which benefit from always being infused).
4 */
5 ( function ( mw, $ ) {
6
7 mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
8 var $oouiNodes, modules, extraModules;
9
10 $oouiNodes = $root.find( '.mw-htmlform-field-autoinfuse' );
11 if ( $oouiNodes.length ) {
12 // The modules are preloaded (added server-side in HTMLFormField, and the individual fields
13 // which need extra ones), but this module doesn't depend on them. Wait until they're loaded.
14 modules = [ 'mediawiki.htmlform.ooui' ];
15 $oouiNodes.each( function () {
16 var data = $( this ).data( 'mw-modules' );
17 if ( data ) {
18 // We can trust this value, 'data-mw-*' attributes are banned from user content in Sanitizer
19 extraModules = data.split( ',' );
20 modules.push.apply( modules, extraModules );
21 }
22 } );
23 mw.loader.using( modules ).done( function () {
24 $oouiNodes.each( function () {
25 OO.ui.infuse( this );
26 } );
27 } );
28 }
29
30 } );
31
32 }( mediaWiki, jQuery ) );