X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki%2Fhtmlform%2Fautoinfuse.js;h=f2e0f4dd2c35c1693ecdd1c831a41d36b7515ace;hb=237d3271fd313ebe09858a5c442a91216a7b61cf;hp=f77e36720bc2c25593ae3508cf8ef5030f75b74c;hpb=fe79bc528b0e054aa630bd4fcfcdd4a9804892da;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki/htmlform/autoinfuse.js b/resources/src/mediawiki/htmlform/autoinfuse.js index f77e36720b..f2e0f4dd2c 100644 --- a/resources/src/mediawiki/htmlform/autoinfuse.js +++ b/resources/src/mediawiki/htmlform/autoinfuse.js @@ -2,30 +2,24 @@ * HTMLForm enhancements: * Infuse some OOjs UI HTMLForm fields (those which benefit from always being infused). */ -( function ( mw ) { +( function ( mw, $ ) { mw.hook( 'htmlform.enhance' ).add( function ( $root ) { - var $oouiNodes, modules; + var $oouiNodes, modules, extraModules; $oouiNodes = $root.find( '.mw-htmlform-field-autoinfuse' ); if ( $oouiNodes.length ) { // The modules are preloaded (added server-side in HTMLFormField, and the individual fields // which need extra ones), but this module doesn't depend on them. Wait until they're loaded. - modules = [ 'oojs-ui-core' ]; - if ( $oouiNodes.filter( '.mw-htmlform-field-HTMLTitleTextField' ).length ) { - // FIXME: TitleInputWidget should be in its own module - modules.push( 'mediawiki.widgets' ); - } - if ( $oouiNodes.filter( '.mw-htmlform-field-HTMLUserTextField' ).length ) { - modules.push( 'mediawiki.widgets.UserInputWidget' ); - } - if ( - $oouiNodes.filter( '.mw-htmlform-field-HTMLSelectNamespace' ).length || - $oouiNodes.filter( '.mw-htmlform-field-HTMLSelectNamespaceWithButton' ).length - ) { - // FIXME: NamespaceInputWidget should be in its own module (probably?) - modules.push( 'mediawiki.widgets' ); - } + modules = [ 'mediawiki.htmlform.ooui' ]; + $oouiNodes.each( function () { + var data = $( this ).data( 'mw-modules' ); + if ( data ) { + // We can trust this value, 'data-mw-*' attributes are banned from user content in Sanitizer + extraModules = data.split( ',' ); + modules.push.apply( modules, extraModules ); + } + } ); mw.loader.using( modules ).done( function () { $oouiNodes.each( function () { OO.ui.infuse( this ); @@ -35,4 +29,4 @@ } ); -}( mediaWiki ) ); +}( mediaWiki, jQuery ) );