diff options
Diffstat (limited to 'js/dojo-1.6/dojox/wire')
31 files changed, 6612 insertions, 0 deletions
diff --git a/js/dojo-1.6/dojox/wire/CompositeWire.js b/js/dojo-1.6/dojox/wire/CompositeWire.js new file mode 100644 index 0000000..f5cd38c --- /dev/null +++ b/js/dojo-1.6/dojox/wire/CompositeWire.js @@ -0,0 +1,110 @@ +/*
+ 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.wire.CompositeWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.CompositeWire"] = true;
+dojo.provide("dojox.wire.CompositeWire");
+
+dojo.require("dojox.wire._base");
+dojo.require("dojox.wire.Wire");
+
+dojo.declare("dojox.wire.CompositeWire", dojox.wire.Wire, {
+ // summary:
+ // A Wire for composite values in object or array
+ // description:
+ // This class has multiple child Wires for object properties or array
+ // elements.
+ // When an object with Wires is specified to 'children' property, they
+ // are used to get or set an object with property values.
+ // When an array of Wiares is specified to 'children' property, they
+ // are used to get or set an array with element values.
+
+ _wireClass: "dojox.wire.CompositeWire",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If object properties or array elements specified in 'children'
+ // property are not Wires, Wires are created from them as
+ // arguments, with 'parent' property set to this Wire instance.
+ // args:
+ // Arguments to initialize properties
+ // children:
+ // An object or array containing child Wires
+ this._initializeChildren(this.children);
+ },
+ _getValue: function(/*Object||Array*/object){
+ // summary:
+ // Return an object with property values or an array with element
+ // values
+ // description:
+ // This method calls getValue() method of the child Wires with
+ // 'object' argument and returns an object with the values as
+ // properties or an arary of the values as elements.
+ // object:
+ // A root object
+ // returns:
+ // An object or array with values
+ if(!object || !this.children){
+ return object; //Object||Array
+ }
+
+ var value = (dojo.isArray(this.children) ? [] : {}); // array or object
+ for(var c in this.children){
+ value[c] = this.children[c].getValue(object);
+ }
+ return value;//Object||Array
+ },
+
+ _setValue: function(/*Object||Array*/object, /*Object||Array*/value){
+ // summary:
+ // Set an object properties or an array elements to an object
+ // desription:
+ // This method calls setValues() method of the child Wires with
+ // a corresponding property or element in 'value' argument and
+ // 'object' argument.
+ // object:
+ // A root object
+ // value:
+ // An object or array with values to set
+ // returns:
+ // 'object'
+ if(!object || !this.children){
+ return object; //Object||Array
+ }
+
+ for(var c in this.children){
+ this.children[c].setValue(value[c], object);
+ }
+ return object; //Object||Array
+ },
+
+ _initializeChildren: function(/*Object||Array*/children){
+ // summary:
+ // Initialize child Wires
+ // description:
+ // If object properties or array elements specified in 'children'
+ // argument are not Wires, Wires are created from them as
+ // arguments, with 'parent' property set to this Wire instance.
+ // children:
+ // An object or array containing child Wires
+ if(!children){
+ return; //undefined
+ }
+
+ for(var c in children){
+ var child = children[c];
+ child.parent = this;
+ if(!dojox.wire.isWire(child)){
+ children[c] = dojox.wire.create(child);
+ }
+ }
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/CompositeWire.xd.js b/js/dojo-1.6/dojox/wire/CompositeWire.xd.js new file mode 100644 index 0000000..1d504e3 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/CompositeWire.xd.js @@ -0,0 +1,116 @@ +/*
+ 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.wire.CompositeWire"],
+["require", "dojox.wire._base"],
+["require", "dojox.wire.Wire"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.CompositeWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.CompositeWire"] = true;
+dojo.provide("dojox.wire.CompositeWire");
+
+dojo.require("dojox.wire._base");
+dojo.require("dojox.wire.Wire");
+
+dojo.declare("dojox.wire.CompositeWire", dojox.wire.Wire, {
+ // summary:
+ // A Wire for composite values in object or array
+ // description:
+ // This class has multiple child Wires for object properties or array
+ // elements.
+ // When an object with Wires is specified to 'children' property, they
+ // are used to get or set an object with property values.
+ // When an array of Wiares is specified to 'children' property, they
+ // are used to get or set an array with element values.
+
+ _wireClass: "dojox.wire.CompositeWire",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If object properties or array elements specified in 'children'
+ // property are not Wires, Wires are created from them as
+ // arguments, with 'parent' property set to this Wire instance.
+ // args:
+ // Arguments to initialize properties
+ // children:
+ // An object or array containing child Wires
+ this._initializeChildren(this.children);
+ },
+ _getValue: function(/*Object||Array*/object){
+ // summary:
+ // Return an object with property values or an array with element
+ // values
+ // description:
+ // This method calls getValue() method of the child Wires with
+ // 'object' argument and returns an object with the values as
+ // properties or an arary of the values as elements.
+ // object:
+ // A root object
+ // returns:
+ // An object or array with values
+ if(!object || !this.children){
+ return object; //Object||Array
+ }
+
+ var value = (dojo.isArray(this.children) ? [] : {}); // array or object
+ for(var c in this.children){
+ value[c] = this.children[c].getValue(object);
+ }
+ return value;//Object||Array
+ },
+
+ _setValue: function(/*Object||Array*/object, /*Object||Array*/value){
+ // summary:
+ // Set an object properties or an array elements to an object
+ // desription:
+ // This method calls setValues() method of the child Wires with
+ // a corresponding property or element in 'value' argument and
+ // 'object' argument.
+ // object:
+ // A root object
+ // value:
+ // An object or array with values to set
+ // returns:
+ // 'object'
+ if(!object || !this.children){
+ return object; //Object||Array
+ }
+
+ for(var c in this.children){
+ this.children[c].setValue(value[c], object);
+ }
+ return object; //Object||Array
+ },
+
+ _initializeChildren: function(/*Object||Array*/children){
+ // summary:
+ // Initialize child Wires
+ // description:
+ // If object properties or array elements specified in 'children'
+ // argument are not Wires, Wires are created from them as
+ // arguments, with 'parent' property set to this Wire instance.
+ // children:
+ // An object or array containing child Wires
+ if(!children){
+ return; //undefined
+ }
+
+ for(var c in children){
+ var child = children[c];
+ child.parent = this;
+ if(!dojox.wire.isWire(child)){
+ children[c] = dojox.wire.create(child);
+ }
+ }
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/DataWire.js b/js/dojo-1.6/dojox/wire/DataWire.js new file mode 100644 index 0000000..1d1e9a9 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/DataWire.js @@ -0,0 +1,186 @@ +/*
+ 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.wire.DataWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.DataWire"] = true;
+dojo.provide("dojox.wire.DataWire");
+
+dojo.require("dojox.wire.Wire");
+
+dojo.declare("dojox.wire.DataWire", dojox.wire.Wire, {
+ // summary:
+ // A Wire for item attributes of data stores
+ // description:
+ // This class accesses item attributes of data stores with a dotted
+ // notation of attribute names specified to 'attribute' property,
+ // using data APIs of a data store specified to 'dataStore' property.
+ // The root object for this class must be an item of the data store.
+ // Intermediate attribute names in the dotted notation specify
+ // attributes for child items, which are used for repeated calls to
+ // data APIs until reached to a descendant attribute.
+ // Attribute names may have an array index, such as "a[0]", to
+ // identify an array element of the attribute value.
+
+ _wireClass: "dojox.wire.DataWire",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If 'dataStore' property is not specified, but 'parent' property
+ // is specified, 'dataStore' property is copied from the parent.
+ // args:
+ // Arguments to initialize properties
+ // dataStore:
+ // A data store
+ // attribute:
+ // A dotted notation to a descendant attribute
+ if(!this.dataStore && this.parent){
+ this.dataStore = this.parent.dataStore;
+ }
+ },
+ _getValue: function(/*Object*/object){
+ // summary:
+ // Return an attribute value of an item
+ // description:
+ // This method uses a root item passed in 'object' argument and
+ // 'attribute' property to call getValue() method of
+ // 'dataStore'.
+ // If an attribute name have an array suffix ("[]"), getValues()
+ // method is called, instead.
+ // If an index is specified in the array suffix, an array element
+ // for the index is returned, instead of the array itself.
+ // object:
+ // A root item
+ // returns:
+ // A value found, otherwise 'undefined'
+ if(!object || !this.attribute || !this.dataStore){
+ return object; //Object
+ }
+
+ var value = object;
+ var list = this.attribute.split('.');
+ for(var i in list){
+ value = this._getAttributeValue(value, list[i]);
+ if(!value){
+ return undefined; //undefined
+ }
+ }
+ return value; //anything
+ },
+
+ _setValue: function(/*Object*/object, /*anything*/value){
+ // summary:
+ // Set an attribute value to an item
+ // description:
+ // This method uses a root item passed in 'object' argument and
+ // 'attribute' property to identify an item.
+ // Then, setValue() method of 'dataStore' is called with a leaf
+ // attribute name and 'value' argument.
+ // If an attribute name have an array suffix ("[]"), setValues()
+ // method is called, instead.
+ // If an index is specified in the array suffix, an array element
+ // for the index is set to 'value', instead of the array itself.
+ // object:
+ // A root item
+ // value:
+ // A value to set
+ // returns:
+ // 'object', or 'undefined' for invalid attribute
+ if(!object || !this.attribute || !this.dataStore){
+ return object; //Object
+ }
+
+ var item = object;
+ var list = this.attribute.split('.');
+ var last = list.length - 1;
+ for(var i = 0; i < last; i++){
+ item = this._getAttributeValue(item, list[i]);
+ if(!item){
+ return undefined; //undefined
+ }
+ }
+ this._setAttributeValue(item, list[last], value);
+ return object; //Object
+ },
+
+ _getAttributeValue: function(/*Object*/item, /*String*/attribute){
+ // summary:
+ // Return an attribute value of an item
+ // description:
+ // This method uses an item passed in 'item' argument and
+ // 'attribute' argument to call getValue() method of 'dataStore'.
+ // If an attribute name have an array suffix ("[]"), getValues()
+ // method is called, instead.
+ // If an index is specified in the array suffix, an array element
+ // for the index is returned, instead of the array itself.
+ // item:
+ // An item
+ // attribute
+ // An attribute name
+ // returns:
+ // A value found, otherwise 'undefined'
+ var value = undefined;
+ var i1 = attribute.indexOf('[');
+ if(i1 >= 0){
+ var i2 = attribute.indexOf(']');
+ var index = attribute.substring(i1 + 1, i2);
+ attribute = attribute.substring(0, i1);
+ var array = this.dataStore.getValues(item, attribute);
+ if(array){
+ if(!index){ // return array for "attribute[]"
+ value = array;
+ }else{
+ value = array[index];
+ }
+ }
+ }else{
+ value = this.dataStore.getValue(item, attribute);
+ }
+ return value; //anything
+ },
+
+ _setAttributeValue: function(/*Object*/item, /*String*/attribute, /*anything*/value){
+ // summary:
+ // Set an attribute value to an item
+ // description:
+ // This method uses an item passed in 'item' argument and
+ // 'attribute' argument to call setValue() method of 'dataStore'
+ // with 'value' argument.
+ // If an attribute name have an array suffix ("[]"), setValues()
+ // method is called, instead.
+ // If an index is specified in the array suffix, an array element
+ // for the index is set to 'value', instead of the array itself.
+ // item:
+ // An item
+ // attribute:
+ // An attribute name
+ // value:
+ // A value to set
+ var i1 = attribute.indexOf('[');
+ if(i1 >= 0){
+ var i2 = attribute.indexOf(']');
+ var index = attribute.substring(i1 + 1, i2);
+ attribute = attribute.substring(0, i1);
+ var array = null;
+ if(!index){ // replace whole array for "attribute[]"
+ array = value;
+ }else{
+ array = this.dataStore.getValues(item, attribute);
+ if(!array){
+ array = [];
+ }
+ array[index] = value;
+ }
+ this.dataStore.setValues(item, attribute, array);
+ }else{
+ this.dataStore.setValue(item, attribute, value);
+ }
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/DataWire.xd.js b/js/dojo-1.6/dojox/wire/DataWire.xd.js new file mode 100644 index 0000000..b48a700 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/DataWire.xd.js @@ -0,0 +1,191 @@ +/*
+ 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.wire.DataWire"],
+["require", "dojox.wire.Wire"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.DataWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.DataWire"] = true;
+dojo.provide("dojox.wire.DataWire");
+
+dojo.require("dojox.wire.Wire");
+
+dojo.declare("dojox.wire.DataWire", dojox.wire.Wire, {
+ // summary:
+ // A Wire for item attributes of data stores
+ // description:
+ // This class accesses item attributes of data stores with a dotted
+ // notation of attribute names specified to 'attribute' property,
+ // using data APIs of a data store specified to 'dataStore' property.
+ // The root object for this class must be an item of the data store.
+ // Intermediate attribute names in the dotted notation specify
+ // attributes for child items, which are used for repeated calls to
+ // data APIs until reached to a descendant attribute.
+ // Attribute names may have an array index, such as "a[0]", to
+ // identify an array element of the attribute value.
+
+ _wireClass: "dojox.wire.DataWire",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If 'dataStore' property is not specified, but 'parent' property
+ // is specified, 'dataStore' property is copied from the parent.
+ // args:
+ // Arguments to initialize properties
+ // dataStore:
+ // A data store
+ // attribute:
+ // A dotted notation to a descendant attribute
+ if(!this.dataStore && this.parent){
+ this.dataStore = this.parent.dataStore;
+ }
+ },
+ _getValue: function(/*Object*/object){
+ // summary:
+ // Return an attribute value of an item
+ // description:
+ // This method uses a root item passed in 'object' argument and
+ // 'attribute' property to call getValue() method of
+ // 'dataStore'.
+ // If an attribute name have an array suffix ("[]"), getValues()
+ // method is called, instead.
+ // If an index is specified in the array suffix, an array element
+ // for the index is returned, instead of the array itself.
+ // object:
+ // A root item
+ // returns:
+ // A value found, otherwise 'undefined'
+ if(!object || !this.attribute || !this.dataStore){
+ return object; //Object
+ }
+
+ var value = object;
+ var list = this.attribute.split('.');
+ for(var i in list){
+ value = this._getAttributeValue(value, list[i]);
+ if(!value){
+ return undefined; //undefined
+ }
+ }
+ return value; //anything
+ },
+
+ _setValue: function(/*Object*/object, /*anything*/value){
+ // summary:
+ // Set an attribute value to an item
+ // description:
+ // This method uses a root item passed in 'object' argument and
+ // 'attribute' property to identify an item.
+ // Then, setValue() method of 'dataStore' is called with a leaf
+ // attribute name and 'value' argument.
+ // If an attribute name have an array suffix ("[]"), setValues()
+ // method is called, instead.
+ // If an index is specified in the array suffix, an array element
+ // for the index is set to 'value', instead of the array itself.
+ // object:
+ // A root item
+ // value:
+ // A value to set
+ // returns:
+ // 'object', or 'undefined' for invalid attribute
+ if(!object || !this.attribute || !this.dataStore){
+ return object; //Object
+ }
+
+ var item = object;
+ var list = this.attribute.split('.');
+ var last = list.length - 1;
+ for(var i = 0; i < last; i++){
+ item = this._getAttributeValue(item, list[i]);
+ if(!item){
+ return undefined; //undefined
+ }
+ }
+ this._setAttributeValue(item, list[last], value);
+ return object; //Object
+ },
+
+ _getAttributeValue: function(/*Object*/item, /*String*/attribute){
+ // summary:
+ // Return an attribute value of an item
+ // description:
+ // This method uses an item passed in 'item' argument and
+ // 'attribute' argument to call getValue() method of 'dataStore'.
+ // If an attribute name have an array suffix ("[]"), getValues()
+ // method is called, instead.
+ // If an index is specified in the array suffix, an array element
+ // for the index is returned, instead of the array itself.
+ // item:
+ // An item
+ // attribute
+ // An attribute name
+ // returns:
+ // A value found, otherwise 'undefined'
+ var value = undefined;
+ var i1 = attribute.indexOf('[');
+ if(i1 >= 0){
+ var i2 = attribute.indexOf(']');
+ var index = attribute.substring(i1 + 1, i2);
+ attribute = attribute.substring(0, i1);
+ var array = this.dataStore.getValues(item, attribute);
+ if(array){
+ if(!index){ // return array for "attribute[]"
+ value = array;
+ }else{
+ value = array[index];
+ }
+ }
+ }else{
+ value = this.dataStore.getValue(item, attribute);
+ }
+ return value; //anything
+ },
+
+ _setAttributeValue: function(/*Object*/item, /*String*/attribute, /*anything*/value){
+ // summary:
+ // Set an attribute value to an item
+ // description:
+ // This method uses an item passed in 'item' argument and
+ // 'attribute' argument to call setValue() method of 'dataStore'
+ // with 'value' argument.
+ // If an attribute name have an array suffix ("[]"), setValues()
+ // method is called, instead.
+ // If an index is specified in the array suffix, an array element
+ // for the index is set to 'value', instead of the array itself.
+ // item:
+ // An item
+ // attribute:
+ // An attribute name
+ // value:
+ // A value to set
+ var i1 = attribute.indexOf('[');
+ if(i1 >= 0){
+ var i2 = attribute.indexOf(']');
+ var index = attribute.substring(i1 + 1, i2);
+ attribute = attribute.substring(0, i1);
+ var array = null;
+ if(!index){ // replace whole array for "attribute[]"
+ array = value;
+ }else{
+ array = this.dataStore.getValues(item, attribute);
+ if(!array){
+ array = [];
+ }
+ array[index] = value;
+ }
+ this.dataStore.setValues(item, attribute, array);
+ }else{
+ this.dataStore.setValue(item, attribute, value);
+ }
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/README b/js/dojo-1.6/dojox/wire/README new file mode 100644 index 0000000..d33edee --- /dev/null +++ b/js/dojo-1.6/dojox/wire/README @@ -0,0 +1,54 @@ +------------------------------------------------------------------------------- +DojoX Wire +------------------------------------------------------------------------------- +Version 1.0 +Release date: 05/29/2007 +------------------------------------------------------------------------------- +Project state: production +------------------------------------------------------------------------------- +Project authors + Jared Jurkiewicz (jared.jurkiewicz@gmail.com) +------------------------------------------------------------------------------- +Project description + +The DojoX Wire project is a set of functions that build a generic data binding +and service invocation library to simplify how data values across a wide +variety of widget and non-widget JavaScript constructs are accessed, updated, +and passed to and from services. It also provides a set of widgets +within the dojox.wire.ml package to allow for declarative data binding +definitions in addition to the programmatic APIs. + +In essense, this project is an API to provide a simplified way of doing MVC +patterns in the client. + +------------------------------------------------------------------------------- +Dependencies: + +DojoX Wire has dependencies on core dojo, the dijit widget system (for classes +in the dojox.wire.ml package), dojox.data, dojox.xml, and the D.O.H. unit test +framework. +------------------------------------------------------------------------------- +Documentation: + +See the Dojo API tool (http://dojotoolkit.org/api) +------------------------------------------------------------------------------- +Installation instructions + +Grab the following from the Dojo SVN Repository: +http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/wire.js +http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/wire/* + +Install into the following directory structure: +/dojox/wire/ + +...which should be at the same level as your Dojo checkout. + +It should look like: +/dojox/wire.js +/dojox/wire/* + +Require in dojox.wire for all baseline functions (dojox.wire.connect, +dojox.wire.register, etc). For specific Wire classes, +require in the appropriate dojox.wire.<Class>. +------------------------------------------------------------------------------- + diff --git a/js/dojo-1.6/dojox/wire/TableAdapter.js b/js/dojo-1.6/dojox/wire/TableAdapter.js new file mode 100644 index 0000000..7fcca8a --- /dev/null +++ b/js/dojo-1.6/dojox/wire/TableAdapter.js @@ -0,0 +1,95 @@ +/*
+ 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.wire.TableAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.TableAdapter"] = true;
+dojo.provide("dojox.wire.TableAdapter");
+
+dojo.require("dojox.wire.CompositeWire");
+
+dojo.declare("dojox.wire.TableAdapter", dojox.wire.CompositeWire, {
+ // summary:
+ // A composite Wire for table rows
+ // description:
+ // This class has multiple child Wires for object properties or array
+ // elements of a table row.
+ // The root object for this class must be an array.
+ // When an object with Wires is specified to 'columns' property, they
+ // are used to get a row object with property values.
+ // When an array of Wires is specified to 'columns' property, they
+ // are used to get a row array with element values.
+ // The row values are returned in an array.
+ // This class only supports getValue(), but not setValue().
+
+ _wireClass: "dojox.wire.TableAdapter",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If object properties or array elements specified in 'columns'
+ // property are not Wires, Wires are created from them as
+ // arguments, with 'parent' property set to this Wire instance.
+ // args:
+ // Arguments to initialize properties
+ // columns:
+ // An object or array containing child Wires for column values
+ this._initializeChildren(this.columns);
+ },
+
+ _getValue: function(/*Array*/object){
+ // summary:
+ // Return an array of table row value (object or array)
+ // description:
+ // This method iterates over an array specified to 'object'
+ // argument and calls getValue() method of the child Wires with
+ // each element of the array to get a row object or array.
+ // Finally, an array with the row objects or arrays are retuned.
+ // object:
+ // A root array
+ // returns:
+ // An array of table row value
+ if(!object || !this.columns){
+ return object; //Array
+ }
+
+ var array = object;
+ if(!dojo.isArray(array)){
+ array = [array];
+ }
+
+ var rows = [];
+ for(var i in array){
+ var row = this._getRow(array[i]);
+ rows.push(row);
+ }
+ return rows; //Array
+ },
+
+ _setValue: function(/*Array*/object, /*Array*/value){
+ // summary:
+ // Not supported
+ throw new Error("Unsupported API: " + this._wireClass + "._setValue");
+ },
+
+ _getRow: function(/*Object||Array*/object){
+ // summary:
+ // Return an array or object for a table row
+ // description:
+ // This method calls getValue() method of the child Wires to
+ // create a row object or array.
+ // returns:
+ // An array or object for a table row
+ var row = (dojo.isArray(this.columns) ? [] : {}); // array or object
+ for(var c in this.columns){
+ row[c] = this.columns[c].getValue(object);
+ }
+ return row; //Array||Object
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/TableAdapter.xd.js b/js/dojo-1.6/dojox/wire/TableAdapter.xd.js new file mode 100644 index 0000000..6a2352a --- /dev/null +++ b/js/dojo-1.6/dojox/wire/TableAdapter.xd.js @@ -0,0 +1,100 @@ +/*
+ 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.wire.TableAdapter"],
+["require", "dojox.wire.CompositeWire"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.TableAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.TableAdapter"] = true;
+dojo.provide("dojox.wire.TableAdapter");
+
+dojo.require("dojox.wire.CompositeWire");
+
+dojo.declare("dojox.wire.TableAdapter", dojox.wire.CompositeWire, {
+ // summary:
+ // A composite Wire for table rows
+ // description:
+ // This class has multiple child Wires for object properties or array
+ // elements of a table row.
+ // The root object for this class must be an array.
+ // When an object with Wires is specified to 'columns' property, they
+ // are used to get a row object with property values.
+ // When an array of Wires is specified to 'columns' property, they
+ // are used to get a row array with element values.
+ // The row values are returned in an array.
+ // This class only supports getValue(), but not setValue().
+
+ _wireClass: "dojox.wire.TableAdapter",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If object properties or array elements specified in 'columns'
+ // property are not Wires, Wires are created from them as
+ // arguments, with 'parent' property set to this Wire instance.
+ // args:
+ // Arguments to initialize properties
+ // columns:
+ // An object or array containing child Wires for column values
+ this._initializeChildren(this.columns);
+ },
+
+ _getValue: function(/*Array*/object){
+ // summary:
+ // Return an array of table row value (object or array)
+ // description:
+ // This method iterates over an array specified to 'object'
+ // argument and calls getValue() method of the child Wires with
+ // each element of the array to get a row object or array.
+ // Finally, an array with the row objects or arrays are retuned.
+ // object:
+ // A root array
+ // returns:
+ // An array of table row value
+ if(!object || !this.columns){
+ return object; //Array
+ }
+
+ var array = object;
+ if(!dojo.isArray(array)){
+ array = [array];
+ }
+
+ var rows = [];
+ for(var i in array){
+ var row = this._getRow(array[i]);
+ rows.push(row);
+ }
+ return rows; //Array
+ },
+
+ _setValue: function(/*Array*/object, /*Array*/value){
+ // summary:
+ // Not supported
+ throw new Error("Unsupported API: " + this._wireClass + "._setValue");
+ },
+
+ _getRow: function(/*Object||Array*/object){
+ // summary:
+ // Return an array or object for a table row
+ // description:
+ // This method calls getValue() method of the child Wires to
+ // create a row object or array.
+ // returns:
+ // An array or object for a table row
+ var row = (dojo.isArray(this.columns) ? [] : {}); // array or object
+ for(var c in this.columns){
+ row[c] = this.columns[c].getValue(object);
+ }
+ return row; //Array||Object
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/TextAdapter.js b/js/dojo-1.6/dojox/wire/TextAdapter.js new file mode 100644 index 0000000..0eca4f7 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/TextAdapter.js @@ -0,0 +1,95 @@ +/*
+ 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.wire.TextAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.TextAdapter"] = true;
+dojo.provide("dojox.wire.TextAdapter");
+
+dojo.require("dojox.wire.CompositeWire");
+
+dojo.declare("dojox.wire.TextAdapter", dojox.wire.CompositeWire, {
+ // summary:
+ // A composite Wire for a concatenated text
+ // description:
+ // This class has multiple child Wires for text segment values.
+ // Wires in 'segments' property are used to get text segments and
+ // values are concatenated with an optional delimiter string specified
+ // to 'delimiter' property.
+
+ _wireClass: "dojox.wire.TextAdapter",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If array elements specified in 'segments' are not Wires, Wires
+ // are created from them as arguments, with 'parent' property set
+ // to this Wire instance.
+ // args:
+ // Arguments to initialize properties
+ // segments:
+ // An array containing child Wires for text segment values
+ // delimiter:
+ // A delimiter string
+ this._initializeChildren(this.segments);
+ if(!this.delimiter){
+ this.delimiter = "";
+ }
+ },
+
+ _getValue: function(/*Object||Array*/object){
+ // summary:
+ // Return a concatenated text
+ // description:
+ // This method calls getValue() method of the child Wires wuth
+ // 'object' argument and concatenate the values with 'delimiter'
+ // property to return.
+ // arg:
+ // A root object
+ // returns:
+ // A concatinated text
+ if(!object || !this.segments){
+ return object; //Object||Array
+ }
+
+ var text = "";
+ for(var i in this.segments){
+ var segment = this.segments[i].getValue(object);
+ text = this._addSegment(text, segment);
+ }
+ return text; //String
+ },
+
+ _setValue: function(/*Object||Array*/object, /*String*/value){
+ // summary:
+ // Not supported
+ throw new Error("Unsupported API: " + this._wireClass + "._setValue");
+ },
+
+ _addSegment: function(/*String*/text, /*String*/segment){
+ // summary:
+ // Return a concatenated text
+ // description:
+ // This method add a text segment specified to 'segment' argument
+ // to a base text specified to 'text', with 'delimiter' property.
+ // text:
+ // A base text
+ // segment:
+ // A text segment to add
+ // returns:
+ // A concatinated text
+ if(!segment){
+ return text; //String
+ }else if(!text){
+ return segment; //String
+ }else{
+ return text + this.delimiter + segment; //String
+ }
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/TextAdapter.xd.js b/js/dojo-1.6/dojox/wire/TextAdapter.xd.js new file mode 100644 index 0000000..779d7a2 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/TextAdapter.xd.js @@ -0,0 +1,100 @@ +/*
+ 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.wire.TextAdapter"],
+["require", "dojox.wire.CompositeWire"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.TextAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.TextAdapter"] = true;
+dojo.provide("dojox.wire.TextAdapter");
+
+dojo.require("dojox.wire.CompositeWire");
+
+dojo.declare("dojox.wire.TextAdapter", dojox.wire.CompositeWire, {
+ // summary:
+ // A composite Wire for a concatenated text
+ // description:
+ // This class has multiple child Wires for text segment values.
+ // Wires in 'segments' property are used to get text segments and
+ // values are concatenated with an optional delimiter string specified
+ // to 'delimiter' property.
+
+ _wireClass: "dojox.wire.TextAdapter",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If array elements specified in 'segments' are not Wires, Wires
+ // are created from them as arguments, with 'parent' property set
+ // to this Wire instance.
+ // args:
+ // Arguments to initialize properties
+ // segments:
+ // An array containing child Wires for text segment values
+ // delimiter:
+ // A delimiter string
+ this._initializeChildren(this.segments);
+ if(!this.delimiter){
+ this.delimiter = "";
+ }
+ },
+
+ _getValue: function(/*Object||Array*/object){
+ // summary:
+ // Return a concatenated text
+ // description:
+ // This method calls getValue() method of the child Wires wuth
+ // 'object' argument and concatenate the values with 'delimiter'
+ // property to return.
+ // arg:
+ // A root object
+ // returns:
+ // A concatinated text
+ if(!object || !this.segments){
+ return object; //Object||Array
+ }
+
+ var text = "";
+ for(var i in this.segments){
+ var segment = this.segments[i].getValue(object);
+ text = this._addSegment(text, segment);
+ }
+ return text; //String
+ },
+
+ _setValue: function(/*Object||Array*/object, /*String*/value){
+ // summary:
+ // Not supported
+ throw new Error("Unsupported API: " + this._wireClass + "._setValue");
+ },
+
+ _addSegment: function(/*String*/text, /*String*/segment){
+ // summary:
+ // Return a concatenated text
+ // description:
+ // This method add a text segment specified to 'segment' argument
+ // to a base text specified to 'text', with 'delimiter' property.
+ // text:
+ // A base text
+ // segment:
+ // A text segment to add
+ // returns:
+ // A concatinated text
+ if(!segment){
+ return text; //String
+ }else if(!text){
+ return segment; //String
+ }else{
+ return text + this.delimiter + segment; //String
+ }
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/TreeAdapter.js b/js/dojo-1.6/dojox/wire/TreeAdapter.js new file mode 100644 index 0000000..c489aad --- /dev/null +++ b/js/dojo-1.6/dojox/wire/TreeAdapter.js @@ -0,0 +1,195 @@ +/*
+ 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.wire.TreeAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.TreeAdapter"] = true;
+dojo.provide("dojox.wire.TreeAdapter");
+
+dojo.require("dojox.wire.CompositeWire");
+
+dojo.declare("dojox.wire.TreeAdapter", dojox.wire.CompositeWire, {
+ // summary:
+ // A composite Wire for tree nodes
+ // description:
+ // This class has multiple child Wires for tree nodes, their title and
+ // child nodes.
+ // The root object for this class must be an array.
+ // 'node' Wires in 'nodes' property is used to identify an object
+ // representing a node.
+ // 'title' Wires in 'nodes' property is used to get the title string
+ // of a node.
+ // 'children' Wires in 'nodes' property is used to iterate over child
+ // node objects.
+ // The node values are returned in an array as follows:
+ // [
+ // {title: title1,
+ // children: [
+ // {title: title2,
+ // child: ...},
+ // {title: title3,
+ // child: ...},
+ // ...
+ // ]},
+ // ...
+ // ]
+ // This class only supports getValue(), but not setValue().
+
+ _wireClass: "dojox.wire.TreeAdapter",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If object properties ('node', 'title' and 'children') of array
+ // elements specified in 'nodes' property are not Wires, Wires are
+ // created from them as arguments, with 'parent' property set to
+ // this Wire instance.
+ // args:
+ // Arguments to initialize properties
+ // nodes:
+ // An array containing objects for child Wires for node values
+ this._initializeChildren(this.nodes);
+ },
+ _getValue: function(/*Array*/object){
+ // summary:
+ // Return an array of tree node values
+ // description:
+ // This method iterates over an array specified to 'object'
+ // argument and calls getValue() method of 'node' Wires with each
+ // element of the array to get object(s) that represetns nodes.
+ // (If 'node' Wires are omitted, the array element is used for
+ // further processing.)
+ // Then, getValue() method of 'title' Wires are called to get
+ // title strings for nodes.
+ // (If 'title' Wires are omitted, the objects representing nodes
+ // are used as title strings.)
+ // And if an array of objects with 'node' and 'title' Wires is
+ // specified to 'children', it is used to gather child nodes and
+ // their title strings in the same way recursively.
+ // Finally, an array of the top-level node objects are retuned.
+ // object:
+ // A root array
+ // returns:
+ // An array of tree node values
+ if(!object || !this.nodes){
+ return object; //Array
+ }
+
+ var array = object;
+ if(!dojo.isArray(array)){
+ array = [array];
+ }
+
+ var nodes = [];
+ for(var i in array){
+ for(var i2 in this.nodes){
+ nodes = nodes.concat(this._getNodes(array[i], this.nodes[i2]));
+ }
+ }
+ return nodes; //Array
+ },
+
+ _setValue: function(/*Array*/object, /*Array*/value){
+ // summary:
+ // Not supported
+ throw new Error("Unsupported API: " + this._wireClass + "._setValue");
+ },
+
+ _initializeChildren: function(/*Array*/children){
+ // summary:
+ // Initialize child Wires
+ // description:
+ // If 'node' or 'title' properties of array elements specified in
+ // 'children' argument are not Wires, Wires are created from them
+ // as arguments, with 'parent' property set to this Wire instance.
+ // If an array element has 'children' property, this method is
+ // called recursively with it.
+ // children:
+ // An array of objects containing child Wires
+ if(!children){
+ return; //undefined
+ }
+
+ for(var i in children){
+ var child = children[i];
+ if(child.node){
+ child.node.parent = this;
+ if(!dojox.wire.isWire(child.node)){
+ child.node = dojox.wire.create(child.node);
+ }
+ }
+ if(child.title){
+ child.title.parent = this;
+ if(!dojox.wire.isWire(child.title)){
+ child.title = dojox.wire.create(child.title);
+ }
+ }
+ if(child.children){
+ this._initializeChildren(child.children);
+ }
+ }
+ },
+
+ _getNodes: function(/*Object*/object, /*Object*/child){
+ // summary:
+ // Return an array of tree node values
+ // description:
+ // This method calls getValue() method of 'node' Wires with
+ // 'object' argument to get object(s) that represents nodes.
+ // (If 'node' Wires are omitted, 'object' is used for further
+ // processing.)
+ // Then, getValue() method of 'title' Wires are called to get
+ // title strings for nodes.
+ // (If 'title' Wires are omitted, the objects representing nodes
+ // are used as title strings.)
+ // And if an array of objects with 'node' and 'title' Wires is
+ // specified to 'children', it is used to gather child nodes and
+ // their title strings in the same way recursively.
+ // Finally, an array of node objects are returned.
+ // object:
+ // An object
+ // child:
+ // An object with child Wires
+ // returns:
+ var array = null;
+ if(child.node){
+ array = child.node.getValue(object);
+ if(!array){
+ return [];
+ }
+ if(!dojo.isArray(array)){
+ array = [array];
+ }
+ }else{
+ array = [object];
+ }
+
+ var nodes = [];
+ for(var i in array){
+ object = array[i];
+ var node = {};
+ if(child.title){
+ node.title = child.title.getValue(object);
+ }else{
+ node.title = object;
+ }
+ if(child.children){
+ var children = [];
+ for(var i2 in child.children){
+ children = children.concat(this._getNodes(object, child.children[i2]));
+ }
+ if(children.length > 0){
+ node.children = children;
+ }
+ }
+ nodes.push(node);
+ }
+ return nodes; //Array
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/TreeAdapter.xd.js b/js/dojo-1.6/dojox/wire/TreeAdapter.xd.js new file mode 100644 index 0000000..3f1c914 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/TreeAdapter.xd.js @@ -0,0 +1,200 @@ +/*
+ 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.wire.TreeAdapter"],
+["require", "dojox.wire.CompositeWire"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.TreeAdapter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.TreeAdapter"] = true;
+dojo.provide("dojox.wire.TreeAdapter");
+
+dojo.require("dojox.wire.CompositeWire");
+
+dojo.declare("dojox.wire.TreeAdapter", dojox.wire.CompositeWire, {
+ // summary:
+ // A composite Wire for tree nodes
+ // description:
+ // This class has multiple child Wires for tree nodes, their title and
+ // child nodes.
+ // The root object for this class must be an array.
+ // 'node' Wires in 'nodes' property is used to identify an object
+ // representing a node.
+ // 'title' Wires in 'nodes' property is used to get the title string
+ // of a node.
+ // 'children' Wires in 'nodes' property is used to iterate over child
+ // node objects.
+ // The node values are returned in an array as follows:
+ // [
+ // {title: title1,
+ // children: [
+ // {title: title2,
+ // child: ...},
+ // {title: title3,
+ // child: ...},
+ // ...
+ // ]},
+ // ...
+ // ]
+ // This class only supports getValue(), but not setValue().
+
+ _wireClass: "dojox.wire.TreeAdapter",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If object properties ('node', 'title' and 'children') of array
+ // elements specified in 'nodes' property are not Wires, Wires are
+ // created from them as arguments, with 'parent' property set to
+ // this Wire instance.
+ // args:
+ // Arguments to initialize properties
+ // nodes:
+ // An array containing objects for child Wires for node values
+ this._initializeChildren(this.nodes);
+ },
+ _getValue: function(/*Array*/object){
+ // summary:
+ // Return an array of tree node values
+ // description:
+ // This method iterates over an array specified to 'object'
+ // argument and calls getValue() method of 'node' Wires with each
+ // element of the array to get object(s) that represetns nodes.
+ // (If 'node' Wires are omitted, the array element is used for
+ // further processing.)
+ // Then, getValue() method of 'title' Wires are called to get
+ // title strings for nodes.
+ // (If 'title' Wires are omitted, the objects representing nodes
+ // are used as title strings.)
+ // And if an array of objects with 'node' and 'title' Wires is
+ // specified to 'children', it is used to gather child nodes and
+ // their title strings in the same way recursively.
+ // Finally, an array of the top-level node objects are retuned.
+ // object:
+ // A root array
+ // returns:
+ // An array of tree node values
+ if(!object || !this.nodes){
+ return object; //Array
+ }
+
+ var array = object;
+ if(!dojo.isArray(array)){
+ array = [array];
+ }
+
+ var nodes = [];
+ for(var i in array){
+ for(var i2 in this.nodes){
+ nodes = nodes.concat(this._getNodes(array[i], this.nodes[i2]));
+ }
+ }
+ return nodes; //Array
+ },
+
+ _setValue: function(/*Array*/object, /*Array*/value){
+ // summary:
+ // Not supported
+ throw new Error("Unsupported API: " + this._wireClass + "._setValue");
+ },
+
+ _initializeChildren: function(/*Array*/children){
+ // summary:
+ // Initialize child Wires
+ // description:
+ // If 'node' or 'title' properties of array elements specified in
+ // 'children' argument are not Wires, Wires are created from them
+ // as arguments, with 'parent' property set to this Wire instance.
+ // If an array element has 'children' property, this method is
+ // called recursively with it.
+ // children:
+ // An array of objects containing child Wires
+ if(!children){
+ return; //undefined
+ }
+
+ for(var i in children){
+ var child = children[i];
+ if(child.node){
+ child.node.parent = this;
+ if(!dojox.wire.isWire(child.node)){
+ child.node = dojox.wire.create(child.node);
+ }
+ }
+ if(child.title){
+ child.title.parent = this;
+ if(!dojox.wire.isWire(child.title)){
+ child.title = dojox.wire.create(child.title);
+ }
+ }
+ if(child.children){
+ this._initializeChildren(child.children);
+ }
+ }
+ },
+
+ _getNodes: function(/*Object*/object, /*Object*/child){
+ // summary:
+ // Return an array of tree node values
+ // description:
+ // This method calls getValue() method of 'node' Wires with
+ // 'object' argument to get object(s) that represents nodes.
+ // (If 'node' Wires are omitted, 'object' is used for further
+ // processing.)
+ // Then, getValue() method of 'title' Wires are called to get
+ // title strings for nodes.
+ // (If 'title' Wires are omitted, the objects representing nodes
+ // are used as title strings.)
+ // And if an array of objects with 'node' and 'title' Wires is
+ // specified to 'children', it is used to gather child nodes and
+ // their title strings in the same way recursively.
+ // Finally, an array of node objects are returned.
+ // object:
+ // An object
+ // child:
+ // An object with child Wires
+ // returns:
+ var array = null;
+ if(child.node){
+ array = child.node.getValue(object);
+ if(!array){
+ return [];
+ }
+ if(!dojo.isArray(array)){
+ array = [array];
+ }
+ }else{
+ array = [object];
+ }
+
+ var nodes = [];
+ for(var i in array){
+ object = array[i];
+ var node = {};
+ if(child.title){
+ node.title = child.title.getValue(object);
+ }else{
+ node.title = object;
+ }
+ if(child.children){
+ var children = [];
+ for(var i2 in child.children){
+ children = children.concat(this._getNodes(object, child.children[i2]));
+ }
+ if(children.length > 0){
+ node.children = children;
+ }
+ }
+ nodes.push(node);
+ }
+ return nodes; //Array
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/Wire.js b/js/dojo-1.6/dojox/wire/Wire.js new file mode 100644 index 0000000..5182214 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/Wire.js @@ -0,0 +1,388 @@ +/*
+ 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.wire.Wire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.Wire"] = true;
+dojo.provide("dojox.wire.Wire");
+
+dojo.require("dojox.wire._base");
+
+dojo.declare("dojox.wire.Wire", null, {
+ // summary:
+ // A default and base Wire to access an object property
+ // description:
+ // This class accesses a property of an object with a dotted notation
+ // specified to 'property' property, such as "a.b.c", which identifies
+ // a descendant property, "object.a.b.c".
+ // Property names in the dotted notation may have an array index, such
+ // as "a[0]", to identify an array element, literally, "object.a[0]".
+ // When a notation start with an array index, such as "[0].a", it
+ // specifies an array element of the root object (array),
+ // "object[0].a".
+ // This class also serves as a base class for other Wire classes,
+ // preparing a root object and converting a return value, so that
+ // sub-classes just can implement _getValue() and _setValue() called
+ // from getValue() and setValue() implemented by this calss.
+
+ _wireClass: "dojox.wire.Wire",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If 'converter' property is specified and is a string for
+ // a converter class, an instanceof the converter class is
+ // created.
+ // args:
+ // Arguments to initialize properties
+ // object:
+ // A root object (or another Wire to access a root object)
+ // property:
+ // A dotted notation to a descendant property
+ // type:
+ // A type of the return value (for the source Wire)
+ // converter:
+ // A converter object (or class name) to convert the return
+ // value (for the source Wire)
+ dojo.mixin(this, args);
+
+ if(this.converter){
+ if(dojo.isString(this.converter)){
+ //First check the object tree for it. Might be defined variable
+ //name/global function (like a jsId, or just a function name).
+ var convertObject = dojo.getObject(this.converter);
+ if(dojo.isFunction(convertObject)){
+ //We need to see if this is a pure function or an object constructor...
+ try{
+ var testObj = new convertObject();
+ if(testObj && !dojo.isFunction(testObj["convert"])){
+ //Looks like a 'pure' function...
+ this.converter = {convert: convertObject};
+ }else{
+ this.converter = testObj;
+ }
+ }catch(e){
+ //Do if this fails.
+ }
+ }else if(dojo.isObject(convertObject)){
+ //It's an object, like a jsId ... see if it has a convert function
+ if(dojo.isFunction(convertObject["convert"])){
+ this.converter = convertObject;
+ }
+ }
+
+ //No object with that name (Converter is still a string),
+ //then look for a class that needs to be dynamically loaded...
+ if(dojo.isString(this.converter)){
+ var converterClass = dojox.wire._getClass(this.converter);
+ if(converterClass){
+ this.converter = new converterClass();
+ }else{
+ this.converter = undefined;
+ }
+ }
+ }else if(dojo.isFunction(this.converter)){
+ this.converter = {convert: this.converter};
+ }
+ }
+ },
+
+ getValue: function(/*Object||Array*/defaultObject){
+ // summary:
+ // Return a value of an object
+ // description:
+ // This method first determins a root object as follows:
+ // 1. If 'object' property specified,
+ // 1.1 If 'object' is a Wire, its getValue() method is called to
+ // obtain a root object.
+ // 1.2 Otherwise, use 'object' as a root object.
+ // 2. Otherwise, use 'defaultObject' argument.
+ // 3. If 'property' is specified, it is used to get a property
+ // value.
+ // Then, if a sub-class implements _getValue() method, it is
+ // called with the root object to get the return value.
+ // Otherwise, the root object (typically, a property valye) is
+ // used for the return value.
+ // Finally, if 'type' property is specified, the return value is
+ // converted to the specified primitive type ("string", "number",
+ // "boolean" and "array").
+ // If 'converter' property is specified, its convert() method is
+ // called to convert the value.
+ // defaultObject:
+ // A default root object
+ // returns:
+ // A value found
+ var object = undefined;
+ if(dojox.wire.isWire(this.object)){
+ object = this.object.getValue(defaultObject);
+ }else{
+ object = (this.object || defaultObject);
+ }
+
+ if(this.property){
+ var list = this.property.split('.');
+ for(var i in list){
+ if(!object){
+ return object; //anything (null, undefined, etc)
+ }
+ object = this._getPropertyValue(object, list[i]);
+ }
+ }
+
+ var value = undefined;
+ if(this._getValue){
+ value = this._getValue(object);
+ }else{
+ value = object;
+ }
+
+ if(value){
+ if(this.type){
+ if(this.type == "string"){
+ value = value.toString();
+ }else if(this.type == "number"){
+ value = parseInt(value, 10);
+ }else if(this.type == "boolean"){
+ value = (value != "false");
+ }else if(this.type == "array"){
+ if(!dojo.isArray(value)){
+ value = [value];
+ }
+ }
+ }
+ if(this.converter && this.converter.convert){
+ value = this.converter.convert(value, this); // optional "this" context
+ }
+ }
+ return value; //anything
+ },
+
+ setValue: function(/*anything*/value, /*Object||Array*/defaultObject){
+ // summary:
+ // Set a value to an object
+ // description:
+ // This method first determins a root object as follows:
+ // 1. If 'object' property specified,
+ // 1.1 If 'object' is a Wire, its getValue() method is called to
+ // obtain a root object.
+ // 1.2 Otherwise, use 'object' as a root object.
+ // 2. Otherwise, use 'defaultObject' argument.
+ // 3. If 'property' is specified, it is used to get a property
+ // value.
+ // Then, if a sub-class implements _setValue() method, it is
+ // called with the root object and 'value' argument to set
+ // the value.
+ // Otherwise, 'value' is set to a property specified with
+ // 'property' property.
+ // If the root object is undefined and 'object' property is a Wire
+ // and a new object is created and returned by _setValue() it is
+ // set through 'object' (setValue() method).
+ // value:
+ // A value to set
+ // defaultObject:
+ // A default root object
+ var object = undefined;
+ if(dojox.wire.isWire(this.object)){
+ object = this.object.getValue(defaultObject);
+ }else{
+ object = (this.object || defaultObject);
+ }
+
+ var property = undefined;
+ var o;
+ if(this.property){
+ if(!object){
+ if(dojox.wire.isWire(this.object)){
+ object = {};
+ this.object.setValue(object, defaultObject);
+ }else{
+ throw new Error(this._wireClass + ".setValue(): invalid object");
+ }
+ }
+ var list = this.property.split('.');
+ var last = list.length - 1;
+ for(var i = 0; i < last; i++){
+ var p = list[i];
+ o = this._getPropertyValue(object, p);
+ if(!o){
+ o = {};
+ this._setPropertyValue(object, p, o);
+ }
+ object = o;
+ }
+ property = list[last];
+ }
+
+ if(this._setValue){
+ if(property){
+ o = this._getPropertyValue(object, property);
+ if(!o){
+ o = {};
+ this._setPropertyValue(object, property, o);
+ }
+ object = o;
+ }
+ var newObject = this._setValue(object, value);
+ if(!object && newObject){
+ if(dojox.wire.isWire(this.object)){
+ this.object.setValue(newObject, defaultObject);
+ }else{
+ throw new Error(this._wireClass + ".setValue(): invalid object");
+ }
+ }
+ }else{
+ if(property){
+ this._setPropertyValue(object, property, value);
+ }else{
+ if(dojox.wire.isWire(this.object)){
+ this.object.setValue(value, defaultObject);
+ }else{
+ throw new Error(this._wireClass + ".setValue(): invalid property");
+ }
+ }
+ }
+ },
+
+ _getPropertyValue: function(/*Object||Array*/object, /*String*/property){
+ // summary:
+ // Return a property value of an object
+ // description:
+ // A value for 'property' of 'object' is returned.
+ // If 'property' ends with an array index, it is used to indentify
+ // an element of an array property.
+ // If 'object' implements getPropertyValue(), it is called with
+ // 'property' to obtain the property value.
+ // If 'object' implements a getter for the property, it is called
+ // to obtain the property value.
+ // object:
+ // A default root object
+ // property:
+ // A property name
+ // returns:
+ // A value found, otherwise 'undefined'
+ var value = undefined;
+ var i1 = property.indexOf('[');
+ if(i1 >= 0){
+ var i2 = property.indexOf(']');
+ var index = property.substring(i1 + 1, i2);
+ var array = null;
+ if(i1 === 0){ // object is array
+ array = object;
+ }else{
+ property = property.substring(0, i1);
+ array = this._getPropertyValue(object, property);
+ if(array && !dojo.isArray(array)){
+ array = [array];
+ }
+ }
+ if(array){
+ value = array[index];
+ }
+ }else if(object.getPropertyValue){
+ value = object.getPropertyValue(property);
+ }else{
+ var getter = "get" + property.charAt(0).toUpperCase() + property.substring(1);
+ if(this._useGet(object)){
+ value = object.get(property);
+ }else if(this._useAttr(object)){
+ value = object.attr(property);
+ } else if(object[getter]){
+ value = object[getter]();
+ }else{
+ value = object[property];
+ }
+ }
+ return value; //anything
+ },
+
+ _setPropertyValue: function(/*Object||Array*/object, /*String*/property, /*anything*/value){
+ // summary:
+ // Set a property value to an object
+ // description:
+ // 'value' is set to 'property' of 'object'.
+ // If 'property' ends with an array index, it is used to indentify
+ // an element of an array property to set the value.
+ // If 'object' implements setPropertyValue(), it is called with
+ // 'property' and 'value' to set the property value.
+ // If 'object' implements a setter for the property, it is called
+ // with 'value' to set the property value.
+ // object:
+ // An object
+ // property:
+ // A property name
+ // value:
+ // A value to set
+ var i1 = property.indexOf('[');
+ if(i1 >= 0){
+ var i2 = property.indexOf(']');
+ var index = property.substring(i1 + 1, i2);
+ var array = null;
+ if(i1 === 0){ // object is array
+ array = object;
+ }else{
+ property = property.substring(0, i1);
+ array = this._getPropertyValue(object, property);
+ if(!array){
+ array = [];
+ this._setPropertyValue(object, property, array);
+ }
+ }
+ array[index] = value;
+ }else if(object.setPropertyValue){
+ object.setPropertyValue(property, value);
+ }else{
+ var setter = "set" + property.charAt(0).toUpperCase() + property.substring(1);
+ if(this._useSet(object)){
+ object.set(property, value);
+ }else if(this._useAttr(object)){
+ object.attr(property, value);
+ }else if(object[setter]){
+ object[setter](value);
+ }else{
+ object[property] = value;
+ }
+ }
+ },
+
+ _useGet: function(object){
+ // summary:
+ // Function to detect if dijit.get support exists on the target
+ // object:
+ // The target object to set the property of.
+ var useGet = false;
+ if(dojo.isFunction(object.get)){
+ useGet = true;
+ }
+ return useGet;
+ },
+
+ _useSet: function(object){
+ // summary:
+ // Function to detect if dijit.set support exists on the target
+ // object:
+ // The target object to set the property of.
+ var useSet = false;
+ if(dojo.isFunction(object.set)){
+ useSet = true;
+ }
+ return useSet;
+ },
+
+ _useAttr: function(object){
+ // summary:
+ // Function to detect if dijit.attr support exists on the target
+ // object:
+ // The target object to set the property of.
+ var useAttr = false;
+ if(dojo.isFunction(object.attr)){
+ useAttr = true;
+ }
+ return useAttr;
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/Wire.xd.js b/js/dojo-1.6/dojox/wire/Wire.xd.js new file mode 100644 index 0000000..24dc785 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/Wire.xd.js @@ -0,0 +1,393 @@ +/*
+ 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.wire.Wire"],
+["require", "dojox.wire._base"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.Wire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.Wire"] = true;
+dojo.provide("dojox.wire.Wire");
+
+dojo.require("dojox.wire._base");
+
+dojo.declare("dojox.wire.Wire", null, {
+ // summary:
+ // A default and base Wire to access an object property
+ // description:
+ // This class accesses a property of an object with a dotted notation
+ // specified to 'property' property, such as "a.b.c", which identifies
+ // a descendant property, "object.a.b.c".
+ // Property names in the dotted notation may have an array index, such
+ // as "a[0]", to identify an array element, literally, "object.a[0]".
+ // When a notation start with an array index, such as "[0].a", it
+ // specifies an array element of the root object (array),
+ // "object[0].a".
+ // This class also serves as a base class for other Wire classes,
+ // preparing a root object and converting a return value, so that
+ // sub-classes just can implement _getValue() and _setValue() called
+ // from getValue() and setValue() implemented by this calss.
+
+ _wireClass: "dojox.wire.Wire",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // If 'converter' property is specified and is a string for
+ // a converter class, an instanceof the converter class is
+ // created.
+ // args:
+ // Arguments to initialize properties
+ // object:
+ // A root object (or another Wire to access a root object)
+ // property:
+ // A dotted notation to a descendant property
+ // type:
+ // A type of the return value (for the source Wire)
+ // converter:
+ // A converter object (or class name) to convert the return
+ // value (for the source Wire)
+ dojo.mixin(this, args);
+
+ if(this.converter){
+ if(dojo.isString(this.converter)){
+ //First check the object tree for it. Might be defined variable
+ //name/global function (like a jsId, or just a function name).
+ var convertObject = dojo.getObject(this.converter);
+ if(dojo.isFunction(convertObject)){
+ //We need to see if this is a pure function or an object constructor...
+ try{
+ var testObj = new convertObject();
+ if(testObj && !dojo.isFunction(testObj["convert"])){
+ //Looks like a 'pure' function...
+ this.converter = {convert: convertObject};
+ }else{
+ this.converter = testObj;
+ }
+ }catch(e){
+ //Do if this fails.
+ }
+ }else if(dojo.isObject(convertObject)){
+ //It's an object, like a jsId ... see if it has a convert function
+ if(dojo.isFunction(convertObject["convert"])){
+ this.converter = convertObject;
+ }
+ }
+
+ //No object with that name (Converter is still a string),
+ //then look for a class that needs to be dynamically loaded...
+ if(dojo.isString(this.converter)){
+ var converterClass = dojox.wire._getClass(this.converter);
+ if(converterClass){
+ this.converter = new converterClass();
+ }else{
+ this.converter = undefined;
+ }
+ }
+ }else if(dojo.isFunction(this.converter)){
+ this.converter = {convert: this.converter};
+ }
+ }
+ },
+
+ getValue: function(/*Object||Array*/defaultObject){
+ // summary:
+ // Return a value of an object
+ // description:
+ // This method first determins a root object as follows:
+ // 1. If 'object' property specified,
+ // 1.1 If 'object' is a Wire, its getValue() method is called to
+ // obtain a root object.
+ // 1.2 Otherwise, use 'object' as a root object.
+ // 2. Otherwise, use 'defaultObject' argument.
+ // 3. If 'property' is specified, it is used to get a property
+ // value.
+ // Then, if a sub-class implements _getValue() method, it is
+ // called with the root object to get the return value.
+ // Otherwise, the root object (typically, a property valye) is
+ // used for the return value.
+ // Finally, if 'type' property is specified, the return value is
+ // converted to the specified primitive type ("string", "number",
+ // "boolean" and "array").
+ // If 'converter' property is specified, its convert() method is
+ // called to convert the value.
+ // defaultObject:
+ // A default root object
+ // returns:
+ // A value found
+ var object = undefined;
+ if(dojox.wire.isWire(this.object)){
+ object = this.object.getValue(defaultObject);
+ }else{
+ object = (this.object || defaultObject);
+ }
+
+ if(this.property){
+ var list = this.property.split('.');
+ for(var i in list){
+ if(!object){
+ return object; //anything (null, undefined, etc)
+ }
+ object = this._getPropertyValue(object, list[i]);
+ }
+ }
+
+ var value = undefined;
+ if(this._getValue){
+ value = this._getValue(object);
+ }else{
+ value = object;
+ }
+
+ if(value){
+ if(this.type){
+ if(this.type == "string"){
+ value = value.toString();
+ }else if(this.type == "number"){
+ value = parseInt(value, 10);
+ }else if(this.type == "boolean"){
+ value = (value != "false");
+ }else if(this.type == "array"){
+ if(!dojo.isArray(value)){
+ value = [value];
+ }
+ }
+ }
+ if(this.converter && this.converter.convert){
+ value = this.converter.convert(value, this); // optional "this" context
+ }
+ }
+ return value; //anything
+ },
+
+ setValue: function(/*anything*/value, /*Object||Array*/defaultObject){
+ // summary:
+ // Set a value to an object
+ // description:
+ // This method first determins a root object as follows:
+ // 1. If 'object' property specified,
+ // 1.1 If 'object' is a Wire, its getValue() method is called to
+ // obtain a root object.
+ // 1.2 Otherwise, use 'object' as a root object.
+ // 2. Otherwise, use 'defaultObject' argument.
+ // 3. If 'property' is specified, it is used to get a property
+ // value.
+ // Then, if a sub-class implements _setValue() method, it is
+ // called with the root object and 'value' argument to set
+ // the value.
+ // Otherwise, 'value' is set to a property specified with
+ // 'property' property.
+ // If the root object is undefined and 'object' property is a Wire
+ // and a new object is created and returned by _setValue() it is
+ // set through 'object' (setValue() method).
+ // value:
+ // A value to set
+ // defaultObject:
+ // A default root object
+ var object = undefined;
+ if(dojox.wire.isWire(this.object)){
+ object = this.object.getValue(defaultObject);
+ }else{
+ object = (this.object || defaultObject);
+ }
+
+ var property = undefined;
+ var o;
+ if(this.property){
+ if(!object){
+ if(dojox.wire.isWire(this.object)){
+ object = {};
+ this.object.setValue(object, defaultObject);
+ }else{
+ throw new Error(this._wireClass + ".setValue(): invalid object");
+ }
+ }
+ var list = this.property.split('.');
+ var last = list.length - 1;
+ for(var i = 0; i < last; i++){
+ var p = list[i];
+ o = this._getPropertyValue(object, p);
+ if(!o){
+ o = {};
+ this._setPropertyValue(object, p, o);
+ }
+ object = o;
+ }
+ property = list[last];
+ }
+
+ if(this._setValue){
+ if(property){
+ o = this._getPropertyValue(object, property);
+ if(!o){
+ o = {};
+ this._setPropertyValue(object, property, o);
+ }
+ object = o;
+ }
+ var newObject = this._setValue(object, value);
+ if(!object && newObject){
+ if(dojox.wire.isWire(this.object)){
+ this.object.setValue(newObject, defaultObject);
+ }else{
+ throw new Error(this._wireClass + ".setValue(): invalid object");
+ }
+ }
+ }else{
+ if(property){
+ this._setPropertyValue(object, property, value);
+ }else{
+ if(dojox.wire.isWire(this.object)){
+ this.object.setValue(value, defaultObject);
+ }else{
+ throw new Error(this._wireClass + ".setValue(): invalid property");
+ }
+ }
+ }
+ },
+
+ _getPropertyValue: function(/*Object||Array*/object, /*String*/property){
+ // summary:
+ // Return a property value of an object
+ // description:
+ // A value for 'property' of 'object' is returned.
+ // If 'property' ends with an array index, it is used to indentify
+ // an element of an array property.
+ // If 'object' implements getPropertyValue(), it is called with
+ // 'property' to obtain the property value.
+ // If 'object' implements a getter for the property, it is called
+ // to obtain the property value.
+ // object:
+ // A default root object
+ // property:
+ // A property name
+ // returns:
+ // A value found, otherwise 'undefined'
+ var value = undefined;
+ var i1 = property.indexOf('[');
+ if(i1 >= 0){
+ var i2 = property.indexOf(']');
+ var index = property.substring(i1 + 1, i2);
+ var array = null;
+ if(i1 === 0){ // object is array
+ array = object;
+ }else{
+ property = property.substring(0, i1);
+ array = this._getPropertyValue(object, property);
+ if(array && !dojo.isArray(array)){
+ array = [array];
+ }
+ }
+ if(array){
+ value = array[index];
+ }
+ }else if(object.getPropertyValue){
+ value = object.getPropertyValue(property);
+ }else{
+ var getter = "get" + property.charAt(0).toUpperCase() + property.substring(1);
+ if(this._useGet(object)){
+ value = object.get(property);
+ }else if(this._useAttr(object)){
+ value = object.attr(property);
+ } else if(object[getter]){
+ value = object[getter]();
+ }else{
+ value = object[property];
+ }
+ }
+ return value; //anything
+ },
+
+ _setPropertyValue: function(/*Object||Array*/object, /*String*/property, /*anything*/value){
+ // summary:
+ // Set a property value to an object
+ // description:
+ // 'value' is set to 'property' of 'object'.
+ // If 'property' ends with an array index, it is used to indentify
+ // an element of an array property to set the value.
+ // If 'object' implements setPropertyValue(), it is called with
+ // 'property' and 'value' to set the property value.
+ // If 'object' implements a setter for the property, it is called
+ // with 'value' to set the property value.
+ // object:
+ // An object
+ // property:
+ // A property name
+ // value:
+ // A value to set
+ var i1 = property.indexOf('[');
+ if(i1 >= 0){
+ var i2 = property.indexOf(']');
+ var index = property.substring(i1 + 1, i2);
+ var array = null;
+ if(i1 === 0){ // object is array
+ array = object;
+ }else{
+ property = property.substring(0, i1);
+ array = this._getPropertyValue(object, property);
+ if(!array){
+ array = [];
+ this._setPropertyValue(object, property, array);
+ }
+ }
+ array[index] = value;
+ }else if(object.setPropertyValue){
+ object.setPropertyValue(property, value);
+ }else{
+ var setter = "set" + property.charAt(0).toUpperCase() + property.substring(1);
+ if(this._useSet(object)){
+ object.set(property, value);
+ }else if(this._useAttr(object)){
+ object.attr(property, value);
+ }else if(object[setter]){
+ object[setter](value);
+ }else{
+ object[property] = value;
+ }
+ }
+ },
+
+ _useGet: function(object){
+ // summary:
+ // Function to detect if dijit.get support exists on the target
+ // object:
+ // The target object to set the property of.
+ var useGet = false;
+ if(dojo.isFunction(object.get)){
+ useGet = true;
+ }
+ return useGet;
+ },
+
+ _useSet: function(object){
+ // summary:
+ // Function to detect if dijit.set support exists on the target
+ // object:
+ // The target object to set the property of.
+ var useSet = false;
+ if(dojo.isFunction(object.set)){
+ useSet = true;
+ }
+ return useSet;
+ },
+
+ _useAttr: function(object){
+ // summary:
+ // Function to detect if dijit.attr support exists on the target
+ // object:
+ // The target object to set the property of.
+ var useAttr = false;
+ if(dojo.isFunction(object.attr)){
+ useAttr = true;
+ }
+ return useAttr;
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/XmlWire.js b/js/dojo-1.6/dojox/wire/XmlWire.js new file mode 100644 index 0000000..4fec68a --- /dev/null +++ b/js/dojo-1.6/dojox/wire/XmlWire.js @@ -0,0 +1,253 @@ +/*
+ 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.wire.XmlWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.XmlWire"] = true;
+dojo.provide("dojox.wire.XmlWire");
+
+dojo.require("dojox.xml.parser");
+dojo.require("dojox.wire.Wire");
+
+dojo.declare("dojox.wire.XmlWire", dojox.wire.Wire, {
+ // summary:
+ // A Wire for XML nodes or values (element, attribute and text)
+ // description:
+ // This class accesses XML nodes or value with a simplified XPath
+ // specified to 'path' property.
+ // The root object for this class must be an DOM document or element
+ // node.
+ // "@name" accesses to an attribute value of an element and "text()"
+ // accesses to a text value of an element.
+ // The hierarchy of the elements from the root node can be specified
+ // with slash-separated list, such as "a/b/@c", which specifies
+ // the value of an attribute named "c" of an element named "b" as
+ // a child of another element named "a" of a child of the root node.
+
+ _wireClass: "dojox.wire.XmlWire",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // 'args' is just mixed in with no further processing.
+ // args:
+ // Arguments to initialize properties
+ // path:
+ // A simplified XPath to an attribute, a text or elements
+ },
+ _getValue: function(/*Node*/object){
+ // summary:
+ // Return an attribute value, a text value or an array of elements
+ // description:
+ // This method first uses a root node passed in 'object' argument
+ // and 'path' property to identify an attribute, a text or
+ // elements.
+ // If 'path' starts with a slash (absolute), the first path
+ // segment is ignored assuming it point to the root node.
+ // (That is, "/a/b/@c" and "b/@c" against a root node access
+ // the same attribute value, assuming the root node is an element
+ // with a tag name, "a".)
+ // object:
+ // A root node
+ // returns:
+ // A value found, otherwise 'undefined'
+ if(!object || !this.path){
+ return object; //Node
+ }
+
+ var node = object;
+ var path = this.path;
+ var i;
+ if(path.charAt(0) == '/'){ // absolute
+ // skip the first expression (supposed to select the top node)
+ i = path.indexOf('/', 1);
+ path = path.substring(i + 1);
+ }
+ var list = path.split('/');
+ var last = list.length - 1;
+ for(i = 0; i < last; i++){
+ node = this._getChildNode(node, list[i]);
+ if(!node){
+ return undefined; //undefined
+ }
+ }
+ var value = this._getNodeValue(node, list[last]);
+ return value; //String||Array
+ },
+
+ _setValue: function(/*Node*/object, /*String*/value){
+ // summary:
+ // Set an attribute value or a child text value to an element
+ // description:
+ // This method first uses a root node passed in 'object' argument
+ // and 'path' property to identify an attribute, a text or
+ // elements.
+ // If an intermediate element does not exist, it creates
+ // an element of the tag name in the 'path' segment as a child
+ // node of the current node.
+ // Finally, 'value' argument is set to an attribute or a text
+ // (a child node) of the leaf element.
+ // object:
+ // A root node
+ // value:
+ // A value to set
+ if(!this.path){
+ return object; //Node
+ }
+
+ var node = object;
+ var doc = this._getDocument(node);
+ var path = this.path;
+ var i;
+ if(path.charAt(0) == '/'){ // absolute
+ i = path.indexOf('/', 1);
+ if(!node){
+ var name = path.substring(1, i);
+ node = doc.createElement(name);
+ object = node; // to be returned as a new object
+ }
+ // skip the first expression (supposed to select the top node)
+ path = path.substring(i + 1);
+ }else{
+ if(!node){
+ return undefined; //undefined
+ }
+ }
+
+ var list = path.split('/');
+ var last = list.length - 1;
+ for(i = 0; i < last; i++){
+ var child = this._getChildNode(node, list[i]);
+ if(!child){
+ child = doc.createElement(list[i]);
+ node.appendChild(child);
+ }
+ node = child;
+ }
+ this._setNodeValue(node, list[last], value);
+ return object; //Node
+ },
+
+ _getNodeValue: function(/*Node*/node, /*String*/exp){
+ // summary:
+ // Return an attribute value, a text value or an array of elements
+ // description:
+ // If 'exp' starts with '@', an attribute value of the specified
+ // attribute is returned.
+ // If 'exp' is "text()", a child text value is returned.
+ // Otherwise, an array of child elements, the tag name of which
+ // match 'exp', is returned.
+ // node:
+ // A node
+ // exp:
+ // An expression for attribute, text or elements
+ // returns:
+ // A value found, otherwise 'undefined'
+ var value = undefined;
+ if(exp.charAt(0) == '@'){
+ var attribute = exp.substring(1);
+ value = node.getAttribute(attribute);
+ }else if(exp == "text()"){
+ var text = node.firstChild;
+ if(text){
+ value = text.nodeValue;
+ }
+ }else{ // assume elements
+ value = [];
+ for(var i = 0; i < node.childNodes.length; i++){
+ var child = node.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == exp){
+ value.push(child);
+ }
+ }
+ }
+ return value; //String||Array
+ },
+
+ _setNodeValue: function(/*Node*/node, /*String*/exp, /*String*/value){
+ // summary:
+ // Set an attribute value or a child text value to an element
+ // description:
+ // If 'exp' starts with '@', 'value' is set to the specified
+ // attribute.
+ // If 'exp' is "text()", 'value' is set to a child text.
+ // node:
+ // A node
+ // exp:
+ // An expression for attribute or text
+ // value:
+ // A value to set
+ if(exp.charAt(0) == '@'){
+ var attribute = exp.substring(1);
+ if(value){
+ node.setAttribute(attribute, value);
+ }else{
+ node.removeAttribute(attribute);
+ }
+ }else if(exp == "text()"){
+ while(node.firstChild){
+ node.removeChild(node.firstChild);
+ }
+ if(value){
+ var text = this._getDocument(node).createTextNode(value);
+ node.appendChild(text);
+ }
+ }
+ // else not supported
+ },
+
+ _getChildNode: function(/*Node*/node, /*String*/name){
+ // summary:
+ // Return a child node
+ // description:
+ // A child element of the tag name specified with 'name' is
+ // returned.
+ // If 'name' ends with an array index, it is used to pick up
+ // the corresponding element from multiple child elements.
+ // node:
+ // A parent node
+ // name:
+ // A tag name
+ // returns:
+ // A child node
+ var index = 1;
+ var i1 = name.indexOf('[');
+ if(i1 >= 0){
+ var i2 = name.indexOf(']');
+ index = name.substring(i1 + 1, i2);
+ name = name.substring(0, i1);
+ }
+ var count = 1;
+ for(var i = 0; i < node.childNodes.length; i++){
+ var child = node.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == name){
+ if(count == index){
+ return child; //Node
+ }
+ count++;
+ }
+ }
+ return null; //null
+ },
+
+ _getDocument: function(/*Node*/node){
+ // summary:
+ // Return a DOM document
+ // description:
+ // If 'node' is specified, a DOM document of the node is returned.
+ // Otherwise, a DOM document is created.
+ // returns:
+ // A DOM document
+ if(node){
+ return (node.nodeType == 9 /* DOCUMENT_NODE */ ? node : node.ownerDocument); //Document
+ }else{
+ return dojox.xml.parser.parse(); //Document
+ }
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/XmlWire.xd.js b/js/dojo-1.6/dojox/wire/XmlWire.xd.js new file mode 100644 index 0000000..62e8291 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/XmlWire.xd.js @@ -0,0 +1,259 @@ +/*
+ 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.wire.XmlWire"],
+["require", "dojox.xml.parser"],
+["require", "dojox.wire.Wire"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.XmlWire"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.XmlWire"] = true;
+dojo.provide("dojox.wire.XmlWire");
+
+dojo.require("dojox.xml.parser");
+dojo.require("dojox.wire.Wire");
+
+dojo.declare("dojox.wire.XmlWire", dojox.wire.Wire, {
+ // summary:
+ // A Wire for XML nodes or values (element, attribute and text)
+ // description:
+ // This class accesses XML nodes or value with a simplified XPath
+ // specified to 'path' property.
+ // The root object for this class must be an DOM document or element
+ // node.
+ // "@name" accesses to an attribute value of an element and "text()"
+ // accesses to a text value of an element.
+ // The hierarchy of the elements from the root node can be specified
+ // with slash-separated list, such as "a/b/@c", which specifies
+ // the value of an attribute named "c" of an element named "b" as
+ // a child of another element named "a" of a child of the root node.
+
+ _wireClass: "dojox.wire.XmlWire",
+
+ constructor: function(/*Object*/args){
+ // summary:
+ // Initialize properties
+ // description:
+ // 'args' is just mixed in with no further processing.
+ // args:
+ // Arguments to initialize properties
+ // path:
+ // A simplified XPath to an attribute, a text or elements
+ },
+ _getValue: function(/*Node*/object){
+ // summary:
+ // Return an attribute value, a text value or an array of elements
+ // description:
+ // This method first uses a root node passed in 'object' argument
+ // and 'path' property to identify an attribute, a text or
+ // elements.
+ // If 'path' starts with a slash (absolute), the first path
+ // segment is ignored assuming it point to the root node.
+ // (That is, "/a/b/@c" and "b/@c" against a root node access
+ // the same attribute value, assuming the root node is an element
+ // with a tag name, "a".)
+ // object:
+ // A root node
+ // returns:
+ // A value found, otherwise 'undefined'
+ if(!object || !this.path){
+ return object; //Node
+ }
+
+ var node = object;
+ var path = this.path;
+ var i;
+ if(path.charAt(0) == '/'){ // absolute
+ // skip the first expression (supposed to select the top node)
+ i = path.indexOf('/', 1);
+ path = path.substring(i + 1);
+ }
+ var list = path.split('/');
+ var last = list.length - 1;
+ for(i = 0; i < last; i++){
+ node = this._getChildNode(node, list[i]);
+ if(!node){
+ return undefined; //undefined
+ }
+ }
+ var value = this._getNodeValue(node, list[last]);
+ return value; //String||Array
+ },
+
+ _setValue: function(/*Node*/object, /*String*/value){
+ // summary:
+ // Set an attribute value or a child text value to an element
+ // description:
+ // This method first uses a root node passed in 'object' argument
+ // and 'path' property to identify an attribute, a text or
+ // elements.
+ // If an intermediate element does not exist, it creates
+ // an element of the tag name in the 'path' segment as a child
+ // node of the current node.
+ // Finally, 'value' argument is set to an attribute or a text
+ // (a child node) of the leaf element.
+ // object:
+ // A root node
+ // value:
+ // A value to set
+ if(!this.path){
+ return object; //Node
+ }
+
+ var node = object;
+ var doc = this._getDocument(node);
+ var path = this.path;
+ var i;
+ if(path.charAt(0) == '/'){ // absolute
+ i = path.indexOf('/', 1);
+ if(!node){
+ var name = path.substring(1, i);
+ node = doc.createElement(name);
+ object = node; // to be returned as a new object
+ }
+ // skip the first expression (supposed to select the top node)
+ path = path.substring(i + 1);
+ }else{
+ if(!node){
+ return undefined; //undefined
+ }
+ }
+
+ var list = path.split('/');
+ var last = list.length - 1;
+ for(i = 0; i < last; i++){
+ var child = this._getChildNode(node, list[i]);
+ if(!child){
+ child = doc.createElement(list[i]);
+ node.appendChild(child);
+ }
+ node = child;
+ }
+ this._setNodeValue(node, list[last], value);
+ return object; //Node
+ },
+
+ _getNodeValue: function(/*Node*/node, /*String*/exp){
+ // summary:
+ // Return an attribute value, a text value or an array of elements
+ // description:
+ // If 'exp' starts with '@', an attribute value of the specified
+ // attribute is returned.
+ // If 'exp' is "text()", a child text value is returned.
+ // Otherwise, an array of child elements, the tag name of which
+ // match 'exp', is returned.
+ // node:
+ // A node
+ // exp:
+ // An expression for attribute, text or elements
+ // returns:
+ // A value found, otherwise 'undefined'
+ var value = undefined;
+ if(exp.charAt(0) == '@'){
+ var attribute = exp.substring(1);
+ value = node.getAttribute(attribute);
+ }else if(exp == "text()"){
+ var text = node.firstChild;
+ if(text){
+ value = text.nodeValue;
+ }
+ }else{ // assume elements
+ value = [];
+ for(var i = 0; i < node.childNodes.length; i++){
+ var child = node.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == exp){
+ value.push(child);
+ }
+ }
+ }
+ return value; //String||Array
+ },
+
+ _setNodeValue: function(/*Node*/node, /*String*/exp, /*String*/value){
+ // summary:
+ // Set an attribute value or a child text value to an element
+ // description:
+ // If 'exp' starts with '@', 'value' is set to the specified
+ // attribute.
+ // If 'exp' is "text()", 'value' is set to a child text.
+ // node:
+ // A node
+ // exp:
+ // An expression for attribute or text
+ // value:
+ // A value to set
+ if(exp.charAt(0) == '@'){
+ var attribute = exp.substring(1);
+ if(value){
+ node.setAttribute(attribute, value);
+ }else{
+ node.removeAttribute(attribute);
+ }
+ }else if(exp == "text()"){
+ while(node.firstChild){
+ node.removeChild(node.firstChild);
+ }
+ if(value){
+ var text = this._getDocument(node).createTextNode(value);
+ node.appendChild(text);
+ }
+ }
+ // else not supported
+ },
+
+ _getChildNode: function(/*Node*/node, /*String*/name){
+ // summary:
+ // Return a child node
+ // description:
+ // A child element of the tag name specified with 'name' is
+ // returned.
+ // If 'name' ends with an array index, it is used to pick up
+ // the corresponding element from multiple child elements.
+ // node:
+ // A parent node
+ // name:
+ // A tag name
+ // returns:
+ // A child node
+ var index = 1;
+ var i1 = name.indexOf('[');
+ if(i1 >= 0){
+ var i2 = name.indexOf(']');
+ index = name.substring(i1 + 1, i2);
+ name = name.substring(0, i1);
+ }
+ var count = 1;
+ for(var i = 0; i < node.childNodes.length; i++){
+ var child = node.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == name){
+ if(count == index){
+ return child; //Node
+ }
+ count++;
+ }
+ }
+ return null; //null
+ },
+
+ _getDocument: function(/*Node*/node){
+ // summary:
+ // Return a DOM document
+ // description:
+ // If 'node' is specified, a DOM document of the node is returned.
+ // Otherwise, a DOM document is created.
+ // returns:
+ // A DOM document
+ if(node){
+ return (node.nodeType == 9 /* DOCUMENT_NODE */ ? node : node.ownerDocument); //Document
+ }else{
+ return dojox.xml.parser.parse(); //Document
+ }
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/_base.js b/js/dojo-1.6/dojox/wire/_base.js new file mode 100644 index 0000000..07ae683 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/_base.js @@ -0,0 +1,202 @@ +/*
+ 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.wire._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire._base"] = true;
+dojo.provide("dojox.wire._base");
+
+dojox.wire._defaultWireClass = "dojox.wire.Wire";
+
+dojox.wire._wireClasses = {
+ "attribute": "dojox.wire.DataWire",
+ "path": "dojox.wire.XmlWire",
+ "children": "dojox.wire.CompositeWire",
+ "columns": "dojox.wire.TableAdapter",
+ "nodes": "dojox.wire.TreeAdapter",
+ "segments": "dojox.wire.TextAdapter"
+};
+
+dojox.wire.register = function(/*Function||String*/wireClass, /*String*/key){
+ // summary:
+ // Register a Wire class
+ // desription:
+ // The specified Wire class or a class name is registered with
+ // a key property of arguments to create a Wire
+ // wireClass:
+ // A class or full qualified class name
+ // key:
+ // A key property of arguments to create a Wire
+ if(!wireClass || !key){
+ return; //undefined
+ }
+ if(dojox.wire._wireClasses[key]){ // key already in use
+ return; //undefined
+ }
+ dojox.wire._wireClasses[key] = wireClass;
+};
+
+dojox.wire._getClass = function(/*String*/name){
+ // summary:
+ // Returns a class
+ // description:
+ // The class is loaded by dojo.require() and returned
+ // by dojo.getObject().
+ // name:
+ // A class name
+ // returns:
+ // A class
+ dojo["require"](name); // use dojo["require"] instead of dojo.require to avoid a build problem
+ return dojo.getObject(name); //Function
+};
+
+dojox.wire.create = function(/*Object*/args){
+ // summary:
+ // Create a Wire from arguments
+ // description:
+ // If 'args' specifies 'wireClass', it is used as a class or full
+ // qualified class name to create a Wire with 'args' as arguments.
+ // Otherwise, a Wire class is determined by other proeprties of 'args'
+ // checking if 'args' specifies a key property for a Wire class.
+ // If no key property found, the default Wire class is used.
+ // args:
+ // Arguments to create a Wire
+ // returns:
+ // A Wire
+ if(!args){
+ args = {};
+ }
+ var wireClass = args.wireClass;
+ if(wireClass){
+ if(dojo.isString(wireClass)){
+ wireClass = dojox.wire._getClass(wireClass);
+ }
+ }else{
+ for(var key in args){
+ if(!args[key]){
+ continue;
+ }
+ wireClass = dojox.wire._wireClasses[key];
+ if(wireClass){
+ if(dojo.isString(wireClass)){
+ wireClass = dojox.wire._getClass(wireClass);
+ dojox.wire._wireClasses[key] = wireClass;
+ }
+ break;
+ }
+ }
+ }
+ if(!wireClass){
+ if(dojo.isString(dojox.wire._defaultWireClass)){
+ dojox.wire._defaultWireClass = dojox.wire._getClass(dojox.wire._defaultWireClass);
+ }
+ wireClass = dojox.wire._defaultWireClass;
+ }
+ return new wireClass(args); //Object
+};
+
+dojox.wire.isWire = function(/*Object*/wire){
+ // summary:
+ // Check if an object is a Wire
+ // description:
+ // If the specified object is a Wire, true is returned.
+ // Otherwise, false is returned.
+ // wire:
+ // An object to check
+ // returns:
+ // True if the object is a Wire, otherwise false
+ return (wire && wire._wireClass); //Boolean
+};
+
+dojox.wire.transfer = function(/*Wire||Object*/source, /*Wire||Object*/target, /*Object?*/defaultObject, /*Object?*/defaultTargetObject){
+ // summary:
+ // Transfer a source value to a target value
+ // description:
+ // If 'source' and/or 'target' are not Wires, Wires are created with
+ // them as arguments.
+ // A value is got through the source Wire and set through the target
+ // Wire.
+ // 'defaultObject' is passed to Wires as a default root object.
+ // If 'defaultTargetObject' is specified, it is passed to the target
+ // Wire as a default root object, instead of 'defaultObject'.
+ // source:
+ // A Wire or arguments to create a Wire for a source value
+ // target:
+ // A Wire or arguments to create a Wire for a target value
+ // defaultObject:
+ // defaultTargetObject;
+ // Optional default root objects passed to Wires
+ if(!source || !target){
+ return; //undefined
+ }
+ if(!dojox.wire.isWire(source)){
+ source = dojox.wire.create(source);
+ }
+ if(!dojox.wire.isWire(target)){
+ target = dojox.wire.create(target);
+ }
+
+ var value = source.getValue(defaultObject);
+ target.setValue(value, (defaultTargetObject || defaultObject));
+};
+
+dojox.wire.connect = function(/*Object*/trigger, /*Wire||Object*/source, /*Wire||Object*/target){
+ // summary:
+ // Transfer a source value to a target value on a trigger event or
+ // topic
+ // description:
+ // If 'trigger' specifies 'topic', the topic is subscribed to transer
+ // a value on the topic.
+ // Otherwise, the event specified to 'event' of 'trigger' is listened
+ // to transfer a value.
+ // On the specified event or topic, transfer() is called with
+ // 'source', 'target' and the arguments of the event or topic (as
+ // default root objects).
+ // trigger:
+ // An event or topic to trigger a transfer
+ // source:
+ // A Wire or arguments to create a Wire for a source value
+ // target:
+ // A Wire or arguments to create a Wire for a target value
+ // returns:
+ // A connection handle for disconnect()
+ if(!trigger || !source || !target){
+ return; //undefined
+ }
+
+ var connection = {topic: trigger.topic};
+ if(trigger.topic){
+ connection.handle = dojo.subscribe(trigger.topic, function(){
+ dojox.wire.transfer(source, target, arguments);
+ });
+ }else if(trigger.event){
+ connection.handle = dojo.connect(trigger.scope, trigger.event, function(){
+ dojox.wire.transfer(source, target, arguments);
+ });
+ }
+ return connection; //Object
+};
+
+dojox.wire.disconnect = function(/*Object*/connection){
+ // summary:
+ // Remove a connection or subscription for transfer
+ // description:
+ // If 'handle' has 'topic', the topic is unsubscribed.
+ // Otherwise, the listener to an event is removed.
+ // connection:
+ // A connection handle returned by connect()
+ if(!connection || !connection.handle){
+ return; //undefined
+ }
+
+ if(connection.topic){
+ dojo.unsubscribe(connection.handle);
+ }else{
+ dojo.disconnect(connection.handle);
+ }
+};
+
+}
diff --git a/js/dojo-1.6/dojox/wire/_base.xd.js b/js/dojo-1.6/dojox/wire/_base.xd.js new file mode 100644 index 0000000..bf4fc9d --- /dev/null +++ b/js/dojo-1.6/dojox/wire/_base.xd.js @@ -0,0 +1,206 @@ +/*
+ 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.wire._base"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire._base"] = true;
+dojo.provide("dojox.wire._base");
+
+dojox.wire._defaultWireClass = "dojox.wire.Wire";
+
+dojox.wire._wireClasses = {
+ "attribute": "dojox.wire.DataWire",
+ "path": "dojox.wire.XmlWire",
+ "children": "dojox.wire.CompositeWire",
+ "columns": "dojox.wire.TableAdapter",
+ "nodes": "dojox.wire.TreeAdapter",
+ "segments": "dojox.wire.TextAdapter"
+};
+
+dojox.wire.register = function(/*Function||String*/wireClass, /*String*/key){
+ // summary:
+ // Register a Wire class
+ // desription:
+ // The specified Wire class or a class name is registered with
+ // a key property of arguments to create a Wire
+ // wireClass:
+ // A class or full qualified class name
+ // key:
+ // A key property of arguments to create a Wire
+ if(!wireClass || !key){
+ return; //undefined
+ }
+ if(dojox.wire._wireClasses[key]){ // key already in use
+ return; //undefined
+ }
+ dojox.wire._wireClasses[key] = wireClass;
+};
+
+dojox.wire._getClass = function(/*String*/name){
+ // summary:
+ // Returns a class
+ // description:
+ // The class is loaded by dojo.require() and returned
+ // by dojo.getObject().
+ // name:
+ // A class name
+ // returns:
+ // A class
+ dojo["require"](name); // use dojo["require"] instead of dojo.require to avoid a build problem
+ return dojo.getObject(name); //Function
+};
+
+dojox.wire.create = function(/*Object*/args){
+ // summary:
+ // Create a Wire from arguments
+ // description:
+ // If 'args' specifies 'wireClass', it is used as a class or full
+ // qualified class name to create a Wire with 'args' as arguments.
+ // Otherwise, a Wire class is determined by other proeprties of 'args'
+ // checking if 'args' specifies a key property for a Wire class.
+ // If no key property found, the default Wire class is used.
+ // args:
+ // Arguments to create a Wire
+ // returns:
+ // A Wire
+ if(!args){
+ args = {};
+ }
+ var wireClass = args.wireClass;
+ if(wireClass){
+ if(dojo.isString(wireClass)){
+ wireClass = dojox.wire._getClass(wireClass);
+ }
+ }else{
+ for(var key in args){
+ if(!args[key]){
+ continue;
+ }
+ wireClass = dojox.wire._wireClasses[key];
+ if(wireClass){
+ if(dojo.isString(wireClass)){
+ wireClass = dojox.wire._getClass(wireClass);
+ dojox.wire._wireClasses[key] = wireClass;
+ }
+ break;
+ }
+ }
+ }
+ if(!wireClass){
+ if(dojo.isString(dojox.wire._defaultWireClass)){
+ dojox.wire._defaultWireClass = dojox.wire._getClass(dojox.wire._defaultWireClass);
+ }
+ wireClass = dojox.wire._defaultWireClass;
+ }
+ return new wireClass(args); //Object
+};
+
+dojox.wire.isWire = function(/*Object*/wire){
+ // summary:
+ // Check if an object is a Wire
+ // description:
+ // If the specified object is a Wire, true is returned.
+ // Otherwise, false is returned.
+ // wire:
+ // An object to check
+ // returns:
+ // True if the object is a Wire, otherwise false
+ return (wire && wire._wireClass); //Boolean
+};
+
+dojox.wire.transfer = function(/*Wire||Object*/source, /*Wire||Object*/target, /*Object?*/defaultObject, /*Object?*/defaultTargetObject){
+ // summary:
+ // Transfer a source value to a target value
+ // description:
+ // If 'source' and/or 'target' are not Wires, Wires are created with
+ // them as arguments.
+ // A value is got through the source Wire and set through the target
+ // Wire.
+ // 'defaultObject' is passed to Wires as a default root object.
+ // If 'defaultTargetObject' is specified, it is passed to the target
+ // Wire as a default root object, instead of 'defaultObject'.
+ // source:
+ // A Wire or arguments to create a Wire for a source value
+ // target:
+ // A Wire or arguments to create a Wire for a target value
+ // defaultObject:
+ // defaultTargetObject;
+ // Optional default root objects passed to Wires
+ if(!source || !target){
+ return; //undefined
+ }
+ if(!dojox.wire.isWire(source)){
+ source = dojox.wire.create(source);
+ }
+ if(!dojox.wire.isWire(target)){
+ target = dojox.wire.create(target);
+ }
+
+ var value = source.getValue(defaultObject);
+ target.setValue(value, (defaultTargetObject || defaultObject));
+};
+
+dojox.wire.connect = function(/*Object*/trigger, /*Wire||Object*/source, /*Wire||Object*/target){
+ // summary:
+ // Transfer a source value to a target value on a trigger event or
+ // topic
+ // description:
+ // If 'trigger' specifies 'topic', the topic is subscribed to transer
+ // a value on the topic.
+ // Otherwise, the event specified to 'event' of 'trigger' is listened
+ // to transfer a value.
+ // On the specified event or topic, transfer() is called with
+ // 'source', 'target' and the arguments of the event or topic (as
+ // default root objects).
+ // trigger:
+ // An event or topic to trigger a transfer
+ // source:
+ // A Wire or arguments to create a Wire for a source value
+ // target:
+ // A Wire or arguments to create a Wire for a target value
+ // returns:
+ // A connection handle for disconnect()
+ if(!trigger || !source || !target){
+ return; //undefined
+ }
+
+ var connection = {topic: trigger.topic};
+ if(trigger.topic){
+ connection.handle = dojo.subscribe(trigger.topic, function(){
+ dojox.wire.transfer(source, target, arguments);
+ });
+ }else if(trigger.event){
+ connection.handle = dojo.connect(trigger.scope, trigger.event, function(){
+ dojox.wire.transfer(source, target, arguments);
+ });
+ }
+ return connection; //Object
+};
+
+dojox.wire.disconnect = function(/*Object*/connection){
+ // summary:
+ // Remove a connection or subscription for transfer
+ // description:
+ // If 'handle' has 'topic', the topic is unsubscribed.
+ // Otherwise, the listener to an event is removed.
+ // connection:
+ // A connection handle returned by connect()
+ if(!connection || !connection.handle){
+ return; //undefined
+ }
+
+ if(connection.topic){
+ dojo.unsubscribe(connection.handle);
+ }else{
+ dojo.disconnect(connection.handle);
+ }
+};
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/ml/Action.js b/js/dojo-1.6/dojox/wire/ml/Action.js new file mode 100644 index 0000000..c359290 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/Action.js @@ -0,0 +1,232 @@ +/*
+ 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.wire.ml.Action"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.Action"] = true;
+dojo.provide("dojox.wire.ml.Action");
+dojo.provide("dojox.wire.ml.ActionFilter");
+
+dojo.require("dijit._Widget");
+dojo.require("dijit._Container");
+dojo.require("dojox.wire.Wire");
+dojo.require("dojox.wire.ml.util");
+
+dojo.declare("dojox.wire.ml.Action", [dijit._Widget, dijit._Container], {
+ // summary:
+ // A base widget to "run" a task on an event or a topic
+ // description:
+ // This widget represents a controller task to be run when an event
+ // (a function) or a topic is issued.
+ // Sub-classes must implement _run() method to implement their tasks.
+ // 'trigger' specifies an event scope, an ID of a widget or an DOM
+ // element, or its property with the optional dotted notation.
+ // If this widget has child ActionFilter widgets, their filter()
+ // methods are called with the arguments to the event or the topic.
+ // If one of filter() methods returns false, run() won't be invoked.
+ // This widget also can serve as a composite task to run child
+ // Actions on an event or a topic specified to this widget.
+ // trigger:
+ // An event scope
+ // triggerEvent:
+ // An event (function) name
+ // triggerTopic:
+ // A topic name
+ trigger: "",
+ triggerEvent: "",
+ triggerTopic: "",
+
+ postCreate: function(){
+ // summary:
+ // Call _connect()
+ // description:
+ // See _connect().
+ this._connect();
+ },
+
+ _connect: function(){
+ // summary:
+ // Connect run() method to an event or a topic
+ // description:
+ // If 'triggerEvent' and 'trigger' are specified, connect() is
+ // used to set up run() to be called on the event.
+ // If 'triggerTopic' is specified, subscribe() is used to set up
+ // run() to be called on the topic.
+ if(this.triggerEvent){
+ if(this.trigger){
+ var scope = dojox.wire.ml._getValue(this.trigger);
+ if(scope){
+ if(!scope[this.triggerEvent]){
+ // set a dummy function for an anonymous object
+ scope[this.triggerEvent] = function(){};
+ }
+ this._triggerHandle = dojo.connect(scope, this.triggerEvent, this, "run");
+ }
+ }else{
+ var event = this.triggerEvent.toLowerCase();
+ if(event == "onload"){
+ var self = this;
+ dojo.addOnLoad(function(){
+ self._run.apply(self, arguments);
+ });
+ }
+ }
+ }else if(this.triggerTopic){
+ this._triggerHandle = dojo.subscribe(this.triggerTopic, this, "run");
+ }
+ },
+
+ _disconnect: function(){
+ // summary:
+ // Disconnect run() method from an event or a topic
+ // description:
+ // If 'triggerEvent' and 'trigger' are specified, disconnect() is
+ // used to set up run() not to be called on the event.
+ // If 'triggerTopic' is specified, unsubscribe() is used to set up
+ // run() not to be called on the topic.
+ if(this._triggerHandle){
+ if(this.triggerTopic){
+ dojo.unsubscribe(this.triggerTopic, this._triggerHandle);
+ }else{
+ dojo.disconnect(this._triggerHandle);
+ }
+ }
+ },
+
+ run: function(){
+ // summary:
+ // Run a task
+ // description:
+ // This method calls filter() method of child ActionFilter
+ // widgets.
+ // If one of them returns false, this method returns.
+ // Otherwise, _run() method is called.
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.ActionFilter){
+ if(!child.filter.apply(child, arguments)){
+ return;
+ }
+ }
+ }
+ this._run.apply(this, arguments);
+ },
+
+ _run: function(){
+ // summary:
+ // Call run() methods of child Action widgets
+ // description:
+ // If this widget has child Action widgets, their run() methods
+ // are called.
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.Action){
+ child.run.apply(child, arguments);
+ }
+ }
+ },
+
+ uninitialize: function(){
+ // summary:
+ // Over-ride of base widget unitialize function to do some connection cleanup.
+ this._disconnect();
+ return true;
+ }
+});
+
+dojo.declare("dojox.wire.ml.ActionFilter", dijit._Widget, {
+ // summary:
+ // A widget to define a filter for the parent Action to run
+ // description:
+ // This base class checks a required property specified with
+ // 'required' attribute.
+ // If 'message' is specified, the message is set to a property
+ // specified with 'error'.
+ // Subclasses may implement their own filter() method.
+ // required:
+ // A property required
+ // requiredValue:
+ // Optional. A specific value the property is required to have. If this isn't provided
+ // than any non-false/non-null value of the required propery will cause this filter
+ // to pass.
+ // type:
+ // Optional. A specific type to compare the values as (if requiredValue is set)
+ // Valid values for type are boolean, int, string. Default is string.
+ // message:
+ // An error message to emit if the filter doesn't execute due to property mismatch.
+ // error:
+ // A property to store an error due to property mismatch.
+ required: "",
+ requiredValue: "",
+ type: "",
+ message: "",
+ error: "",
+
+
+ filter: function(){
+ // summary:
+ // Check if a required property is specified. Also, if provided, check to see
+ // if the required property contains a specific value.
+ // description:
+ // If a value is undefined for a property, specified with
+ // 'required', this method returns false.
+ // If the value for a property is defined, but there isn't a requiredValue for it
+ // then any non-false value will cause the method to return true.
+ // if requiredValue is set, then filter compares that value with the value from
+ // the required property and returns true if and only if they match.
+ // The type option just allows for a way to convert the required property values
+ // into a proper form for comparison (boolean, number, etc).
+ // If 'message' is specified, it is set to a proeprty specified
+ // with 'error' or shown with alert().
+ // If 'required' starts with "arguments", a property of
+ // the method arguments are checked.
+ // returns:
+ // True if a required property is specified (and if requiredValue is specified,
+ // that they match), otherwise false
+ if(this.required === ""){
+ return true; //Boolean
+ }else{
+ var value = dojox.wire.ml._getValue(this.required, arguments);
+ if(this.requiredValue === ""){
+ //Just see if there's a value, nothing to compare it to.
+ if(value){
+ return true; //Boolean
+ }
+ }else{
+ //See if we need to type convert.
+ var reqValue = this.requiredValue;
+ if(this.type !== ""){
+ var lType = this.type.toLowerCase();
+ if(lType === "boolean"){
+ if(reqValue.toLowerCase() === "false"){
+ reqValue = false;
+ }else{
+ reqValue = true;
+ }
+ }else if(lType === "number"){
+ reqValue = parseInt(reqValue, 10);
+ }
+ }
+ if(value === reqValue){
+ return true; //boolean
+ }
+ }
+ }
+
+ if(this.message){
+ if(this.error){
+ dojox.wire.ml._setValue(this.error, this.message);
+ }else{
+ alert(this.message);
+ }
+ }
+ return false; //Boolean
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/ml/Action.xd.js b/js/dojo-1.6/dojox/wire/ml/Action.xd.js new file mode 100644 index 0000000..7894d11 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/Action.xd.js @@ -0,0 +1,241 @@ +/*
+ 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.wire.ml.Action"],
+["provide", "dojox.wire.ml.ActionFilter"],
+["require", "dijit._Widget"],
+["require", "dijit._Container"],
+["require", "dojox.wire.Wire"],
+["require", "dojox.wire.ml.util"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.ml.Action"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.Action"] = true;
+dojo.provide("dojox.wire.ml.Action");
+dojo.provide("dojox.wire.ml.ActionFilter");
+
+dojo.require("dijit._Widget");
+dojo.require("dijit._Container");
+dojo.require("dojox.wire.Wire");
+dojo.require("dojox.wire.ml.util");
+
+dojo.declare("dojox.wire.ml.Action", [dijit._Widget, dijit._Container], {
+ // summary:
+ // A base widget to "run" a task on an event or a topic
+ // description:
+ // This widget represents a controller task to be run when an event
+ // (a function) or a topic is issued.
+ // Sub-classes must implement _run() method to implement their tasks.
+ // 'trigger' specifies an event scope, an ID of a widget or an DOM
+ // element, or its property with the optional dotted notation.
+ // If this widget has child ActionFilter widgets, their filter()
+ // methods are called with the arguments to the event or the topic.
+ // If one of filter() methods returns false, run() won't be invoked.
+ // This widget also can serve as a composite task to run child
+ // Actions on an event or a topic specified to this widget.
+ // trigger:
+ // An event scope
+ // triggerEvent:
+ // An event (function) name
+ // triggerTopic:
+ // A topic name
+ trigger: "",
+ triggerEvent: "",
+ triggerTopic: "",
+
+ postCreate: function(){
+ // summary:
+ // Call _connect()
+ // description:
+ // See _connect().
+ this._connect();
+ },
+
+ _connect: function(){
+ // summary:
+ // Connect run() method to an event or a topic
+ // description:
+ // If 'triggerEvent' and 'trigger' are specified, connect() is
+ // used to set up run() to be called on the event.
+ // If 'triggerTopic' is specified, subscribe() is used to set up
+ // run() to be called on the topic.
+ if(this.triggerEvent){
+ if(this.trigger){
+ var scope = dojox.wire.ml._getValue(this.trigger);
+ if(scope){
+ if(!scope[this.triggerEvent]){
+ // set a dummy function for an anonymous object
+ scope[this.triggerEvent] = function(){};
+ }
+ this._triggerHandle = dojo.connect(scope, this.triggerEvent, this, "run");
+ }
+ }else{
+ var event = this.triggerEvent.toLowerCase();
+ if(event == "onload"){
+ var self = this;
+ dojo.addOnLoad(function(){
+ self._run.apply(self, arguments);
+ });
+ }
+ }
+ }else if(this.triggerTopic){
+ this._triggerHandle = dojo.subscribe(this.triggerTopic, this, "run");
+ }
+ },
+
+ _disconnect: function(){
+ // summary:
+ // Disconnect run() method from an event or a topic
+ // description:
+ // If 'triggerEvent' and 'trigger' are specified, disconnect() is
+ // used to set up run() not to be called on the event.
+ // If 'triggerTopic' is specified, unsubscribe() is used to set up
+ // run() not to be called on the topic.
+ if(this._triggerHandle){
+ if(this.triggerTopic){
+ dojo.unsubscribe(this.triggerTopic, this._triggerHandle);
+ }else{
+ dojo.disconnect(this._triggerHandle);
+ }
+ }
+ },
+
+ run: function(){
+ // summary:
+ // Run a task
+ // description:
+ // This method calls filter() method of child ActionFilter
+ // widgets.
+ // If one of them returns false, this method returns.
+ // Otherwise, _run() method is called.
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.ActionFilter){
+ if(!child.filter.apply(child, arguments)){
+ return;
+ }
+ }
+ }
+ this._run.apply(this, arguments);
+ },
+
+ _run: function(){
+ // summary:
+ // Call run() methods of child Action widgets
+ // description:
+ // If this widget has child Action widgets, their run() methods
+ // are called.
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.Action){
+ child.run.apply(child, arguments);
+ }
+ }
+ },
+
+ uninitialize: function(){
+ // summary:
+ // Over-ride of base widget unitialize function to do some connection cleanup.
+ this._disconnect();
+ return true;
+ }
+});
+
+dojo.declare("dojox.wire.ml.ActionFilter", dijit._Widget, {
+ // summary:
+ // A widget to define a filter for the parent Action to run
+ // description:
+ // This base class checks a required property specified with
+ // 'required' attribute.
+ // If 'message' is specified, the message is set to a property
+ // specified with 'error'.
+ // Subclasses may implement their own filter() method.
+ // required:
+ // A property required
+ // requiredValue:
+ // Optional. A specific value the property is required to have. If this isn't provided
+ // than any non-false/non-null value of the required propery will cause this filter
+ // to pass.
+ // type:
+ // Optional. A specific type to compare the values as (if requiredValue is set)
+ // Valid values for type are boolean, int, string. Default is string.
+ // message:
+ // An error message to emit if the filter doesn't execute due to property mismatch.
+ // error:
+ // A property to store an error due to property mismatch.
+ required: "",
+ requiredValue: "",
+ type: "",
+ message: "",
+ error: "",
+
+
+ filter: function(){
+ // summary:
+ // Check if a required property is specified. Also, if provided, check to see
+ // if the required property contains a specific value.
+ // description:
+ // If a value is undefined for a property, specified with
+ // 'required', this method returns false.
+ // If the value for a property is defined, but there isn't a requiredValue for it
+ // then any non-false value will cause the method to return true.
+ // if requiredValue is set, then filter compares that value with the value from
+ // the required property and returns true if and only if they match.
+ // The type option just allows for a way to convert the required property values
+ // into a proper form for comparison (boolean, number, etc).
+ // If 'message' is specified, it is set to a proeprty specified
+ // with 'error' or shown with alert().
+ // If 'required' starts with "arguments", a property of
+ // the method arguments are checked.
+ // returns:
+ // True if a required property is specified (and if requiredValue is specified,
+ // that they match), otherwise false
+ if(this.required === ""){
+ return true; //Boolean
+ }else{
+ var value = dojox.wire.ml._getValue(this.required, arguments);
+ if(this.requiredValue === ""){
+ //Just see if there's a value, nothing to compare it to.
+ if(value){
+ return true; //Boolean
+ }
+ }else{
+ //See if we need to type convert.
+ var reqValue = this.requiredValue;
+ if(this.type !== ""){
+ var lType = this.type.toLowerCase();
+ if(lType === "boolean"){
+ if(reqValue.toLowerCase() === "false"){
+ reqValue = false;
+ }else{
+ reqValue = true;
+ }
+ }else if(lType === "number"){
+ reqValue = parseInt(reqValue, 10);
+ }
+ }
+ if(value === reqValue){
+ return true; //boolean
+ }
+ }
+ }
+
+ if(this.message){
+ if(this.error){
+ dojox.wire.ml._setValue(this.error, this.message);
+ }else{
+ alert(this.message);
+ }
+ }
+ return false; //Boolean
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/ml/Data.js b/js/dojo-1.6/dojox/wire/ml/Data.js new file mode 100644 index 0000000..fefe0d7 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/Data.js @@ -0,0 +1,154 @@ +/*
+ 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.wire.ml.Data"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.Data"] = true;
+dojo.provide("dojox.wire.ml.Data");
+dojo.provide("dojox.wire.ml.DataProperty");
+
+dojo.require("dijit._Widget");
+dojo.require("dijit._Container");
+dojo.require("dojox.wire.ml.util");
+
+dojo.declare("dojox.wire.ml.Data", [dijit._Widget, dijit._Container], {
+ // summary:
+ // A widget for a data object
+ // description:
+ // This widget represents an object with '_properties' property.
+ // If child 'DataProperty' widgets exist, they are used to initialize
+ // propertiy values of '_properties' object.
+
+ startup: function(){
+ // summary:
+ // Call _initializeProperties()
+ // description:
+ // See _initializeProperties().
+ this._initializeProperties();
+ },
+
+ _initializeProperties: function(/*Boolean*/reset){
+ // summary:
+ // Initialize a data object
+ // description:
+ // If this widget has child DataProperty widgets, their getValue()
+ // methods are called and set the return value to a property
+ // specified by 'name' attribute of the child widgets.
+ // reset:
+ // A boolean to reset current properties
+ if(!this._properties || reset){
+ this._properties = {};
+ }
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if((child instanceof dojox.wire.ml.DataProperty) && child.name){
+ this.setPropertyValue(child.name, child.getValue());
+ }
+ }
+ },
+
+ getPropertyValue: function(/*String*/property){
+ // summary:
+ // Return a property value
+ // description:
+ // This method returns the value of a property, specified with
+ // 'property' argument, in '_properties' object.
+ // property:
+ // A property name
+ // returns:
+ // A property value
+ return this._properties[property]; //anything
+ },
+
+ setPropertyValue: function(/*String*/property, /*anything*/value){
+ // summary:
+ // Store a property value
+ // description:
+ // This method stores 'value' as a property, specified with
+ // 'property' argument, in '_properties' object.
+ // property:
+ // A property name
+ // value:
+ // A property value
+ this._properties[property] = value;
+ }
+});
+
+dojo.declare("dojox.wire.ml.DataProperty", [dijit._Widget, dijit._Container], {
+ // summary:
+ // A widget to define a data property
+ // description:
+ // Attributes of this widget are used to add a property to the parent
+ // Data widget.
+ // 'type' attribute specifies one of "string", "number", "boolean",
+ // "array", "object" and "element" (DOM Element)
+ // (default to "string").
+ // If 'type' is "array" or "object", child DataProperty widgets are
+ // used to initialize the array elements or the object properties.
+ // name:
+ // A property name
+ // type:
+ // A property type name
+ // value:
+ // A property value
+ name: "",
+ type: "",
+ value: "",
+
+ _getValueAttr: function(){
+ return this.getValue();
+ },
+
+ getValue: function(){
+ // summary:
+ // Returns a property value
+ // description:
+ // If 'type' is specified, 'value' attribute is converted to
+ // the specified type and returned.
+ // Otherwise, 'value' attribute is returned as is.
+ // returns:
+ // A property value
+ var value = this.value;
+ if(this.type){
+ if(this.type == "number"){
+ value = parseInt(value);
+ }else if(this.type == "boolean"){
+ value = (value == "true");
+ }else if(this.type == "array"){
+ value = [];
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.DataProperty){
+ value.push(child.getValue());
+ }
+ }
+ }else if(this.type == "object"){
+ value = {};
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if((child instanceof dojox.wire.ml.DataProperty) && child.name){
+ value[child.name] = child.getValue();
+ }
+ }
+ }else if(this.type == "element"){
+ value = new dojox.wire.ml.XmlElement(value);
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if((child instanceof dojox.wire.ml.DataProperty) && child.name){
+ value.setPropertyValue(child.name, child.getValue());
+ }
+ }
+ }
+ }
+ return value; //anything
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/ml/Data.xd.js b/js/dojo-1.6/dojox/wire/ml/Data.xd.js new file mode 100644 index 0000000..cdaf822 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/Data.xd.js @@ -0,0 +1,162 @@ +/*
+ 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.wire.ml.Data"],
+["provide", "dojox.wire.ml.DataProperty"],
+["require", "dijit._Widget"],
+["require", "dijit._Container"],
+["require", "dojox.wire.ml.util"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.ml.Data"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.Data"] = true;
+dojo.provide("dojox.wire.ml.Data");
+dojo.provide("dojox.wire.ml.DataProperty");
+
+dojo.require("dijit._Widget");
+dojo.require("dijit._Container");
+dojo.require("dojox.wire.ml.util");
+
+dojo.declare("dojox.wire.ml.Data", [dijit._Widget, dijit._Container], {
+ // summary:
+ // A widget for a data object
+ // description:
+ // This widget represents an object with '_properties' property.
+ // If child 'DataProperty' widgets exist, they are used to initialize
+ // propertiy values of '_properties' object.
+
+ startup: function(){
+ // summary:
+ // Call _initializeProperties()
+ // description:
+ // See _initializeProperties().
+ this._initializeProperties();
+ },
+
+ _initializeProperties: function(/*Boolean*/reset){
+ // summary:
+ // Initialize a data object
+ // description:
+ // If this widget has child DataProperty widgets, their getValue()
+ // methods are called and set the return value to a property
+ // specified by 'name' attribute of the child widgets.
+ // reset:
+ // A boolean to reset current properties
+ if(!this._properties || reset){
+ this._properties = {};
+ }
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if((child instanceof dojox.wire.ml.DataProperty) && child.name){
+ this.setPropertyValue(child.name, child.getValue());
+ }
+ }
+ },
+
+ getPropertyValue: function(/*String*/property){
+ // summary:
+ // Return a property value
+ // description:
+ // This method returns the value of a property, specified with
+ // 'property' argument, in '_properties' object.
+ // property:
+ // A property name
+ // returns:
+ // A property value
+ return this._properties[property]; //anything
+ },
+
+ setPropertyValue: function(/*String*/property, /*anything*/value){
+ // summary:
+ // Store a property value
+ // description:
+ // This method stores 'value' as a property, specified with
+ // 'property' argument, in '_properties' object.
+ // property:
+ // A property name
+ // value:
+ // A property value
+ this._properties[property] = value;
+ }
+});
+
+dojo.declare("dojox.wire.ml.DataProperty", [dijit._Widget, dijit._Container], {
+ // summary:
+ // A widget to define a data property
+ // description:
+ // Attributes of this widget are used to add a property to the parent
+ // Data widget.
+ // 'type' attribute specifies one of "string", "number", "boolean",
+ // "array", "object" and "element" (DOM Element)
+ // (default to "string").
+ // If 'type' is "array" or "object", child DataProperty widgets are
+ // used to initialize the array elements or the object properties.
+ // name:
+ // A property name
+ // type:
+ // A property type name
+ // value:
+ // A property value
+ name: "",
+ type: "",
+ value: "",
+
+ _getValueAttr: function(){
+ return this.getValue();
+ },
+
+ getValue: function(){
+ // summary:
+ // Returns a property value
+ // description:
+ // If 'type' is specified, 'value' attribute is converted to
+ // the specified type and returned.
+ // Otherwise, 'value' attribute is returned as is.
+ // returns:
+ // A property value
+ var value = this.value;
+ if(this.type){
+ if(this.type == "number"){
+ value = parseInt(value);
+ }else if(this.type == "boolean"){
+ value = (value == "true");
+ }else if(this.type == "array"){
+ value = [];
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.DataProperty){
+ value.push(child.getValue());
+ }
+ }
+ }else if(this.type == "object"){
+ value = {};
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if((child instanceof dojox.wire.ml.DataProperty) && child.name){
+ value[child.name] = child.getValue();
+ }
+ }
+ }else if(this.type == "element"){
+ value = new dojox.wire.ml.XmlElement(value);
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if((child instanceof dojox.wire.ml.DataProperty) && child.name){
+ value.setPropertyValue(child.name, child.getValue());
+ }
+ }
+ }
+ }
+ return value; //anything
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/ml/DataStore.js b/js/dojo-1.6/dojox/wire/ml/DataStore.js new file mode 100644 index 0000000..56475da --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/DataStore.js @@ -0,0 +1,123 @@ +/*
+ 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.wire.ml.DataStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.DataStore"] = true;
+dojo.provide("dojox.wire.ml.DataStore");
+
+dojo.require("dijit._Widget");
+dojo.require("dojox.wire._base");
+
+dojo.declare("dojox.wire.ml.DataStore", dijit._Widget, {
+ // summary:
+ // A widget for a data store
+ // description:
+ // This widget represents a data store of 'storeClass' attribute.
+ // storeClass:
+ // A class name of a data store
+ storeClass: "",
+
+ postCreate: function(){
+ // summary:
+ // Call _createStore()
+ // description:
+ // See _createStore().
+ this.store = this._createStore();
+ },
+
+ _createStore: function(){
+ // summary:
+ // Create a data store
+ // desription:
+ // A data store of 'storeClass' is created with arguments
+ // specified with attributes.
+ // returns:
+ // A data store
+ if(!this.storeClass){
+ return null; //null
+ }
+ var storeClass = dojox.wire._getClass(this.storeClass);
+ if(!storeClass){
+ return null; //null
+ }
+ var args = {};
+ var attributes = this.domNode.attributes;
+ for(var i = 0; i < attributes.length; i++){
+ var a = attributes.item(i);
+ if(a.specified && !this[a.nodeName]){
+ args[a.nodeName] = a.nodeValue;
+ }
+ }
+ return new storeClass(args); //Object
+ },
+
+ getFeatures: function(){
+ // summary:
+ // Call getFeatures() method of a data store
+ // description:
+ // See dojo.data.api.Read.getFeatures().
+ // returns:
+ // A features object
+ return this.store.getFeatures(); //Object
+ },
+
+ fetch: function(/*Object*/request){
+ // summary:
+ // Call fetch() method of a data store
+ // description:
+ // See dojo.data.api.Read.fetch().
+ // request:
+ // A request object
+ // returns:
+ // A request object
+ return this.store.fetch(request); //Object
+ },
+
+ save: function(/*Object*/args){
+ // summary:
+ // Call save() method of a data store
+ // description:
+ // See dojo.data.api.Write.save().
+ // args:
+ // A save arguments object
+ this.store.save(args);
+ },
+
+ newItem: function(/*Object*/args){
+ // summary:
+ // Call newItem() method of a data store
+ // description:
+ // See dojo.data.api.Write.newItem().
+ // args:
+ // A new item arguments object
+ // returns:
+ // A new item
+ return this.store.newItem(args); //Object
+ },
+
+ deleteItem: function(/*Object*/item){
+ // summary:
+ // Call deleteItem() method of a data store
+ // description:
+ // See dojo.data.api.Write.deleteItem().
+ // returns:
+ // A boolean
+ return this.store.deleteItem(item); //Boolean
+ },
+
+ revert: function(){
+ // summary:
+ // Call revert() method of a data store
+ // description:
+ // See dojo.data.api.Write.revert().
+ // returns:
+ // A boolean
+ return this.store.revert(); //Boolean
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/ml/DataStore.xd.js b/js/dojo-1.6/dojox/wire/ml/DataStore.xd.js new file mode 100644 index 0000000..484dc38 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/DataStore.xd.js @@ -0,0 +1,129 @@ +/*
+ 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.wire.ml.DataStore"],
+["require", "dijit._Widget"],
+["require", "dojox.wire._base"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.ml.DataStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.DataStore"] = true;
+dojo.provide("dojox.wire.ml.DataStore");
+
+dojo.require("dijit._Widget");
+dojo.require("dojox.wire._base");
+
+dojo.declare("dojox.wire.ml.DataStore", dijit._Widget, {
+ // summary:
+ // A widget for a data store
+ // description:
+ // This widget represents a data store of 'storeClass' attribute.
+ // storeClass:
+ // A class name of a data store
+ storeClass: "",
+
+ postCreate: function(){
+ // summary:
+ // Call _createStore()
+ // description:
+ // See _createStore().
+ this.store = this._createStore();
+ },
+
+ _createStore: function(){
+ // summary:
+ // Create a data store
+ // desription:
+ // A data store of 'storeClass' is created with arguments
+ // specified with attributes.
+ // returns:
+ // A data store
+ if(!this.storeClass){
+ return null; //null
+ }
+ var storeClass = dojox.wire._getClass(this.storeClass);
+ if(!storeClass){
+ return null; //null
+ }
+ var args = {};
+ var attributes = this.domNode.attributes;
+ for(var i = 0; i < attributes.length; i++){
+ var a = attributes.item(i);
+ if(a.specified && !this[a.nodeName]){
+ args[a.nodeName] = a.nodeValue;
+ }
+ }
+ return new storeClass(args); //Object
+ },
+
+ getFeatures: function(){
+ // summary:
+ // Call getFeatures() method of a data store
+ // description:
+ // See dojo.data.api.Read.getFeatures().
+ // returns:
+ // A features object
+ return this.store.getFeatures(); //Object
+ },
+
+ fetch: function(/*Object*/request){
+ // summary:
+ // Call fetch() method of a data store
+ // description:
+ // See dojo.data.api.Read.fetch().
+ // request:
+ // A request object
+ // returns:
+ // A request object
+ return this.store.fetch(request); //Object
+ },
+
+ save: function(/*Object*/args){
+ // summary:
+ // Call save() method of a data store
+ // description:
+ // See dojo.data.api.Write.save().
+ // args:
+ // A save arguments object
+ this.store.save(args);
+ },
+
+ newItem: function(/*Object*/args){
+ // summary:
+ // Call newItem() method of a data store
+ // description:
+ // See dojo.data.api.Write.newItem().
+ // args:
+ // A new item arguments object
+ // returns:
+ // A new item
+ return this.store.newItem(args); //Object
+ },
+
+ deleteItem: function(/*Object*/item){
+ // summary:
+ // Call deleteItem() method of a data store
+ // description:
+ // See dojo.data.api.Write.deleteItem().
+ // returns:
+ // A boolean
+ return this.store.deleteItem(item); //Boolean
+ },
+
+ revert: function(){
+ // summary:
+ // Call revert() method of a data store
+ // description:
+ // See dojo.data.api.Write.revert().
+ // returns:
+ // A boolean
+ return this.store.revert(); //Boolean
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/ml/Invocation.js b/js/dojo-1.6/dojox/wire/ml/Invocation.js new file mode 100644 index 0000000..6f1ba00 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/Invocation.js @@ -0,0 +1,178 @@ +/*
+ 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.wire.ml.Invocation"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.Invocation"] = true;
+dojo.provide("dojox.wire.ml.Invocation");
+
+dojo.require("dojox.wire.ml.Action");
+
+dojo.declare("dojox.wire.ml.Invocation", dojox.wire.ml.Action, {
+ // summary:
+ // A widget to invoke a method or publish a topic
+ // description:
+ // This widget represents a controller task to invoke a method or
+ // publish a topic when an event (a function) or a topic is issued.
+ // object:
+ // A scope of a method to invoke
+ // method:
+ // A name of a method to invoke
+ // topic:
+ // A name of a topic to publish
+ // parameters:
+ // Arguments for the method or the topic
+ // result:
+ // A property to store a return value of the method call
+ // error:
+ // A property to store an error on the method call
+ object: "",
+ method: "",
+ topic: "",
+ parameters: "",
+ result: "",
+ error: "",
+
+ _run: function(){
+ // summary:
+ // Invoke a method or publish a topic
+ // description:
+ // If 'topic' is specified, the topic is published with arguments
+ // specified to 'parameters'.
+ // If 'method' and 'object' are specified, the method is invoked
+ // with arguments specified to 'parameters' and set the return
+ // value to a property specified to 'result'.
+ // 'object', 'parameters' and 'result' can specify properties of
+ // a widget or an DOM element with the dotted notation.
+ // If 'parameters' are omitted, the arguments to this method are
+ // passed as is.
+ if(this.topic){
+ var args = this._getParameters(arguments);
+ try{
+ dojo.publish(this.topic, args);
+ this.onComplete();
+ }catch(e){
+ this.onError(e);
+ }
+ }else if(this.method){
+ var scope = (this.object ? dojox.wire.ml._getValue(this.object) : dojo.global);
+ if(!scope){
+ return; //undefined
+ }
+ var args = this._getParameters(arguments);
+ var func = scope[this.method];
+ if(!func){
+ func = scope.callMethod;
+ if(!func){
+ return; //undefined
+ }
+ args = [this.method, args];
+ }
+ try{
+ var connected = false;
+ if(scope.getFeatures){
+ var features = scope.getFeatures();
+ if((this.method == "fetch" && features["dojo.data.api.Read"]) ||
+ (this.method == "save" && features["dojo.data.api.Write"])){
+ var arg = args[0];
+ if(!arg.onComplete){
+ arg.onComplete = function(){};
+ }
+ //dojo.connect(arg, "onComplete", this, "onComplete");
+ this.connect(arg, "onComplete", "onComplete");
+ if(!arg.onError){
+ arg.onError = function(){};
+ }
+ //dojo.connect(arg, "onError", this, "onError");
+ this.connect(arg, "onError", "onError");
+ connected = true;
+ }
+ }
+ var r = func.apply(scope, args);
+ if(!connected){
+ if(r && (r instanceof dojo.Deferred)){
+ var self = this;
+ r.addCallbacks(
+ function(result){self.onComplete(result);},
+ function(error){self.onError(error);}
+ );
+ }else{
+ this.onComplete(r);
+ }
+ }
+ }catch(e){
+ this.onError(e);
+ }
+ }
+ },
+
+ onComplete: function(/*anything*/result){
+ // summary:
+ // A function called when the method or the topic publish
+ // completed
+ // description:
+ // If 'result' attribute is specified, the result object also set
+ // to the specified property.
+ // result:
+ // The return value of a method or undefined for a topic
+ if(this.result){
+ dojox.wire.ml._setValue(this.result, result);
+ }
+ if(this.error){ // clear error
+ dojox.wire.ml._setValue(this.error, "");
+ }
+ },
+
+ onError: function(/*anything*/error){
+ // summary:
+ // A function called on an error occurs
+ // description:
+ // If 'error' attribute is specified, the error object also set to
+ // the specified property.
+ // error:
+ // The exception or error occurred
+ if(this.error){
+ if(error && error.message){
+ error = error.message;
+ }
+ dojox.wire.ml._setValue(this.error, error);
+ }
+ },
+
+ _getParameters: function(/*Array*/args){
+ // summary:
+ // Returns arguments to a method or topic to invoke
+ // description:
+ // This method retunrs an array of arguments specified by
+ // 'parameters' attribute, a comma-separated list of IDs and
+ // their properties in a dotted notation.
+ // If 'parameters' are omitted, the original arguments are
+ // used.
+ // args:
+ // Arguments to a trigger event or topic
+ if(!this.parameters){
+ // use arguments as is
+ return args; //Array
+ }
+ var parameters = [];
+ var list = this.parameters.split(",");
+ if(list.length == 1){
+ var parameter = dojox.wire.ml._getValue(dojo.trim(list[0]), args);
+ if(dojo.isArray(parameter)){
+ parameters = parameter;
+ }else{
+ parameters.push(parameter);
+ }
+ }else{
+ for(var i in list){
+ parameters.push(dojox.wire.ml._getValue(dojo.trim(list[i]), args));
+ }
+ }
+ return parameters; //Array
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/ml/Invocation.xd.js b/js/dojo-1.6/dojox/wire/ml/Invocation.xd.js new file mode 100644 index 0000000..b3b3556 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/Invocation.xd.js @@ -0,0 +1,183 @@ +/*
+ 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.wire.ml.Invocation"],
+["require", "dojox.wire.ml.Action"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.ml.Invocation"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.Invocation"] = true;
+dojo.provide("dojox.wire.ml.Invocation");
+
+dojo.require("dojox.wire.ml.Action");
+
+dojo.declare("dojox.wire.ml.Invocation", dojox.wire.ml.Action, {
+ // summary:
+ // A widget to invoke a method or publish a topic
+ // description:
+ // This widget represents a controller task to invoke a method or
+ // publish a topic when an event (a function) or a topic is issued.
+ // object:
+ // A scope of a method to invoke
+ // method:
+ // A name of a method to invoke
+ // topic:
+ // A name of a topic to publish
+ // parameters:
+ // Arguments for the method or the topic
+ // result:
+ // A property to store a return value of the method call
+ // error:
+ // A property to store an error on the method call
+ object: "",
+ method: "",
+ topic: "",
+ parameters: "",
+ result: "",
+ error: "",
+
+ _run: function(){
+ // summary:
+ // Invoke a method or publish a topic
+ // description:
+ // If 'topic' is specified, the topic is published with arguments
+ // specified to 'parameters'.
+ // If 'method' and 'object' are specified, the method is invoked
+ // with arguments specified to 'parameters' and set the return
+ // value to a property specified to 'result'.
+ // 'object', 'parameters' and 'result' can specify properties of
+ // a widget or an DOM element with the dotted notation.
+ // If 'parameters' are omitted, the arguments to this method are
+ // passed as is.
+ if(this.topic){
+ var args = this._getParameters(arguments);
+ try{
+ dojo.publish(this.topic, args);
+ this.onComplete();
+ }catch(e){
+ this.onError(e);
+ }
+ }else if(this.method){
+ var scope = (this.object ? dojox.wire.ml._getValue(this.object) : dojo.global);
+ if(!scope){
+ return; //undefined
+ }
+ var args = this._getParameters(arguments);
+ var func = scope[this.method];
+ if(!func){
+ func = scope.callMethod;
+ if(!func){
+ return; //undefined
+ }
+ args = [this.method, args];
+ }
+ try{
+ var connected = false;
+ if(scope.getFeatures){
+ var features = scope.getFeatures();
+ if((this.method == "fetch" && features["dojo.data.api.Read"]) ||
+ (this.method == "save" && features["dojo.data.api.Write"])){
+ var arg = args[0];
+ if(!arg.onComplete){
+ arg.onComplete = function(){};
+ }
+ //dojo.connect(arg, "onComplete", this, "onComplete");
+ this.connect(arg, "onComplete", "onComplete");
+ if(!arg.onError){
+ arg.onError = function(){};
+ }
+ //dojo.connect(arg, "onError", this, "onError");
+ this.connect(arg, "onError", "onError");
+ connected = true;
+ }
+ }
+ var r = func.apply(scope, args);
+ if(!connected){
+ if(r && (r instanceof dojo.Deferred)){
+ var self = this;
+ r.addCallbacks(
+ function(result){self.onComplete(result);},
+ function(error){self.onError(error);}
+ );
+ }else{
+ this.onComplete(r);
+ }
+ }
+ }catch(e){
+ this.onError(e);
+ }
+ }
+ },
+
+ onComplete: function(/*anything*/result){
+ // summary:
+ // A function called when the method or the topic publish
+ // completed
+ // description:
+ // If 'result' attribute is specified, the result object also set
+ // to the specified property.
+ // result:
+ // The return value of a method or undefined for a topic
+ if(this.result){
+ dojox.wire.ml._setValue(this.result, result);
+ }
+ if(this.error){ // clear error
+ dojox.wire.ml._setValue(this.error, "");
+ }
+ },
+
+ onError: function(/*anything*/error){
+ // summary:
+ // A function called on an error occurs
+ // description:
+ // If 'error' attribute is specified, the error object also set to
+ // the specified property.
+ // error:
+ // The exception or error occurred
+ if(this.error){
+ if(error && error.message){
+ error = error.message;
+ }
+ dojox.wire.ml._setValue(this.error, error);
+ }
+ },
+
+ _getParameters: function(/*Array*/args){
+ // summary:
+ // Returns arguments to a method or topic to invoke
+ // description:
+ // This method retunrs an array of arguments specified by
+ // 'parameters' attribute, a comma-separated list of IDs and
+ // their properties in a dotted notation.
+ // If 'parameters' are omitted, the original arguments are
+ // used.
+ // args:
+ // Arguments to a trigger event or topic
+ if(!this.parameters){
+ // use arguments as is
+ return args; //Array
+ }
+ var parameters = [];
+ var list = this.parameters.split(",");
+ if(list.length == 1){
+ var parameter = dojox.wire.ml._getValue(dojo.trim(list[0]), args);
+ if(dojo.isArray(parameter)){
+ parameters = parameter;
+ }else{
+ parameters.push(parameter);
+ }
+ }else{
+ for(var i in list){
+ parameters.push(dojox.wire.ml._getValue(dojo.trim(list[i]), args));
+ }
+ }
+ return parameters; //Array
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/ml/Service.js b/js/dojo-1.6/dojox/wire/ml/Service.js new file mode 100644 index 0000000..a25a22d --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/Service.js @@ -0,0 +1,347 @@ +/*
+ 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.wire.ml.Service"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.Service"] = true;
+dojo.provide("dojox.wire.ml.Service");
+dojo.provide("dojox.wire.ml.RestHandler");
+dojo.provide("dojox.wire.ml.XmlHandler");
+dojo.provide("dojox.wire.ml.JsonHandler");
+
+dojo.require("dijit._Widget");
+dojo.require("dojox.xml.parser");
+dojo.require("dojox.wire._base");
+dojo.require("dojox.wire.ml.util");
+
+dojo.declare("dojox.wire.ml.Service", dijit._Widget, {
+ // summary:
+ // A widget for a service
+ // description:
+ // This widget represents a service defined by a service description
+ // specified with 'url' attribute.
+ // If 'serviceType' and 'serviceUrl' attributes are specified, 'url'
+ // attribute can be omitted.
+ // url:
+ // A URL to a service description
+ // serviceUrl:
+ // A URL to a service
+ // serviceType:
+ // A service type
+ // handlerClass:
+ // A service handler class name
+ url: "",
+ serviceUrl: "",
+ serviceType: "",
+ handlerClass: "",
+ preventCache: true,
+
+ postCreate: function(){
+ // summary:
+ // Call _createHandler()
+ // description:
+ // See _createHandler().
+ this.handler = this._createHandler();
+ },
+
+ _handlerClasses: {
+ "TEXT": "dojox.wire.ml.RestHandler",
+ "XML": "dojox.wire.ml.XmlHandler",
+ "JSON": "dojox.wire.ml.JsonHandler",
+ "JSON-RPC": "dojo.rpc.JsonService"
+ },
+
+ _createHandler: function(){
+ // summary:
+ // Create a service handler
+ // desription:
+ // A service handler class is determined by:
+ // 1. 'handlerClass' attribute
+ // 2. 'serviceType' attribute
+ // 3. 'serviceType' property in a service description
+ // returns:
+ // A service handler
+ if(this.url){
+ var self = this;
+ var d = dojo.xhrGet({
+ url: this.url,
+ handleAs: "json",
+ sync: true
+ });
+ d.addCallback(function(result){
+ self.smd = result;
+ });
+ if(this.smd && !this.serviceUrl){
+ this.serviceUrl = (this.smd.serviceUrl || this.smd.serviceURL);
+ }
+ }
+ var handlerClass = undefined;
+ if(this.handlerClass){
+ handlerClass = dojox.wire._getClass(this.handlerClass);
+ }else if(this.serviceType){
+ handlerClass = this._handlerClasses[this.serviceType];
+ if(handlerClass && dojo.isString(handlerClass)){
+ handlerClass = dojox.wire._getClass(handlerClass);
+ this._handlerClasses[this.serviceType] = handlerClass;
+ }
+ }else if(this.smd && this.smd.serviceType){
+ handlerClass = this._handlerClasses[this.smd.serviceType];
+ if(handlerClass && dojo.isString(handlerClass)){
+ handlerClass = dojox.wire._getClass(handlerClass);
+ this._handlerClasses[this.smd.serviceType] = handlerClass;
+ }
+ }
+ if(!handlerClass){
+ return null; //null
+ }
+ return new handlerClass(); //Object
+ },
+
+ callMethod: function(method, parameters){
+ // summary:
+ // Call a service method with parameters
+ // method:
+ // A method name
+ // parameters:
+ // An array parameters
+ var deferred = new dojo.Deferred();
+ this.handler.bind(method, parameters, deferred, this.serviceUrl);
+ return deferred;
+ }
+});
+
+dojo.declare("dojox.wire.ml.RestHandler", null, {
+ // summary:
+ // A REST service handler
+ // description:
+ // This class serves as a base REST service.
+ // Sub-classes may override _getContent() and _getResult() to handle
+ // specific content types.
+ contentType: "text/plain",
+ handleAs: "text",
+
+ bind: function(method, parameters, deferred, url){
+ // summary:
+ // Call a service method with parameters.
+ // description:
+ // A service is called with a URL generated by _getUrl() and
+ // an HTTP method specified with 'method'.
+ // For "POST" and "PUT", a content is generated by _getContent().
+ // When data is loaded, _getResult() is used to pass the result to
+ // Deferred.callback().
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // deferred:
+ // 'Deferred'
+ // url:
+ // A URL for the method
+ method = method.toUpperCase();
+ var self = this;
+ var args = {
+ url: this._getUrl(method, parameters, url),
+ contentType: this.contentType,
+ handleAs: this.handleAs,
+ headers: this.headers,
+ preventCache: this.preventCache
+ };
+ var d = null;
+ if(method == "POST"){
+ args.postData = this._getContent(method, parameters);
+ d = dojo.rawXhrPost(args);
+ }else if(method == "PUT"){
+ args.putData = this._getContent(method, parameters);
+ d = dojo.rawXhrPut(args);
+ }else if(method == "DELETE"){
+ d = dojo.xhrDelete(args);
+ }else{ // "GET"
+ d = dojo.xhrGet(args);
+ }
+ d.addCallbacks(function(result){
+ deferred.callback(self._getResult(result));
+ }, function(error){
+ deferred.errback(error);
+ });
+ },
+
+ _getUrl: function(/*String*/method, /*Array*/parameters, /*String*/url){
+ // summary:
+ // Generate a URL
+ // description:
+ // If 'method' is "GET" or "DELETE", a query string is generated
+ // from a query object specified to the first parameter in
+ // 'parameters' and appended to 'url'.
+ // If 'url' contains variable seguments ("{parameter_name}"),
+ // they are replaced with corresponding parameter values, instead.
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // url:
+ // A base URL
+ // returns:
+ // A URL
+ var query;
+ if(method == "GET" || method == "DELETE"){
+ if(parameters.length > 0){
+ query = parameters[0];
+ }
+ }else{ // "POST" || "PUT"
+ if(parameters.length > 1){
+ query = parameters[1];
+ }
+ }
+ if(query){
+ var queryString = "";
+ for(var name in query){
+ var value = query[name];
+ if(value){
+ value = encodeURIComponent(value);
+ var variable = "{" + name + "}";
+ var index = url.indexOf(variable);
+ if(index >= 0){ // encode in path
+ url = url.substring(0, index) + value + url.substring(index + variable.length);
+ }else{ // encode as query string
+ if(queryString){
+ queryString += "&";
+ }
+ queryString += (name + "=" + value);
+ }
+ }
+ }
+ if(queryString){
+ url += "?" + queryString;
+ }
+ }
+ return url; //String
+ },
+
+ _getContent: function(/*String*/method, /*Array*/parameters){
+ // summary:
+ // Generate a request content
+ // description:
+ // If 'method' is "POST" or "PUT", the first parameter in
+ // 'parameters' is returned.
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // returns:
+ // A request content
+ if(method == "POST" || method == "PUT"){
+ return (parameters ? parameters[0] : null); //anything
+ }else{
+ return null; //null
+ }
+ },
+
+ _getResult: function(/*anything*/data){
+ // summary:
+ // Extract a result
+ // description:
+ // A response data is returned as is.
+ // data:
+ // A response data returned by a service
+ // returns:
+ // A result object
+ return data; //anything
+ }
+});
+
+dojo.declare("dojox.wire.ml.XmlHandler", dojox.wire.ml.RestHandler, {
+ // summary:
+ // A REST service handler for XML
+ // description:
+ // This class provides XML handling for a REST service.
+ contentType: "text/xml",
+ handleAs: "xml",
+
+ _getContent: function(/*String*/method, /*Array*/parameters){
+ // description:
+ // If 'method' is "POST" or "PUT", the first parameter in
+ // 'parameters' is used to generate an XML content.
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // returns:
+ // A request content
+ var content = null;
+ if(method == "POST" || method == "PUT"){
+ var p = parameters[0];
+ if(p){
+ if(dojo.isString(p)){
+ content = p;
+ }else{
+ var element = p;
+ if(element instanceof dojox.wire.ml.XmlElement){
+ element = element.element;
+ }else if(element.nodeType === 9 /* DOCUMENT_NODE */){
+ element = element.documentElement;
+ }
+ var declaration = "<?xml version=\"1.0\"?>"; // TODO: encoding?
+ content = declaration + dojox.xml.parser.innerXML(element);
+ }
+ }
+ }
+ return content;
+ },
+
+ _getResult: function(/*Document*/data){
+ // summary:
+ // Extract a result
+ // description:
+ // A response data (XML Document) is returned wrapped with
+ // XmlElement.
+ // data:
+ // A response data returned by a service
+ // returns:
+ // A result object
+ if(data){
+ data = new dojox.wire.ml.XmlElement(data);
+ }
+ return data;
+ }
+});
+
+dojo.declare("dojox.wire.ml.JsonHandler", dojox.wire.ml.RestHandler, {
+ // summary:
+ // A REST service handler for JSON
+ // description:
+ // This class provides JSON handling for a REST service.
+ contentType: "text/json",
+ handleAs: "json",
+ headers: {"Accept": "*/json"},
+
+ _getContent: function(/*String*/method, /*Array*/parameters){
+ // summary:
+ // Generate a request content
+ // description:
+ // If 'method' is "POST" or "PUT", the first parameter in
+ // 'parameter' is used to generate a JSON content.
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // returns:
+ // A request content
+ var content = null;
+ if(method == "POST" || method == "PUT"){
+ var p = (parameters ? parameters[0] : undefined);
+ if(p){
+ if(dojo.isString(p)){
+ content = p;
+ }else{
+ content = dojo.toJson(p);
+ }
+ }
+ }
+ return content; //String
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/ml/Service.xd.js b/js/dojo-1.6/dojox/wire/ml/Service.xd.js new file mode 100644 index 0000000..d0587c6 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/Service.xd.js @@ -0,0 +1,358 @@ +/*
+ 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.wire.ml.Service"],
+["provide", "dojox.wire.ml.RestHandler"],
+["provide", "dojox.wire.ml.XmlHandler"],
+["provide", "dojox.wire.ml.JsonHandler"],
+["require", "dijit._Widget"],
+["require", "dojox.xml.parser"],
+["require", "dojox.wire._base"],
+["require", "dojox.wire.ml.util"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.ml.Service"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.Service"] = true;
+dojo.provide("dojox.wire.ml.Service");
+dojo.provide("dojox.wire.ml.RestHandler");
+dojo.provide("dojox.wire.ml.XmlHandler");
+dojo.provide("dojox.wire.ml.JsonHandler");
+
+dojo.require("dijit._Widget");
+dojo.require("dojox.xml.parser");
+dojo.require("dojox.wire._base");
+dojo.require("dojox.wire.ml.util");
+
+dojo.declare("dojox.wire.ml.Service", dijit._Widget, {
+ // summary:
+ // A widget for a service
+ // description:
+ // This widget represents a service defined by a service description
+ // specified with 'url' attribute.
+ // If 'serviceType' and 'serviceUrl' attributes are specified, 'url'
+ // attribute can be omitted.
+ // url:
+ // A URL to a service description
+ // serviceUrl:
+ // A URL to a service
+ // serviceType:
+ // A service type
+ // handlerClass:
+ // A service handler class name
+ url: "",
+ serviceUrl: "",
+ serviceType: "",
+ handlerClass: "",
+ preventCache: true,
+
+ postCreate: function(){
+ // summary:
+ // Call _createHandler()
+ // description:
+ // See _createHandler().
+ this.handler = this._createHandler();
+ },
+
+ _handlerClasses: {
+ "TEXT": "dojox.wire.ml.RestHandler",
+ "XML": "dojox.wire.ml.XmlHandler",
+ "JSON": "dojox.wire.ml.JsonHandler",
+ "JSON-RPC": "dojo.rpc.JsonService"
+ },
+
+ _createHandler: function(){
+ // summary:
+ // Create a service handler
+ // desription:
+ // A service handler class is determined by:
+ // 1. 'handlerClass' attribute
+ // 2. 'serviceType' attribute
+ // 3. 'serviceType' property in a service description
+ // returns:
+ // A service handler
+ if(this.url){
+ var self = this;
+ var d = dojo.xhrGet({
+ url: this.url,
+ handleAs: "json",
+ sync: true
+ });
+ d.addCallback(function(result){
+ self.smd = result;
+ });
+ if(this.smd && !this.serviceUrl){
+ this.serviceUrl = (this.smd.serviceUrl || this.smd.serviceURL);
+ }
+ }
+ var handlerClass = undefined;
+ if(this.handlerClass){
+ handlerClass = dojox.wire._getClass(this.handlerClass);
+ }else if(this.serviceType){
+ handlerClass = this._handlerClasses[this.serviceType];
+ if(handlerClass && dojo.isString(handlerClass)){
+ handlerClass = dojox.wire._getClass(handlerClass);
+ this._handlerClasses[this.serviceType] = handlerClass;
+ }
+ }else if(this.smd && this.smd.serviceType){
+ handlerClass = this._handlerClasses[this.smd.serviceType];
+ if(handlerClass && dojo.isString(handlerClass)){
+ handlerClass = dojox.wire._getClass(handlerClass);
+ this._handlerClasses[this.smd.serviceType] = handlerClass;
+ }
+ }
+ if(!handlerClass){
+ return null; //null
+ }
+ return new handlerClass(); //Object
+ },
+
+ callMethod: function(method, parameters){
+ // summary:
+ // Call a service method with parameters
+ // method:
+ // A method name
+ // parameters:
+ // An array parameters
+ var deferred = new dojo.Deferred();
+ this.handler.bind(method, parameters, deferred, this.serviceUrl);
+ return deferred;
+ }
+});
+
+dojo.declare("dojox.wire.ml.RestHandler", null, {
+ // summary:
+ // A REST service handler
+ // description:
+ // This class serves as a base REST service.
+ // Sub-classes may override _getContent() and _getResult() to handle
+ // specific content types.
+ contentType: "text/plain",
+ handleAs: "text",
+
+ bind: function(method, parameters, deferred, url){
+ // summary:
+ // Call a service method with parameters.
+ // description:
+ // A service is called with a URL generated by _getUrl() and
+ // an HTTP method specified with 'method'.
+ // For "POST" and "PUT", a content is generated by _getContent().
+ // When data is loaded, _getResult() is used to pass the result to
+ // Deferred.callback().
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // deferred:
+ // 'Deferred'
+ // url:
+ // A URL for the method
+ method = method.toUpperCase();
+ var self = this;
+ var args = {
+ url: this._getUrl(method, parameters, url),
+ contentType: this.contentType,
+ handleAs: this.handleAs,
+ headers: this.headers,
+ preventCache: this.preventCache
+ };
+ var d = null;
+ if(method == "POST"){
+ args.postData = this._getContent(method, parameters);
+ d = dojo.rawXhrPost(args);
+ }else if(method == "PUT"){
+ args.putData = this._getContent(method, parameters);
+ d = dojo.rawXhrPut(args);
+ }else if(method == "DELETE"){
+ d = dojo.xhrDelete(args);
+ }else{ // "GET"
+ d = dojo.xhrGet(args);
+ }
+ d.addCallbacks(function(result){
+ deferred.callback(self._getResult(result));
+ }, function(error){
+ deferred.errback(error);
+ });
+ },
+
+ _getUrl: function(/*String*/method, /*Array*/parameters, /*String*/url){
+ // summary:
+ // Generate a URL
+ // description:
+ // If 'method' is "GET" or "DELETE", a query string is generated
+ // from a query object specified to the first parameter in
+ // 'parameters' and appended to 'url'.
+ // If 'url' contains variable seguments ("{parameter_name}"),
+ // they are replaced with corresponding parameter values, instead.
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // url:
+ // A base URL
+ // returns:
+ // A URL
+ var query;
+ if(method == "GET" || method == "DELETE"){
+ if(parameters.length > 0){
+ query = parameters[0];
+ }
+ }else{ // "POST" || "PUT"
+ if(parameters.length > 1){
+ query = parameters[1];
+ }
+ }
+ if(query){
+ var queryString = "";
+ for(var name in query){
+ var value = query[name];
+ if(value){
+ value = encodeURIComponent(value);
+ var variable = "{" + name + "}";
+ var index = url.indexOf(variable);
+ if(index >= 0){ // encode in path
+ url = url.substring(0, index) + value + url.substring(index + variable.length);
+ }else{ // encode as query string
+ if(queryString){
+ queryString += "&";
+ }
+ queryString += (name + "=" + value);
+ }
+ }
+ }
+ if(queryString){
+ url += "?" + queryString;
+ }
+ }
+ return url; //String
+ },
+
+ _getContent: function(/*String*/method, /*Array*/parameters){
+ // summary:
+ // Generate a request content
+ // description:
+ // If 'method' is "POST" or "PUT", the first parameter in
+ // 'parameters' is returned.
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // returns:
+ // A request content
+ if(method == "POST" || method == "PUT"){
+ return (parameters ? parameters[0] : null); //anything
+ }else{
+ return null; //null
+ }
+ },
+
+ _getResult: function(/*anything*/data){
+ // summary:
+ // Extract a result
+ // description:
+ // A response data is returned as is.
+ // data:
+ // A response data returned by a service
+ // returns:
+ // A result object
+ return data; //anything
+ }
+});
+
+dojo.declare("dojox.wire.ml.XmlHandler", dojox.wire.ml.RestHandler, {
+ // summary:
+ // A REST service handler for XML
+ // description:
+ // This class provides XML handling for a REST service.
+ contentType: "text/xml",
+ handleAs: "xml",
+
+ _getContent: function(/*String*/method, /*Array*/parameters){
+ // description:
+ // If 'method' is "POST" or "PUT", the first parameter in
+ // 'parameters' is used to generate an XML content.
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // returns:
+ // A request content
+ var content = null;
+ if(method == "POST" || method == "PUT"){
+ var p = parameters[0];
+ if(p){
+ if(dojo.isString(p)){
+ content = p;
+ }else{
+ var element = p;
+ if(element instanceof dojox.wire.ml.XmlElement){
+ element = element.element;
+ }else if(element.nodeType === 9 /* DOCUMENT_NODE */){
+ element = element.documentElement;
+ }
+ var declaration = "<?xml version=\"1.0\"?>"; // TODO: encoding?
+ content = declaration + dojox.xml.parser.innerXML(element);
+ }
+ }
+ }
+ return content;
+ },
+
+ _getResult: function(/*Document*/data){
+ // summary:
+ // Extract a result
+ // description:
+ // A response data (XML Document) is returned wrapped with
+ // XmlElement.
+ // data:
+ // A response data returned by a service
+ // returns:
+ // A result object
+ if(data){
+ data = new dojox.wire.ml.XmlElement(data);
+ }
+ return data;
+ }
+});
+
+dojo.declare("dojox.wire.ml.JsonHandler", dojox.wire.ml.RestHandler, {
+ // summary:
+ // A REST service handler for JSON
+ // description:
+ // This class provides JSON handling for a REST service.
+ contentType: "text/json",
+ handleAs: "json",
+ headers: {"Accept": "*/json"},
+
+ _getContent: function(/*String*/method, /*Array*/parameters){
+ // summary:
+ // Generate a request content
+ // description:
+ // If 'method' is "POST" or "PUT", the first parameter in
+ // 'parameter' is used to generate a JSON content.
+ // method:
+ // A method name
+ // parameters:
+ // An array of parameters
+ // returns:
+ // A request content
+ var content = null;
+ if(method == "POST" || method == "PUT"){
+ var p = (parameters ? parameters[0] : undefined);
+ if(p){
+ if(dojo.isString(p)){
+ content = p;
+ }else{
+ content = dojo.toJson(p);
+ }
+ }
+ }
+ return content; //String
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/ml/Transfer.js b/js/dojo-1.6/dojox/wire/ml/Transfer.js new file mode 100644 index 0000000..f4bfc6f --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/Transfer.js @@ -0,0 +1,366 @@ +/*
+ 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.wire.ml.Transfer"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.Transfer"] = true;
+dojo.provide("dojox.wire.ml.Transfer");
+dojo.provide("dojox.wire.ml.ChildWire");
+dojo.provide("dojox.wire.ml.ColumnWire");
+dojo.provide("dojox.wire.ml.NodeWire");
+dojo.provide("dojox.wire.ml.SegmentWire");
+
+dojo.require("dijit._Widget");
+dojo.require("dijit._Container");
+dojo.require("dojox.wire._base");
+dojo.require("dojox.wire.ml.Action");
+
+dojo.declare("dojox.wire.ml.Transfer", dojox.wire.ml.Action, {
+ // summary:
+ // A widget to transfer values through source and target Wires
+ // description:
+ // This widget represents a controller task to transfer a value from
+ // a source to a target, through a source and a target Wires, when
+ // an event (a function) or a topic is issued.
+ // If this widget has child ChildWire widgets, their _addWire()
+ // methods are called to add Wire arguments to a source or a target
+ // Wire.
+ // source:
+ // A source object and/or property
+ // sourceStore:
+ // A data store for a source data item
+ // sourceAttribute:
+ // An attribute of a source data item
+ // sourcePath:
+ // A simplified XPath to a source property of an XML element
+ // type:
+ // A type of the value to be transferred
+ // converter:
+ // A class name of a converter for the value to be transferred
+ // target:
+ // A target object and/or property
+ // targetStore:
+ // A data store for a target data item
+ // targetAttribute:
+ // An attribute of a target data item
+ // targetPath:
+ // A simplified XPath to a target property of an XML element
+ source: "",
+ sourceStore: "",
+ sourceAttribute: "",
+ sourcePath: "",
+ type: "",
+ converter: "",
+ delimiter: "",
+ target: "",
+ targetStore: "",
+ targetAttribute: "",
+ targetPath: "",
+
+ _run: function(){
+ // summary:
+ // Transfer a value from a source to a target
+ // description:
+ // First, Wires for a source and a target are created from attributes.
+ // Then, a value is obtained by getValue() of the source Wire is set
+ // by setValue() of the target Wire.
+ // The arguments to this method is passed to getValue() and setValue()
+ // of Wires, so that they can be used to identify the root objects off
+ // the arguments.
+ var sourceWire = this._getWire("source");
+ var targetWire = this._getWire("target");
+ dojox.wire.transfer(sourceWire, targetWire, arguments);
+ },
+
+ _getWire: function(/*String*/which){
+ // summary:
+ // Build Wire arguments from attributes
+ // description:
+ // Arguments object for a source or a target Wire, specified by
+ // 'which' argument, are build from corresponding attributes,
+ // including '*Store' (for 'dataStore'), '*Attribute'
+ // (for 'attribute), '*Path' (for 'path'), 'type' and 'converter'.
+ // 'source' or 'target' attribute is parsed as:
+ // "object_id.property_name[.sub_property_name...]"
+ // If 'source' or 'target' starts with "arguments", 'object'
+ // argument for a Wire is set to null, so that the root object is
+ // given as an event or topic arguments.
+ // If this widget has child ChildWire widgets with a corresponding
+ // 'which' attribute, their _addWire() methods are called to add
+ // additional Wire arguments and nested Wire is created,
+ // specifying the Wire defined by this widget to 'object' argument.
+ // which:
+ // Which Wire arguments to build, "source" or "target"
+ // returns:
+ // Wire arguments object
+ var args = undefined;
+ if(which == "source"){
+ args = {
+ object: this.source,
+ dataStore: this.sourceStore,
+ attribute: this.sourceAttribute,
+ path: this.sourcePath,
+ type: this.type,
+ converter: this.converter
+ };
+ }else{ // "target"
+ args = {
+ object: this.target,
+ dataStore: this.targetStore,
+ attribute: this.targetAttribute,
+ path: this.targetPath
+ };
+ }
+ if(args.object){
+ if(args.object.length >= 9 && args.object.substring(0, 9) == "arguments"){
+ args.property = args.object.substring(9);
+ args.object = null;
+ }else{
+ var i = args.object.indexOf('.');
+ if(i < 0){
+ args.object = dojox.wire.ml._getValue(args.object);
+ }else{
+ args.property = args.object.substring(i + 1);
+ args.object = dojox.wire.ml._getValue(args.object.substring(0, i));
+ }
+ }
+ }
+ if(args.dataStore){
+ args.dataStore = dojox.wire.ml._getValue(args.dataStore);
+ }
+ var childArgs = undefined;
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.ChildWire && child.which == which){
+ if(!childArgs){
+ childArgs = {};
+ }
+ child._addWire(this, childArgs);
+ }
+ }
+ if(childArgs){ // make nested Wires
+ childArgs.object = dojox.wire.create(args);
+ childArgs.dataStore = args.dataStore;
+ args = childArgs;
+ }
+ return args; //Object
+ }
+});
+
+dojo.declare("dojox.wire.ml.ChildWire", dijit._Widget, {
+ // summary:
+ // A widget to add a child wire
+ // description:
+ // Attributes of this widget are used to add a child Wire to
+ // a composite Wire of the parent Transfer widget.
+ // which:
+ // Which Wire to add a child Wire, "source" or "target", default to
+ // "source"
+ // object:
+ // A root object for the value
+ // property:
+ // A property for the value
+ // type:
+ // A type of the value
+ // converter:
+ // A class name of a converter for the value
+ // attribute:
+ // A data item attribute for the value
+ // path:
+ // A simplified XPath for the value
+ // name:
+ // A composite property name
+ which: "source",
+ object: "",
+ property: "",
+ type: "",
+ converter: "",
+ attribute: "",
+ path: "",
+ name: "",
+
+ _addWire: function(/*Transfer*/parent, /*Object*/args){
+ // summary:
+ // Add a child Wire to Wire arguments
+ // description:
+ // If 'name' attribute is specified, a child Wire is added as
+ // the named property of 'children' object of 'args'.
+ // Otherwise, a child Wire is added to 'children' array of 'args'.
+ // parent:
+ // A parent Transfer widget
+ // args:
+ // Wire arguments
+ if(this.name){ // object
+ if(!args.children){
+ args.children = {};
+ }
+ args.children[this.name] = this._getWire(parent);
+ }else{ // array
+ if(!args.children){
+ args.children = [];
+ }
+ args.children.push(this._getWire(parent));
+ }
+ },
+
+ _getWire: function(/*Transfer*/parent){
+ // summary:
+ // Build child Wire arguments from attributes
+ // description:
+ // Arguments object for a child Wire are build from attributes,
+ // including 'object', 'property', 'type', 'converter',
+ // 'attribute' and 'path'.
+ // parent:
+ // A parent Transfer widget
+ // returns:
+ // Wire arguments object
+ return {
+ object: (this.object ? dojox.wire.ml._getValue(this.object) : undefined),
+ property: this.property,
+ type: this.type,
+ converter: this.converter,
+ attribute: this.attribute,
+ path: this.path
+ }; //Object
+ }
+});
+
+dojo.declare("dojox.wire.ml.ColumnWire", dojox.wire.ml.ChildWire, {
+ // summary:
+ // A widget to add a column wire
+ // description:
+ // Attributes of this widget are used to add a column Wire to
+ // a TableAdapter of the parent Transfer widget.
+ // column:
+ // A column name
+ column: "",
+
+ _addWire: function(/*Transfer*/parent, /*Object*/args){
+ // summary:
+ // Add a column Wire to Wire arguments
+ // description:
+ // If 'column' attribute is specified, a column Wire is added as
+ // the named property of 'columns' object of 'args'.
+ // Otherwise, a column Wire is added to 'columns' array of 'args'.
+ // parent:
+ // A parent Transfer widget
+ // args:
+ // Wire arguments
+ if(this.column){ // object
+ if(!args.columns){
+ args.columns = {};
+ }
+ args.columns[this.column] = this._getWire(parent);
+ }else{ // array
+ if(!args.columns){
+ args.columns = [];
+ }
+ args.columns.push(this._getWire(parent));
+ }
+ }
+});
+
+dojo.declare("dojox.wire.ml.NodeWire", [dojox.wire.ml.ChildWire, dijit._Container], {
+ // summary:
+ // A widget to add node wires
+ // description:
+ // Attributes of this widget are used to add node Wires to
+ // a TreeAdapter of the parent Transfer widget.
+ // titleProperty:
+ // A property for the node title
+ // titleAttribute:
+ // A data item attribute for the node title
+ // titlePath:
+ // A simplified XPath for the node title
+ titleProperty: "",
+ titleAttribute: "",
+ titlePath: "",
+
+ _addWire: function(/*Transfer*/parent, /*Object*/args){
+ // summary:
+ // Add node Wires to Wire arguments
+ // description:
+ // Node Wires are added to 'nodes' array of 'args'.
+ // parent:
+ // A parent Transfer widget
+ // args:
+ // Wire arguments
+ if(!args.nodes){
+ args.nodes = [];
+ }
+ args.nodes.push(this._getWires(parent));
+ },
+
+ _getWires: function(/*Transfer*/parent){
+ // summary:
+ // Build node Wires arguments from attributes
+ // description:
+ // Arguments object for 'node' Wire are build from attributes,
+ // including 'object', 'property', 'type', 'converter',
+ // 'attribute' and 'path'.
+ // Arguments object for 'title' Wire are build from another set of
+ // attributes, 'titleProperty', 'titleAttribute' and 'titlePath'.
+ // If this widget has child NodeWire widgets, their _getWires()
+ // methods are called recursively to build 'children' array of
+ // 'args'.
+ // parent:
+ // A parent Transfer widget
+ // returns:
+ // Wire arguments object
+ var args = {
+ node: this._getWire(parent),
+ title: {
+ type: "string",
+ property: this.titleProperty,
+ attribute: this.titleAttribute,
+ path: this.titlePath
+ }
+ };
+ var childArgs = [];
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.NodeWire){
+ childArgs.push(child._getWires(parent));
+ }
+ }
+ if(childArgs.length > 0){
+ args.children = childArgs;
+ }
+ return args; //Object
+ }
+});
+
+dojo.declare("dojox.wire.ml.SegmentWire", dojox.wire.ml.ChildWire, {
+ // summary:
+ // A widget to add a segment wire
+ // description:
+ // Attributes of this widget are used to add a segment Wire to
+ // a TextAdapter of the parent Transfer widget.
+
+ _addWire: function(/*Transfer*/parent, /*Object*/args){
+ // summary:
+ // Add a segument Wire to Wire arguments
+ // description:
+ // A segment Wire is added to 'segments' array of 'args'.
+ // If 'parent' has 'delimiter' attribute, it is used for
+ // 'delimiter' property of 'args'.
+ // parent:
+ // A parent Transfer widget
+ // args:
+ // Wire arguments
+ if(!args.segments){
+ args.segments = [];
+ }
+ args.segments.push(this._getWire(parent));
+ if(parent.delimiter && !args.delimiter){
+ args.delimiter = parent.delimiter;
+ }
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/ml/Transfer.xd.js b/js/dojo-1.6/dojox/wire/ml/Transfer.xd.js new file mode 100644 index 0000000..a181d35 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/Transfer.xd.js @@ -0,0 +1,378 @@ +/*
+ 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.wire.ml.Transfer"],
+["provide", "dojox.wire.ml.ChildWire"],
+["provide", "dojox.wire.ml.ColumnWire"],
+["provide", "dojox.wire.ml.NodeWire"],
+["provide", "dojox.wire.ml.SegmentWire"],
+["require", "dijit._Widget"],
+["require", "dijit._Container"],
+["require", "dojox.wire._base"],
+["require", "dojox.wire.ml.Action"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.ml.Transfer"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.Transfer"] = true;
+dojo.provide("dojox.wire.ml.Transfer");
+dojo.provide("dojox.wire.ml.ChildWire");
+dojo.provide("dojox.wire.ml.ColumnWire");
+dojo.provide("dojox.wire.ml.NodeWire");
+dojo.provide("dojox.wire.ml.SegmentWire");
+
+dojo.require("dijit._Widget");
+dojo.require("dijit._Container");
+dojo.require("dojox.wire._base");
+dojo.require("dojox.wire.ml.Action");
+
+dojo.declare("dojox.wire.ml.Transfer", dojox.wire.ml.Action, {
+ // summary:
+ // A widget to transfer values through source and target Wires
+ // description:
+ // This widget represents a controller task to transfer a value from
+ // a source to a target, through a source and a target Wires, when
+ // an event (a function) or a topic is issued.
+ // If this widget has child ChildWire widgets, their _addWire()
+ // methods are called to add Wire arguments to a source or a target
+ // Wire.
+ // source:
+ // A source object and/or property
+ // sourceStore:
+ // A data store for a source data item
+ // sourceAttribute:
+ // An attribute of a source data item
+ // sourcePath:
+ // A simplified XPath to a source property of an XML element
+ // type:
+ // A type of the value to be transferred
+ // converter:
+ // A class name of a converter for the value to be transferred
+ // target:
+ // A target object and/or property
+ // targetStore:
+ // A data store for a target data item
+ // targetAttribute:
+ // An attribute of a target data item
+ // targetPath:
+ // A simplified XPath to a target property of an XML element
+ source: "",
+ sourceStore: "",
+ sourceAttribute: "",
+ sourcePath: "",
+ type: "",
+ converter: "",
+ delimiter: "",
+ target: "",
+ targetStore: "",
+ targetAttribute: "",
+ targetPath: "",
+
+ _run: function(){
+ // summary:
+ // Transfer a value from a source to a target
+ // description:
+ // First, Wires for a source and a target are created from attributes.
+ // Then, a value is obtained by getValue() of the source Wire is set
+ // by setValue() of the target Wire.
+ // The arguments to this method is passed to getValue() and setValue()
+ // of Wires, so that they can be used to identify the root objects off
+ // the arguments.
+ var sourceWire = this._getWire("source");
+ var targetWire = this._getWire("target");
+ dojox.wire.transfer(sourceWire, targetWire, arguments);
+ },
+
+ _getWire: function(/*String*/which){
+ // summary:
+ // Build Wire arguments from attributes
+ // description:
+ // Arguments object for a source or a target Wire, specified by
+ // 'which' argument, are build from corresponding attributes,
+ // including '*Store' (for 'dataStore'), '*Attribute'
+ // (for 'attribute), '*Path' (for 'path'), 'type' and 'converter'.
+ // 'source' or 'target' attribute is parsed as:
+ // "object_id.property_name[.sub_property_name...]"
+ // If 'source' or 'target' starts with "arguments", 'object'
+ // argument for a Wire is set to null, so that the root object is
+ // given as an event or topic arguments.
+ // If this widget has child ChildWire widgets with a corresponding
+ // 'which' attribute, their _addWire() methods are called to add
+ // additional Wire arguments and nested Wire is created,
+ // specifying the Wire defined by this widget to 'object' argument.
+ // which:
+ // Which Wire arguments to build, "source" or "target"
+ // returns:
+ // Wire arguments object
+ var args = undefined;
+ if(which == "source"){
+ args = {
+ object: this.source,
+ dataStore: this.sourceStore,
+ attribute: this.sourceAttribute,
+ path: this.sourcePath,
+ type: this.type,
+ converter: this.converter
+ };
+ }else{ // "target"
+ args = {
+ object: this.target,
+ dataStore: this.targetStore,
+ attribute: this.targetAttribute,
+ path: this.targetPath
+ };
+ }
+ if(args.object){
+ if(args.object.length >= 9 && args.object.substring(0, 9) == "arguments"){
+ args.property = args.object.substring(9);
+ args.object = null;
+ }else{
+ var i = args.object.indexOf('.');
+ if(i < 0){
+ args.object = dojox.wire.ml._getValue(args.object);
+ }else{
+ args.property = args.object.substring(i + 1);
+ args.object = dojox.wire.ml._getValue(args.object.substring(0, i));
+ }
+ }
+ }
+ if(args.dataStore){
+ args.dataStore = dojox.wire.ml._getValue(args.dataStore);
+ }
+ var childArgs = undefined;
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.ChildWire && child.which == which){
+ if(!childArgs){
+ childArgs = {};
+ }
+ child._addWire(this, childArgs);
+ }
+ }
+ if(childArgs){ // make nested Wires
+ childArgs.object = dojox.wire.create(args);
+ childArgs.dataStore = args.dataStore;
+ args = childArgs;
+ }
+ return args; //Object
+ }
+});
+
+dojo.declare("dojox.wire.ml.ChildWire", dijit._Widget, {
+ // summary:
+ // A widget to add a child wire
+ // description:
+ // Attributes of this widget are used to add a child Wire to
+ // a composite Wire of the parent Transfer widget.
+ // which:
+ // Which Wire to add a child Wire, "source" or "target", default to
+ // "source"
+ // object:
+ // A root object for the value
+ // property:
+ // A property for the value
+ // type:
+ // A type of the value
+ // converter:
+ // A class name of a converter for the value
+ // attribute:
+ // A data item attribute for the value
+ // path:
+ // A simplified XPath for the value
+ // name:
+ // A composite property name
+ which: "source",
+ object: "",
+ property: "",
+ type: "",
+ converter: "",
+ attribute: "",
+ path: "",
+ name: "",
+
+ _addWire: function(/*Transfer*/parent, /*Object*/args){
+ // summary:
+ // Add a child Wire to Wire arguments
+ // description:
+ // If 'name' attribute is specified, a child Wire is added as
+ // the named property of 'children' object of 'args'.
+ // Otherwise, a child Wire is added to 'children' array of 'args'.
+ // parent:
+ // A parent Transfer widget
+ // args:
+ // Wire arguments
+ if(this.name){ // object
+ if(!args.children){
+ args.children = {};
+ }
+ args.children[this.name] = this._getWire(parent);
+ }else{ // array
+ if(!args.children){
+ args.children = [];
+ }
+ args.children.push(this._getWire(parent));
+ }
+ },
+
+ _getWire: function(/*Transfer*/parent){
+ // summary:
+ // Build child Wire arguments from attributes
+ // description:
+ // Arguments object for a child Wire are build from attributes,
+ // including 'object', 'property', 'type', 'converter',
+ // 'attribute' and 'path'.
+ // parent:
+ // A parent Transfer widget
+ // returns:
+ // Wire arguments object
+ return {
+ object: (this.object ? dojox.wire.ml._getValue(this.object) : undefined),
+ property: this.property,
+ type: this.type,
+ converter: this.converter,
+ attribute: this.attribute,
+ path: this.path
+ }; //Object
+ }
+});
+
+dojo.declare("dojox.wire.ml.ColumnWire", dojox.wire.ml.ChildWire, {
+ // summary:
+ // A widget to add a column wire
+ // description:
+ // Attributes of this widget are used to add a column Wire to
+ // a TableAdapter of the parent Transfer widget.
+ // column:
+ // A column name
+ column: "",
+
+ _addWire: function(/*Transfer*/parent, /*Object*/args){
+ // summary:
+ // Add a column Wire to Wire arguments
+ // description:
+ // If 'column' attribute is specified, a column Wire is added as
+ // the named property of 'columns' object of 'args'.
+ // Otherwise, a column Wire is added to 'columns' array of 'args'.
+ // parent:
+ // A parent Transfer widget
+ // args:
+ // Wire arguments
+ if(this.column){ // object
+ if(!args.columns){
+ args.columns = {};
+ }
+ args.columns[this.column] = this._getWire(parent);
+ }else{ // array
+ if(!args.columns){
+ args.columns = [];
+ }
+ args.columns.push(this._getWire(parent));
+ }
+ }
+});
+
+dojo.declare("dojox.wire.ml.NodeWire", [dojox.wire.ml.ChildWire, dijit._Container], {
+ // summary:
+ // A widget to add node wires
+ // description:
+ // Attributes of this widget are used to add node Wires to
+ // a TreeAdapter of the parent Transfer widget.
+ // titleProperty:
+ // A property for the node title
+ // titleAttribute:
+ // A data item attribute for the node title
+ // titlePath:
+ // A simplified XPath for the node title
+ titleProperty: "",
+ titleAttribute: "",
+ titlePath: "",
+
+ _addWire: function(/*Transfer*/parent, /*Object*/args){
+ // summary:
+ // Add node Wires to Wire arguments
+ // description:
+ // Node Wires are added to 'nodes' array of 'args'.
+ // parent:
+ // A parent Transfer widget
+ // args:
+ // Wire arguments
+ if(!args.nodes){
+ args.nodes = [];
+ }
+ args.nodes.push(this._getWires(parent));
+ },
+
+ _getWires: function(/*Transfer*/parent){
+ // summary:
+ // Build node Wires arguments from attributes
+ // description:
+ // Arguments object for 'node' Wire are build from attributes,
+ // including 'object', 'property', 'type', 'converter',
+ // 'attribute' and 'path'.
+ // Arguments object for 'title' Wire are build from another set of
+ // attributes, 'titleProperty', 'titleAttribute' and 'titlePath'.
+ // If this widget has child NodeWire widgets, their _getWires()
+ // methods are called recursively to build 'children' array of
+ // 'args'.
+ // parent:
+ // A parent Transfer widget
+ // returns:
+ // Wire arguments object
+ var args = {
+ node: this._getWire(parent),
+ title: {
+ type: "string",
+ property: this.titleProperty,
+ attribute: this.titleAttribute,
+ path: this.titlePath
+ }
+ };
+ var childArgs = [];
+ var children = this.getChildren();
+ for(var i in children){
+ var child = children[i];
+ if(child instanceof dojox.wire.ml.NodeWire){
+ childArgs.push(child._getWires(parent));
+ }
+ }
+ if(childArgs.length > 0){
+ args.children = childArgs;
+ }
+ return args; //Object
+ }
+});
+
+dojo.declare("dojox.wire.ml.SegmentWire", dojox.wire.ml.ChildWire, {
+ // summary:
+ // A widget to add a segment wire
+ // description:
+ // Attributes of this widget are used to add a segment Wire to
+ // a TextAdapter of the parent Transfer widget.
+
+ _addWire: function(/*Transfer*/parent, /*Object*/args){
+ // summary:
+ // Add a segument Wire to Wire arguments
+ // description:
+ // A segment Wire is added to 'segments' array of 'args'.
+ // If 'parent' has 'delimiter' attribute, it is used for
+ // 'delimiter' property of 'args'.
+ // parent:
+ // A parent Transfer widget
+ // args:
+ // Wire arguments
+ if(!args.segments){
+ args.segments = [];
+ }
+ args.segments.push(this._getWire(parent));
+ if(parent.delimiter && !args.delimiter){
+ args.delimiter = parent.delimiter;
+ }
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/wire/ml/util.js b/js/dojo-1.6/dojox/wire/ml/util.js new file mode 100644 index 0000000..a4a1011 --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/util.js @@ -0,0 +1,306 @@ +/*
+ 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.wire.ml.util"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.util"] = true;
+dojo.provide("dojox.wire.ml.util");
+
+dojo.require("dojox.xml.parser");
+dojo.require("dojox.wire.Wire");
+
+dojox.wire.ml._getValue = function(/*String*/source, /*Array*/args){
+ // summary:
+ // Return a value
+ // description:
+ // This method obtains an object by an ID of a widget or an DOM
+ // element.
+ // If 'source' specifies a dotted notation to its property, a Wire is
+ // used to get the object property.
+ // If 'source' starts with "arguments", 'args' is used as a root
+ // object for the Wire.
+ // source:
+ // A string to specify an object and its property
+ // args:
+ // An optional arguments array
+ // returns:
+ // A value
+ if(!source){
+ return undefined; //undefined
+ }
+ var property = undefined;
+ if(args && source.length >= 9 && source.substring(0, 9) == "arguments"){
+ property = source.substring(9);
+ return new dojox.wire.Wire({property: property}).getValue(args);
+ }
+ var i = source.indexOf('.');
+ if(i >= 0){
+ property = source.substring(i + 1);
+ source = source.substring(0, i);
+ }
+ var object = (dijit.byId(source) || dojo.byId(source) || dojo.getObject(source));
+ if(!object){
+ return undefined; //undefined
+ }
+ if(!property){
+ return object; //Object
+ }else{
+ return new dojox.wire.Wire({object: object, property: property}).getValue(); //anything
+ }
+};
+
+dojox.wire.ml._setValue = function(/*String*/target, /*anything*/value){
+ // summary:
+ // Store a value
+ // description:
+ // This method stores a value by an ID of a widget or an DOM
+ // element with a dotted notation to its property, using a Wire.
+ // target:
+ // A string to specify an object and its property
+ // value:
+ // A value
+ if(!target){
+ return; //undefined
+ }
+ var i = target.indexOf('.');
+ if(i < 0){
+ return; //undefined
+ }
+ var object = this._getValue(target.substring(0, i));
+ if(!object){
+ return; //undefined
+ }
+ var property = target.substring(i + 1);
+ var wire = new dojox.wire.Wire({object: object, property: property}).setValue(value);
+};
+
+dojo.declare("dojox.wire.ml.XmlElement", null, {
+ // summary:
+ // An object wrapping an XML element
+ // description:
+ // This class represents an XML element.
+
+ constructor: function(/*Element||String*/element){
+ // summary:
+ // Initialize with an XML element or a tag name
+ // element:
+ // An XML element or a tag name
+ if(dojo.isString(element)){
+ element = this._getDocument().createElement(element);
+ }
+ this.element = element;
+ },
+ getPropertyValue: function(/*String*/property){
+ // summary:
+ // Return a property value
+ // description:
+ // If 'property' starts with '@', the attribute value is returned.
+ // If 'property' specifies "text()", the value of the first child
+ // text is returned.
+ // Otherwise, child elements of the tag name specified with
+ // 'property' are returned.
+ // property:
+ // A property name
+ // returns:
+ // A property value
+ var value = undefined;
+ if(!this.element){
+ return value; //undefined
+ }
+ if(!property){
+ return value; //undefined
+ }
+
+ if(property.charAt(0) == '@'){
+ var attribute = property.substring(1);
+ value = this.element.getAttribute(attribute);
+ }else if(property == "text()"){
+ var text = this.element.firstChild;
+ if(text){
+ value = text.nodeValue;
+ }
+ }else{ // child elements
+ var elements = [];
+ for(var i = 0; i < this.element.childNodes.length; i++){
+ var child = this.element.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == property){
+ elements.push(new dojox.wire.ml.XmlElement(child));
+ }
+ }
+ if(elements.length > 0){
+ if(elements.length === 1){
+ value = elements[0];
+ }else{
+ value = elements;
+ }
+ }
+ }
+ return value; //String||Array||XmlElement
+ },
+
+ setPropertyValue: function(/*String*/property, /*String||Array||XmlElement*/value){
+ // summary:
+ // Store a property value
+ // description:
+ // If 'property' starts with '@', 'value' is set to the attribute.
+ // If 'property' specifies "text()", 'value' is set as the first
+ // child text.
+ // If 'value' is a string, a child element of the tag name
+ // specified with 'property' is created and 'value' is set as
+ // the first child text of the child element.
+ // Otherwise, 'value' is set to as child elements.
+ // property:
+ // A property name
+ // value:
+ // A property value
+ var i;
+ var text;
+ if(!this.element){
+ return; //undefined
+ }
+ if(!property){
+ return; //undefined
+ }
+
+ if(property.charAt(0) == '@'){
+ var attribute = property.substring(1);
+ if(value){
+ this.element.setAttribute(attribute, value);
+ }else{
+ this.element.removeAttribute(attribute);
+ }
+ }else if(property == "text()"){
+ while(this.element.firstChild){
+ this.element.removeChild(this.element.firstChild);
+ }
+ if(value){
+ text = this._getDocument().createTextNode(value);
+ this.element.appendChild(text);
+ }
+ }else{ // child elements
+ var nextChild = null;
+ var child;
+ for(i = this.element.childNodes.length - 1; i >= 0; i--){
+ child = this.element.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == property){
+ if(!nextChild){
+ nextChild = child.nextSibling;
+ }
+ this.element.removeChild(child);
+ }
+ }
+ if(value){
+ if(dojo.isArray(value)){
+ for(i in value){
+ var e = value[i];
+ if(e.element){
+ this.element.insertBefore(e.element, nextChild);
+ }
+ }
+ }else if(value instanceof dojox.wire.ml.XmlElement){
+ if(value.element){
+ this.element.insertBefore(value.element, nextChild);
+ }
+ }else{ // assume string
+ child = this._getDocument().createElement(property);
+ text = this._getDocument().createTextNode(value);
+ child.appendChild(text);
+ this.element.insertBefore(child, nextChild);
+ }
+ }
+ }
+ },
+
+ toString: function(){
+ // summary:
+ // Return a value of the first text child of the element
+ // description:
+ // A value of the first text child of the element is returned.
+ // returns:
+ // A value of the first text child of the element
+ var s = "";
+ if(this.element){
+ var text = this.element.firstChild;
+ if(text){
+ s = text.nodeValue;
+ }
+ }
+ return s; //String
+ },
+
+ toObject: function(){
+ // summary:
+ // Return an object representation of the element
+ // description:
+ // An object with properties for child elements, attributes and
+ // text is returned.
+ // returns:
+ // An object representation of the element
+ if(!this.element){
+ return null; //null
+ }
+ var text = "";
+ var obj = {};
+ var elements = 0;
+ var i;
+ for(i = 0; i < this.element.childNodes.length; i++){
+ var child = this.element.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */){
+ elements++;
+ var o = new dojox.wire.ml.XmlElement(child).toObject();
+ var name = child.nodeName;
+ var p = obj[name];
+ if(!p){
+ obj[name] = o;
+ }else if(dojo.isArray(p)){
+ p.push(o);
+ }else{
+ obj[name] = [p, o]; // make them array
+ }
+ }else if(child.nodeType === 3 /* TEXT_NODE */ ||
+ child.nodeType === 4 /* CDATA_SECTION_NODE */){
+ text += child.nodeValue;
+ }
+ }
+ var attributes = 0;
+ if(this.element.nodeType === 1 /* ELEMENT_NODE */){
+ attributes = this.element.attributes.length;
+ for(i = 0; i < attributes; i++){
+ var attr = this.element.attributes[i];
+ obj["@" + attr.nodeName] = attr.nodeValue;
+ }
+ }
+ if(elements === 0){
+ if(attributes === 0){
+ // text only
+ return text; //String
+ }
+ // text with attributes
+ obj["text()"] = text;
+ }
+ // else ignore text
+ return obj; //Object
+ },
+
+ _getDocument: function(){
+ // summary:
+ // Return a DOM document
+ // description:
+ // If 'element' is specified, a DOM document of the element is
+ // returned.
+ // Otherwise, a DOM document is created.
+ // returns:
+ // A DOM document
+ if(this.element){
+ return (this.element.nodeType == 9 /* DOCUMENT_NODE */ ?
+ this.element : this.element.ownerDocument); //Document
+ }else{
+ return dojox.xml.parser.parse(); //Document
+ }
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/wire/ml/util.xd.js b/js/dojo-1.6/dojox/wire/ml/util.xd.js new file mode 100644 index 0000000..2b5ce3d --- /dev/null +++ b/js/dojo-1.6/dojox/wire/ml/util.xd.js @@ -0,0 +1,312 @@ +/*
+ 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.wire.ml.util"],
+["require", "dojox.xml.parser"],
+["require", "dojox.wire.Wire"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.wire.ml.util"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.wire.ml.util"] = true;
+dojo.provide("dojox.wire.ml.util");
+
+dojo.require("dojox.xml.parser");
+dojo.require("dojox.wire.Wire");
+
+dojox.wire.ml._getValue = function(/*String*/source, /*Array*/args){
+ // summary:
+ // Return a value
+ // description:
+ // This method obtains an object by an ID of a widget or an DOM
+ // element.
+ // If 'source' specifies a dotted notation to its property, a Wire is
+ // used to get the object property.
+ // If 'source' starts with "arguments", 'args' is used as a root
+ // object for the Wire.
+ // source:
+ // A string to specify an object and its property
+ // args:
+ // An optional arguments array
+ // returns:
+ // A value
+ if(!source){
+ return undefined; //undefined
+ }
+ var property = undefined;
+ if(args && source.length >= 9 && source.substring(0, 9) == "arguments"){
+ property = source.substring(9);
+ return new dojox.wire.Wire({property: property}).getValue(args);
+ }
+ var i = source.indexOf('.');
+ if(i >= 0){
+ property = source.substring(i + 1);
+ source = source.substring(0, i);
+ }
+ var object = (dijit.byId(source) || dojo.byId(source) || dojo.getObject(source));
+ if(!object){
+ return undefined; //undefined
+ }
+ if(!property){
+ return object; //Object
+ }else{
+ return new dojox.wire.Wire({object: object, property: property}).getValue(); //anything
+ }
+};
+
+dojox.wire.ml._setValue = function(/*String*/target, /*anything*/value){
+ // summary:
+ // Store a value
+ // description:
+ // This method stores a value by an ID of a widget or an DOM
+ // element with a dotted notation to its property, using a Wire.
+ // target:
+ // A string to specify an object and its property
+ // value:
+ // A value
+ if(!target){
+ return; //undefined
+ }
+ var i = target.indexOf('.');
+ if(i < 0){
+ return; //undefined
+ }
+ var object = this._getValue(target.substring(0, i));
+ if(!object){
+ return; //undefined
+ }
+ var property = target.substring(i + 1);
+ var wire = new dojox.wire.Wire({object: object, property: property}).setValue(value);
+};
+
+dojo.declare("dojox.wire.ml.XmlElement", null, {
+ // summary:
+ // An object wrapping an XML element
+ // description:
+ // This class represents an XML element.
+
+ constructor: function(/*Element||String*/element){
+ // summary:
+ // Initialize with an XML element or a tag name
+ // element:
+ // An XML element or a tag name
+ if(dojo.isString(element)){
+ element = this._getDocument().createElement(element);
+ }
+ this.element = element;
+ },
+ getPropertyValue: function(/*String*/property){
+ // summary:
+ // Return a property value
+ // description:
+ // If 'property' starts with '@', the attribute value is returned.
+ // If 'property' specifies "text()", the value of the first child
+ // text is returned.
+ // Otherwise, child elements of the tag name specified with
+ // 'property' are returned.
+ // property:
+ // A property name
+ // returns:
+ // A property value
+ var value = undefined;
+ if(!this.element){
+ return value; //undefined
+ }
+ if(!property){
+ return value; //undefined
+ }
+
+ if(property.charAt(0) == '@'){
+ var attribute = property.substring(1);
+ value = this.element.getAttribute(attribute);
+ }else if(property == "text()"){
+ var text = this.element.firstChild;
+ if(text){
+ value = text.nodeValue;
+ }
+ }else{ // child elements
+ var elements = [];
+ for(var i = 0; i < this.element.childNodes.length; i++){
+ var child = this.element.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == property){
+ elements.push(new dojox.wire.ml.XmlElement(child));
+ }
+ }
+ if(elements.length > 0){
+ if(elements.length === 1){
+ value = elements[0];
+ }else{
+ value = elements;
+ }
+ }
+ }
+ return value; //String||Array||XmlElement
+ },
+
+ setPropertyValue: function(/*String*/property, /*String||Array||XmlElement*/value){
+ // summary:
+ // Store a property value
+ // description:
+ // If 'property' starts with '@', 'value' is set to the attribute.
+ // If 'property' specifies "text()", 'value' is set as the first
+ // child text.
+ // If 'value' is a string, a child element of the tag name
+ // specified with 'property' is created and 'value' is set as
+ // the first child text of the child element.
+ // Otherwise, 'value' is set to as child elements.
+ // property:
+ // A property name
+ // value:
+ // A property value
+ var i;
+ var text;
+ if(!this.element){
+ return; //undefined
+ }
+ if(!property){
+ return; //undefined
+ }
+
+ if(property.charAt(0) == '@'){
+ var attribute = property.substring(1);
+ if(value){
+ this.element.setAttribute(attribute, value);
+ }else{
+ this.element.removeAttribute(attribute);
+ }
+ }else if(property == "text()"){
+ while(this.element.firstChild){
+ this.element.removeChild(this.element.firstChild);
+ }
+ if(value){
+ text = this._getDocument().createTextNode(value);
+ this.element.appendChild(text);
+ }
+ }else{ // child elements
+ var nextChild = null;
+ var child;
+ for(i = this.element.childNodes.length - 1; i >= 0; i--){
+ child = this.element.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */ && child.nodeName == property){
+ if(!nextChild){
+ nextChild = child.nextSibling;
+ }
+ this.element.removeChild(child);
+ }
+ }
+ if(value){
+ if(dojo.isArray(value)){
+ for(i in value){
+ var e = value[i];
+ if(e.element){
+ this.element.insertBefore(e.element, nextChild);
+ }
+ }
+ }else if(value instanceof dojox.wire.ml.XmlElement){
+ if(value.element){
+ this.element.insertBefore(value.element, nextChild);
+ }
+ }else{ // assume string
+ child = this._getDocument().createElement(property);
+ text = this._getDocument().createTextNode(value);
+ child.appendChild(text);
+ this.element.insertBefore(child, nextChild);
+ }
+ }
+ }
+ },
+
+ toString: function(){
+ // summary:
+ // Return a value of the first text child of the element
+ // description:
+ // A value of the first text child of the element is returned.
+ // returns:
+ // A value of the first text child of the element
+ var s = "";
+ if(this.element){
+ var text = this.element.firstChild;
+ if(text){
+ s = text.nodeValue;
+ }
+ }
+ return s; //String
+ },
+
+ toObject: function(){
+ // summary:
+ // Return an object representation of the element
+ // description:
+ // An object with properties for child elements, attributes and
+ // text is returned.
+ // returns:
+ // An object representation of the element
+ if(!this.element){
+ return null; //null
+ }
+ var text = "";
+ var obj = {};
+ var elements = 0;
+ var i;
+ for(i = 0; i < this.element.childNodes.length; i++){
+ var child = this.element.childNodes[i];
+ if(child.nodeType === 1 /* ELEMENT_NODE */){
+ elements++;
+ var o = new dojox.wire.ml.XmlElement(child).toObject();
+ var name = child.nodeName;
+ var p = obj[name];
+ if(!p){
+ obj[name] = o;
+ }else if(dojo.isArray(p)){
+ p.push(o);
+ }else{
+ obj[name] = [p, o]; // make them array
+ }
+ }else if(child.nodeType === 3 /* TEXT_NODE */ ||
+ child.nodeType === 4 /* CDATA_SECTION_NODE */){
+ text += child.nodeValue;
+ }
+ }
+ var attributes = 0;
+ if(this.element.nodeType === 1 /* ELEMENT_NODE */){
+ attributes = this.element.attributes.length;
+ for(i = 0; i < attributes; i++){
+ var attr = this.element.attributes[i];
+ obj["@" + attr.nodeName] = attr.nodeValue;
+ }
+ }
+ if(elements === 0){
+ if(attributes === 0){
+ // text only
+ return text; //String
+ }
+ // text with attributes
+ obj["text()"] = text;
+ }
+ // else ignore text
+ return obj; //Object
+ },
+
+ _getDocument: function(){
+ // summary:
+ // Return a DOM document
+ // description:
+ // If 'element' is specified, a DOM document of the element is
+ // returned.
+ // Otherwise, a DOM document is created.
+ // returns:
+ // A DOM document
+ if(this.element){
+ return (this.element.nodeType == 9 /* DOCUMENT_NODE */ ?
+ this.element : this.element.ownerDocument); //Document
+ }else{
+ return dojox.xml.parser.parse(); //Document
+ }
+ }
+});
+
+}
+
+}};});
|
