Trevor Parscal has uploaded a new change for review.

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


Change subject: Add icon option to ve.ui.TextInputWidget
......................................................................

Add icon option to ve.ui.TextInputWidget

Changes:

ve.ui.Widget.css
* Add styles for decorated text input widgets and their icon elements

ve.ui.TextInputWidget.js
* Add icon option which adds an icon before input text

Change-Id: Ib48d795391cb5d110e7dc05658d51129792dfc33
---
M modules/ve/ui/styles/ve.ui.Widget.css
M modules/ve/ui/widgets/ve.ui.TextInputWidget.js
2 files changed, 27 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/63/65963/1

diff --git a/modules/ve/ui/styles/ve.ui.Widget.css 
b/modules/ve/ui/styles/ve.ui.Widget.css
index ccdbc64..f2e449a 100644
--- a/modules/ve/ui/styles/ve.ui.Widget.css
+++ b/modules/ve/ui/styles/ve.ui.Widget.css
@@ -268,6 +268,21 @@
        text-shadow: 0 1px 1px #fff;
 }
 
+.ve-ui-textInputWidget-decorated input,
+.ve-ui-textInputWidget-decorated textarea {
+       padding-left: 2em;
+}
+
+.ve-ui-textInputWidget-icon {
+       position: absolute;
+       top: 0;
+       left: 0;
+       width: 2em;
+       height: 100%;
+       background-position: right center;
+       background-repeat: no-repeat;
+}
+
 /* ve.ui.MenuWidget */
 
 .ve-ui-menuWidget {
diff --git a/modules/ve/ui/widgets/ve.ui.TextInputWidget.js 
b/modules/ve/ui/widgets/ve.ui.TextInputWidget.js
index df1d599..eb99821 100644
--- a/modules/ve/ui/widgets/ve.ui.TextInputWidget.js
+++ b/modules/ve/ui/widgets/ve.ui.TextInputWidget.js
@@ -14,6 +14,7 @@
  * @constructor
  * @param {Object} [config] Config options
  * @cfg {string} [placeholder] Placeholder text
+ * @cfg {string} [icon] Symbolic name of icon
  */
 ve.ui.TextInputWidget = function VeUiTextInputWidget( config ) {
        // Parent constructor
@@ -21,6 +22,17 @@
 
        // Initialization
        this.$.addClass( 've-ui-textInputWidget' );
+       if ( config.icon ) {
+               this.$.addClass( 've-ui-textInputWidget-decorated' );
+               this.$.append(
+                       $( '<span>' )
+                               .addClass( 've-ui-textInputWidget-icon 
ve-ui-icon-' + config.icon )
+                               .mousedown( ve.bind( function () {
+                                       this.$input.focus();
+                                       return false;
+                               }, this ) )
+               );
+       }
        if ( config.placeholder ) {
                this.$input.attr( 'placeholder', config.placeholder );
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib48d795391cb5d110e7dc05658d51129792dfc33
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Trevor Parscal <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to