]> git.wh0rd.org - tt-rss.git/blame - lib/dijit/form/Form.js.uncompressed.js
modify dojo rebuild script to remove uncompressed files
[tt-rss.git] / lib / dijit / form / Form.js.uncompressed.js
CommitLineData
f0cfe83e
AD
1define("dijit/form/Form", [
2 "dojo/_base/declare", // declare
3 "dojo/dom-attr", // domAttr.set
4 "dojo/_base/event", // event.stop
5 "dojo/_base/kernel", // kernel.deprecated
6 "dojo/sniff", // has("ie")
7 "../_Widget",
8 "../_TemplatedMixin",
9 "./_FormMixin",
10 "../layout/_ContentPaneResizeMixin"
11], function(declare, domAttr, event, kernel, has, _Widget, _TemplatedMixin, _FormMixin, _ContentPaneResizeMixin){
12
13 // module:
14 // dijit/form/Form
15
16
17 return declare("dijit.form.Form", [_Widget, _TemplatedMixin, _FormMixin, _ContentPaneResizeMixin], {
18 // summary:
19 // Widget corresponding to HTML form tag, for validation and serialization
20 //
21 // example:
22 // | <form data-dojo-type="dijit/form/Form" id="myForm">
23 // | Name: <input type="text" name="name" />
24 // | </form>
25 // | myObj = {name: "John Doe"};
26 // | dijit.byId('myForm').set('value', myObj);
27 // |
28 // | myObj=dijit.byId('myForm').get('value');
29
30 // HTML <FORM> attributes
31
32 // name: String?
33 // Name of form for scripting.
34 name: "",
35
36 // action: String?
37 // Server-side form handler.
38 action: "",
39
40 // method: String?
41 // HTTP method used to submit the form, either "GET" or "POST".
42 method: "",
43
44 // encType: String?
45 // Encoding type for the form, ex: application/x-www-form-urlencoded.
46 encType: "",
47
48 // accept-charset: String?
49 // List of supported charsets.
50 "accept-charset": "",
51
52 // accept: String?
53 // List of MIME types for file upload.
54 accept: "",
55
56 // target: String?
57 // Target frame for the document to be opened in.
58 target: "",
59
60 templateString: "<form data-dojo-attach-point='containerNode' data-dojo-attach-event='onreset:_onReset,onsubmit:_onSubmit' ${!nameAttrSetting}></form>",
61
62 postMixInProperties: function(){
63 // Setup name=foo string to be referenced from the template (but only if a name has been specified)
64 // Unfortunately we can't use _setNameAttr to set the name due to IE limitations, see #8660
65 this.nameAttrSetting = this.name ? ("name='" + this.name + "'") : "";
66 this.inherited(arguments);
67 },
68
69 execute: function(/*Object*/ /*===== formContents =====*/){
70 // summary:
71 // Deprecated: use submit()
72 // tags:
73 // deprecated
74 },
75
76 onExecute: function(){
77 // summary:
78 // Deprecated: use onSubmit()
79 // tags:
80 // deprecated
81 },
82
83 _setEncTypeAttr: function(/*String*/ value){
84 this.encType = value;
85 domAttr.set(this.domNode, "encType", value);
86 if(has("ie")){ this.domNode.encoding = value; }
87 },
88
89 reset: function(/*Event?*/ e){
90 // summary:
91 // restores all widget values back to their init values,
92 // calls onReset() which can cancel the reset by returning false
93
94 // create fake event so we can know if preventDefault() is called
95 var faux = {
96 returnValue: true, // the IE way
97 preventDefault: function(){ // not IE
98 this.returnValue = false;
99 },
100 stopPropagation: function(){},
101 currentTarget: e ? e.target : this.domNode,
102 target: e ? e.target : this.domNode
103 };
104 // if return value is not exactly false, and haven't called preventDefault(), then reset
105 if(!(this.onReset(faux) === false) && faux.returnValue){
106 this.inherited(arguments, []);
107 }
108 },
109
110 onReset: function(/*Event?*/ /*===== e =====*/){
111 // summary:
112 // Callback when user resets the form. This method is intended
113 // to be over-ridden. When the `reset` method is called
114 // programmatically, the return value from `onReset` is used
115 // to compute whether or not resetting should proceed
116 // tags:
117 // callback
118 return true; // Boolean
119 },
120
121 _onReset: function(e){
122 this.reset(e);
123 event.stop(e);
124 return false;
125 },
126
127 _onSubmit: function(e){
128 var fp = this.constructor.prototype;
129 // TODO: remove this if statement beginning with 2.0
130 if(this.execute != fp.execute || this.onExecute != fp.onExecute){
131 kernel.deprecated("dijit.form.Form:execute()/onExecute() are deprecated. Use onSubmit() instead.", "", "2.0");
132 this.onExecute();
133 this.execute(this.getValues());
134 }
135 if(this.onSubmit(e) === false){ // only exactly false stops submit
136 event.stop(e);
137 }
138 },
139
140 onSubmit: function(/*Event?*/ /*===== e =====*/){
141 // summary:
142 // Callback when user submits the form.
143 // description:
144 // This method is intended to be over-ridden, but by default it checks and
145 // returns the validity of form elements. When the `submit`
146 // method is called programmatically, the return value from
147 // `onSubmit` is used to compute whether or not submission
148 // should proceed
149 // tags:
150 // extension
151
152 return this.isValid(); // Boolean
153 },
154
155 submit: function(){
156 // summary:
157 // programmatically submit form if and only if the `onSubmit` returns true
158 if(!(this.onSubmit() === false)){
159 this.containerNode.submit();
160 }
161 }
162 });
163});