MWTimestamp: Allow providing a DateTime object directly
[lhc/web/wiklou.git] / resources / src / mediawiki / htmlform / autoinfuse.js
1 /*
2 * HTMLForm enhancements:
3 * Infuse some OOjs UI 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;
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 = [ 'oojs-ui-core' ];
15 if ( $oouiNodes.filter( '.mw-htmlform-field-HTMLTitleTextField' ).length ) {
16 // FIXME: TitleInputWidget should be in its own module
17 modules.push( 'mediawiki.widgets' );
18 }
19 if ( $oouiNodes.filter( '.mw-htmlform-field-HTMLUserTextField' ).length ) {
20 modules.push( 'mediawiki.widgets.UserInputWidget' );
21 }
22 if (
23 $oouiNodes.filter( '.mw-htmlform-field-HTMLSelectNamespace' ).length ||
24 $oouiNodes.filter( '.mw-htmlform-field-HTMLSelectNamespaceWithButton' ).length
25 ) {
26 // FIXME: NamespaceInputWidget should be in its own module (probably?)
27 modules.push( 'mediawiki.widgets' );
28 }
29 mw.loader.using( modules ).done( function () {
30 $oouiNodes.each( function () {
31 OO.ui.infuse( this );
32 } );
33 } );
34 }
35
36 } );
37
38 }( mediaWiki ) );