source: Dev/trunk/src/client/dijit/form/_FormValueMixin.js

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 2.5 KB
Line 
1define([
2        "dojo/_base/declare", // declare
3        "dojo/dom-attr", // domAttr.set
4        "dojo/keys", // keys.ESCAPE
5        "dojo/_base/lang",
6        "dojo/on",
7        "dojo/sniff", // has("ie"), has("quirks")
8        "./_FormWidgetMixin"
9], function(declare, domAttr, keys, lang, on, has, _FormWidgetMixin){
10
11        // module:
12        //              dijit/form/_FormValueMixin
13
14        return declare("dijit.form._FormValueMixin", _FormWidgetMixin, {
15                // summary:
16                //              Mixin for widgets corresponding to native HTML elements such as `<input>` or `<select>`
17                //              that have user changeable values.
18                // description:
19                //              Each _FormValueMixin represents a single input value, and has a (possibly hidden) `<input>` element,
20                //              to which it serializes it's input value, so that form submission (either normal submission or via FormBind?)
21                //              works as expected.
22
23                // readOnly: Boolean
24                //              Should this widget respond to user input?
25                //              In markup, this is specified as "readOnly".
26                //              Similar to disabled except readOnly form values are submitted.
27                readOnly: false,
28
29                _setReadOnlyAttr: function(/*Boolean*/ value){
30                        domAttr.set(this.focusNode, 'readOnly', value);
31                        this._set("readOnly", value);
32                },
33
34                postCreate: function(){
35                        this.inherited(arguments);
36
37                        // Update our reset value if it hasn't yet been set (because this.set()
38                        // is only called when there *is* a value)
39                        if(this._resetValue === undefined){
40                                this._lastValueReported = this._resetValue = this.value;
41                        }
42                },
43
44                _setValueAttr: function(/*anything*/ newValue, /*Boolean?*/ priorityChange){
45                        // summary:
46                        //              Hook so set('value', value) works.
47                        // description:
48                        //              Sets the value of the widget.
49                        //              If the value has changed, then fire onChange event, unless priorityChange
50                        //              is specified as null (or false?)
51                        this._handleOnChange(newValue, priorityChange);
52                },
53
54                _handleOnChange: function(/*anything*/ newValue, /*Boolean?*/ priorityChange){
55                        // summary:
56                        //              Called when the value of the widget has changed.  Saves the new value in this.value,
57                        //              and calls onChange() if appropriate.   See _FormWidget._handleOnChange() for details.
58                        this._set("value", newValue);
59                        this.inherited(arguments);
60                },
61
62                undo: function(){
63                        // summary:
64                        //              Restore the value to the last value passed to onChange
65                        this._setValueAttr(this._lastValueReported, false);
66                },
67
68                reset: function(){
69                        // summary:
70                        //              Reset the widget's value to what it was at initialization time
71                        this._hasBeenBlurred = false;
72                        this._setValueAttr(this._resetValue, true);
73                }
74        });
75});
Note: See TracBrowser for help on using the repository browser.