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
<!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-form-field-FileButton'>/**
</span> *
 */
Ext.define('Ext.form.field.FileButton', {
    extend: 'Ext.button.Button',
    alias: 'widget.filebutton',
    
<span id='Ext-form-field-FileButton-property-childEls'>    childEls: [
</span>        'btnEl', 'btnWrap', 'btnInnerEl', 'btnIconEl', 'fileInputEl'
    ],
    
<span id='Ext-form-field-FileButton-property-inputCls'>    inputCls: Ext.baseCSSPrefix + 'form-file-input',
</span>    
<span id='Ext-form-field-FileButton-cfg-cls'>    cls: Ext.baseCSSPrefix + 'form-file-btn',
</span>    
<span id='Ext-form-field-FileButton-cfg-preventDefault'>    preventDefault: false,
</span>
<span id='Ext-form-field-FileButton-cfg-renderTpl'>    renderTpl: [
</span>        '&lt;span id=&quot;{id}-btnWrap&quot; class=&quot;{baseCls}-wrap',
            '&lt;tpl if=&quot;splitCls&quot;&gt; {splitCls}&lt;/tpl&gt;',
            '{childElCls}&quot; unselectable=&quot;on&quot;&gt;',
            '&lt;span id=&quot;{id}-btnEl&quot; class=&quot;{baseCls}-button&quot;&gt;',
                '&lt;span id=&quot;{id}-btnInnerEl&quot; class=&quot;{baseCls}-inner {innerCls}',
                    '{childElCls}&quot; unselectable=&quot;on&quot;&gt;',
                    '{text}',
                '&lt;/span&gt;',
                '&lt;span role=&quot;img&quot; id=&quot;{id}-btnIconEl&quot; class=&quot;{baseCls}-icon-el {iconCls}',
                    '{childElCls} {glyphCls}&quot; unselectable=&quot;on&quot; style=&quot;',
                    '&lt;tpl if=&quot;iconUrl&quot;&gt;background-image:url({iconUrl});&lt;/tpl&gt;',
                    '&lt;tpl if=&quot;glyph &amp;&amp; glyphFontFamily&quot;&gt;font-family:{glyphFontFamily};&lt;/tpl&gt;&quot;&gt;',
                    '&lt;tpl if=&quot;glyph&quot;&gt;&amp;#{glyph};&lt;/tpl&gt;&lt;tpl if=&quot;iconCls || iconUrl&quot;&gt;&amp;#160;&lt;/tpl&gt;',
                '&lt;/span&gt;',
            '&lt;/span&gt;',
        '&lt;/span&gt;',
        '&lt;input id=&quot;{id}-fileInputEl&quot; class=&quot;{childElCls} {inputCls}&quot; type=&quot;file&quot; size=&quot;1&quot; name=&quot;{inputName}&quot;&gt;'
    ],
    
<span id='Ext-form-field-FileButton-method-getTemplateArgs'>    getTemplateArgs: function(){
</span>        var args = this.callParent();
        args.inputCls = this.inputCls;
        args.inputName = this.inputName;
        return args;
    },
    
<span id='Ext-form-field-FileButton-method-afterRender'>    afterRender: function(){
</span>        var me = this;
        me.callParent(arguments);
        me.fileInputEl.on('change', me.fireChange, me);    
    },
    
<span id='Ext-form-field-FileButton-method-fireChange'>    fireChange: function(e){
</span>        this.fireEvent('change', this, e, this.fileInputEl.dom.value);
    },
    
<span id='Ext-form-field-FileButton-method-createFileInput'>    /**
</span>     * @private
     * Creates the file input element. It is inserted into the trigger button component, made
     * invisible, and floated on top of the button's other content so that it will receive the
     * button's clicks.
     */
    createFileInput : function(isTemporary) {
        var me = this;
        me.fileInputEl = me.el.createChild({
            name: me.inputName,
            id: !isTemporary ? me.id + '-fileInputEl' : undefined,
            cls: me.inputCls,
            tag: 'input',
            type: 'file',
            size: 1
        });
        me.fileInputEl.on('change', me.fireChange, me);  
    },
    
<span id='Ext-form-field-FileButton-method-reset'>    reset: function(remove){
</span>        if (remove) {
            this.fileInputEl.remove();
        }
        this.createFileInput(!remove);
    },
    
<span id='Ext-form-field-FileButton-method-restoreInput'>    restoreInput: function(el){
</span>        this.fileInputEl.remove();
        el = Ext.get(el);
        this.el.appendChild(el);
        this.fileInputEl = el;
    },
    
<span id='Ext-form-field-FileButton-method-onDisable'>    onDisable: function(){
</span>        this.callParent();
        this.fileInputEl.dom.disabled = true;
    },
 
<span id='Ext-form-field-FileButton-method-onEnable'>    onEnable : function() {
</span>        this.callParent();
        this.fileInputEl.dom.disabled = false;
    }
});
</pre>
</body>
</html>