Ticket #3183: dojox.wire_20070529.patch

File dojox.wire_20070529.patch, 15.4 kB (added by jaredj, 19 months ago)

Minor patch to add readme and update the load of core functions

  • wire.js

     
     1dojo.provide("dojox.wire"); 
     2dojo.require("dojox.wire._base"); 
     3 
  • wire/Wire.js

    Property changes on: wire.js
    ___________________________________________________________________
    Name: svn:eol-style
       + native
    
     
    11dojo.provide("dojox.wire.Wire"); 
    22 
    3 dojo.require("dojox.wire.common"); 
     3dojo.require("dojox.wire._base"); 
    44 
    55dojo.declare("dojox.wire.Wire", 
    66        null, 
  • wire/tests/wire.js

     
    11dojo.provide("dojox.wire.tests.wire"); 
    22 
    33try{ 
    4         dojo.require("dojox.wire.tests.programmatic.common"); 
     4        dojo.require("dojox.wire.tests.programmatic._base"); 
    55        dojo.require("dojox.wire.tests.programmatic.Wire"); 
    66        dojo.require("dojox.wire.tests.programmatic.DataWire"); 
    77        dojo.require("dojox.wire.tests.programmatic.XmlWire"); 
  • wire/tests/programmatic/common.js

     
    1 dojo.provide("dojox.wire.tests.programmatic.common"); 
    2  
    3 dojo.require("dojox.wire.common"); 
    4  
    5 tests.register("dojox.wire.tests.programmatic.common", [ 
    6  
    7         function test_create(t){ 
    8                 var wire = dojox.wire.create({}); 
    9                 t.assertTrue(wire instanceof dojox.wire.Wire); 
    10  
    11                 wire = dojox.wire.create({property: "a"}); 
    12                 t.assertTrue(wire instanceof dojox.wire.Wire); 
    13  
    14                 wire = dojox.wire.create({attribute: "a"}); 
    15                 t.assertTrue(wire instanceof dojox.wire.DataWire); 
    16  
    17                 wire = dojox.wire.create({path: "a"}); 
    18                 t.assertTrue(wire instanceof dojox.wire.XmlWire); 
    19  
    20                 wire = dojox.wire.create({children: "a"}); 
    21                 t.assertTrue(wire instanceof dojox.wire.CompositeWire); 
    22  
    23                 wire = dojox.wire.create({columns: "a"}); 
    24                 t.assertTrue(wire instanceof dojox.wire.TableAdapter); 
    25  
    26                 wire = dojox.wire.create({nodes: "a"}); 
    27                 t.assertTrue(wire instanceof dojox.wire.TreeAdapter); 
    28  
    29                 wire = dojox.wire.create({segments: "a"}); 
    30                 t.assertTrue(wire instanceof dojox.wire.TextAdapter); 
    31  
    32                 wire = dojox.wire.create({wireClass: "dojox.wire.DataWire"}); 
    33                 t.assertTrue(wire instanceof dojox.wire.DataWire); 
    34         }, 
    35          
    36         function test_transfer(t){ 
    37                 var source = {a: "A"}; 
    38                 var target = {}; 
    39                 dojox.wire.transfer( 
    40                         {object: source, property: "a"}, 
    41                         {object: target, property: "a"}); 
    42                 t.assertEqual(source.a, target.a); 
    43         }, 
    44  
    45         function test_connect(t){ 
    46                 var trigger = {transfer: function() {}, transferArgument: function() {}}; 
    47                 var source = {a: "A"}; 
    48                 var target = {}; 
    49                 dojox.wire.connect({scope: trigger, event: "transfer"}, 
    50                         {object: source, property: "a"}, 
    51                         {object: target, property: "a"}); 
    52                 trigger.transfer(); 
    53                 t.assertEqual(source.a, target.a); 
    54  
    55                 // with argument 
    56                 target = {}; 
    57                 dojox.wire.connect({scope: trigger, event: "transferArgument"}, 
    58                         {property: "[0].a"}, 
    59                         {object: target, property: "a"}); 
    60                 trigger.transferArgument(source); 
    61                 t.assertEqual(source.a, target.a); 
    62  
    63                 // by topic 
    64                 target = {}; 
    65                 dojox.wire.connect({topic: "transfer"}, 
    66                         {object: source, property: "a"}, 
    67                         {object: target, property: "a"}); 
    68                 dojo.publish("transfer"); 
    69                 t.assertEqual(source.a, target.a); 
    70  
    71                 // by topic with argument 
    72                 target = {}; 
    73                 dojox.wire.connect({topic: "transferArgument"}, 
    74                         {property: "[0].a"}, 
    75                         {object: target, property: "a"}); 
    76                 dojo.publish("transferArgument", [source]); 
    77                 t.assertEqual(source.a, target.a); 
    78         }, 
    79  
    80         function test_disconnect(t){ 
    81                 var trigger = {transferDisconnect: function() {}}; 
    82                 var source = {a: "A"}; 
    83                 var target = {}; 
    84                 var connection = dojox.wire.connect({scope: trigger, event: "transferDisconnect"}, 
    85                         {object: source, property: "a"}, 
    86                         {object: target, property: "a"}); 
    87                 trigger.transferDisconnect(); 
    88                 t.assertEqual(source.a, target.a); 
    89                 delete target.a; 
    90                 dojox.wire.disconnect(connection); 
    91                 trigger.transferDisconnect(); 
    92                 t.assertEqual(undefined, target.a); 
    93  
    94                 // by topic 
    95                 target = {}; 
    96                 connection = dojox.wire.connect({topic: "transferDisconnect"}, 
    97                         {object: source, property: "a"}, 
    98                         {object: target, property: "a"}); 
    99                 dojo.publish("transferDisconnect"); 
    100                 t.assertEqual(source.a, target.a); 
    101                 delete target.a; 
    102                 dojox.wire.disconnect(connection); 
    103                 dojo.publish("transferDisconnect"); 
    104                 t.assertEqual(undefined, target.a); 
    105         } 
    106  
    107 ]); 
  • wire/tests/programmatic/_base.js

     
    1 dojo.provide("dojox.wire.tests.programmatic.common"); 
     1dojo.provide("dojox.wire.tests.programmatic._base"); 
    22 
    3 dojo.require("dojox.wire.common"); 
     3dojo.require("dojox.wire._base"); 
    44 
    5 tests.register("dojox.wire.tests.programmatic.common", [ 
     5tests.register("dojox.wire.tests.programmatic._base", [ 
    66 
    77        function test_create(t){ 
    88                var wire = dojox.wire.create({}); 
  • wire/common.js

     
    1 dojo.provide("dojox.wire.common"); 
    2  
    3 dojox.wire._defaultWireClass = "dojox.wire.Wire"; 
    4  
    5 dojox.wire._wireClasses = { 
    6         "attribute": "dojox.wire.DataWire", 
    7         "path": "dojox.wire.XmlWire", 
    8         "children": "dojox.wire.CompositeWire", 
    9         "columns": "dojox.wire.TableAdapter", 
    10         "nodes": "dojox.wire.TreeAdapter", 
    11         "segments": "dojox.wire.TextAdapter" 
    12 }; 
    13  
    14 dojox.wire.register = function(/*Function||String*/wireClass, /*String*/key){ 
    15         //      summary: 
    16         //              Register a Wire class 
    17         //      desription: 
    18         //              The specified Wire class or a class name is registered with 
    19         //              a key property of arguments to create a Wire 
    20         //      wireClass: 
    21         //              A class or full qualified class name 
    22         //      key: 
    23         //              A key property of arguments to create a Wire 
    24         if(!wireClass || !key){ 
    25                 return; //undefined 
    26         } 
    27         if(dojox.wire._wireClasses[key]){ // key already in use 
    28                 return; //undefined 
    29         } 
    30         dojox.wire._wireClasses[key] = wireClass; 
    31 }; 
    32  
    33 dojox.wire._getClass = function(/*String*/name){ 
    34         //      summary: 
    35         //              Returns a class  
    36         //      description: 
    37         //              The class is loaded by dojo.require() and returned 
    38         //              by dojo.getObject(). 
    39         //      name: 
    40         //              A class name 
    41         //      returns: 
    42         //              A class 
    43         dojo["require"](name); // use dojo["require"] instead of dojo.require to avoid a build problem 
    44         return dojo.getObject(name); //Function 
    45 }; 
    46  
    47 dojox.wire.create = function(/*Object*/args){ 
    48         //      summary: 
    49         //              Create a Wire from arguments 
    50         //      description: 
    51         //              If 'args' specifies 'wireClass', it is used as a class or full 
    52         //              qualified class name to create a Wire with 'args' as arguments. 
    53         //              Otherwise, a Wire class is determined by other proeprties of 'args' 
    54         //              checking if 'args' specifies a key property for a Wire class. 
    55         //              If no key property found, the default Wire class is used. 
    56         //      args: 
    57         //              Arguments to create a Wire 
    58         //      returns: 
    59         //              A Wire 
    60         if(!args){ 
    61                 args = {}; 
    62         } 
    63         var wireClass = args.wireClass; 
    64         if(wireClass){ 
    65                 if(dojo.isString(wireClass)){ 
    66                         wireClass = dojox.wire._getClass(wireClass); 
    67                 } 
    68         }else{ 
    69                 for(var key in args){ 
    70                         if(!args[key]){ 
    71                                 continue; 
    72                         } 
    73                         wireClass = dojox.wire._wireClasses[key]; 
    74                         if(wireClass){ 
    75                                 if(dojo.isString(wireClass)){ 
    76                                         wireClass = dojox.wire._getClass(wireClass); 
    77                                         dojox.wire._wireClasses[key] = wireClass; 
    78                                 } 
    79                                 break; 
    80                         } 
    81                 } 
    82         } 
    83         if(!wireClass){ 
    84                 if(dojo.isString(dojox.wire._defaultWireClass)){ 
    85                         dojox.wire._defaultWireClass = dojox.wire._getClass(dojox.wire._defaultWireClass); 
    86                 } 
    87                 wireClass = dojox.wire._defaultWireClass; 
    88         } 
    89         return new wireClass(args); //Object 
    90 }; 
    91  
    92 dojox.wire.isWire = function(/*Object*/wire){ 
    93         //      summary: 
    94         //              Check if an object is a Wire 
    95         //      description: 
    96         //              If the specified object is a Wire, true is returned. 
    97         //              Otherwise, false is returned. 
    98         //      wire: 
    99         //              An object to check 
    100         //      returns: 
    101         //              True if the object is a Wire, otherwise false 
    102         return (wire && wire._wireClass); //Boolean 
    103 }; 
    104  
    105 dojox.wire.transfer = function(/*Wire||Object*/source, /*Wire||Object*/target, /*Object?*/defaultObject, /*Object?*/defaultTargetObject){ 
    106         //      summary: 
    107         //              Transfer a source value to a target value 
    108         //      description: 
    109         //              If 'source' and/or 'target' are not Wires, Wires are created with 
    110         //              them as arguments. 
    111         //              A value is got through the source Wire and set through the target 
    112         //              Wire. 
    113         //              'defaultObject' is passed to Wires as a default root object. 
    114         //              If 'defaultTargetObject' is specified, it is passed to the target 
    115         //              Wire as a default root object, instead of 'defaultObject'. 
    116         //      source: 
    117         //              A Wire or arguments to create a Wire for a source value 
    118         //      target: 
    119         //              A Wire or arguments to create a Wire for a target value 
    120         //      defaultObject: 
    121         //      defaultTargetObject; 
    122         //              Optional default root objects passed to Wires 
    123         if(!source || !target){ 
    124                 return; //undefined 
    125         } 
    126         if(!dojox.wire.isWire(source)){ 
    127                 source = dojox.wire.create(source); 
    128         } 
    129         if(!dojox.wire.isWire(target)){ 
    130                 target = dojox.wire.create(target); 
    131         } 
    132  
    133         var value = source.getValue(defaultObject); 
    134         target.setValue(value, (defaultTargetObject || defaultObject)); 
    135 }; 
    136  
    137 dojox.wire.connect = function(/*Object*/trigger, /*Wire||Object*/source, /*Wire||Object*/target){ 
    138         //      summary: 
    139         //              Transfer a source value to a target value on a trigger event or 
    140         //              topic 
    141         //      description: 
    142         //              If 'trigger' specifies 'topic', the topic is subscribed to transer 
    143         //              a value on the topic. 
    144         //              Otherwise, the event specified to 'event' of 'trigger' is listened 
    145         //              to transfer a value. 
    146         //              On the specified event or topic, transfer() is called with 
    147         //              'source', 'target' and the arguments of the event or topic (as 
    148         //              default root objects). 
    149         //      trigger: 
    150         //              An event or topic to trigger a transfer 
    151         //      source: 
    152         //              A Wire or arguments to create a Wire for a source value 
    153         //      target: 
    154         //              A Wire or arguments to create a Wire for a target value 
    155         //      returns: 
    156         //              A connection handle for disconnect() 
    157         if(!trigger || !source || !target){ 
    158                 return; //undefined 
    159         } 
    160  
    161         var connection = {topic: trigger.topic}; 
    162         if(trigger.topic){ 
    163                 connection.handle = dojo.subscribe(trigger.topic, function(){ 
    164                         dojox.wire.transfer(source, target, arguments); 
    165                 }); 
    166         }else if(trigger.event){ 
    167                 connection.handle = dojo.connect(trigger.scope, trigger.event, function(){ 
    168                         dojox.wire.transfer(source, target, arguments); 
    169                 }); 
    170         } 
    171         return connection; //Object 
    172 }; 
    173  
    174 dojox.wire.disconnect = function(/*Object*/connection){ 
    175         //      summary: 
    176         //              Remove a connection or subscription for transfer 
    177         //      description: 
    178         //              If 'handle' has 'topic', the topic is unsubscribed. 
    179         //              Otherwise, the listener to an event is removed. 
    180         //      connection: 
    181         //              A connection handle returned by connect() 
    182         if(!connection || !connection.handle){ 
    183                 return; //undefined 
    184         } 
    185  
    186         if(connection.topic){ 
    187                 dojo.unsubscribe(connection.topic, connection.handle); 
    188         }else{ 
    189                 dojo.disconnect(connection.handle); 
    190         } 
    191 }; 
  • wire/CompositeWire.js

     
    11dojo.provide("dojox.wire.CompositeWire"); 
    22 
    3 dojo.require("dojox.wire.common"); 
     3dojo.require("dojox.wire._base"); 
    44dojo.require("dojox.wire.Wire"); 
    55 
    66dojo.declare("dojox.wire.CompositeWire", 
  • wire/_base.js

     
    1 dojo.provide("dojox.wire.common"); 
     1dojo.provide("dojox.wire._base"); 
    22 
    33dojox.wire._defaultWireClass = "dojox.wire.Wire"; 
    44 
  • wire/ml/Transfer.js

     
    66 
    77dojo.require("dijit.base.Widget"); 
    88dojo.require("dijit.base.Container"); 
    9 dojo.require("dojox.wire.common"); 
     9dojo.require("dojox.wire._base"); 
    1010dojo.require("dojox.wire.ml.Action"); 
    1111 
    1212dojo.declare("dojox.wire.ml.Transfer", 
  • wire/ml/DataStore.js

     
    11dojo.provide("dojox.wire.ml.DataStore"); 
    22 
    33dojo.require("dijit.base.Widget"); 
    4 dojo.require("dojox.wire.common"); 
     4dojo.require("dojox.wire._base"); 
    55 
    66dojo.declare("dojox.wire.ml.DataStore", 
    77        dijit.base.Widget, { 
  • wire/ml/Service.js

     
    55 
    66dojo.require("dijit.base.Widget"); 
    77dojo.require("dojox.data.dom"); 
    8 dojo.require("dojox.wire.common"); 
     8dojo.require("dojox.wire._base"); 
    99dojo.require("dojox.wire.ml.util"); 
    1010 
    1111dojo.declare("dojox.wire.ml.Service", 
  • wire/README

     
     1 
     2joX Wire 
     3------------------------------------------------------------------------------- 
     4Version 0.9 
     5Release date: 05/29/2007 
     6------------------------------------------------------------------------------- 
     7Project state: beta 
     8------------------------------------------------------------------------------- 
     9Project authors 
     10        Jared Jurkiewicz (jared.jurkiewicz@gmail.com) 
     11------------------------------------------------------------------------------- 
     12Project description 
     13 
     14The DojoX Wire project is a set of functions that build a generic data binding 
     15and service invocation library to simplify how data values across a wide 
     16variety of widget and non-widget JavaScript constructs are accessed, updated, 
     17and passed to and from services.  It also provides a set of widgets  
     18within the dojox.wire.ml package to allow for declarative data binding  
     19definitions in addition to the programmatic APIs. 
     20 
     21In essense, this project is an API to provide a simplified way of doing MVC 
     22patterns in the client. 
     23 
     24------------------------------------------------------------------------------- 
     25Dependencies: 
     26 
     27DojoX Wire has dependencies on core dojo, the dijit widget system (for classes  
     28in the dojox.wire.ml package), dojox.data, and the D.O.H. unit test framework. 
     29------------------------------------------------------------------------------- 
     30Documentation: 
     31 
     32See the Dojo API tool (http://dojotoolkit.org/api) 
     33------------------------------------------------------------------------------- 
     34Installation instructions 
     35 
     36Grab the following from the Dojo SVN Repository: 
     37http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/wire.js 
     38http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/wire/* 
     39 
     40Install into the following directory structure: 
     41/dojox/wire/ 
     42 
     43...which should be at the same level as your Dojo checkout. 
     44 
     45It should look like: 
     46/dojox/wire.js 
     47/dojox/wire/* 
     48 
     49Require in dojox.wire for all baseline functions (dojox.wire.connect,  
     50dojox.wire.register, etc).  For specific Wire classes, 
     51require in the appropriate dojox.wire.<Class>. 
     52------------------------------------------------------------------------------- 
     53