[483] | 1 | define([ |
---|
| 2 | "dojo/_base/lang", |
---|
| 3 | "dijit/_WidgetBase", |
---|
| 4 | "dijit/form/ValidationTextBox", |
---|
| 5 | "dijit/form/NumberTextBox" |
---|
| 6 | ], function(lang, WidgetBase, ValidationTextBox, NumberTextBox){ |
---|
| 7 | |
---|
| 8 | // monkey patch dijit/form/ValidationTextBox.isValid to check this.inherited for isValid. |
---|
| 9 | // hide patch from doc parser though because we want it to display the original definition of isValid. |
---|
| 10 | var oldValidationTextBoxIsValid = ValidationTextBox.prototype.isValid; |
---|
| 11 | ValidationTextBox.prototype.isValid = /*===== oldValidationTextBoxIsValid || =====*/ function(/*Boolean*/ isFocused){ |
---|
| 12 | return (this.inherited("isValid", arguments) !== false && oldValidationTextBoxIsValid.apply(this, [isFocused])); |
---|
| 13 | }; |
---|
| 14 | |
---|
| 15 | // monkey patch dijit/form/NumberTextBox.isValid to check this.inherited for isValid. |
---|
| 16 | // hide patch from doc parser though because we want it to display the original definition of isValid. |
---|
| 17 | var oldNumberTextBoxIsValid = NumberTextBox.prototype.isValid; |
---|
| 18 | NumberTextBox.prototype.isValid = /*===== oldNumberTextBoxIsValid || =====*/ function(/*Boolean*/ isFocused){ |
---|
| 19 | return (this.inherited("isValid", arguments) !== false && oldNumberTextBoxIsValid.apply(this, [isFocused])); |
---|
| 20 | }; |
---|
| 21 | |
---|
| 22 | if(!lang.isFunction(WidgetBase.prototype.isValid)){ |
---|
| 23 | WidgetBase.prototype.isValid = function(){ |
---|
| 24 | var valid = this.get("valid"); |
---|
| 25 | return typeof valid == "undefined" ? true : valid; |
---|
| 26 | }; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | WidgetBase.prototype._setValidAttr = function(value){ |
---|
| 30 | this._set("valid", value); |
---|
| 31 | this.validate(); |
---|
| 32 | }; |
---|
| 33 | }); |
---|