Text.js
2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* 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);
}
});