From f0cfe83e3725f9a3928da97a6e3085e79cb25309 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 18 Mar 2013 10:26:24 +0400 Subject: upgrade dojo to 1.8.3 (refs #570) --- .../form/RangeBoundTextBox.js.uncompressed.js | 110 +++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 lib/dijit/form/RangeBoundTextBox.js.uncompressed.js (limited to 'lib/dijit/form/RangeBoundTextBox.js.uncompressed.js') diff --git a/lib/dijit/form/RangeBoundTextBox.js.uncompressed.js b/lib/dijit/form/RangeBoundTextBox.js.uncompressed.js new file mode 100644 index 000000000..f617df512 --- /dev/null +++ b/lib/dijit/form/RangeBoundTextBox.js.uncompressed.js @@ -0,0 +1,110 @@ +define("dijit/form/RangeBoundTextBox", [ + "dojo/_base/declare", // declare + "dojo/i18n", // i18n.getLocalization + "./MappedTextBox" +], function(declare, i18n, MappedTextBox){ + + // module: + // dijit/form/RangeBoundTextBox + + + var RangeBoundTextBox = declare("dijit.form.RangeBoundTextBox", MappedTextBox, { + // summary: + // Base class for textbox form widgets which defines a range of valid values. + + // rangeMessage: String + // The message to display if value is out-of-range + rangeMessage: "", + + /*===== + // constraints: RangeBoundTextBox.__Constraints + constraints: {}, + ======*/ + + rangeCheck: function(/*Number*/ primitive, /*dijit/form/RangeBoundTextBox.__Constraints*/ constraints){ + // summary: + // Overridable function used to validate the range of the numeric input value. + // tags: + // protected + return ("min" in constraints? (this.compare(primitive,constraints.min) >= 0) : true) && + ("max" in constraints? (this.compare(primitive,constraints.max) <= 0) : true); // Boolean + }, + + isInRange: function(/*Boolean*/ /*===== isFocused =====*/){ + // summary: + // Tests if the value is in the min/max range specified in constraints + // tags: + // protected + return this.rangeCheck(this.get('value'), this.constraints); + }, + + _isDefinitelyOutOfRange: function(){ + // summary: + // Returns true if the value is out of range and will remain + // out of range even if the user types more characters + var val = this.get('value'); + if(val == null){ return false; } // not yet valid enough to compare to + var outOfRange = false; + if("min" in this.constraints){ + var min = this.constraints.min; + outOfRange = this.compare(val, ((typeof min == "number") && min >= 0 && val != 0) ? 0 : min) < 0; + } + if(!outOfRange && ("max" in this.constraints)){ + var max = this.constraints.max; + outOfRange = this.compare(val, ((typeof max != "number") || max > 0) ? max : 0) > 0; + } + return outOfRange; + }, + + _isValidSubset: function(){ + // summary: + // Overrides `dijit/form/ValidationTextBox._isValidSubset()`. + // Returns true if the input is syntactically valid, and either within + // range or could be made in range by more typing. + return this.inherited(arguments) && !this._isDefinitelyOutOfRange(); + }, + + isValid: function(/*Boolean*/ isFocused){ + // Overrides dijit/form/ValidationTextBox.isValid() to check that the value is also in range. + return this.inherited(arguments) && + ((this._isEmpty(this.textbox.value) && !this.required) || this.isInRange(isFocused)); // Boolean + }, + + getErrorMessage: function(/*Boolean*/ isFocused){ + // Overrides dijit/form/ValidationTextBox.getErrorMessage() to print "out of range" message if appropriate + var v = this.get('value'); + if(v != null /* and !undefined */ && v !== '' && (typeof v != "number" || !isNaN(v)) && !this.isInRange(isFocused)){ // don't check isInRange w/o a real value + return this.rangeMessage; // String + } + return this.inherited(arguments); + }, + + postMixInProperties: function(){ + this.inherited(arguments); + if(!this.rangeMessage){ + this.messages = i18n.getLocalization("dijit.form", "validate", this.lang); + this.rangeMessage = this.messages.rangeMessage; + } + }, + + applyTextDir: function(/*===== element, text =====*/){ + // summary: + // The function overridden in the _BidiSupport module, + // originally used for setting element.dir according to this.textDir. + // In this case does nothing. + // element: Object + // text: String + // tags: + // protected. + } + }); + /*===== + RangeBoundTextBox.__Constraints = declare(null, { + // min: Number + // Minimum signed value. Default is -Infinity + // max: Number + // Maximum signed value. Default is +Infinity + }); + =====*/ + return RangeBoundTextBox; +}); -- cgit v1.2.3