' );
$container = $( '
' );
addMulti( $oldContainer, $container );
}
$fieldLabel.attr( 'class', 'mw-label' );
$fieldLabelText.text( $oldContainer.find( '.mw-label label' ).text() );
$fieldLabel.append( $fieldLabelText );
$container.prepend( $fieldLabel );
$oldContainer.replaceWith( $container );
return $container;
}
if ( $root.find( '.mw-chosen' ).length ) {
mw.loader.using( 'jquery.chosen', function () {
$root.find( '.mw-chosen' ).each( function () {
var type = this.nodeName.toLowerCase(),
$converted = convertCheckboxesToMulti( $( this ), type );
$converted.find( '.htmlform-chzn-select' ).chosen( { width: 'auto' } );
} );
} );
}
$matrixTooltips = $root.find( '.mw-htmlform-matrix .mw-htmlform-tooltip' );
if ( $matrixTooltips.length ) {
mw.loader.using( 'jquery.tipsy', function () {
$matrixTooltips.tipsy( { gravity: 's' } );
} );
}
// Set up autocomplete fields
$autocomplete = $root.find( '.mw-htmlform-autocomplete' );
if ( $autocomplete.length ) {
mw.loader.using( 'jquery.suggestions', function () {
$autocomplete.suggestions( {
fetch: function ( val ) {
var $el = $( this );
$el.suggestions( 'suggestions',
$.grep( $el.data( 'autocomplete' ), function ( v ) {
return v.indexOf( val ) === 0;
} )
);
}
} );
} );
}
// Add/remove cloner clones without having to resubmit the form
$root.find( '.mw-htmlform-cloner-delete-button' ).filter( ':input' ).click( function ( ev ) {
ev.preventDefault();
$( this ).closest( 'li.mw-htmlform-cloner-li' ).remove();
} );
$root.find( '.mw-htmlform-cloner-create-button' ).filter( ':input' ).click( function ( ev ) {
var $ul, $li, html;
ev.preventDefault();
$ul = $( this ).prev( 'ul.mw-htmlform-cloner-ul' );
html = $ul.data( 'template' ).replace(
new RegExp( $.escapeRE( $ul.data( 'uniqueId' ) ), 'g' ),
'clone' + ( ++cloneCounter )
);
$li = $( '
' )
.addClass( 'mw-htmlform-cloner-li' )
.html( html )
.appendTo( $ul );
enhance( $li );
} );
mw.hook( 'htmlform.enhance' ).fire( $root );
}
$( function () {
enhance( $( document ) );
} );
/**
* @class jQuery
* @mixins jQuery.plugin.htmlform
*/
}( mediaWiki, jQuery ) );