Merge "Multiline option for ve.ui.TextInputWidget.js"

This commit is contained in:
jenkins-bot 2013-05-15 21:47:25 +00:00 committed by Gerrit Code Review
commit 943301f2c9
3 changed files with 37 additions and 22 deletions

View file

@ -220,7 +220,10 @@
.ve-ui-textInputWidget input,
.ve-ui-textInputWidget input:focus[readonly],
.ve-ui-widget-disabled.ve-ui-textInputWidget input:focus {
.ve-ui-widget-disabled.ve-ui-textInputWidget input:focus,
.ve-ui-textInputWidget textarea,
.ve-ui-textInputWidget textarea:focus[readonly],
.ve-ui-widget-disabled.ve-ui-textInputWidget textarea:focus {
display: inline-block;
font-size: 1em;
font-family: sans-serif;
@ -242,20 +245,24 @@
transition: border-color 200ms, box-shadow 200ms, background-color 200ms;
}
.ve-ui-textInputWidget input:focus {
.ve-ui-textInputWidget input:focus,
.ve-ui-textInputWidget textarea:focus {
outline: none;
border-color: #a7dcff;
box-shadow: 0 0 0.3em #a7dcff, 0 0 0 white;
background-color: #fff;
}
.ve-ui-textInputWidget input[readonly] {
.ve-ui-textInputWidget input[readonly],
.ve-ui-textInputWidget textarea[readonly] {
color: #777;
text-shadow: 0 1px 1px #fff;
}
.ve-ui-widget-disabled.ve-ui-textInputWidget input,
.ve-ui-widget-disabled.ve-ui-textInputWidget input:focus {
.ve-ui-widget-disabled.ve-ui-textInputWidget input:focus,
.ve-ui-widget-disabled.ve-ui-textInputWidget textarea,
.ve-ui-widget-disabled.ve-ui-textInputWidget textarea:focus {
color: #ccc;
text-shadow: 0 1px 1px #fff;
}
@ -297,7 +304,8 @@
/* ve.ui.PendingInputWidget */
.ve-ui-pendingInputWidget input {
.ve-ui-pendingInputWidget input,
.ve-ui-pendingInputWidget textarea {
background-image: url(images/pending.gif);
}

View file

@ -26,7 +26,7 @@ ve.ui.InputWidget = function VeUiInputWidget( config ) {
ve.ui.Widget.call( this, config );
// Properties
this.$input = this.$$( '<input>' );
this.$input = this.getInputElement( config );
this.value = '';
this.readonly = false;
@ -34,11 +34,7 @@ ve.ui.InputWidget = function VeUiInputWidget( config ) {
this.$input.on( 'keydown mouseup cut paste change input select', ve.bind( this.onEdit, this ) );
// Initialization
this.$input.attr( {
'type': this.constructor.static.inputType,
'name': config.name,
'value': config.value
} );
this.$input.attr( 'name', config.name ).val( config.value );
this.setReadOnly( config.readOnly );
this.$.addClass( 've-ui-inputWidget' ).append( this.$input );
};
@ -54,17 +50,19 @@ ve.inheritClass( ve.ui.InputWidget, ve.ui.Widget );
* @param value
*/
/**
* HTML input type.
*
* @static
* @property {string}
* @inheritable
*/
ve.ui.InputWidget.static.inputType = '';
/* Methods */
/**
* Get input element.
*
* @method
* @param {Object} [config] Config options
* @return {jQuery} Input element
*/
ve.ui.InputWidget.prototype.getInputElement = function () {
return this.$$( '<input>' );
};
/**
* Handle potentially value-changing events.
*

View file

@ -30,6 +30,15 @@ ve.ui.TextInputWidget = function VeUiTextInputWidget( config ) {
ve.inheritClass( ve.ui.TextInputWidget, ve.ui.InputWidget );
/* Static Properties */
/* Methods */
ve.ui.TextInputWidget.static.inputType = 'text';
/**
* Get input element.
*
* @method
* @param {Object} [config] Config options
* @return {jQuery} Input element
*/
ve.ui.TextInputWidget.prototype.getInputElement = function ( config ) {
return config.multiline ? this.$$( '<textarea>' ) : this.$$( '<input>' ).attr( 'type', 'text' );
};