diff options
Diffstat (limited to 'js/dojo-1.6/dojox/form/manager')
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_ClassMixin.js | 81 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_ClassMixin.xd.js | 86 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_DisplayMixin.js | 72 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_DisplayMixin.xd.js | 76 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_EnableMixin.js | 92 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_EnableMixin.xd.js | 97 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_FormMixin.js | 163 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_FormMixin.xd.js | 168 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_Mixin.js | 495 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_Mixin.xd.js | 500 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_NodeMixin.js | 371 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_NodeMixin.xd.js | 376 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_ValueMixin.js | 88 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/form/manager/_ValueMixin.xd.js | 92 |
14 files changed, 2757 insertions, 0 deletions
diff --git a/js/dojo-1.6/dojox/form/manager/_ClassMixin.js b/js/dojo-1.6/dojox/form/manager/_ClassMixin.js new file mode 100644 index 0000000..98d5a07 --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_ClassMixin.js @@ -0,0 +1,81 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.form.manager._ClassMixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.form.manager._ClassMixin"] = true;
+dojo.provide("dojox.form.manager._ClassMixin");
+
+dojo.require("dojox.form.manager._Mixin");
+
+(function(){
+ var fm = dojox.form.manager,
+ aa = fm.actionAdapter,
+ ia = fm.inspectorAdapter;
+
+ dojo.declare("dojox.form.manager._ClassMixin", null, {
+ // summary:
+ // Form manager's mixin for testing/assigning/removing
+ // classes of controlled elements.
+ // description:
+ // This mixin provides unified way to check/add/remove a class
+ // of controlled elements.
+ // It should be used together with dojox.form.manager.Mixin.
+
+ gatherClassState: function(className, names){
+ // summary:
+ // Gather the presence of a certain class in all controlled elements.
+ // className: String:
+ // The class name to test for.
+ // names: Object?:
+ // If it is an array, it is a list of names to be processed.
+ // If it is an object, dictionary keys are names to be processed.
+ // If it is omitted, all known form elements are to be processed.
+
+ var result = this.inspect(ia(function(name, node){
+ return dojo.hasClass(node, className);
+ }), names);
+
+ return result; // Object
+ },
+
+ addClass: function(className, names){
+ // summary:
+ // Add a class to nodes according to the supplied set of names
+ // className: String:
+ // Class name to add.
+ // names: Object?:
+ // If it is an array, it is a list of names to be processed.
+ // If it is an object, dictionary keys are names to be processed.
+ // If it is omitted, all known form elements are to be processed.
+
+ this.inspect(aa(function(name, node){
+ dojo.addClass(node, className);
+ }), names);
+
+ return this; // self
+ },
+
+ removeClass: function(className, names){
+ // summary:
+ // Remove a class from nodes according to the supplied set of names
+ // className: String:
+ // Class name to remove.
+ // names: Object?:
+ // If it is an array, it is a list of names to be processed.
+ // If it is an object, dictionary keys are names to be processed.
+ // If it is omitted, all known form elements are to be processed.
+
+ this.inspect(aa(function(name, node){
+ dojo.removeClass(node, className);
+ }), names);
+
+ return this; // self
+ }
+ });
+})();
+
+}
diff --git a/js/dojo-1.6/dojox/form/manager/_ClassMixin.xd.js b/js/dojo-1.6/dojox/form/manager/_ClassMixin.xd.js new file mode 100644 index 0000000..64e511b --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_ClassMixin.xd.js @@ -0,0 +1,86 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.form.manager._ClassMixin"],
+["require", "dojox.form.manager._Mixin"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.form.manager._ClassMixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.form.manager._ClassMixin"] = true;
+dojo.provide("dojox.form.manager._ClassMixin");
+
+dojo.require("dojox.form.manager._Mixin");
+
+(function(){
+ var fm = dojox.form.manager,
+ aa = fm.actionAdapter,
+ ia = fm.inspectorAdapter;
+
+ dojo.declare("dojox.form.manager._ClassMixin", null, {
+ // summary:
+ // Form manager's mixin for testing/assigning/removing
+ // classes of controlled elements.
+ // description:
+ // This mixin provides unified way to check/add/remove a class
+ // of controlled elements.
+ // It should be used together with dojox.form.manager.Mixin.
+
+ gatherClassState: function(className, names){
+ // summary:
+ // Gather the presence of a certain class in all controlled elements.
+ // className: String:
+ // The class name to test for.
+ // names: Object?:
+ // If it is an array, it is a list of names to be processed.
+ // If it is an object, dictionary keys are names to be processed.
+ // If it is omitted, all known form elements are to be processed.
+
+ var result = this.inspect(ia(function(name, node){
+ return dojo.hasClass(node, className);
+ }), names);
+
+ return result; // Object
+ },
+
+ addClass: function(className, names){
+ // summary:
+ // Add a class to nodes according to the supplied set of names
+ // className: String:
+ // Class name to add.
+ // names: Object?:
+ // If it is an array, it is a list of names to be processed.
+ // If it is an object, dictionary keys are names to be processed.
+ // If it is omitted, all known form elements are to be processed.
+
+ this.inspect(aa(function(name, node){
+ dojo.addClass(node, className);
+ }), names);
+
+ return this; // self
+ },
+
+ removeClass: function(className, names){
+ // summary:
+ // Remove a class from nodes according to the supplied set of names
+ // className: String:
+ // Class name to remove.
+ // names: Object?:
+ // If it is an array, it is a list of names to be processed.
+ // If it is an object, dictionary keys are names to be processed.
+ // If it is omitted, all known form elements are to be processed.
+
+ this.inspect(aa(function(name, node){
+ dojo.removeClass(node, className);
+ }), names);
+
+ return this; // self
+ }
+ });
+})();
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/form/manager/_DisplayMixin.js b/js/dojo-1.6/dojox/form/manager/_DisplayMixin.js new file mode 100644 index 0000000..63f4b95 --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_DisplayMixin.js @@ -0,0 +1,72 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.form.manager._DisplayMixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.form.manager._DisplayMixin"] = true;
+dojo.provide("dojox.form.manager._DisplayMixin");
+
+dojo.declare("dojox.form.manager._DisplayMixin", null, {
+ // summary:
+ // Form manager's mixin for controlling show/hide state of
+ // controlled elements (defined by dojoAttachPoint attributes).
+ // description:
+ // This mixin provides unified show/hide functionality for
+ // controlled elements (indicated by dojoAttachPoint attribute).
+ // Essentially it provides a way to change "style.display"
+ // parameter of controlled nodes.
+ // It should be used together with dojox.form.manager.Mixin.
+
+ gatherDisplayState: function(names){
+ // summary:
+ // Gather display state of all attached elements and return as a dictionary.
+ // names: Object?:
+ // If it is an array, it is a list of names to be processed.
+ // If it is an object, dictionary keys are names to be processed.
+ // If it is omitted, all known attach point nodes are to be processed.
+
+ var result = this.inspectAttachedPoints(function(name, node){
+ return dojo.style(node, "display") != "none";
+ }, names);
+
+ return result; // Object
+ },
+
+ show: function(state, defaultState){
+ // summary:
+ // Show attached nodes according to the supplied state object.
+ // state: Object?:
+ // Optional. If a name-value dictionary, the value is true
+ // to show and false to hide. If an array, all names in the
+ // array will be set to defaultState. If omitted, all form
+ // elements will be set to defaultState.
+ // defaultState: Boolean?:
+ // The default state (true, if omitted).
+
+ if(arguments.length < 2){
+ defaultState = true;
+ }
+
+ this.inspectAttachedPoints(function(name, node, value){
+ dojo.style(node, "display", value ? "" : "none");
+ }, state, defaultState);
+
+ return this; // self
+ },
+
+ hide: function(state){
+ // summary:
+ // Hide attached nodes according to the supplied state object.
+ // state: Object?:
+ // Optional. If a name-value dictionary, the value is true
+ // to show and false to hide. If an array, all names in the
+ // array will be hidden. If omitted, all form elements
+ // will be hidden.
+ return this.show(state, false); // self
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/form/manager/_DisplayMixin.xd.js b/js/dojo-1.6/dojox/form/manager/_DisplayMixin.xd.js new file mode 100644 index 0000000..7de37c4 --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_DisplayMixin.xd.js @@ -0,0 +1,76 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.form.manager._DisplayMixin"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.form.manager._DisplayMixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.form.manager._DisplayMixin"] = true;
+dojo.provide("dojox.form.manager._DisplayMixin");
+
+dojo.declare("dojox.form.manager._DisplayMixin", null, {
+ // summary:
+ // Form manager's mixin for controlling show/hide state of
+ // controlled elements (defined by dojoAttachPoint attributes).
+ // description:
+ // This mixin provides unified show/hide functionality for
+ // controlled elements (indicated by dojoAttachPoint attribute).
+ // Essentially it provides a way to change "style.display"
+ // parameter of controlled nodes.
+ // It should be used together with dojox.form.manager.Mixin.
+
+ gatherDisplayState: function(names){
+ // summary:
+ // Gather display state of all attached elements and return as a dictionary.
+ // names: Object?:
+ // If it is an array, it is a list of names to be processed.
+ // If it is an object, dictionary keys are names to be processed.
+ // If it is omitted, all known attach point nodes are to be processed.
+
+ var result = this.inspectAttachedPoints(function(name, node){
+ return dojo.style(node, "display") != "none";
+ }, names);
+
+ return result; // Object
+ },
+
+ show: function(state, defaultState){
+ // summary:
+ // Show attached nodes according to the supplied state object.
+ // state: Object?:
+ // Optional. If a name-value dictionary, the value is true
+ // to show and false to hide. If an array, all names in the
+ // array will be set to defaultState. If omitted, all form
+ // elements will be set to defaultState.
+ // defaultState: Boolean?:
+ // The default state (true, if omitted).
+
+ if(arguments.length < 2){
+ defaultState = true;
+ }
+
+ this.inspectAttachedPoints(function(name, node, value){
+ dojo.style(node, "display", value ? "" : "none");
+ }, state, defaultState);
+
+ return this; // self
+ },
+
+ hide: function(state){
+ // summary:
+ // Hide attached nodes according to the supplied state object.
+ // state: Object?:
+ // Optional. If a name-value dictionary, the value is true
+ // to show and false to hide. If an array, all names in the
+ // array will be hidden. If omitted, all form elements
+ // will be hidden.
+ return this.show(state, false); // self
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/form/manager/_EnableMixin.js b/js/dojo-1.6/dojox/form/manager/_EnableMixin.js new file mode 100644 index 0000000..2245be6 --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_EnableMixin.js @@ -0,0 +1,92 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.form.manager._EnableMixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.form.manager._EnableMixin"] = true;
+dojo.provide("dojox.form.manager._EnableMixin");
+
+dojo.require("dojox.form.manager._Mixin");
+
+(function(){
+ var fm = dojox.form.manager,
+ aa = fm.actionAdapter,
+ ia = fm.inspectorAdapter;
+
+ dojo.declare("dojox.form.manager._EnableMixin", null, {
+ // summary:
+ // Form manager's mixin for controlling enable/disable state of
+ // form elements.
+ // description:
+ // This mixin provides unified enable/disable functionality for
+ // form widgets and form elements. It should be used together
+ // with dojox.form.manager.Mixin.
+
+ gatherEnableState: function(names){
+ // summary:
+ // Gather enable state of all form elements and return as a dictionary.
+ // names: Object?:
+ // If it is an array, it is a list of names to be processed.
+ // If it is an object, dictionary keys are names to be processed.
+ // If it is omitted, all known form elements are to be processed.
+
+ var result = this.inspectFormWidgets(ia(function(name, widget){
+ return !widget.get("disabled");
+ }), names);
+
+ if(this.inspectFormNodes){
+ dojo.mixin(result, this.inspectFormNodes(ia(function(name, node){
+ return !dojo.attr(node, "disabled");
+ }), names));
+ }
+
+ return result; // Object
+ },
+
+ enable: function(state, defaultState){
+ // summary:
+ // Enable form controls according to the supplied state object.
+ // state: Object?:
+ // Optional. If a name-value dictionary, the value is true
+ // to enable and false to disable. If an array, all names in the
+ // array will be set to defaultState. If omitted, all form
+ // elements will be set to defaultState.
+ // defaultState: Boolean:
+ // The default state (true, if omitted).
+
+ if(arguments.length < 2 || defaultState === undefined){
+ defaultState = true;
+ }
+
+ this.inspectFormWidgets(aa(function(name, widget, value){
+ widget.set("disabled", !value);
+ }), state, defaultState);
+
+ if(this.inspectFormNodes){
+ this.inspectFormNodes(aa(function(name, node, value){
+ dojo.attr(node, "disabled", !value);
+ }), state, defaultState);
+ }
+
+ return this; // self
+ },
+
+ disable: function(state){
+ // summary:
+ // Disable form controls according to the supplied state object
+ // returning the previous state.
+ // state: Object?:
+ // Optional. If a name-value dictionary, the value is true
+ // to enable and false to disable. If an array, all names in the
+ // array will be disabled. If omitted, disables all.
+ var oldState = this.gatherEnableState();
+ this.enable(state, false);
+ return oldState; // Object
+ }
+ });
+})();
+
+}
diff --git a/js/dojo-1.6/dojox/form/manager/_EnableMixin.xd.js b/js/dojo-1.6/dojox/form/manager/_EnableMixin.xd.js new file mode 100644 index 0000000..0771ef9 --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_EnableMixin.xd.js @@ -0,0 +1,97 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.form.manager._EnableMixin"],
+["require", "dojox.form.manager._Mixin"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.form.manager._EnableMixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.form.manager._EnableMixin"] = true;
+dojo.provide("dojox.form.manager._EnableMixin");
+
+dojo.require("dojox.form.manager._Mixin");
+
+(function(){
+ var fm = dojox.form.manager,
+ aa = fm.actionAdapter,
+ ia = fm.inspectorAdapter;
+
+ dojo.declare("dojox.form.manager._EnableMixin", null, {
+ // summary:
+ // Form manager's mixin for controlling enable/disable state of
+ // form elements.
+ // description:
+ // This mixin provides unified enable/disable functionality for
+ // form widgets and form elements. It should be used together
+ // with dojox.form.manager.Mixin.
+
+ gatherEnableState: function(names){
+ // summary:
+ // Gather enable state of all form elements and return as a dictionary.
+ // names: Object?:
+ // If it is an array, it is a list of names to be processed.
+ // If it is an object, dictionary keys are names to be processed.
+ // If it is omitted, all known form elements are to be processed.
+
+ var result = this.inspectFormWidgets(ia(function(name, widget){
+ return !widget.get("disabled");
+ }), names);
+
+ if(this.inspectFormNodes){
+ dojo.mixin(result, this.inspectFormNodes(ia(function(name, node){
+ return !dojo.attr(node, "disabled");
+ }), names));
+ }
+
+ return result; // Object
+ },
+
+ enable: function(state, defaultState){
+ // summary:
+ // Enable form controls according to the supplied state object.
+ // state: Object?:
+ // Optional. If a name-value dictionary, the value is true
+ // to enable and false to disable. If an array, all names in the
+ // array will be set to defaultState. If omitted, all form
+ // elements will be set to defaultState.
+ // defaultState: Boolean:
+ // The default state (true, if omitted).
+
+ if(arguments.length < 2 || defaultState === undefined){
+ defaultState = true;
+ }
+
+ this.inspectFormWidgets(aa(function(name, widget, value){
+ widget.set("disabled", !value);
+ }), state, defaultState);
+
+ if(this.inspectFormNodes){
+ this.inspectFormNodes(aa(function(name, node, value){
+ dojo.attr(node, "disabled", !value);
+ }), state, defaultState);
+ }
+
+ return this; // self
+ },
+
+ disable: function(state){
+ // summary:
+ // Disable form controls according to the supplied state object
+ // returning the previous state.
+ // state: Object?:
+ // Optional. If a name-value dictionary, the value is true
+ // to enable and false to disable. If an array, all names in the
+ // array will be disabled. If omitted, disables all.
+ var oldState = this.gatherEnableState();
+ this.enable(state, false);
+ return oldState; // Object
+ }
+ });
+})();
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/form/manager/_FormMixin.js b/js/dojo-1.6/dojox/form/manager/_FormMixin.js new file mode 100644 index 0000000..f7c9037 --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_FormMixin.js @@ -0,0 +1,163 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.form.manager._FormMixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+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, {
+ // summary:
+ // Form manager's mixin for form-specific functionality.
+ // description:
+ // This mixin adds automated "onreset", and "onsubmit" event processing
+ // if we are based on a form node, defines onReset(), onSubmit(),
+ // reset(), submit(), and isValid() methods like dijit.form.Form.
+ // It should be used together with dojox.form.manager.Mixin.
+
+ // HTML <FORM> attributes (if we are based on the form element)
+ 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);
+ },
+
+ // form-specific functionality
+
+ _onReset: function(evt){
+ // NOTE: this function is taken from dijit.formForm, it works only
+ // for form-based managers.
+
+ // create fake event so we can know if preventDefault() is called
+ var faux = {
+ returnValue: true, // the IE way
+ preventDefault: function(){ // not IE
+ this.returnValue = false;
+ },
+ stopPropagation: function(){}, currentTarget: evt.currentTarget, target: evt.target
+ };
+ // if return value is not exactly false, and haven't called preventDefault(), then reset
+ if(!(this.onReset(faux) === false) && faux.returnValue){
+ this.reset();
+ }
+ dojo.stopEvent(evt);
+ return false;
+ },
+
+ onReset: function(){
+ // summary:
+ // Callback when user resets the form. This method is intended
+ // to be over-ridden. When the `reset` method is called
+ // programmatically, the return value from `onReset` is used
+ // to compute whether or not resetting should proceed
+ return true; // Boolean
+ },
+
+ reset: function(){
+ // summary:
+ // Resets form widget values.
+ this.inspectFormWidgets(aa(function(_, widget){
+ if(widget.reset){
+ widget.reset();
+ }
+ }));
+ if(this.isForm){
+ this.domNode.reset();
+ }
+ return this;
+ },
+
+ _onSubmit: function(evt){
+ // NOTE: this function is taken from dijit.formForm, it works only
+ // for form-based managers.
+
+ if(this.onSubmit(evt) === false){ // only exactly false stops submit
+ dojo.stopEvent(evt);
+ }
+ },
+
+ onSubmit: function(){
+ // summary:
+ // Callback when user submits the form. This method is
+ // intended to be over-ridden, but by default it checks and
+ // returns the validity of form elements. When the `submit`
+ // method is called programmatically, the return value from
+ // `onSubmit` is used to compute whether or not submission
+ // should proceed
+
+ return this.isValid(); // Boolean
+ },
+
+ submit: function(){
+ // summary:
+ // programmatically submit form if and only if the `onSubmit` returns true
+ if(this.isForm){
+ if(!(this.onSubmit() === false)){
+ this.domNode.submit();
+ }
+ }
+ },
+
+ isValid: function(){
+ // summary:
+ // Make sure that every widget that has a validator function returns true.
+ 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){
+ // Need to set this so that "required" widgets get their
+ // state set.
+ widget._hasBeenBlurred = true;
+ var valid = widget.disabled || !widget.validate || widget.validate();
+ if(!valid && !didFocus){
+ // Set focus of the first non-valid widget
+ dojo.window.scrollIntoView(widget.containerNode || widget.domNode);
+ widget.focus();
+ didFocus = true;
+ }
+ isValid = isValid && valid;
+ }).call(this, null, formWidgets[name].widget);
+ }
+
+ return isValid;
+ }
+ });
+})();
+
+}
diff --git a/js/dojo-1.6/dojox/form/manager/_FormMixin.xd.js b/js/dojo-1.6/dojox/form/manager/_FormMixin.xd.js new file mode 100644 index 0000000..c9695d7 --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_FormMixin.xd.js @@ -0,0 +1,168 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.form.manager._FormMixin"],
+["require", "dojox.form.manager._Mixin"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.form.manager._FormMixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+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, {
+ // summary:
+ // Form manager's mixin for form-specific functionality.
+ // description:
+ // This mixin adds automated "onreset", and "onsubmit" event processing
+ // if we are based on a form node, defines onReset(), onSubmit(),
+ // reset(), submit(), and isValid() methods like dijit.form.Form.
+ // It should be used together with dojox.form.manager.Mixin.
+
+ // HTML <FORM> attributes (if we are based on the form element)
+ 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);
+ },
+
+ // form-specific functionality
+
+ _onReset: function(evt){
+ // NOTE: this function is taken from dijit.formForm, it works only
+ // for form-based managers.
+
+ // create fake event so we can know if preventDefault() is called
+ var faux = {
+ returnValue: true, // the IE way
+ preventDefault: function(){ // not IE
+ this.returnValue = false;
+ },
+ stopPropagation: function(){}, currentTarget: evt.currentTarget, target: evt.target
+ };
+ // if return value is not exactly false, and haven't called preventDefault(), then reset
+ if(!(this.onReset(faux) === false) && faux.returnValue){
+ this.reset();
+ }
+ dojo.stopEvent(evt);
+ return false;
+ },
+
+ onReset: function(){
+ // summary:
+ // Callback when user resets the form. This method is intended
+ // to be over-ridden. When the `reset` method is called
+ // programmatically, the return value from `onReset` is used
+ // to compute whether or not resetting should proceed
+ return true; // Boolean
+ },
+
+ reset: function(){
+ // summary:
+ // Resets form widget values.
+ this.inspectFormWidgets(aa(function(_, widget){
+ if(widget.reset){
+ widget.reset();
+ }
+ }));
+ if(this.isForm){
+ this.domNode.reset();
+ }
+ return this;
+ },
+
+ _onSubmit: function(evt){
+ // NOTE: this function is taken from dijit.formForm, it works only
+ // for form-based managers.
+
+ if(this.onSubmit(evt) === false){ // only exactly false stops submit
+ dojo.stopEvent(evt);
+ }
+ },
+
+ onSubmit: function(){
+ // summary:
+ // Callback when user submits the form. This method is
+ // intended to be over-ridden, but by default it checks and
+ // returns the validity of form elements. When the `submit`
+ // method is called programmatically, the return value from
+ // `onSubmit` is used to compute whether or not submission
+ // should proceed
+
+ return this.isValid(); // Boolean
+ },
+
+ submit: function(){
+ // summary:
+ // programmatically submit form if and only if the `onSubmit` returns true
+ if(this.isForm){
+ if(!(this.onSubmit() === false)){
+ this.domNode.submit();
+ }
+ }
+ },
+
+ isValid: function(){
+ // summary:
+ // Make sure that every widget that has a validator function returns true.
+ 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){
+ // Need to set this so that "required" widgets get their
+ // state set.
+ widget._hasBeenBlurred = true;
+ var valid = widget.disabled || !widget.validate || widget.validate();
+ if(!valid && !didFocus){
+ // Set focus of the first non-valid widget
+ dojo.window.scrollIntoView(widget.containerNode || widget.domNode);
+ widget.focus();
+ didFocus = true;
+ }
+ isValid = isValid && valid;
+ }).call(this, null, formWidgets[name].widget);
+ }
+
+ return isValid;
+ }
+ });
+})();
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/form/manager/_Mixin.js b/js/dojo-1.6/dojox/form/manager/_Mixin.js new file mode 100644 index 0000000..63681e1 --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_Mixin.js @@ -0,0 +1,495 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.form.manager._Mixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.form.manager._Mixin"] = true;
+dojo.provide("dojox.form.manager._Mixin");
+
+dojo.require("dijit._Widget");
+
+(function(){
+ var fm = dojox.form.manager,
+
+ aa = fm.actionAdapter = function(action){
+ // summary:
+ // Adapter that automates application of actions to arrays.
+ // action: Function:
+ // Function that takes three parameters: a name, an object
+ // (usually node or widget), and a value. This action will
+ // be applied to all elements of array.
+ return function(name, elems, value){
+ if(dojo.isArray(elems)){
+ dojo.forEach(elems, function(elem){
+ action.call(this, name, elem, value);
+ }, this);
+ }else{
+ action.apply(this, arguments);
+ }
+ };
+ },
+
+ ia = fm.inspectorAdapter = function(inspector){
+ // summary:
+ // Adapter that applies an inspector only to the first item of the array.
+ // inspector: Function:
+ // Function that takes three parameters: a name, an object
+ // (usually node or widget), and a value.
+ return function(name, elem, value){
+ return inspector.call(this, name, dojo.isArray(elem) ? elem[0] : elem, value);
+ };
+ },
+
+ skipNames = {domNode: 1, containerNode: 1, srcNodeRef: 1, bgIframe: 1},
+
+ keys = fm._keys = function(o){
+ // similar to dojox.lang.functional.keys
+ var list = [], key;
+ for(key in o){
+ if(o.hasOwnProperty(key)){
+ list.push(key);
+ }
+ }
+ return list;
+ },
+
+ registerWidget = function(widget){
+ var name = widget.get("name");
+ if(name && widget instanceof dijit.form._FormWidget){
+ if(name in this.formWidgets){
+ var a = this.formWidgets[name].widget;
+ if(dojo.isArray(a)){
+ a.push(widget);
+ }else{
+ this.formWidgets[name].widget = [a, widget];
+ }
+ }else{
+ this.formWidgets[name] = {widget: widget, connections: []};
+ }
+ }else{
+ name = null;
+ }
+ return name;
+ },
+
+ getObserversFromWidget = function(name){
+ var observers = {};
+ aa(function(_, w){
+ var o = w.get("observer");
+ if(o && typeof o == "string"){
+ dojo.forEach(o.split(","), function(o){
+ o = dojo.trim(o);
+ if(o && dojo.isFunction(this[o])){
+ observers[o] = 1;
+ }
+ }, this);
+ }
+ }).call(this, null, this.formWidgets[name].widget);
+ return keys(observers);
+ },
+
+ connectWidget = function(name, observers){
+ var t = this.formWidgets[name], w = t.widget, c = t.connections;
+ if(c.length){
+ dojo.forEach(c, dojo.disconnect);
+ c = t.connections = [];
+ }
+ if(dojo.isArray(w)){
+ // radio buttons
+ dojo.forEach(w, function(w){
+ dojo.forEach(observers, function(o){
+ c.push(dojo.connect(w, "onChange", this, function(evt){
+ // TODO: for some reason for radio button widgets
+ // w.checked != w.focusNode.checked when value changes.
+ // We test the underlying value to be 100% sure.
+ if(this.watching && dojo.attr(w.focusNode, "checked")){
+ this[o](w.get("value"), name, w, evt);
+ }
+ }));
+ }, this);
+ }, this);
+ }else{
+ // the rest
+ // the next line is a crude workaround for dijit.form.Button that fires onClick instead of onChange
+ var eventName = w.declaredClass == "dijit.form.Button" ?
+ "onClick" : "onChange";
+ dojo.forEach(observers, function(o){
+ c.push(dojo.connect(w, eventName, this, function(evt){
+ if(this.watching){
+ this[o](w.get("value"), name, w, evt);
+ }
+ }));
+ }, this);
+ }
+ };
+
+ dojo.declare("dojox.form.manager._Mixin", null, {
+ // summary:
+ // Mixin to orchestrate dynamic forms.
+ // description:
+ // This mixin provideas a foundation for an enhanced form
+ // functionality: unified access to individual form elements,
+ // unified "onchange" event processing, general event
+ // processing, I/O orchestration, and common form-related
+ // functionality. See additional mixins in dojox.form.manager
+ // namespace.
+
+ watching: true,
+
+ startup: function(){
+ // summary:
+ // Called after all the widgets have been instantiated and their
+ // dom nodes have been inserted somewhere under dojo.doc.body.
+
+ if(this._started){ return; }
+
+ this.formWidgets = {};
+ this.formNodes = {};
+ this.registerWidgetDescendants(this);
+
+ this.inherited(arguments);
+ },
+
+ destroy: function(){
+ // summary:
+ // Called when the widget is being destroyed
+
+ for(var name in this.formWidgets){
+ dojo.forEach(this.formWidgets[name].connections, dojo.disconnect);
+ }
+ this.formWidgets = {};
+
+ this.inherited(arguments);
+ },
+
+ // register/unregister widgets and nodes
+
+ registerWidget: function(widget){
+ // summary:
+ // Register a widget with the form manager
+ // widget: String|Node|dijit.form._FormWidget:
+ // A widget, or its widgetId, or its DOM node
+ // returns: Object:
+ // Returns self
+ if(typeof widget == "string"){
+ widget = dijit.byId(widget);
+ }else if(widget.tagName && widget.cloneNode){
+ widget = dijit.byNode(widget);
+ }
+ var name = registerWidget.call(this, widget);
+ if(name){
+ connectWidget.call(this, name, getObserversFromWidget.call(this, name));
+ }
+ return this;
+ },
+
+ unregisterWidget: function(name){
+ // summary:
+ // Removes the widget by name from internal tables unregistering
+ // connected observers
+ // name: String:
+ // Name of the to unregister
+ // returns: Object:
+ // Returns self
+ if(name in this.formWidgets){
+ dojo.forEach(this.formWidgets[name].connections, this.disconnect, this);
+ delete this.formWidgets[name];
+ }
+ return this;
+ },
+
+ registerWidgetDescendants: function(widget){
+ // summary:
+ // Register widget's descendants with the form manager
+ // widget: String|Node|dijit._Widget:
+ // A widget, or its widgetId, or its DOM node
+ // returns: Object:
+ // Returns self
+
+ // convert to widget, if required
+ if(typeof widget == "string"){
+ widget = dijit.byId(widget);
+ }else if(widget.tagName && widget.cloneNode){
+ widget = dijit.byNode(widget);
+ }
+
+ // build the map of widgets
+ var widgets = dojo.map(widget.getDescendants(), registerWidget, this);
+
+ // process observers for widgets
+ dojo.forEach(widgets, function(name){
+ if(name){
+ connectWidget.call(this, name, getObserversFromWidget.call(this, name));
+ }
+ }, this);
+
+ // do the same with nodes, if available
+ return this.registerNodeDescendants ?
+ this.registerNodeDescendants(widget.domNode) : this;
+ },
+
+ unregisterWidgetDescendants: function(widget){
+ // summary:
+ // Unregister widget's descendants with the form manager
+ // widget: String|Node|dijit._Widget:
+ // A widget, or its widgetId, or its DOM node
+ // returns: Object:
+ // Returns self
+
+ // convert to widget, if required
+ if(typeof widget == "string"){
+ widget = dijit.byId(widget);
+ }else if(widget.tagName && widget.cloneNode){
+ widget = dijit.byNode(widget);
+ }
+
+ // unregister widgets by names
+ dojo.forEach(
+ dojo.map(
+ widget.getDescendants(),
+ function(w){
+ return w instanceof dijit.form._FormWidget && w.get("name") || null;
+ }
+ ),
+ function(name){
+ if(name){
+ this.unregisterNode(name);
+ }
+ },
+ this
+ );
+
+ // do the same with nodes, if available
+ return this.unregisterNodeDescendants ?
+ this.unregisterNodeDescendants(widget.domNode) : this;
+ },
+
+ // value accessors
+
+ formWidgetValue: function(elem, value){
+ // summary:
+ // Set or get a form widget by name.
+ // elem: String|Object|Array:
+ // Form element's name, widget object, or array or radio widgets.
+ // value: Object?:
+ // Optional. The value to set.
+ // returns: Object:
+ // For a getter it returns the value, for a setter it returns
+ // self. If the elem is not valid, null will be returned.
+
+ var isSetter = arguments.length == 2 && value !== undefined, result;
+
+ if(typeof elem == "string"){
+ elem = this.formWidgets[elem];
+ if(elem){
+ elem = elem.widget;
+ }
+ }
+
+ if(!elem){
+ return null; // Object
+ }
+
+ if(dojo.isArray(elem)){
+ // input/radio array of widgets
+ if(isSetter){
+ dojo.forEach(elem, function(widget){
+ widget.set("checked", false, !this.watching);
+ });
+ dojo.forEach(elem, function(widget){
+ widget.set("checked", widget.value === value, !this.watching);
+ });
+ return this; // self
+ }
+ // getter
+ dojo.some(elem, function(widget){
+ // TODO: for some reason for radio button widgets
+ // w.checked != w.focusNode.checked when value changes.
+ // We test the underlying value to be 100% sure.
+ if(dojo.attr(widget.focusNode, "checked")){
+ //if(widget.get("checked")){
+ result = widget;
+ return true;
+ }
+ return false;
+ });
+ return result ? result.get("value") : ""; // String
+ }
+
+ // checkbox widget is a special case :-(
+ if(elem.declaredClass == "dijit.form.CheckBox"){
+ if(isSetter){
+ elem.set("value", Boolean(value), !this.watching);
+ return this; // self
+ }
+ return Boolean(elem.get("value")); // Object
+ }
+
+ // all other elements
+ if(isSetter){
+ elem.set("value", value, !this.watching);
+ return this; // self
+ }
+ return elem.get("value"); // Object
+ },
+
+ formPointValue: function(elem, value){
+ // summary:
+ // Set or get a node context by name (using dojoAttachPoint).
+ // elem: String|Object|Array:
+ // A node.
+ // value: Object?:
+ // Optional. The value to set.
+ // returns: Object:
+ // For a getter it returns the value, for a setter it returns
+ // self. If the elem is not valid, null will be returned.
+
+ if(elem && typeof elem == "string"){
+ elem = this[elem];
+ }
+
+ if(!elem || !elem.tagName || !elem.cloneNode){
+ return null; // Object
+ }
+
+ if(!dojo.hasClass(elem, "dojoFormValue")){
+ // accessing the value of the attached point not marked with CSS class 'dojoFormValue'
+ return null;
+ }
+
+ if(arguments.length == 2 && value !== undefined){
+ // setter
+ elem.innerHTML = value;
+ return this; // self
+ }
+ // getter
+ return elem.innerHTML; // String
+ },
+
+ // inspectors
+
+ inspectFormWidgets: function(inspector, state, defaultValue){
+ // summary:
+ // Run an inspector function on controlled widgets returning a result object.
+ // inspector: Function:
+ // A function to be called on a widget. Takes three arguments: a name, a widget object
+ // or an array of widget objects, and a supplied value. Runs in the context of
+ // the form manager. Returns a value that will be collected and returned as a state.
+ // state: Object?:
+ // Optional. If a name-value dictionary --- only listed names will be processed.
+ // If an array, all names in the array will be processed with defaultValue.
+ // If omitted or null, all widgets will be processed with defaultValue.
+ // defaultValue: Object?:
+ // Optional. The default state (true, if omitted).
+
+ var name, result = {};
+
+ if(state){
+ if(dojo.isArray(state)){
+ dojo.forEach(state, function(name){
+ if(name in this.formWidgets){
+ result[name] = inspector.call(this, name, this.formWidgets[name].widget, defaultValue);
+ }
+ }, this);
+ }else{
+ for(name in state){
+ if(name in this.formWidgets){
+ result[name] = inspector.call(this, name, this.formWidgets[name].widget, state[name]);
+ }
+ }
+ }
+ }else{
+ for(name in this.formWidgets){
+ result[name] = inspector.call(this, name, this.formWidgets[name].widget, defaultValue);
+ }
+ }
+
+ return result; // Object
+ },
+
+ inspectAttachedPoints: function(inspector, state, defaultValue){
+ // summary:
+ // Run an inspector function on "dojoAttachPoint" nodes returning a result object.
+ // inspector: Function:
+ // A function to be called on a node. Takes three arguments: a name, a node or
+ // an array of nodes, and a supplied value. Runs in the context of the form manager.
+ // Returns a value that will be collected and returned as a state.
+ // state: Object?:
+ // Optional. If a name-value dictionary --- only listed names will be processed.
+ // If an array, all names in the array will be processed with defaultValue.
+ // If omitted or null, all attached point nodes will be processed with defaultValue.
+ // defaultValue: Object?:
+ // Optional. The default state (true, if omitted).
+
+ var name, result = {};
+
+ if(state){
+ if(dojo.isArray(state)){
+ dojo.forEach(state, function(name){
+ var elem = this[name];
+ if(elem && elem.tagName && elem.cloneNode){
+ result[name] = inspector.call(this, name, elem, defaultValue);
+ }
+ }, this);
+ }else{
+ for(name in state){
+ var elem = this[name];
+ if(elem && elem.tagName && elem.cloneNode){
+ result[name] = inspector.call(this, name, elem, state[name]);
+ }
+ }
+ }
+ }else{
+ for(name in this){
+ if(!(name in skipNames)){
+ var elem = this[name];
+ if(elem && elem.tagName && elem.cloneNode){
+ result[name] = inspector.call(this, name, elem, defaultValue);
+ }
+ }
+ }
+ }
+
+ return result; // Object
+ },
+
+ inspect: function(inspector, state, defaultValue){
+ // summary:
+ // Run an inspector function on controlled elements returning a result object.
+ // inspector: Function:
+ // A function to be called on a widget, form element, and an attached node.
+ // Takes three arguments: a name, a node (domNode in the case of widget) or
+ // an array of such objects, and a supplied value. Runs in the context of
+ // the form manager. Returns a value that will be collected and returned as a state.
+ // state: Object?:
+ // Optional. If a name-value dictionary --- only listed names will be processed.
+ // If an array, all names in the array will be processed with defaultValue.
+ // If omitted or null, all controlled elements will be processed with defaultValue.
+ // defaultValue: Object?:
+ // Optional. The default state (true, if omitted).
+
+ var result = this.inspectFormWidgets(function(name, widget, value){
+ if(dojo.isArray(widget)){
+ return inspector.call(this, name, dojo.map(widget, function(w){ return w.domNode; }), value);
+ }
+ return inspector.call(this, name, widget.domNode, value);
+ }, state, defaultValue);
+ if(this.inspectFormNodes){
+ dojo.mixin(result, this.inspectFormNodes(inspector, state, defaultValue));
+ }
+ return dojo.mixin(result, this.inspectAttachedPoints(inspector, state, defaultValue)); // Object
+ }
+ });
+})();
+
+// These arguments can be specified for widgets which are used in forms.
+// Since any widget can be specified as sub widgets, mix it into the base
+// widget class. (This is a hack, but it's effective.)
+dojo.extend(dijit._Widget, {
+ observer: ""
+});
+
+}
diff --git a/js/dojo-1.6/dojox/form/manager/_Mixin.xd.js b/js/dojo-1.6/dojox/form/manager/_Mixin.xd.js new file mode 100644 index 0000000..285a406 --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_Mixin.xd.js @@ -0,0 +1,500 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.form.manager._Mixin"],
+["require", "dijit._Widget"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.form.manager._Mixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.form.manager._Mixin"] = true;
+dojo.provide("dojox.form.manager._Mixin");
+
+dojo.require("dijit._Widget");
+
+(function(){
+ var fm = dojox.form.manager,
+
+ aa = fm.actionAdapter = function(action){
+ // summary:
+ // Adapter that automates application of actions to arrays.
+ // action: Function:
+ // Function that takes three parameters: a name, an object
+ // (usually node or widget), and a value. This action will
+ // be applied to all elements of array.
+ return function(name, elems, value){
+ if(dojo.isArray(elems)){
+ dojo.forEach(elems, function(elem){
+ action.call(this, name, elem, value);
+ }, this);
+ }else{
+ action.apply(this, arguments);
+ }
+ };
+ },
+
+ ia = fm.inspectorAdapter = function(inspector){
+ // summary:
+ // Adapter that applies an inspector only to the first item of the array.
+ // inspector: Function:
+ // Function that takes three parameters: a name, an object
+ // (usually node or widget), and a value.
+ return function(name, elem, value){
+ return inspector.call(this, name, dojo.isArray(elem) ? elem[0] : elem, value);
+ };
+ },
+
+ skipNames = {domNode: 1, containerNode: 1, srcNodeRef: 1, bgIframe: 1},
+
+ keys = fm._keys = function(o){
+ // similar to dojox.lang.functional.keys
+ var list = [], key;
+ for(key in o){
+ if(o.hasOwnProperty(key)){
+ list.push(key);
+ }
+ }
+ return list;
+ },
+
+ registerWidget = function(widget){
+ var name = widget.get("name");
+ if(name && widget instanceof dijit.form._FormWidget){
+ if(name in this.formWidgets){
+ var a = this.formWidgets[name].widget;
+ if(dojo.isArray(a)){
+ a.push(widget);
+ }else{
+ this.formWidgets[name].widget = [a, widget];
+ }
+ }else{
+ this.formWidgets[name] = {widget: widget, connections: []};
+ }
+ }else{
+ name = null;
+ }
+ return name;
+ },
+
+ getObserversFromWidget = function(name){
+ var observers = {};
+ aa(function(_, w){
+ var o = w.get("observer");
+ if(o && typeof o == "string"){
+ dojo.forEach(o.split(","), function(o){
+ o = dojo.trim(o);
+ if(o && dojo.isFunction(this[o])){
+ observers[o] = 1;
+ }
+ }, this);
+ }
+ }).call(this, null, this.formWidgets[name].widget);
+ return keys(observers);
+ },
+
+ connectWidget = function(name, observers){
+ var t = this.formWidgets[name], w = t.widget, c = t.connections;
+ if(c.length){
+ dojo.forEach(c, dojo.disconnect);
+ c = t.connections = [];
+ }
+ if(dojo.isArray(w)){
+ // radio buttons
+ dojo.forEach(w, function(w){
+ dojo.forEach(observers, function(o){
+ c.push(dojo.connect(w, "onChange", this, function(evt){
+ // TODO: for some reason for radio button widgets
+ // w.checked != w.focusNode.checked when value changes.
+ // We test the underlying value to be 100% sure.
+ if(this.watching && dojo.attr(w.focusNode, "checked")){
+ this[o](w.get("value"), name, w, evt);
+ }
+ }));
+ }, this);
+ }, this);
+ }else{
+ // the rest
+ // the next line is a crude workaround for dijit.form.Button that fires onClick instead of onChange
+ var eventName = w.declaredClass == "dijit.form.Button" ?
+ "onClick" : "onChange";
+ dojo.forEach(observers, function(o){
+ c.push(dojo.connect(w, eventName, this, function(evt){
+ if(this.watching){
+ this[o](w.get("value"), name, w, evt);
+ }
+ }));
+ }, this);
+ }
+ };
+
+ dojo.declare("dojox.form.manager._Mixin", null, {
+ // summary:
+ // Mixin to orchestrate dynamic forms.
+ // description:
+ // This mixin provideas a foundation for an enhanced form
+ // functionality: unified access to individual form elements,
+ // unified "onchange" event processing, general event
+ // processing, I/O orchestration, and common form-related
+ // functionality. See additional mixins in dojox.form.manager
+ // namespace.
+
+ watching: true,
+
+ startup: function(){
+ // summary:
+ // Called after all the widgets have been instantiated and their
+ // dom nodes have been inserted somewhere under dojo.doc.body.
+
+ if(this._started){ return; }
+
+ this.formWidgets = {};
+ this.formNodes = {};
+ this.registerWidgetDescendants(this);
+
+ this.inherited(arguments);
+ },
+
+ destroy: function(){
+ // summary:
+ // Called when the widget is being destroyed
+
+ for(var name in this.formWidgets){
+ dojo.forEach(this.formWidgets[name].connections, dojo.disconnect);
+ }
+ this.formWidgets = {};
+
+ this.inherited(arguments);
+ },
+
+ // register/unregister widgets and nodes
+
+ registerWidget: function(widget){
+ // summary:
+ // Register a widget with the form manager
+ // widget: String|Node|dijit.form._FormWidget:
+ // A widget, or its widgetId, or its DOM node
+ // returns: Object:
+ // Returns self
+ if(typeof widget == "string"){
+ widget = dijit.byId(widget);
+ }else if(widget.tagName && widget.cloneNode){
+ widget = dijit.byNode(widget);
+ }
+ var name = registerWidget.call(this, widget);
+ if(name){
+ connectWidget.call(this, name, getObserversFromWidget.call(this, name));
+ }
+ return this;
+ },
+
+ unregisterWidget: function(name){
+ // summary:
+ // Removes the widget by name from internal tables unregistering
+ // connected observers
+ // name: String:
+ // Name of the to unregister
+ // returns: Object:
+ // Returns self
+ if(name in this.formWidgets){
+ dojo.forEach(this.formWidgets[name].connections, this.disconnect, this);
+ delete this.formWidgets[name];
+ }
+ return this;
+ },
+
+ registerWidgetDescendants: function(widget){
+ // summary:
+ // Register widget's descendants with the form manager
+ // widget: String|Node|dijit._Widget:
+ // A widget, or its widgetId, or its DOM node
+ // returns: Object:
+ // Returns self
+
+ // convert to widget, if required
+ if(typeof widget == "string"){
+ widget = dijit.byId(widget);
+ }else if(widget.tagName && widget.cloneNode){
+ widget = dijit.byNode(widget);
+ }
+
+ // build the map of widgets
+ var widgets = dojo.map(widget.getDescendants(), registerWidget, this);
+
+ // process observers for widgets
+ dojo.forEach(widgets, function(name){
+ if(name){
+ connectWidget.call(this, name, getObserversFromWidget.call(this, name));
+ }
+ }, this);
+
+ // do the same with nodes, if available
+ return this.registerNodeDescendants ?
+ this.registerNodeDescendants(widget.domNode) : this;
+ },
+
+ unregisterWidgetDescendants: function(widget){
+ // summary:
+ // Unregister widget's descendants with the form manager
+ // widget: String|Node|dijit._Widget:
+ // A widget, or its widgetId, or its DOM node
+ // returns: Object:
+ // Returns self
+
+ // convert to widget, if required
+ if(typeof widget == "string"){
+ widget = dijit.byId(widget);
+ }else if(widget.tagName && widget.cloneNode){
+ widget = dijit.byNode(widget);
+ }
+
+ // unregister widgets by names
+ dojo.forEach(
+ dojo.map(
+ widget.getDescendants(),
+ function(w){
+ return w instanceof dijit.form._FormWidget && w.get("name") || null;
+ }
+ ),
+ function(name){
+ if(name){
+ this.unregisterNode(name);
+ }
+ },
+ this
+ );
+
+ // do the same with nodes, if available
+ return this.unregisterNodeDescendants ?
+ this.unregisterNodeDescendants(widget.domNode) : this;
+ },
+
+ // value accessors
+
+ formWidgetValue: function(elem, value){
+ // summary:
+ // Set or get a form widget by name.
+ // elem: String|Object|Array:
+ // Form element's name, widget object, or array or radio widgets.
+ // value: Object?:
+ // Optional. The value to set.
+ // returns: Object:
+ // For a getter it returns the value, for a setter it returns
+ // self. If the elem is not valid, null will be returned.
+
+ var isSetter = arguments.length == 2 && value !== undefined, result;
+
+ if(typeof elem == "string"){
+ elem = this.formWidgets[elem];
+ if(elem){
+ elem = elem.widget;
+ }
+ }
+
+ if(!elem){
+ return null; // Object
+ }
+
+ if(dojo.isArray(elem)){
+ // input/radio array of widgets
+ if(isSetter){
+ dojo.forEach(elem, function(widget){
+ widget.set("checked", false, !this.watching);
+ });
+ dojo.forEach(elem, function(widget){
+ widget.set("checked", widget.value === value, !this.watching);
+ });
+ return this; // self
+ }
+ // getter
+ dojo.some(elem, function(widget){
+ // TODO: for some reason for radio button widgets
+ // w.checked != w.focusNode.checked when value changes.
+ // We test the underlying value to be 100% sure.
+ if(dojo.attr(widget.focusNode, "checked")){
+ //if(widget.get("checked")){
+ result = widget;
+ return true;
+ }
+ return false;
+ });
+ return result ? result.get("value") : ""; // String
+ }
+
+ // checkbox widget is a special case :-(
+ if(elem.declaredClass == "dijit.form.CheckBox"){
+ if(isSetter){
+ elem.set("value", Boolean(value), !this.watching);
+ return this; // self
+ }
+ return Boolean(elem.get("value")); // Object
+ }
+
+ // all other elements
+ if(isSetter){
+ elem.set("value", value, !this.watching);
+ return this; // self
+ }
+ return elem.get("value"); // Object
+ },
+
+ formPointValue: function(elem, value){
+ // summary:
+ // Set or get a node context by name (using dojoAttachPoint).
+ // elem: String|Object|Array:
+ // A node.
+ // value: Object?:
+ // Optional. The value to set.
+ // returns: Object:
+ // For a getter it returns the value, for a setter it returns
+ // self. If the elem is not valid, null will be returned.
+
+ if(elem && typeof elem == "string"){
+ elem = this[elem];
+ }
+
+ if(!elem || !elem.tagName || !elem.cloneNode){
+ return null; // Object
+ }
+
+ if(!dojo.hasClass(elem, "dojoFormValue")){
+ // accessing the value of the attached point not marked with CSS class 'dojoFormValue'
+ return null;
+ }
+
+ if(arguments.length == 2 && value !== undefined){
+ // setter
+ elem.innerHTML = value;
+ return this; // self
+ }
+ // getter
+ return elem.innerHTML; // String
+ },
+
+ // inspectors
+
+ inspectFormWidgets: function(inspector, state, defaultValue){
+ // summary:
+ // Run an inspector function on controlled widgets returning a result object.
+ // inspector: Function:
+ // A function to be called on a widget. Takes three arguments: a name, a widget object
+ // or an array of widget objects, and a supplied value. Runs in the context of
+ // the form manager. Returns a value that will be collected and returned as a state.
+ // state: Object?:
+ // Optional. If a name-value dictionary --- only listed names will be processed.
+ // If an array, all names in the array will be processed with defaultValue.
+ // If omitted or null, all widgets will be processed with defaultValue.
+ // defaultValue: Object?:
+ // Optional. The default state (true, if omitted).
+
+ var name, result = {};
+
+ if(state){
+ if(dojo.isArray(state)){
+ dojo.forEach(state, function(name){
+ if(name in this.formWidgets){
+ result[name] = inspector.call(this, name, this.formWidgets[name].widget, defaultValue);
+ }
+ }, this);
+ }else{
+ for(name in state){
+ if(name in this.formWidgets){
+ result[name] = inspector.call(this, name, this.formWidgets[name].widget, state[name]);
+ }
+ }
+ }
+ }else{
+ for(name in this.formWidgets){
+ result[name] = inspector.call(this, name, this.formWidgets[name].widget, defaultValue);
+ }
+ }
+
+ return result; // Object
+ },
+
+ inspectAttachedPoints: function(inspector, state, defaultValue){
+ // summary:
+ // Run an inspector function on "dojoAttachPoint" nodes returning a result object.
+ // inspector: Function:
+ // A function to be called on a node. Takes three arguments: a name, a node or
+ // an array of nodes, and a supplied value. Runs in the context of the form manager.
+ // Returns a value that will be collected and returned as a state.
+ // state: Object?:
+ // Optional. If a name-value dictionary --- only listed names will be processed.
+ // If an array, all names in the array will be processed with defaultValue.
+ // If omitted or null, all attached point nodes will be processed with defaultValue.
+ // defaultValue: Object?:
+ // Optional. The default state (true, if omitted).
+
+ var name, result = {};
+
+ if(state){
+ if(dojo.isArray(state)){
+ dojo.forEach(state, function(name){
+ var elem = this[name];
+ if(elem && elem.tagName && elem.cloneNode){
+ result[name] = inspector.call(this, name, elem, defaultValue);
+ }
+ }, this);
+ }else{
+ for(name in state){
+ var elem = this[name];
+ if(elem && elem.tagName && elem.cloneNode){
+ result[name] = inspector.call(this, name, elem, state[name]);
+ }
+ }
+ }
+ }else{
+ for(name in this){
+ if(!(name in skipNames)){
+ var elem = this[name];
+ if(elem && elem.tagName && elem.cloneNode){
+ result[name] = inspector.call(this, name, elem, defaultValue);
+ }
+ }
+ }
+ }
+
+ return result; // Object
+ },
+
+ inspect: function(inspector, state, defaultValue){
+ // summary:
+ // Run an inspector function on controlled elements returning a result object.
+ // inspector: Function:
+ // A function to be called on a widget, form element, and an attached node.
+ // Takes three arguments: a name, a node (domNode in the case of widget) or
+ // an array of such objects, and a supplied value. Runs in the context of
+ // the form manager. Returns a value that will be collected and returned as a state.
+ // state: Object?:
+ // Optional. If a name-value dictionary --- only listed names will be processed.
+ // If an array, all names in the array will be processed with defaultValue.
+ // If omitted or null, all controlled elements will be processed with defaultValue.
+ // defaultValue: Object?:
+ // Optional. The default state (true, if omitted).
+
+ var result = this.inspectFormWidgets(function(name, widget, value){
+ if(dojo.isArray(widget)){
+ return inspector.call(this, name, dojo.map(widget, function(w){ return w.domNode; }), value);
+ }
+ return inspector.call(this, name, widget.domNode, value);
+ }, state, defaultValue);
+ if(this.inspectFormNodes){
+ dojo.mixin(result, this.inspectFormNodes(inspector, state, defaultValue));
+ }
+ return dojo.mixin(result, this.inspectAttachedPoints(inspector, state, defaultValue)); // Object
+ }
+ });
+})();
+
+// These arguments can be specified for widgets which are used in forms.
+// Since any widget can be specified as sub widgets, mix it into the base
+// widget class. (This is a hack, but it's effective.)
+dojo.extend(dijit._Widget, {
+ observer: ""
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/form/manager/_NodeMixin.js b/js/dojo-1.6/dojox/form/manager/_NodeMixin.js new file mode 100644 index 0000000..bf1d527 --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_NodeMixin.js @@ -0,0 +1,371 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.form.manager._NodeMixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.form.manager._NodeMixin"] = true;
+dojo.provide("dojox.form.manager._NodeMixin");
+
+dojo.require("dojox.form.manager._Mixin");
+
+(function(){
+ var fm = dojox.form.manager,
+ aa = fm.actionAdapter,
+ keys = fm._keys,
+
+ ce = fm.changeEvent = function(node){
+ // summary:
+ // Function that returns a valid "onchange" event for a given form node.
+ // node: Node:
+ // Form node.
+
+ var eventName = "onclick";
+ switch(node.tagName.toLowerCase()){
+ case "textarea":
+ eventName = "onkeyup";
+ break;
+ case "select":
+ eventName = "onchange";
+ break;
+ case "input":
+ switch(node.type.toLowerCase()){
+ case "text":
+ case "password":
+ eventName = "onkeyup";
+ break;
+ }
+ break;
+ // button, input/button, input/checkbox, input/radio,
+ // input/file, input/image, input/submit, input/reset
+ // use "onclick" (the default)
+ }
+ return eventName; // String
+ },
+
+ registerNode = function(node, groupNode){
+ var name = dojo.attr(node, "name");
+ groupNode = groupNode || this.domNode;
+ if(name && !(name in this.formWidgets)){
+ // verify that it is not part of any widget
+ for(var n = node; n && n !== groupNode; n = n.parentNode){
+ if(dojo.attr(n, "widgetId") && dijit.byNode(n) instanceof dijit.form._FormWidget){
+ // this is a child of some widget --- bail out
+ return null;
+ }
+ }
+ // register the node
+ if(node.tagName.toLowerCase() == "input" && node.type.toLowerCase() == "radio"){
+ var a = this.formNodes[name];
+ a = a && a.node;
+ if(a && dojo.isArray(a)){
+ a.push(node);
+ }else{
+ this.formNodes[name] = {node: [node], connections: []};
+ }
+ }else{
+ this.formNodes[name] = {node: node, connections: []};
+ }
+ }else{
+ name = null;
+ }
+ return name;
+ },
+
+ getObserversFromNode = function(name){
+ var observers = {};
+ aa(function(_, n){
+ var o = dojo.attr(n, "observer");
+ if(o && typeof o == "string"){
+ dojo.forEach(o.split(","), function(o){
+ o = dojo.trim(o);
+ if(o && dojo.isFunction(this[o])){
+ observers[o] = 1;
+ }
+ }, this);
+ }
+ }).call(this, null, this.formNodes[name].node);
+ return keys(observers);
+ },
+
+ connectNode = function(name, observers){
+ var t = this.formNodes[name], c = t.connections;
+ if(c.length){
+ dojo.forEach(c, dojo.disconnect);
+ c = t.connections = [];
+ }
+ aa(function(_, n){
+ // the next line is a crude workaround for dijit.form.Button that fires onClick instead of onChange
+ var eventName = ce(n);
+ dojo.forEach(observers, function(o){
+ c.push(dojo.connect(n, eventName, this, function(evt){
+ if(this.watching){
+ this[o](this.formNodeValue(name), name, n, evt);
+ }
+ }));
+ }, this);
+ }).call(this, null, t.node);
+ };
+ dojo.declare("dojox.form.manager._NodeMixin", null, {
+ // summary:
+ // Mixin to orchestrate dynamic forms (works with DOM nodes).
+ // description:
+ // This mixin provideas a foundation for an enhanced form
+ // functionality: unified access to individual form elements,
+ // unified "onchange" event processing, and general event
+ // processing. It complements dojox.form.manager._Mixin
+ // extending the functionality to DOM nodes.
+
+ destroy: function(){
+ // summary:
+ // Called when the widget is being destroyed
+
+ for(var name in this.formNodes){
+ dojo.forEach(this.formNodes[name].connections, dojo.disconnect);
+ }
+ this.formNodes = {};
+
+ this.inherited(arguments);
+ },
+
+ // register/unregister widgets and nodes
+
+ registerNode: function(node){
+ // summary:
+ // Register a node with the form manager
+ // node: String|Node:
+ // A node, or its id
+ // returns: Object:
+ // Returns self
+ if(typeof node == "string"){
+ node = dojo.byId(node);
+ }
+ var name = registerNode.call(this, node);
+ if(name){
+ connectNode.call(this, name, getObserversFromNode.call(this, name));
+ }
+ return this;
+ },
+
+ unregisterNode: function(name){
+ // summary:
+ // Removes the node by name from internal tables unregistering
+ // connected observers
+ // name: String:
+ // Name of the to unregister
+ // returns: Object:
+ // Returns self
+ if(name in this.formNodes){
+ dojo.forEach(this.formNodes[name].connections, this.disconnect, this);
+ delete this.formNodes[name];
+ }
+ return this;
+ },
+
+ registerNodeDescendants: function(node){
+ // summary:
+ // Register node's descendants (form nodes) with the form manager
+ // node: String|Node:
+ // A widget, or its widgetId, or its DOM node
+ // returns: Object:
+ // Returns self
+
+ if(typeof node == "string"){
+ node = dojo.byId(node);
+ }
+
+ dojo.query("input, select, textarea, button", node).
+ map(function(n){
+ return registerNode.call(this, n, node);
+ }, this).
+ forEach(function(name){
+ if(name){
+ connectNode.call(this, name, getObserversFromNode.call(this, name));
+ }
+ }, this);
+
+ return this;
+ },
+
+ unregisterNodeDescendants: function(node){
+ // summary:
+ // Unregister node's descendants (form nodes) with the form manager
+ // node: String|Node:
+ // A widget, or its widgetId, or its DOM node
+ // returns: Object:
+ // Returns self
+
+ if(typeof node == "string"){
+ node = dojo.byId(node);
+ }
+
+ dojo.query("input, select, textarea, button", node).
+ map(function(n){ return dojo.attr(node, "name") || null; }).
+ forEach(function(name){
+ if(name){
+ this.unregisterNode(name);
+ }
+ }, this);
+
+ return this;
+ },
+
+ // value accessors
+
+ formNodeValue: function(elem, value){
+ // summary:
+ // Set or get a form element by name.
+ // elem: String|Node|Array:
+ // Form element's name, DOM node, or array or radio nodes.
+ // value: Object?:
+ // Optional. The value to set.
+ // returns: Object:
+ // For a getter it returns the value, for a setter it returns
+ // self. If the elem is not valid, null will be returned.
+
+ var isSetter = arguments.length == 2 && value !== undefined, result;
+
+ if(typeof elem == "string"){
+ elem = this.formNodes[elem];
+ if(elem){
+ elem = elem.node;
+ }
+ }
+
+ if(!elem){
+ return null; // Object
+ }
+
+ if(dojo.isArray(elem)){
+ // input/radio array
+ if(isSetter){
+ dojo.forEach(elem, function(node){
+ node.checked = "";
+ });
+ dojo.forEach(elem, function(node){
+ node.checked = node.value === value ? "checked" : "";
+ });
+ return this; // self
+ }
+ // getter
+ dojo.some(elem, function(node){
+ if(node.checked){
+ result = node;
+ return true;
+ }
+ return false;
+ });
+ return result ? result.value : ""; // String
+ }
+ // all other elements
+ switch(elem.tagName.toLowerCase()){
+ case "select":
+ if(elem.multiple){
+ // multiple is allowed
+ if(isSetter){
+ if(dojo.isArray(value)){
+ var dict = {};
+ dojo.forEach(value, function(v){
+ dict[v] = 1;
+ });
+ dojo.query("> option", elem).forEach(function(opt){
+ opt.selected = opt.value in dict;
+ });
+ return this; // self
+ }
+ // singular property
+ dojo.query("> option", elem).forEach(function(opt){
+ opt.selected = opt.value === value;
+ });
+ return this; // self
+ }
+ // getter
+ var result = dojo.query("> option", elem).filter(function(opt){
+ return opt.selected;
+ }).map(function(opt){
+ return opt.value;
+ });
+ return result.length == 1 ? result[0] : result; // Object
+ }
+ // singular
+ if(isSetter){
+ dojo.query("> option", elem).forEach(function(opt){
+ opt.selected = opt.value === value;
+ });
+ return this; // self
+ }
+ // getter
+ return elem.value || ""; // String
+ case "button":
+ if(isSetter){
+ elem.innerHTML = "" + value;
+ return this;
+ }
+ // getter
+ return elem.innerHTML;
+ case "input":
+ if(elem.type.toLowerCase() == "checkbox"){
+ // input/checkbox element
+ if(isSetter){
+ elem.checked = value ? "checked" : "";
+ return this;
+ }
+ // getter
+ return Boolean(elem.checked);
+ }
+ }
+ // the rest of inputs
+ if(isSetter){
+ elem.value = "" + value;
+ return this;
+ }
+ // getter
+ return elem.value;
+ },
+
+ // inspectors
+
+ inspectFormNodes: function(inspector, state, defaultValue){
+ // summary:
+ // Run an inspector function on controlled form elements returning a result object.
+ // inspector: Function:
+ // A function to be called on a form element. Takes three arguments: a name, a node or
+ // an array of nodes, and a supplied value. Runs in the context of the form manager.
+ // Returns a value that will be collected and returned as a state.
+ // state: Object?:
+ // Optional. If a name-value dictionary --- only listed names will be processed.
+ // If an array, all names in the array will be processed with defaultValue.
+ // If omitted or null, all form elements will be processed with defaultValue.
+ // defaultValue: Object?:
+ // Optional. The default state (true, if omitted).
+
+ var name, result = {};
+
+ if(state){
+ if(dojo.isArray(state)){
+ dojo.forEach(state, function(name){
+ if(name in this.formNodes){
+ result[name] = inspector.call(this, name, this.formNodes[name].node, defaultValue);
+ }
+ }, this);
+ }else{
+ for(name in state){
+ if(name in this.formNodes){
+ result[name] = inspector.call(this, name, this.formNodes[name].node, state[name]);
+ }
+ }
+ }
+ }else{
+ for(name in this.formNodes){
+ result[name] = inspector.call(this, name, this.formNodes[name].node, defaultValue);
+ }
+ }
+
+ return result; // Object
+ }
+ });
+})();
+
+}
diff --git a/js/dojo-1.6/dojox/form/manager/_NodeMixin.xd.js b/js/dojo-1.6/dojox/form/manager/_NodeMixin.xd.js new file mode 100644 index 0000000..b1d7d29 --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_NodeMixin.xd.js @@ -0,0 +1,376 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.form.manager._NodeMixin"],
+["require", "dojox.form.manager._Mixin"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.form.manager._NodeMixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.form.manager._NodeMixin"] = true;
+dojo.provide("dojox.form.manager._NodeMixin");
+
+dojo.require("dojox.form.manager._Mixin");
+
+(function(){
+ var fm = dojox.form.manager,
+ aa = fm.actionAdapter,
+ keys = fm._keys,
+
+ ce = fm.changeEvent = function(node){
+ // summary:
+ // Function that returns a valid "onchange" event for a given form node.
+ // node: Node:
+ // Form node.
+
+ var eventName = "onclick";
+ switch(node.tagName.toLowerCase()){
+ case "textarea":
+ eventName = "onkeyup";
+ break;
+ case "select":
+ eventName = "onchange";
+ break;
+ case "input":
+ switch(node.type.toLowerCase()){
+ case "text":
+ case "password":
+ eventName = "onkeyup";
+ break;
+ }
+ break;
+ // button, input/button, input/checkbox, input/radio,
+ // input/file, input/image, input/submit, input/reset
+ // use "onclick" (the default)
+ }
+ return eventName; // String
+ },
+
+ registerNode = function(node, groupNode){
+ var name = dojo.attr(node, "name");
+ groupNode = groupNode || this.domNode;
+ if(name && !(name in this.formWidgets)){
+ // verify that it is not part of any widget
+ for(var n = node; n && n !== groupNode; n = n.parentNode){
+ if(dojo.attr(n, "widgetId") && dijit.byNode(n) instanceof dijit.form._FormWidget){
+ // this is a child of some widget --- bail out
+ return null;
+ }
+ }
+ // register the node
+ if(node.tagName.toLowerCase() == "input" && node.type.toLowerCase() == "radio"){
+ var a = this.formNodes[name];
+ a = a && a.node;
+ if(a && dojo.isArray(a)){
+ a.push(node);
+ }else{
+ this.formNodes[name] = {node: [node], connections: []};
+ }
+ }else{
+ this.formNodes[name] = {node: node, connections: []};
+ }
+ }else{
+ name = null;
+ }
+ return name;
+ },
+
+ getObserversFromNode = function(name){
+ var observers = {};
+ aa(function(_, n){
+ var o = dojo.attr(n, "observer");
+ if(o && typeof o == "string"){
+ dojo.forEach(o.split(","), function(o){
+ o = dojo.trim(o);
+ if(o && dojo.isFunction(this[o])){
+ observers[o] = 1;
+ }
+ }, this);
+ }
+ }).call(this, null, this.formNodes[name].node);
+ return keys(observers);
+ },
+
+ connectNode = function(name, observers){
+ var t = this.formNodes[name], c = t.connections;
+ if(c.length){
+ dojo.forEach(c, dojo.disconnect);
+ c = t.connections = [];
+ }
+ aa(function(_, n){
+ // the next line is a crude workaround for dijit.form.Button that fires onClick instead of onChange
+ var eventName = ce(n);
+ dojo.forEach(observers, function(o){
+ c.push(dojo.connect(n, eventName, this, function(evt){
+ if(this.watching){
+ this[o](this.formNodeValue(name), name, n, evt);
+ }
+ }));
+ }, this);
+ }).call(this, null, t.node);
+ };
+ dojo.declare("dojox.form.manager._NodeMixin", null, {
+ // summary:
+ // Mixin to orchestrate dynamic forms (works with DOM nodes).
+ // description:
+ // This mixin provideas a foundation for an enhanced form
+ // functionality: unified access to individual form elements,
+ // unified "onchange" event processing, and general event
+ // processing. It complements dojox.form.manager._Mixin
+ // extending the functionality to DOM nodes.
+
+ destroy: function(){
+ // summary:
+ // Called when the widget is being destroyed
+
+ for(var name in this.formNodes){
+ dojo.forEach(this.formNodes[name].connections, dojo.disconnect);
+ }
+ this.formNodes = {};
+
+ this.inherited(arguments);
+ },
+
+ // register/unregister widgets and nodes
+
+ registerNode: function(node){
+ // summary:
+ // Register a node with the form manager
+ // node: String|Node:
+ // A node, or its id
+ // returns: Object:
+ // Returns self
+ if(typeof node == "string"){
+ node = dojo.byId(node);
+ }
+ var name = registerNode.call(this, node);
+ if(name){
+ connectNode.call(this, name, getObserversFromNode.call(this, name));
+ }
+ return this;
+ },
+
+ unregisterNode: function(name){
+ // summary:
+ // Removes the node by name from internal tables unregistering
+ // connected observers
+ // name: String:
+ // Name of the to unregister
+ // returns: Object:
+ // Returns self
+ if(name in this.formNodes){
+ dojo.forEach(this.formNodes[name].connections, this.disconnect, this);
+ delete this.formNodes[name];
+ }
+ return this;
+ },
+
+ registerNodeDescendants: function(node){
+ // summary:
+ // Register node's descendants (form nodes) with the form manager
+ // node: String|Node:
+ // A widget, or its widgetId, or its DOM node
+ // returns: Object:
+ // Returns self
+
+ if(typeof node == "string"){
+ node = dojo.byId(node);
+ }
+
+ dojo.query("input, select, textarea, button", node).
+ map(function(n){
+ return registerNode.call(this, n, node);
+ }, this).
+ forEach(function(name){
+ if(name){
+ connectNode.call(this, name, getObserversFromNode.call(this, name));
+ }
+ }, this);
+
+ return this;
+ },
+
+ unregisterNodeDescendants: function(node){
+ // summary:
+ // Unregister node's descendants (form nodes) with the form manager
+ // node: String|Node:
+ // A widget, or its widgetId, or its DOM node
+ // returns: Object:
+ // Returns self
+
+ if(typeof node == "string"){
+ node = dojo.byId(node);
+ }
+
+ dojo.query("input, select, textarea, button", node).
+ map(function(n){ return dojo.attr(node, "name") || null; }).
+ forEach(function(name){
+ if(name){
+ this.unregisterNode(name);
+ }
+ }, this);
+
+ return this;
+ },
+
+ // value accessors
+
+ formNodeValue: function(elem, value){
+ // summary:
+ // Set or get a form element by name.
+ // elem: String|Node|Array:
+ // Form element's name, DOM node, or array or radio nodes.
+ // value: Object?:
+ // Optional. The value to set.
+ // returns: Object:
+ // For a getter it returns the value, for a setter it returns
+ // self. If the elem is not valid, null will be returned.
+
+ var isSetter = arguments.length == 2 && value !== undefined, result;
+
+ if(typeof elem == "string"){
+ elem = this.formNodes[elem];
+ if(elem){
+ elem = elem.node;
+ }
+ }
+
+ if(!elem){
+ return null; // Object
+ }
+
+ if(dojo.isArray(elem)){
+ // input/radio array
+ if(isSetter){
+ dojo.forEach(elem, function(node){
+ node.checked = "";
+ });
+ dojo.forEach(elem, function(node){
+ node.checked = node.value === value ? "checked" : "";
+ });
+ return this; // self
+ }
+ // getter
+ dojo.some(elem, function(node){
+ if(node.checked){
+ result = node;
+ return true;
+ }
+ return false;
+ });
+ return result ? result.value : ""; // String
+ }
+ // all other elements
+ switch(elem.tagName.toLowerCase()){
+ case "select":
+ if(elem.multiple){
+ // multiple is allowed
+ if(isSetter){
+ if(dojo.isArray(value)){
+ var dict = {};
+ dojo.forEach(value, function(v){
+ dict[v] = 1;
+ });
+ dojo.query("> option", elem).forEach(function(opt){
+ opt.selected = opt.value in dict;
+ });
+ return this; // self
+ }
+ // singular property
+ dojo.query("> option", elem).forEach(function(opt){
+ opt.selected = opt.value === value;
+ });
+ return this; // self
+ }
+ // getter
+ var result = dojo.query("> option", elem).filter(function(opt){
+ return opt.selected;
+ }).map(function(opt){
+ return opt.value;
+ });
+ return result.length == 1 ? result[0] : result; // Object
+ }
+ // singular
+ if(isSetter){
+ dojo.query("> option", elem).forEach(function(opt){
+ opt.selected = opt.value === value;
+ });
+ return this; // self
+ }
+ // getter
+ return elem.value || ""; // String
+ case "button":
+ if(isSetter){
+ elem.innerHTML = "" + value;
+ return this;
+ }
+ // getter
+ return elem.innerHTML;
+ case "input":
+ if(elem.type.toLowerCase() == "checkbox"){
+ // input/checkbox element
+ if(isSetter){
+ elem.checked = value ? "checked" : "";
+ return this;
+ }
+ // getter
+ return Boolean(elem.checked);
+ }
+ }
+ // the rest of inputs
+ if(isSetter){
+ elem.value = "" + value;
+ return this;
+ }
+ // getter
+ return elem.value;
+ },
+
+ // inspectors
+
+ inspectFormNodes: function(inspector, state, defaultValue){
+ // summary:
+ // Run an inspector function on controlled form elements returning a result object.
+ // inspector: Function:
+ // A function to be called on a form element. Takes three arguments: a name, a node or
+ // an array of nodes, and a supplied value. Runs in the context of the form manager.
+ // Returns a value that will be collected and returned as a state.
+ // state: Object?:
+ // Optional. If a name-value dictionary --- only listed names will be processed.
+ // If an array, all names in the array will be processed with defaultValue.
+ // If omitted or null, all form elements will be processed with defaultValue.
+ // defaultValue: Object?:
+ // Optional. The default state (true, if omitted).
+
+ var name, result = {};
+
+ if(state){
+ if(dojo.isArray(state)){
+ dojo.forEach(state, function(name){
+ if(name in this.formNodes){
+ result[name] = inspector.call(this, name, this.formNodes[name].node, defaultValue);
+ }
+ }, this);
+ }else{
+ for(name in state){
+ if(name in this.formNodes){
+ result[name] = inspector.call(this, name, this.formNodes[name].node, state[name]);
+ }
+ }
+ }
+ }else{
+ for(name in this.formNodes){
+ result[name] = inspector.call(this, name, this.formNodes[name].node, defaultValue);
+ }
+ }
+
+ return result; // Object
+ }
+ });
+})();
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/form/manager/_ValueMixin.js b/js/dojo-1.6/dojox/form/manager/_ValueMixin.js new file mode 100644 index 0000000..b54e617 --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_ValueMixin.js @@ -0,0 +1,88 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.form.manager._ValueMixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.form.manager._ValueMixin"] = true;
+dojo.provide("dojox.form.manager._ValueMixin");
+
+dojo.declare("dojox.form.manager._ValueMixin", null, {
+ // summary:
+ // Form manager's mixin for getting/setting form values in the unified manner.
+ // description:
+ // This mixin adds unified access to form widgets and form elements
+ // in terms of name-value regardless of the underlying type of
+ // an element. It should be used together with dojox.form.manager.Mixin.
+
+ elementValue: function(name, value){
+ // summary:
+ // Set or get a form widget/element or an attached point node by name.
+ // name: String:
+ // The name.
+ // value: Object?:
+ // Optional. The value to set.
+
+ if(name in this.formWidgets){
+ return this.formWidgetValue(name, value); // Object
+ }
+
+ if(this.formNodes && name in this.formNodes){
+ return this.formNodeValue(name, value); // Object
+ }
+
+ return this.formPointValue(name, value); // Object
+ },
+
+ gatherFormValues: function(names){
+ // summary:
+ // Collect form values.
+ // names: Object?:
+ // If it is an array, it is a list of names of form elements to be collected.
+ // If it is an object, dictionary keys are names to be collected.
+ // If it is omitted, all known form elements are to be collected.
+
+ var result = this.inspectFormWidgets(function(name){
+ return this.formWidgetValue(name);
+ }, names);
+
+ if(this.inspectFormNodes){
+ dojo.mixin(result, this.inspectFormNodes(function(name){
+ return this.formNodeValue(name);
+ }, names));
+ }
+
+ dojo.mixin(result, this.inspectAttachedPoints(function(name){
+ return this.formPointValue(name);
+ }, names));
+
+ return result; // Object
+ },
+
+ setFormValues: function(values){
+ // summary:
+ // Set values to form elements
+ // values: Object:
+ // A dictionary of key-value pairs.
+ if(values){
+ this.inspectFormWidgets(function(name, widget, value){
+ this.formWidgetValue(name, value);
+ }, values);
+
+ if(this.inspectFormNodes){
+ this.inspectFormNodes(function(name, node, value){
+ this.formNodeValue(name, value);
+ }, values);
+ }
+
+ this.inspectAttachedPoints(function(name, node, value){
+ this.formPointValue(name, value);
+ }, values);
+ }
+ return this;
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/form/manager/_ValueMixin.xd.js b/js/dojo-1.6/dojox/form/manager/_ValueMixin.xd.js new file mode 100644 index 0000000..215c7a8 --- /dev/null +++ b/js/dojo-1.6/dojox/form/manager/_ValueMixin.xd.js @@ -0,0 +1,92 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.form.manager._ValueMixin"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.form.manager._ValueMixin"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.form.manager._ValueMixin"] = true;
+dojo.provide("dojox.form.manager._ValueMixin");
+
+dojo.declare("dojox.form.manager._ValueMixin", null, {
+ // summary:
+ // Form manager's mixin for getting/setting form values in the unified manner.
+ // description:
+ // This mixin adds unified access to form widgets and form elements
+ // in terms of name-value regardless of the underlying type of
+ // an element. It should be used together with dojox.form.manager.Mixin.
+
+ elementValue: function(name, value){
+ // summary:
+ // Set or get a form widget/element or an attached point node by name.
+ // name: String:
+ // The name.
+ // value: Object?:
+ // Optional. The value to set.
+
+ if(name in this.formWidgets){
+ return this.formWidgetValue(name, value); // Object
+ }
+
+ if(this.formNodes && name in this.formNodes){
+ return this.formNodeValue(name, value); // Object
+ }
+
+ return this.formPointValue(name, value); // Object
+ },
+
+ gatherFormValues: function(names){
+ // summary:
+ // Collect form values.
+ // names: Object?:
+ // If it is an array, it is a list of names of form elements to be collected.
+ // If it is an object, dictionary keys are names to be collected.
+ // If it is omitted, all known form elements are to be collected.
+
+ var result = this.inspectFormWidgets(function(name){
+ return this.formWidgetValue(name);
+ }, names);
+
+ if(this.inspectFormNodes){
+ dojo.mixin(result, this.inspectFormNodes(function(name){
+ return this.formNodeValue(name);
+ }, names));
+ }
+
+ dojo.mixin(result, this.inspectAttachedPoints(function(name){
+ return this.formPointValue(name);
+ }, names));
+
+ return result; // Object
+ },
+
+ setFormValues: function(values){
+ // summary:
+ // Set values to form elements
+ // values: Object:
+ // A dictionary of key-value pairs.
+ if(values){
+ this.inspectFormWidgets(function(name, widget, value){
+ this.formWidgetValue(name, value);
+ }, values);
+
+ if(this.inspectFormNodes){
+ this.inspectFormNodes(function(name, node, value){
+ this.formNodeValue(name, value);
+ }, values);
+ }
+
+ this.inspectAttachedPoints(function(name, node, value){
+ this.formPointValue(name, value);
+ }, values);
+ }
+ return this;
+ }
+});
+
+}
+
+}};});
|
