3 * Fired on page load to enhance any HTML forms on the page.
5 * @event ~'htmlform.enhance'
6 * @param {jQuery} document
9 mw.hook( 'htmlform.enhance' ).fire( $( document ) );
12 mw.hook( 'htmlform.enhance' ).add( ( $root ) => {
13 // Turn HTML5 form validation back on, in cases where it was disabled server-side (see
14 // HTMLForm::needsJSForHtml5FormValidation()) because we need extra logic implemented in JS to
15 // validate correctly. Currently, this is only used for forms containing fields with 'hide-if'.
16 $root.find( '.mw-htmlform' ).removeAttr( 'novalidate' );
18 // Enable collapsible forms
19 const $collapsible = $root.find( '.mw-htmlform-ooui .oo-ui-fieldsetLayout.mw-collapsible' );
20 if ( $collapsible.length ) {
21 mw.loader.using( 'jquery.makeCollapsible' ).then( () => {
22 $collapsible.makeCollapsible();
27 // Collect other hook handlers
28 require( './autocomplete.js' );
29 require( './autoinfuse.js' );
30 require( './cloner.js' );
31 require( './cond-state.js' );
32 require( './selectandother.js' );
33 require( './selectorother.js' );
34 require( './timezone.js' );