X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..6746dc89c47ed01b165cc1152533605f97eb8e8d:/docs/source/Number.html diff --git a/docs/source/Number.html b/docs/source/Number.html index 5f378e6d..e5737171 100644 --- a/docs/source/Number.html +++ b/docs/source/Number.html @@ -1,5 +1,22 @@ -
+ +/** - * @class Ext.form.field.Number + + + + +\ No newline at end of file +The source code + + + + + + +/** + * @class Ext.form.field.Number * @extends Ext.form.field.Spinner A numeric text field that provides automatic keystroke filtering to disallow non-numeric characters, @@ -85,11 +102,7 @@ and mouse wheel handlers set `{@link #keyNavEnabled keyNavEnabled}:false` and }); - * @constructor - * Creates a new Number field - * @param {Object} config Configuration options * - * @xtype numberfield * @markdown * @docauthor Jason Johnston <jason@sencha.com> */ @@ -98,78 +111,78 @@ Ext.define('Ext.form.field.Number', { alias: 'widget.numberfield', alternateClassName: ['Ext.form.NumberField', 'Ext.form.Number'], - /** + /** * @cfg {RegExp} stripCharsRe @hide */ - /** + /** * @cfg {RegExp} maskRe @hide */ - /** + /** * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true) */ allowDecimals : true, - /** + /** * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.') */ decimalSeparator : '.', - /** + /** * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2) */ decimalPrecision : 2, - /** + /** * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY). Will be used by * the field's validation logic, and for * {@link Ext.form.field.Spinner#setSpinUpEnabled enabling/disabling the down spinner button}. */ minValue: Number.NEGATIVE_INFINITY, - /** + /** * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE). Will be used by * the field's validation logic, and for * {@link Ext.form.field.Spinner#setSpinUpEnabled enabling/disabling the up spinner button}. */ maxValue: Number.MAX_VALUE, - /** + /** * @cfg {Number} step Specifies a numeric interval by which the field's value will be incremented or * decremented when the user invokes the spinner. Defaults to <tt>1</tt>. */ step: 1, - /** + /** * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to 'The minimum * value for this field is {minValue}') */ minText : 'The minimum value for this field is {0}', - /** + /** * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to 'The maximum * value for this field is {maxValue}') */ maxText : 'The maximum value for this field is {0}', - /** + /** * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen * if a valid character like '.' or '-' is left in the field with no number (defaults to '{value} is not a valid number') */ nanText : '{0} is not a valid number', - /** + /** * @cfg {String} negativeText Error text to display if the value is negative and {@link #minValue} is set to * <tt>0</tt>. This is used instead of the {@link #minText} in that circumstance only. */ negativeText : 'The value cannot be negative', - /** + /** * @cfg {String} baseChars The base set of characters to evaluate as valid numbers (defaults to '0123456789'). */ baseChars : '0123456789', - /** + /** * @cfg {Boolean} autoStripChars True to automatically strip not allowed characters from the field. Defaults to <tt>false</tt> */ autoStripChars: false, @@ -178,27 +191,29 @@ Ext.define('Ext.form.field.Number', { var me = this, allowed; - this.callParent(); + me.callParent(); me.setMinValue(me.minValue); me.setMaxValue(me.maxValue); // Build regexes for masking and stripping based on the configured options - allowed = me.baseChars + ''; - if (me.allowDecimals) { - allowed += me.decimalSeparator; - } - if (me.minValue < 0) { - allowed += '-'; - } - allowed = Ext.String.escapeRegex(allowed); - me.maskRe = new RegExp('[' + allowed + ']'); - if (me.autoStripChars) { - me.stripCharsRe = new RegExp('[^' + allowed + ']', 'gi'); + if (me.disableKeyFilter !== true) { + allowed = me.baseChars + ''; + if (me.allowDecimals) { + allowed += me.decimalSeparator; + } + if (me.minValue < 0) { + allowed += '-'; + } + allowed = Ext.String.escapeRegex(allowed); + me.maskRe = new RegExp('[' + allowed + ']'); + if (me.autoStripChars) { + me.stripCharsRe = new RegExp('[^' + allowed + ']', 'gi'); + } } }, - /** + /** * Runs all of Number's validations and returns an array of any errors. Note that this first * runs Text's validations, so the returned array is an amalgamation of all field errors. * The additional validations run test that the value is a number, and that it is within the @@ -242,7 +257,11 @@ Ext.define('Ext.form.field.Number', { }, rawToValue: function(rawValue) { - return this.fixPrecision(this.parseValue(rawValue)) || rawValue || null; + var value = this.fixPrecision(this.parseValue(rawValue)); + if (value === null) { + value = rawValue || null; + } + return value; }, valueToRaw: function(value) { @@ -267,7 +286,7 @@ Ext.define('Ext.form.field.Number', { me.setSpinDownEnabled(valueIsNull || value > me.minValue); }, - /** + /** * Replaces any existing {@link #minValue} with the new value. * @param {Number} value The minimum value */ @@ -275,7 +294,7 @@ Ext.define('Ext.form.field.Number', { this.minValue = Ext.Number.from(value, Number.NEGATIVE_INFINITY); }, - /** + /** * Replaces any existing {@link #maxValue} with the new value. * @param {Number} value The maximum value */ @@ -289,7 +308,7 @@ Ext.define('Ext.form.field.Number', { return isNaN(value) ? null : value; }, - /** + /** * @private * */ @@ -330,4 +349,6 @@ Ext.define('Ext.form.field.Number', { } } }); -