Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/222541

Change subject: Support 'cols' and 'rows' in multiline TextInputWidget
......................................................................

Support 'cols' and 'rows' in multiline TextInputWidget

Bug: T104682
Change-Id: I6a8ec1f7d00e73e89b9d25718eac2a547b1e2ba6
---
M demos/pages/widgets.js
M demos/widgets.php
M php/widgets/TextInputWidget.php
M src/widgets/TextInputWidget.js
4 files changed, 52 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/41/222541/1

diff --git a/demos/pages/widgets.js b/demos/pages/widgets.js
index d4880b5..8c9215c 100644
--- a/demos/pages/widgets.js
+++ b/demos/pages/widgets.js
@@ -839,6 +839,18 @@
                                new OO.ui.FieldLayout(
                                        new OO.ui.TextInputWidget( {
                                                multiline: true,
+                                               rows: 25,
+                                               cols: 80,
+                                               value: 'Multiline\nMultiline'
+                                       } ),
+                                       {
+                                               label: 'TextInputWidget 
(multiline, rows=25, cols=80)\u200E',
+                                               align: 'top'
+                                       }
+                               ),
+                               new OO.ui.FieldLayout(
+                                       new OO.ui.TextInputWidget( {
+                                               multiline: true,
                                                autosize: true,
                                                value: 
'Autosize\nAutosize\nAutosize\nAutosize'
                                        } ),
diff --git a/demos/widgets.php b/demos/widgets.php
index d4adbaa..86788fa 100644
--- a/demos/widgets.php
+++ b/demos/widgets.php
@@ -619,6 +619,18 @@
                                                        )
                                                ),
                                                new OOUI\FieldLayout(
+                                                       new 
OOUI\TextInputWidget( array(
+                                                               'multiline' => 
true,
+                                                               'rows' => 25,
+                                                               'cols' => 80,
+                                                               'value' => 
"Multiline\nMultiline"
+                                                       ) ),
+                                                       array(
+                                                               'label' => 
"TextInputWidget (multiline, rows=25, cols=80)\xE2\x80\x8E",
+                                                               'align' => 'top'
+                                                       )
+                                               ),
+                                               new OOUI\FieldLayout(
                                                        new 
OOUI\DropdownInputWidget( array(
                                                                'options' => 
array(
                                                                        array(
diff --git a/php/widgets/TextInputWidget.php b/php/widgets/TextInputWidget.php
index e930790..b2a65f8 100644
--- a/php/widgets/TextInputWidget.php
+++ b/php/widgets/TextInputWidget.php
@@ -33,6 +33,8 @@
         * @param boolean $config['readOnly'] Prevent changes (default: false)
         * @param number $config['maxLength'] Maximum allowed number of 
characters to input
         * @param boolean $config['multiline'] Allow multiple lines of text 
(default: false)
+        * @param boolean $config['cols'] If multiline, width of textarea
+        * @param boolean $config['rows'] If multiline, number of visible lines 
in textarea
         * @param boolean $config['required'] Mark the field as required 
(default: false)
         */
        public function __construct( array $config = array() ) {
@@ -70,6 +72,14 @@
                }
                if ( $config['required'] ) {
                        $this->input->setAttributes( array( 'required' => 
'required', 'aria-required' => 'true' ) );
+               }
+               if ( $this->multiline ) {
+                       if ( isset( $config['cols'] ) ) {
+                               $this->input->setAttributes( array( 'cols' => 
$config['cols'] ) );
+                       }
+                       if ( isset( $config['rows'] ) ) {
+                               $this->input->setAttributes( array( 'rows' => 
$config['rows'] ) );
+                       }
                }
        }
 
@@ -124,6 +134,14 @@
        public function getConfig( &$config ) {
                if ( $this->isMultiline() ) {
                        $config['multiline'] = true;
+                       $cols = $this->input->getAttribute( 'cols' );
+                       if ( $cols !== null ) {
+                               $config['cols'] = $cols;
+                       }
+                       $rows = $this->input->getAttribute( 'rows' );
+                       if ( $rows !== null ) {
+                               $config['rows'] = $rows;
+                       }
                } else {
                        $type = $this->input->getAttribute( 'type' );
                        if ( $type !== 'text' ) {
diff --git a/src/widgets/TextInputWidget.js b/src/widgets/TextInputWidget.js
index 123a13b..e53397b 100644
--- a/src/widgets/TextInputWidget.js
+++ b/src/widgets/TextInputWidget.js
@@ -34,6 +34,8 @@
  * @cfg {boolean} [readOnly=false] Prevent changes to the value of the text 
input.
  * @cfg {number} [maxLength] Maximum number of characters allowed in the input.
  * @cfg {boolean} [multiline=false] Allow multiple lines of text
+ * @cfg {int} [cols] If multiline, width of textarea
+ * @cfg {int} [rows] If multiline, number of visible lines in textarea
  * @cfg {boolean} [autosize=false] Automatically resize the text input to fit 
its content.
  *  Use the #maxRows config to specify a maximum number of displayed rows.
  * @cfg {boolean} [maxRows=10] Maximum number of rows to display when 
#autosize is set to true.
@@ -113,6 +115,14 @@
                this.$input.attr( 'required', 'required' );
                this.$input.attr( 'aria-required', 'true' );
        }
+       if ( this.multiline ) {
+               if ( config.cols ) {
+                       this.$input.attr( 'cols', config.cols );
+               }
+               if ( config.rows ) {
+                       this.$input.attr( 'rows', config.rows );
+               }
+       }
        if ( this.label || config.autosize ) {
                this.installParentChangeDetector();
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/222541
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6a8ec1f7d00e73e89b9d25718eac2a547b1e2ba6
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to