1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>The source code</title>
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
- <style type="text/css">
- .highlight { display: block; background-color: #ddd; }
- </style>
- <script type="text/javascript">
- function highlight() {
- document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
- }
- </script>
- </head>
- <body onload="prettyPrint(); highlight();">
- <pre class="prettyprint lang-js"><span id='Ext-layout-component-field-Text'>/**
- </span> * Layout class for {@link Ext.form.field.Text} fields. Handles sizing the input field.
- * @private
- */
- Ext.define('Ext.layout.component.field.Text', {
- extend: 'Ext.layout.component.field.Field',
- alias: 'layout.textfield',
- requires: ['Ext.util.TextMetrics'],
- type: 'textfield',
-
- canGrowWidth: true,
- beginLayoutCycle: function(ownerContext) {
- var me = this;
-
- me.callParent(arguments);
-
- // Clear height, in case a previous layout cycle stretched it.
- if (ownerContext.shrinkWrap) {
- ownerContext.inputContext.el.setStyle('height', '');
- }
- },
- measureContentWidth: function (ownerContext) {
- var me = this,
- owner = me.owner,
- width = me.callParent(arguments),
- inputContext = ownerContext.inputContext,
- inputEl, value, calcWidth, max, min;
- if (owner.grow && me.canGrowWidth && !ownerContext.state.growHandled) {
- inputEl = owner.inputEl;
- // Find the width that contains the whole text value
- value = Ext.util.Format.htmlEncode(inputEl.dom.value || (owner.hasFocus ? '' : owner.emptyText) || '');
- value += owner.growAppend;
- calcWidth = inputEl.getTextWidth(value) + inputContext.getFrameInfo().width;
- max = owner.growMax;
- min = Math.min(max, width);
- max = Math.max(owner.growMin, max, min);
- // Constrain
- calcWidth = Ext.Number.constrain(calcWidth, owner.growMin, max);
- inputContext.setWidth(calcWidth);
- ownerContext.state.growHandled = true;
-
- // Now that we've set the inputContext, we need to recalculate the width
- inputContext.domBlock(me, 'width');
- width = NaN;
- }
- return width;
- },
-
- publishInnerHeight: function(ownerContext, height) {
- ownerContext.inputContext.setHeight(height - this.measureLabelErrorHeight(ownerContext));
- },
- beginLayoutFixed: function(ownerContext, width, suffix) {
- var me = this,
- ieInputWidthAdjustment = me.ieInputWidthAdjustment;
- if (ieInputWidthAdjustment) {
- // adjust for IE 6/7 strict content-box model
- // RTL: This might have to be padding-left unless the senses of the padding styles switch when in RTL mode.
- me.owner.bodyEl.setStyle('padding-right', ieInputWidthAdjustment + 'px');
- if(suffix === 'px') {
- width -= ieInputWidthAdjustment;
- }
- }
- me.callParent(arguments);
- }
- });
- </pre>
- </body>
- </html>
|