123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- if(!dojo._hasResource["dojox.form.manager._FormMixin"]){
- dojo._hasResource["dojox.form.manager._FormMixin"] = true;
- dojo.provide("dojox.form.manager._FormMixin");
- dojo.require("dojox.form.manager._Mixin");
- (function(){
- var fm = dojox.form.manager,
- aa = fm.actionAdapter;
- dojo.declare("dojox.form.manager._FormMixin", null, {
-
-
-
-
-
-
-
-
- name: "",
- action: "",
- method: "",
- encType: "",
- "accept-charset": "",
- accept: "",
- target: "",
- startup: function(){
- this.isForm = this.domNode.tagName.toLowerCase() == "form";
- if(this.isForm){
- this.connect(this.domNode, "onreset", "_onReset");
- this.connect(this.domNode, "onsubmit", "_onSubmit");
- }
- this.inherited(arguments);
- },
-
- _onReset: function(evt){
-
-
-
- var faux = {
- returnValue: true,
- preventDefault: function(){
- this.returnValue = false;
- },
- stopPropagation: function(){}, currentTarget: evt.currentTarget, target: evt.target
- };
-
- if(!(this.onReset(faux) === false) && faux.returnValue){
- this.reset();
- }
- dojo.stopEvent(evt);
- return false;
- },
- onReset: function(){
-
-
-
-
-
- return true;
- },
- reset: function(){
-
-
- this.inspectFormWidgets(aa(function(_, widget){
- if(widget.reset){
- widget.reset();
- }
- }));
- if(this.isForm){
- this.domNode.reset();
- }
- return this;
- },
- _onSubmit: function(evt){
-
-
- if(this.onSubmit(evt) === false){
- dojo.stopEvent(evt);
- }
- },
- onSubmit: function(){
-
-
-
-
-
-
-
- return this.isValid();
- },
- submit: function(){
-
-
- if(this.isForm){
- if(!(this.onSubmit() === false)){
- this.domNode.submit();
- }
- }
- },
- isValid: function(){
-
-
- for(var name in this.formWidgets){
- var stop = false;
- aa(function(_, widget){
- if(!widget.get("disabled") && widget.isValid && !widget.isValid()){
- stop = true;
- }
- }).call(this, null, this.formWidgets[name].widget);
- if(stop){
- return false;
- }
- }
- return true;
- },
- validate: function () {
- var isValid = true,
- formWidgets = this.formWidgets,
- didFocus = false, name;
- for(name in formWidgets){
- aa(function(_, widget){
-
-
- widget._hasBeenBlurred = true;
- var valid = widget.disabled || !widget.validate || widget.validate();
- if(!valid && !didFocus){
-
- dojo.window.scrollIntoView(widget.containerNode || widget.domNode);
- widget.focus();
- didFocus = true;
- }
- isValid = isValid && valid;
- }).call(this, null, formWidgets[name].widget);
- }
- return isValid;
- }
- });
- })();
- }
|