13693261870
2022-09-16 354b3dbfbffb3df45212a2a44dbbf48b4acc2594
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<!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-Trigger'>/**
</span> * Layout class for {@link Ext.form.field.Trigger} fields. Adjusts the input field size to accommodate
 * the trigger button(s).
 * @private
 */
Ext.define('Ext.layout.component.field.Trigger', {
 
    /* Begin Definitions */
 
    alias: 'layout.triggerfield',
 
    extend: 'Ext.layout.component.field.Field',
 
<span id='Ext-layout-component-field-Trigger-property-type'>    /* End Definitions */
</span>
    type: 'triggerfield',
 
<span id='Ext-layout-component-field-Trigger-property-borderWidths'>    // Private. Cached extra width values containing width of all a trigger field's &quot;furniture&quot; round the actual input element
</span>    borderWidths: {},
 
<span id='Ext-layout-component-field-Trigger-method-beginLayout'>    beginLayout: function(ownerContext) {
</span>        var me = this,
            owner = me.owner,
            flags;
 
        ownerContext.triggerWrap = ownerContext.getEl('triggerWrap');
 
        me.callParent(arguments);
 
        // if any of these important states have changed, sync them now:
        flags = owner.getTriggerStateFlags();
        if (flags != owner.lastTriggerStateFlags) {
            owner.lastTriggerStateFlags = flags;
            me.updateEditState();
        }
    },
    
<span id='Ext-layout-component-field-Trigger-method-beginLayoutCycle'>    beginLayoutCycle: function(ownerContext){
</span>        this.callParent(arguments);
        
        // Clear width, in case a previous layout cycle set an explicit width.
        if (ownerContext.widthModel.shrinkWrap &amp;&amp; !this.owner.inputWidth) {
            ownerContext.inputContext.el.setStyle('width', '');
        }    
    },
 
<span id='Ext-layout-component-field-Trigger-method-beginLayoutFixed'>    beginLayoutFixed: function (ownerContext, width, suffix) {
</span>        var me = this,
            owner = ownerContext.target,
            ieInputWidthAdjustment = me.ieInputWidthAdjustment || 0,
            inputWidth = '100%',
            triggerWrap = owner.triggerWrap;
 
        me.callParent(arguments);
 
        owner.inputCell.setStyle('width', '100%');
        if(ieInputWidthAdjustment) {
            me.adjustIEInputPadding(ownerContext);
            if(suffix === 'px') {
                if (owner.inputWidth) {
                    inputWidth = owner.inputWidth - me.getExtraWidth(ownerContext);
                } else {
                    inputWidth = width - ieInputWidthAdjustment - me.getExtraWidth(ownerContext);
                }
                inputWidth += 'px';
            }
        }
        owner.inputEl.setStyle('width', inputWidth);
        inputWidth = owner.inputWidth;
        if (inputWidth) {
            triggerWrap.setStyle('width', inputWidth + (ieInputWidthAdjustment) + 'px');
        } else {
            triggerWrap.setStyle('width', width + suffix);
        }
        triggerWrap.setStyle('table-layout', 'fixed');
    },
 
<span id='Ext-layout-component-field-Trigger-method-adjustIEInputPadding'>    adjustIEInputPadding: function(ownerContext) {
</span>        // adjust for IE 6/7 strict content-box model
        this.owner.inputCell.setStyle('padding-right', this.ieInputWidthAdjustment + 'px');
    },
 
<span id='Ext-layout-component-field-Trigger-method-getExtraWidth'>    /**
</span>     * @private
     * Returns the width of the &quot;extras&quot; around the input field. This includes the total width
     * of all the triggers in the field and any outer bordering.
     * 
     * This measurement is used when explicitly sizing the contained input field to a smaller inner
     * width while keeping the outer component width the same. This extra width is subtracted from the
     * total component width to calculate the new width for the input field.
     */
    getExtraWidth: function(ownerContext) {
        var me = this,
            owner = me.owner,
            borderWidths = me.borderWidths,
            ui = owner.ui + owner.triggerEl.getCount();
 
        if (!(ui in borderWidths)) {
            borderWidths[ui] = ownerContext.triggerWrap.getBorderInfo().width
        }
        return borderWidths[ui] + owner.getTriggerWidth();
    },
 
<span id='Ext-layout-component-field-Trigger-method-beginLayoutShrinkWrap'>    beginLayoutShrinkWrap: function (ownerContext) {
</span>        var owner = ownerContext.target,
            emptyString = '',
            inputWidth = owner.inputWidth,
            triggerWrap = owner.triggerWrap;
 
        this.callParent(arguments);
 
        if (inputWidth) {
            triggerWrap.setStyle('width', inputWidth + 'px');
            inputWidth = (inputWidth - this.getExtraWidth(ownerContext)) + 'px';
            owner.inputEl.setStyle('width', inputWidth);
            owner.inputCell.setStyle('width', inputWidth);
        } else {
            owner.inputCell.setStyle('width', emptyString);
            owner.inputEl.setStyle('width', emptyString);
            triggerWrap.setStyle('width', emptyString);
            triggerWrap.setStyle('table-layout', 'auto');
        }
    },
 
<span id='Ext-layout-component-field-Trigger-method-getTextWidth'>    getTextWidth: function () {
</span>        var me = this,
            owner = me.owner,
            inputEl = owner.inputEl,
            value;
 
        // Find the width that contains the whole text value
        value = (inputEl.dom.value || (owner.hasFocus ? '' : owner.emptyText) || '') + owner.growAppend;
        return inputEl.getTextWidth(value);
    },
    
<span id='Ext-layout-component-field-Trigger-method-publishOwnerWidth'>    publishOwnerWidth: function(ownerContext, width) {
</span>        var owner = this.owner;
        this.callParent(arguments);
        if (!owner.grow &amp;&amp; !owner.inputWidth) {
            width -= this.getExtraWidth(ownerContext);
            if (owner.labelAlign != 'top') {
                width -= owner.getLabelWidth();
            }
            ownerContext.inputContext.setWidth(width);
        }    
    },
 
<span id='Ext-layout-component-field-Trigger-method-publishInnerHeight'>    publishInnerHeight: function(ownerContext, height) {
</span>        ownerContext.inputContext.setHeight(height - this.measureLabelErrorHeight(ownerContext));
    },
 
<span id='Ext-layout-component-field-Trigger-method-measureContentWidth'>    measureContentWidth: function (ownerContext) {
</span>        var me = this,
            owner = me.owner,
            width = me.callParent(arguments),
            inputContext = ownerContext.inputContext,
            calcWidth, max, min;
 
        if (owner.grow &amp;&amp; !ownerContext.state.growHandled) {
            calcWidth = me.getTextWidth() + ownerContext.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;
        } else if (!owner.inputWidth) {
            width -= me.getExtraWidth(ownerContext);
        }
        return width;
    },
 
<span id='Ext-layout-component-field-Trigger-method-updateEditState'>    updateEditState: function() {
</span>        var me = this,
            owner = me.owner,
            inputEl = owner.inputEl,
            noeditCls = Ext.baseCSSPrefix + 'trigger-noedit',
            displayed,
            readOnly;
 
        if (me.owner.readOnly) {
            inputEl.addCls(noeditCls);
            readOnly = true;
            displayed = false;
        } else {
            if (me.owner.editable) {
                inputEl.removeCls(noeditCls);
                readOnly = false;
            } else {
                inputEl.addCls(noeditCls);
                readOnly = true;
            }
            displayed = !me.owner.hideTrigger;
        }
 
        owner.triggerCell.setDisplayed(displayed);
        inputEl.dom.readOnly = readOnly;
    }
});
</pre>
</body>
</html>