Changeset 12918

Show
Ignore:
Timestamp:
03/05/08 19:01:39 (10 months ago)
Author:
peller
Message:

Add docs. Refs #5962 !strict

Location:
dijit/trunk/form
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/form/DateTextBox.js

    r11916 r12918  
    99        { 
    1010                // summary: 
    11                 //              A validating, serializable, range-bound date text box. 
     11                //              A validating, serializable, range-bound date text box with a popup calendar 
    1212 
    1313                popupClass: "dijit._Calendar", 
  • dijit/trunk/form/TextBox.js

    r12710 r12918  
    3838 
    3939                getDisplayedValue: function(){ 
     40                        //      summary: 
     41                        //              returns the formatted value that the user sees in the textbox, which may be different 
     42                        //              from the serialized value that's actually sent to the server (see dijit.form.ValidationTextBox.serialize) 
    4043                        return this.filter(this.textbox.value); 
    4144                }, 
     
    8588 
    8689                filter: function(val){ 
    87                         // summary: Apply various filters to textbox value 
     90                        // summary: Apply specified filters to textbox value 
    8891                        if(val === null || val === undefined){ return ""; } 
    8992                        else if(typeof val != "string"){ return val; } 
  • dijit/trunk/form/TimeTextBox.js

    r11916 r12918  
    99        { 
    1010                // summary: 
    11                 //              A validating, serializable, range-bound time text box. 
     11                //              A validating, serializable, range-bound time text box with a popup time picker 
    1212 
    1313                popupClass: "dijit._TimePicker", 
  • dijit/trunk/form/ValidationTextBox.js

    r12731 r12918  
    77 
    88dojo.requireLocalization("dijit.form", "validate"); 
     9 
     10/*===== 
     11        dijit.form.ValidationTextBox.__Constraints = function(){ 
     12                // locale: String 
     13                //              locale used for validation, picks up value from this widget's lang attribute 
     14                // _flags_: anything 
     15                //              various flags passed to regExpGen function 
     16                this.locale = ""; 
     17                this._flags_ = ""; 
     18        } 
     19=====*/ 
    920 
    1021dojo.declare( 
     
    3243                invalidMessage: "$_unset_$", // read from the message file if not overridden 
    3344 
    34                 // constraints: Object 
     45                // constraints: dijit.form.ValidationTextBox.__Constraints 
    3546                //              user-defined object needed to pass parameters to the validator functions 
    3647                constraints: {}, 
     
    4455                //              user replaceable function used to generate regExp when dependent on constraints 
    4556                //              Do not specify both regExp and regExpGen 
    46                 regExpGen: function(constraints){ return this.regExp; }, 
     57                regExpGen: function(/*dijit.form.ValidationTextBox.__Constraints*/constraints){ return this.regExp; }, 
    4758 
    4859                // state: String 
     
    5970                }, 
    6071 
    61                 validator: function(value,constraints){ 
     72                validator: function(/*anything*/value, /*dijit.form.ValidationTextBox.__Constraints*/constraints){ 
    6273                        // summary: user replaceable function used to validate the text input against the regular expression. 
    6374                        return (new RegExp("^(" + this.regExpGen(constraints) + ")"+(this.required?"":"?")+"$")).test(value) && 
     
    6677                }, 
    6778 
    68                 isValid: function(/* Boolean*/ isFocused){ 
     79                isValid: function(/*Boolean*/ isFocused){ 
    6980                        // summary: Need to over-ride with your own validation code in subclasses 
    7081                        return this.validator(this.textbox.value, this.constraints); 
     
    7687                }, 
    7788 
    78                 getErrorMessage: function(/* Boolean*/ isFocused){ 
     89                getErrorMessage: function(/*Boolean*/ isFocused){ 
    7990                        // summary: return an error message to show if appropriate 
    8091                        return this.invalidMessage; 
    8192                }, 
    8293 
    83                 getPromptMessage: function(/* Boolean*/ isFocused){ 
     94                getPromptMessage: function(/*Boolean*/ isFocused){ 
    8495                        // summary: return a hint to show if appropriate 
    8596                        return this.promptMessage; 
    8697                }, 
    8798 
    88                 validate: function(/* Boolean*/ isFocused){ 
     99                validate: function(/*Boolean*/ isFocused){ 
    89100                        // summary: 
    90101                        //              Called by oninit, onblur, and onkeypress. 
     
    158169                //              Provides a hidden input field and a serialize method to override 
    159170 
    160                 serialize: function(val, /*Object?*/options){ 
     171                serialize: function(/*anything*/val, /*Object?*/options){ 
    161172                        // summary: user replaceable function used to convert the getValue() result to a String 
    162                         return val.toString ? val.toString() : ""; 
     173                        return val.toString ? val.toString() : ""; // String 
    163174                }, 
    164175 
     
    166177                        // summary: display the widget as a printable string using the widget's value 
    167178                        var val = this.filter(this.getValue()); 
    168                         return val != null ? (typeof val == "string" ? val : this.serialize(val, this.constraints)) : ""; 
     179                        return val != null ? (typeof val == "string" ? val : this.serialize(val, this.constraints)) : ""; // String 
    169180                }, 
    170181 
     
    201212); 
    202213 
     214/*===== 
     215        dijit.form.RangeBoundTextBox.__Constraints = function(){ 
     216                // min: Number 
     217                //              Minimum signed value.  Default is -Infinity 
     218                // max: Number 
     219                //              Maximum signed value.  Default is +Infinity 
     220                this.min = min; 
     221                this.max = max; 
     222        } 
     223=====*/ 
     224 
    203225dojo.declare( 
    204226        "dijit.form.RangeBoundTextBox", 
     
    208230                //              A subclass of MappedTextBox. 
    209231                //              Tests for a value out-of-range 
    210                 /*===== contraints object: 
    211                 // min: Number 
    212                 //              Minimum signed value.  Default is -Infinity 
    213                 min: undefined, 
    214                 // max: Number 
    215                 //              Maximum signed value.  Default is +Infinity 
    216                 max: undefined, 
    217                 =====*/ 
    218  
     232                // 
     233                // constraints: dijit.form.RangeBoundTextBox.__Constraints 
     234                // 
    219235                // rangeMessage: String 
    220236                //              The message to display if value is out-of-range 
    221237                rangeMessage: "", 
    222238 
    223                 compare: function(val1, val2){ 
     239                compare: function(/*anything*/val1, /*anything*/val2){ 
    224240                        // summary: compare 2 values 
    225241                        return val1 - val2; 
    226242                }, 
    227243 
    228                 rangeCheck: function(/* Number */ primitive, /* Object */ constraints){ 
     244                rangeCheck: function(/*Number*/ primitive, /*dijit.form.RangeBoundTextBox.__Constraints*/ constraints){ 
    229245                        // summary: user replaceable function used to validate the range of the numeric input value 
    230246                        var isMin = (constraints.min !== undefined); 
     
    234250                                        (!isMax || this.compare(primitive,constraints.max) <= 0); 
    235251                        } 
    236                         return true; 
    237                 }, 
    238  
    239                 isInRange: function(/* Boolean*/ isFocused){ 
     252                        return true; // Boolean 
     253                }, 
     254 
     255                isInRange: function(/*Boolean*/ isFocused){ 
    240256                        // summary: Need to over-ride with your own validation code in subclasses 
    241257                        return this.rangeCheck(this.getValue(), this.constraints); 
    242258                }, 
    243259 
    244                 isValid: function(/* Boolean*/ isFocused){ 
     260                isValid: function(/*Boolean*/ isFocused){ 
    245261                        return this.inherited(arguments) && 
    246                                 ((this._isEmpty(this.textbox.value) && !this.required) || this.isInRange(isFocused)); 
    247                 }, 
    248  
    249                 getErrorMessage: function(/* Boolean*/ isFocused){ 
    250                         if(dijit.form.RangeBoundTextBox.superclass.isValid.call(this, false) && !this.isInRange(isFocused)){ return this.rangeMessage; } 
     262                                ((this._isEmpty(this.textbox.value) && !this.required) || this.isInRange(isFocused)); // Boolean 
     263                }, 
     264 
     265                getErrorMessage: function(/*Boolean*/ isFocused){ 
     266                        if(dijit.form.RangeBoundTextBox.superclass.isValid.call(this, false) && !this.isInRange(isFocused)){ return this.rangeMessage; } // String 
    251267                        return this.inherited(arguments); 
    252268                }, 
     
    270286                }, 
    271287                 
    272                 setValue: function(/*Number*/ value, /*Boolean, optional*/ priorityChange){ 
     288                setValue: function(/*Number*/ value, /*Boolean?*/ priorityChange){ 
    273289                        dijit.setWaiState(this.focusNode, "valuenow", value); 
    274290                        this.inherited('setValue', arguments); 
  • dijit/trunk/form/_DateTimeTextBox.js

    r12736 r12918  
    66dojo.require("dijit.form.ValidationTextBox"); 
    77 
     8/*===== 
     9dojo.declare( 
     10        "dijit.form._DateTimeTextBox.__Constraints", 
     11        [dijit.form.RangeBoundTextBox.__Constraints, dojo.date.locale.__FormatOptions], 
     12        {} 
     13); 
     14=====*/ 
     15 
    816dojo.declare( 
    917        "dijit.form._DateTimeTextBox", 
     
    1220                // summary: 
    1321                //              A validating, serializable, range-bound date or time text box. 
     22                // 
     23                // constraints: dijit.form._DateTimeTextBox.__Constraints  
    1424 
    15                 // constraints object: min, max 
    1625                regExpGen: dojo.date.locale.regexp, 
    1726                compare: dojo.date.compare, 
    18                 format: function(/*Date*/ value, /*Object*/ constraints){ 
     27                format: function(/*Date*/ value, /*dijit.form._DateTimeTextBox.__Constraints*/ constraints){ 
    1928                        if(!value){ return ''; } 
    2029                        return dojo.date.locale.format(value, constraints); 
    2130                }, 
    22                 parse: function(/*String*/ value, /*Object*/ constraints){ 
     31                parse: function(/*String*/ value, /*dijit.form._DateTimeTextBox.__Constraints*/ constraints){ 
    2332                        return dojo.date.locale.parse(value, constraints) || undefined; /* can't return null to getValue since that's special */ 
    2433                }, 
     
    7281 
    7382                        if(!this._picker){ 
    74                                 var popupProto=dojo.getObject(this.popupClass, false); 
    75                                 this._picker = new popupProto({ 
     83                                var PopupProto=dojo.getObject(this.popupClass, false); 
     84                                this._picker = new PopupProto({ 
    7685                                        onValueSelected: function(value){ 
    7786 
     
    144153                }, 
    145154 
    146                 _onKeyPress: function(e){ 
     155                _onKeyPress: function(/*Event*/e){ 
    147156                        if(dijit.form._DateTimeTextBox.superclass._onKeyPress.apply(this, arguments)){ 
    148157                                if(this._opened && e.keyCode == dojo.keys.ESCAPE && !e.shiftKey && !e.ctrlKey && !e.altKey){