CopyTextLayout: Support multiline text
[lhc/web/wiklou.git] / resources / src / mediawiki.widgets / mw.widgets.CopyTextLayout.js
index 48c14b6..65e7eb7 100644 (file)
         *  defaults to 'mw-widgets-copytextlayout-copy-fail'.
         */
        mw.widgets.CopyTextLayout = function MwWidgetsCopyTextLayout( config ) {
+               var TextClass;
                config = config || {};
 
                // Properties
-               this.textInput = new OO.ui.TextInputWidget( $.extend( {
+               TextClass = config.multiline ? OO.ui.MultilineTextInputWidget : OO.ui.TextInputWidget;
+               this.textInput = new TextClass( $.extend( {
                        value: config.copyText,
                        readOnly: true
                }, config.textInput ) );
                // Parent constructor
                mw.widgets.CopyTextLayout.super.call( this, this.textInput, this.button, config );
 
+               // HACK: Remove classes which connect widgets when using
+               // a multiline text input. TODO: This should be handled in OOUI.
+               if ( config.multiline ) {
+                       this.$input.removeClass( 'oo-ui-actionFieldLayout-input' );
+                       this.$button
+                               .removeClass( 'oo-ui-actionFieldLayout-button' )
+                               .addClass( 'mw-widget-copyTextLayout-multiline-button' );
+               }
+
                // Events
                this.button.connect( this, { click: 'onButtonClick' } );
                this.textInput.$input.on( 'click', this.onInputClick.bind( this ) );