]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/Form.js.uncompressed.js
1 define("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")
10 "../layout/_ContentPaneResizeMixin"
11 ], function(declare
, domAttr
, event
, kernel
, has
, _Widget
, _TemplatedMixin
, _FormMixin
, _ContentPaneResizeMixin
){
17 return declare("dijit.form.Form", [_Widget
, _TemplatedMixin
, _FormMixin
, _ContentPaneResizeMixin
], {
19 // Widget corresponding to HTML form tag, for validation and serialization
22 // | <form data-dojo-type="dijit/form/Form" id="myForm">
23 // | Name: <input type="text" name="name" />
25 // | myObj = {name: "John Doe"};
26 // | dijit.byId('myForm').set('value', myObj);
28 // | myObj=dijit.byId('myForm').get('value');
30 // HTML <FORM> attributes
33 // Name of form for scripting.
37 // Server-side form handler.
41 // HTTP method used to submit the form, either "GET" or "POST".
45 // Encoding type for the form, ex: application/x-www-form-urlencoded.
48 // accept-charset: String?
49 // List of supported charsets.
53 // List of MIME types for file upload.
57 // Target frame for the document to be opened in.
60 templateString
: "<form data-dojo-attach-point='containerNode' data-dojo-attach-event='onreset:_onReset,onsubmit:_onSubmit' ${!nameAttrSetting}></form>",
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
);
69 execute: function(/*Object*/ /*===== formContents =====*/){
71 // Deprecated: use submit()
76 onExecute: function(){
78 // Deprecated: use onSubmit()
83 _setEncTypeAttr: function(/*String*/ value
){
85 domAttr
.set(this.domNode
, "encType", value
);
86 if(has("ie")){ this.domNode
.encoding
= value
; }
89 reset: function(/*Event?*/ e
){
91 // restores all widget values back to their init values,
92 // calls onReset() which can cancel the reset by returning false
94 // create fake event so we can know if preventDefault() is called
96 returnValue
: true, // the IE way
97 preventDefault: function(){ // not IE
98 this.returnValue
= false;
100 stopPropagation: function(){},
101 currentTarget
: e
? e
.target
: this.domNode
,
102 target
: e
? e
.target
: this.domNode
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
, []);
110 onReset: function(/*Event?*/ /*===== e =====*/){
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
118 return true; // Boolean
121 _onReset: function(e
){
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");
133 this.execute(this.getValues());
135 if(this.onSubmit(e
) === false){ // only exactly false stops submit
140 onSubmit: function(/*Event?*/ /*===== e =====*/){
142 // Callback when user submits the form.
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
152 return this.isValid(); // Boolean
157 // programmatically submit form if and only if the `onSubmit` returns true
158 if(!(this.onSubmit() === false)){
159 this.containerNode
.submit();