X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432:/examples/ux/FileUploadField.js..25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775:/examples/ux/fileuploadfield/FileUploadField.js diff --git a/examples/ux/FileUploadField.js b/examples/ux/fileuploadfield/FileUploadField.js similarity index 70% rename from examples/ux/FileUploadField.js rename to examples/ux/fileuploadfield/FileUploadField.js index 57244686..72801ec4 100644 --- a/examples/ux/FileUploadField.js +++ b/examples/ux/fileuploadfield/FileUploadField.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.0.0 + * Ext JS Library 3.0.3 * Copyright(c) 2006-2009 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license @@ -65,15 +65,7 @@ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, { this.wrap = this.el.wrap({cls:'x-form-field-wrap x-form-file-wrap'}); this.el.addClass('x-form-file-text'); this.el.dom.removeAttribute('name'); - - this.fileInput = this.wrap.createChild({ - id: this.getFileInputId(), - name: this.name||this.getId(), - cls: 'x-form-file', - tag: 'input', - type: 'file', - size: 1 - }); + this.createFileInput(); var btnCfg = Ext.applyIf(this.buttonCfg || {}, { text: this.buttonText @@ -88,11 +80,49 @@ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, { this.wrap.setWidth(this.button.getEl().getWidth()); } - this.fileInput.on('change', function(){ - var v = this.fileInput.dom.value; - this.setValue(v); - this.fireEvent('fileselected', this, v); - }, this); + this.bindListeners(); + this.resizeEl = this.positionEl = this.wrap; + }, + + bindListeners: function(){ + this.fileInput.on({ + scope: this, + mouseenter: function() { + this.button.addClass(['x-btn-over','x-btn-focus']) + }, + mouseleave: function(){ + this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click']) + }, + mousedown: function(){ + this.button.addClass('x-btn-click') + }, + mouseup: function(){ + this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click']) + }, + change: function(){ + var v = this.fileInput.dom.value; + this.setValue(v); + this.fireEvent('fileselected', this, v); + } + }); + }, + + createFileInput : function() { + this.fileInput = this.wrap.createChild({ + id: this.getFileInputId(), + name: this.name||this.getId(), + cls: 'x-form-file', + tag: 'input', + type: 'file', + size: 1 + }); + }, + + reset : function(){ + this.fileInput.remove(); + this.createFileInput(); + this.bindListeners(); + Ext.ux.form.FileUploadField.superclass.reset.call(this); }, // private @@ -117,20 +147,27 @@ Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, { Ext.ux.form.FileUploadField.superclass.onDestroy.call(this); Ext.destroy(this.fileInput, this.button, this.wrap); }, + + onDisable: function(){ + Ext.ux.form.FileUploadField.superclass.onDisable.call(this); + this.doDisable(true); + }, + + onEnable: function(){ + Ext.ux.form.FileUploadField.superclass.onEnable.call(this); + this.doDisable(false); - - // private - preFocus : Ext.emptyFn, - + }, + // private - getResizeEl : function(){ - return this.wrap; + doDisable: function(disabled){ + this.fileInput.dom.disabled = disabled; + this.button.setDisabled(disabled); }, + // private - getPositionEl : function(){ - return this.wrap; - }, + preFocus : Ext.emptyFn, // private alignErrorIcon : function(){