+++ /dev/null
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-\r
-Ext.form.FileUploadField = Ext.extend(Ext.form.TextField, {\r
- /**\r
- * @cfg {String} buttonText The button text to display on the upload button (defaults to\r
- * 'Browse...'). Note that if you supply a value for {@link #buttonCfg}, the buttonCfg.text\r
- * value will be used instead if available.\r
- */\r
- buttonText: 'Browse...',\r
- /**\r
- * @cfg {Boolean} buttonOnly True to display the file upload field as a button with no visible\r
- * text field (defaults to false). If true, all inherited TextField members will still be available.\r
- */\r
- buttonOnly: false,\r
- /**\r
- * @cfg {Number} buttonOffset The number of pixels of space reserved between the button and the text field\r
- * (defaults to 3). Note that this only applies if {@link #buttonOnly} = false.\r
- */\r
- buttonOffset: 3,\r
- /**\r
- * @cfg {Object} buttonCfg A standard {@link Ext.Button} config object.\r
- */\r
-\r
- // private\r
- readOnly: true,\r
- \r
- /**\r
- * @hide \r
- * @method autoSize\r
- */\r
- autoSize: Ext.emptyFn,\r
- \r
- // private\r
- initComponent: function(){\r
- Ext.form.FileUploadField.superclass.initComponent.call(this);\r
- \r
- this.addEvents(\r
- /**\r
- * @event fileselected\r
- * Fires when the underlying file input field's value has changed from the user\r
- * selecting a new file from the system file selection dialog.\r
- * @param {Ext.form.FileUploadField} this\r
- * @param {String} value The file value returned by the underlying file input field\r
- */\r
- 'fileselected'\r
- );\r
- },\r
- \r
- // private\r
- onRender : function(ct, position){\r
- Ext.form.FileUploadField.superclass.onRender.call(this, ct, position);\r
- \r
- this.wrap = this.el.wrap({cls:'x-form-field-wrap x-form-file-wrap'});\r
- this.el.addClass('x-form-file-text');\r
- this.el.dom.removeAttribute('name');\r
- \r
- this.fileInput = this.wrap.createChild({\r
- id: this.getFileInputId(),\r
- name: this.name||this.getId(),\r
- cls: 'x-form-file',\r
- tag: 'input', \r
- type: 'file',\r
- size: 1\r
- });\r
- \r
- var btnCfg = Ext.applyIf(this.buttonCfg || {}, {\r
- text: this.buttonText\r
- });\r
- this.button = new Ext.Button(Ext.apply(btnCfg, {\r
- renderTo: this.wrap,\r
- cls: 'x-form-file-btn' + (btnCfg.iconCls ? ' x-btn-icon' : '')\r
- }));\r
- \r
- if(this.buttonOnly){\r
- this.el.hide();\r
- this.wrap.setWidth(this.button.getEl().getWidth());\r
- }\r
- \r
- this.fileInput.on('change', function(){\r
- var v = this.fileInput.dom.value;\r
- this.setValue(v);\r
- this.fireEvent('fileselected', this, v);\r
- }, this);\r
- },\r
- \r
- // private\r
- getFileInputId: function(){\r
- return this.id+'-file';\r
- },\r
- \r
- // private\r
- onResize : function(w, h){\r
- Ext.form.FileUploadField.superclass.onResize.call(this, w, h);\r
- \r
- this.wrap.setWidth(w);\r
- \r
- if(!this.buttonOnly){\r
- var w = this.wrap.getWidth() - this.button.getEl().getWidth() - this.buttonOffset;\r
- this.el.setWidth(w);\r
- }\r
- },\r
- \r
- // private\r
- preFocus : Ext.emptyFn,\r
- \r
- // private\r
- getResizeEl : function(){\r
- return this.wrap;\r
- },\r
-\r
- // private\r
- getPositionEl : function(){\r
- return this.wrap;\r
- },\r
-\r
- // private\r
- alignErrorIcon : function(){\r
- this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);\r
- }\r
- \r
-});\r
-Ext.reg('fileuploadfield', Ext.form.FileUploadField);
\ No newline at end of file