neyric/wireit

View on GitHub
sandbox/guide.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>WireIt 3 guide</title>
    
    <meta name="author" content="Eric Abouaf" />
    <meta name="copyright" content="Copyright 2006-2012 Eric Abouaf" />
    <meta name="keywords" content="wireit,javascript,library,pipes,visualization,yui,programming,canvas,wire,wires,framework,webdev,ajax,ui,web,graphics,graph,graphs,opensource,tools" />
    <meta name="description" content="WireIt is an open-source javascript library to create web wirable interfaces for dataflow applications, visual programming languages or graphical modeling." />
    
    <link rel="alternate" type="application/rss+xml" title="WireIt blog" href="http://neyric.com/feed/" />
    <link rel="shortcut icon" type="images/x-icon" href="res/favicon.ico" />
    
    <link rel="stylesheet" type="text/css" href="res/SyntaxHighlighter/shCore.css" />    
    <link type="text/css" rel="stylesheet" href="res/SyntaxHighlighter/shThemeDefault.css" id="shTheme"/>
    
    <script type="text/javascript" src="res/SyntaxHighlighter/shCore.js"></script>
    <script type="text/javascript" src="res/SyntaxHighlighter/shBrushJScript.js"></script>
    <script type="text/javascript" src="res/SyntaxHighlighter/shBrushXml.js"></script>
    <script type="text/javascript" src="res/SyntaxHighlighter/shBrushCss.js"></script>
    <script type="text/javascript">SyntaxHighlighter.config.clipboardSwf = 'res/SyntaxHighlighter/clipboard.swf';SyntaxHighlighter.all();</script>
    
    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Le styles -->
    <link href="res/bootstrap.min.css" rel="stylesheet">
    <style type="text/css">
      body {
        padding-top: 60px;
      }
    </style>

    <!-- Le fav and touch icons -->
    <!--link rel="apple-touch-icon" href="images/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png"-->
  </head>

  <body>

    <div class="topbar">
      <div class="topbar-inner">
        <div class="container-fluid">
          <a class="brand" href="#">WireIt library</a>
          <ul class="nav">
            <li><a href="index.html">Home</a></li>
            <li class="active"><a href="guide.html">Guide</a></li>
            <li><a href="api/index.html">API Documentation</a></li>
            <li><a href="https://github.com/neyric/wireit/">GitHub</a></li>
            <li><a href="https://github.com/neyric/wireit/issues">Issues</a></li>
            <li><a href="http://neyric.com/category/wireit/">Blog</a></li>
            <li><a href="http://groups.google.com/group/wireit/">Forums</a></li>
          </ul>
        </div>
      </div>
    </div>

    <div class="container-fluid">
      <div class="sidebar">
        <div class="well">
          <h5>Sidebar</h5>
          <ol class="topLevel">
                <li>
                    <a href="#overview"><span>Overview</span></a>

                    <ul class="secondLevel">
                    <li><a href="#presentation">Presentation</a></li>
                        <li><a href="#terminology">Terminology</a></li>
                        <li><a href="#components">Core components and widgets</a></li>
                        <li><a href="#plugins">Plugins</a></li>
                    </ul>
                </li>    

                <li>
                    <a href="#GettingStarted"><span>Getting Started</span></a>

                    <ul class="secondLevel">
                    <li><a href="#installation">Installation</a></li>
                        <li><a href="#directoryStructure">Directory structure</a></li>
                    <li><a href="#firstApp">Create Your First WireIt Application</a></li>
                    </ul>
                </li>

                <li>
                    <a href="#visualLanguage"><span>Create your visual language</span></a>

                    <ul class="secondLevel">
                        <li><a href="#xtypeConvention"><i>xtype</i> convention</a></li>
                        <li><a href="#customizingWiresAndTerminals">Customizing Wires and Terminals</a></li>
                        <li><a href="#visualLanguageDefinition">Visual Language Definition</a></li>
                        <li><a href="#moduleDefinition">Module Definition</a></li>
                        <li><a href="#BaseContainer">Using the basic Container</a></li>
                        <li><a href="#InOutContainer">Using InOutContainer</a></li>
                        <li><a href="#FormContainer">Using FormContainer</a></li>
                        <li><a href="#ImageContainer">Using ImageContainer</a></li>
                        <li><a href="#propertiesForm">Edit the "Properties" form</a></li>
                        <li><a href="#stylingContainers">Styling containers</a></li>
                    </ul>
                </li>


                <li>
                    <a href="#adapters"><span>Adapters - Connecting to another database or backend</span></a>

                    <ul class="secondLevel">
                        <li><a href="#adaptersIntroduction">Introduction</a></li>
                        <li><a href="#adaptersConfiguration">Configuring the adapter</a></li>
                        <li><a href="#ajaxAdapter">Ajax adapter</a></li>
                        <li><a href="#jsonRPCAdapter">Json-RPC Adapter</a></li>
                        <li><a href="#gearsAdapter">Gears adapter</a></li>
                    <li><a href="#adaptersCreation">Create an adapter</a></li>
                    </ul>
                </li>

                <li>
                    <a href="#wirings"><span>Working with Wirings</span></a>

                    <ul class="secondLevel">
                        <li><a href="#outputFormat">WiringEditor ouput format</a></li>
                        <li><a href="#convertFormat">Converting the format</a></li>
                        <li><a href="#storage">Storing wirings</a></li>
                    </ul>
                </li>


                <li>
                    <a href="#containers"><span>Creating custom Containers</span></a>

                    <ul class="secondLevel">
                        <li><a href="#yuiInheritance">YUI Inheritance</a></li>
                        <li><a href="#createContainers">Creating new Containers / Extending existing containers</a></li>
                        <li><a href="#logicgates">Example - Logic Gates</a></li>
                    </ul>
                </li>

                <li>
                    <a href="#composablePlugin"><span>The <i>Composable</i> plugin</span></a>

                    <ul class="secondLevel">
                        <li><a href="#composableIntro">Introduction</a></li>
                        <li><a href="#composableHow">How does it work</a></li>
                    </ul>
                </li>


                <li>
                    <a href="#advancedTopics"><span>Advanced Topics</span></a>

                    <ul class="secondLevel">
                        <li><a href="#autoload">WiringEditor autoload feature</a></li>
                        <li><a href="#mouseEvents">Handling Wire mouse events</a></li>
                        <li><a href="#production">notes on production</a></li>
                    </ul>
                </li>


                <li>
                    <a href="#contribute"><span>Contribute</span></a>

                    <ul class="secondLevel">
                        <li><a href="#issues">Reporting an Issue</a></li>
                        <li><a href="#documentation">Contributing to the Documentation</a></li>
                        <li><a href="#code">Contributing to the Code</a></li>
                        <li><a href="#contributors">Contributors</a></li>
                        <li><a href="#donate">Donate</a></li>
                        <li><a href="#roadmap">Roadmap</a></li>
                    </ul>
                </li>

                <li>
                    <a href="#moreInformation"><span>Other resources</span></a>

                    <ul class="secondLevel">
                        <li><a href="#examples">All examples</a></li>
                        <li><a href="#apiReferences">API References</a></li>
                        <li><a href="#otherResources">Other resources</a></li>
                        <li><a href="#projects">WireIt-based projects</a></li>
                    </ul>
                </li>


            </ol>
            
        </div>
      </div>
      <div class="content">
        
        <div class="row">
          <div class="span16">
              <h1>WireIt Guide</h1>
              
              <div class="alert alert-error">
                <p>Warning: the Guide is not up-to-date for the WireIt 3 version...</p>
                <p>This doc is still a work in progress</p>
              </div>
              
              <h2>Overview</h2>
              
              <p>WireIt is an open-source javascript library to create web wirable interfaces for dataflow applications, visual programming languages, graphical modeling, or graph editors.</p>
              
              <p>WireIt heavily relies on the YUI3 framework.</p>
              
              
              <h2>Terminology</h2>
              
              <!--center>
                  <div style="width:425px;text-align:left" id="__ss_1835190">
                      <object style="margin:0px" width="425" height="355">
                          <param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=wireitpresentation-090810065216-phpapp02&stripped_title=wire-it-050-presentation" />
                          <param name="allowFullScreen" value="true"/>
                          <param name="allowScriptAccess" value="always"/>
                          <embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=wireitpresentation-090810065216-phpapp02&stripped_title=wire-it-050-presentation" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed>
                      </object>
                  </div>
                  </center-->
              
          </div>
        </div>
        
        
        <div class="row">
          <div class="span16">
              
              
              <a name="overview"><h1>1 Overview</h1></a>

              <a name="presentation"><h2>1.1 Presentation</h2></a>

              <p>WireIt is an open-source javascript library to create <i>web wirable interfaces</i> for <b>dataflow applications</b>, <b>visual programming languages, graphical modeling,</b> or <b>graph editors</b>.</p>

              <p>WireIt is tested on all <a href="http://developer.yahoo.com/yui/articles/gbs/">A-Grade Browsers</a>, although it might work with older versions of browsers and platforms. Please report your issues with specific browsers in <a href="http://groups.google.com/group/wireit/">the forum</a>.</p> 

              <p>It uses the <a href="http://developer.yahoo.com/yui/">YUI library</a>, the <a href="http://neyric.github.com/inputex/">inputEx library</a> for forms and fields, and <a href="http://excanvas.sourceforge.net/">excanvas</a> for IE support of the canvas tag.</p>


              <p>The code for Wireit is provided under <a href="license.txt">MIT license</a>.</p>


              <a name="terminology"><h2>1.2 Terminology</h2></a>

              <p>This section defines some concepts that will be used throughout this guide.</p>

              <h3>Wires and Terminals</h3>

              <p><i>Wires</i> are pretty explicit. They connect two <i>Terminals</i> together :</p>

              <img src="res/guide/wire_terminals.png" /><br />


              <p><i>Terminals</i> are responsible for the graph edition :</p>

              <ul>
                  <li>You can create a Wire by dragging a terminal to another one</li>
                  <li>You can destroy all the wires connected to a terminal by clicking on the scissors</li>
              </ul>

              <p><i>Terminals</i> have various configuration options, such as the number of wires that can be connected to them, wether they are editable or not, or style informations about the wires that are connected. <a href="examples/wires_and_terminals.html">Check out this example to see some of those properties in action.</a></p>

              <div class="alert-message block-message info"><p>At this time, two <i>Terminals</i> can only be connected using one <i>Wire</i> only.</p></div>


              <h3>Containers</h3>

              <p><i>Containers</i> are "boxes", containing one or more <i>Terminals</i>. <i>Containers</i> are willingly generic, so that an application can easily create custom <i>Containers</i>.</p>

              <div class="alert-message block-message info"><p>See the chapter <a href="#createContainers"><i>Creating new containers/Extending existing containers</i></a>.</p></div>



              <h3>Layer</h3>

              <p>A <i>Layer</i> handles multiple containers and connected wires. It keeps an internal representation of the whole graph and is responsible for <b>saving/loading a graph</b>.</p>

              <br />

              <a name="components"><h2>1.3 Core components and widgets</h2></a>

              <p>WireIt is able to draw several types of wires :</p>

              <ul>
                  <li>Straight - draws a straight line</li>
                  <li>Bezier - using bezier curves</li>
                  <li>Arrow - for directed directed graphs</li>
                  <li>BezierArrow - a mix of the two above</li>
                  <li>Step - using only horizontal and vertical lines</li>
              </ul>


              <p>Different types of Container are provided :</p>
              <ul>
                  <li>InOutContainer - simple module with named inputs and outputs</li>    
                  <li>ImageContainer - use images as graph nodes</li>
                  <li>FormContainer - displays a form with wirable inputs (optional). (requires the <i>inputEx plugin</i>)</li>
              </ul>

              <img src="res/guide/containers.png" /><br />    

              <div class="alert-message block-message info"><p>You can create your own <i>Containers</i> by subclassing the base <i>Container</i> class.<br />
                   See the chapter <a href="#createContainers"><i>Creating new containers/Extending existing containers</i></a>.</p></div>


              <a name="plugins"><h2>1.4 Plugins</h2></a>

              <p>Introduced in version 0.6.0, plugins are separated from the core components to build <i>à la carte</i> applications. <br />
                  All plugins are optional, although some of them have dependencies to others.</p>


              <h3>1.4.1 The inputEx plugin</h3>

              <p>The <a href="http://neyric.github.com/inputex/">inputEx library</a> and WireIt share the same creator, and their dependency to YUI. inputEx is an open-source javascript framework to build fields and forms. All the fields and forms are configured using JSON or created in Javascript. It provides a very efficient abstraction for building interactive web applications.</p>

              <p>The inputEx plugin, besides containing the inputEx library, adds two major components :</p>

              <ul>
                  <li>WirableField - replace the root inputEx.Field class to add a <i>Terminal</i>, to "wire" the field (optional)</li>
                  <li>FormContainer - build form containers based on <a href="http://neyric.github.com/inputex/">inputEx</a> forms</li>
              </ul>


              <h3>1.4.2 The editor plugin</h3>

              <p>The editor plugin provides another very useful component: the <b>WiringEditor</b>.<br />
                   It provides the common features of most visual editors for <i>your visual language</i>.</p>

              <center>
                  <img src="res/guide/editor2.png" />
                  <br /><br />
                  <img src="res/guide/editor.png" />
              </center>


              <div class="alert-message block-message info"><p>The WiringEditor requires a connection to a database or file system to use save/load features. You can customize it using <a href="#adapters">Adapters</a>.</p></div>


              <h3>1.4.3 Other plugins</h3>


              <ul>
                  <li>animations - utility to provide YUI Animations on any DOM element containing terminals</li>
                  <li>composable - extends the WiringEditor with composable wirings (a wiring can use other wirings)</li>
                  <li>grouping - extends the WiringEditor with module grouping feature (if you have large wirings)</li>
                  <li>layout - provide functions to layout the Layer</li>
              </ul>

              <div class="alert-message block-message info"><p>Read the README.md file of each plugin to learn more about them !</p></div>


              <br /><br />



              <a name="GettingStarted"><h1>2 Getting Started</h1></a>


              <p>Most of this guide explain the usage and customization of the WiringEditor. If you are not using it, you will still learn about customizing/creating containers, and the Wires/Terminals options.</p>


              <a name="installation"><h2>2.1 Installation</h2></a>

              <p>WireIt is mostly a bunch of static javascript, css, and image files, so you can just <a href="https://github.com/neyric/wireit/downloads">download the latest version of the library</a> and put the files in your project library directory.</p>

              <p>However, the WiringEditor requires a database connection to use the save/load features. (see <a href="#WiringEditorInstallation">WiringEditor installation</a>)</p>


              <div class="alert-message block-message info"><p>You could also clone the <a href="https://github.com/neyric/wireit">development repository</a> to get the edge version.</p></div>

              <div class="alert-message block-message info"><p>In a production environment, documentation and examples are not necessary. More on this in <a href="#production">production</a>.</p></div>



              <a name="directoryStructure"><h2>2.2 Directory structure</h2></a>

              <table>
                  <thead>
                      <tr>
                          <th>file or directory</th>
                          <th></th>
                      </tr>
                  </thead>
                  <tbody>
                      <tr>
                          <td>api/</td>
                          <td>Auto-generated <a href="api/index.html">API documentation</a></td>
                      </tr>
                      <tr>
                          <td>assets/</td>
                          <td>Contains WireIt CSS and images</td>
                      </tr>
                      <tr>
                          <td>build/</td>
                          <td>Contains the minified javascript (More on this in <a href="#production">production</a>)</td>
                      </tr>
                      <tr>
                          <td>examples/</td>
                          <td>Examples or applications that are part of the library</td>
                      </tr>
                      <tr>
                          <td>images/</td>
                          <td>WireIt images</td>
                      </tr>
                      <tr>
                          <td>index.html</td>
                          <td>WireIt Home page</td>
                      </tr>
                      <tr>
                          <td>js/</td>
                          <td>javascript sources</td>
                      </tr>
                      <tr>
                          <td>lib/</td>
                          <td>librairies required by WireIt core</td>
                      </tr>
                      <tr>
                          <td>license.txt</td>
                          <td>MIT license details</td>
                      </tr>
                      <tr>
                          <td>plugins/</td>
                          <td>WireIt plugins directory</td>
                      </tr>
                      <tr>
                          <td>README.md</td>
                             <td>links for the GitHub page</td>
                      </tr>
                      <tr>
                          <td>res/</td>
                          <td>resources for WireIt website and documentation</td>
                      </tr>
                      <tr>
                          <td>scripts/</td>
                          <td>scripts to build rollup files and documentation</td>
                      </tr>
                      <tr>
                          <td>VERSION.txt</td>
                          <td>change log</td>
                      </tr>
              </tbody>
              </table>





              <a name="firstApp"><h2>2.3 Create Your First WireIt Application</h2></a>

              <p>The easiest way to start creating your visual language is to copy one of the editor example from the <i>plugins/editor/examples</i> directory.</p>

              <p>Depending on which default adapter you decided to use, copy the examples/gearsAdapter/ or examples/WiringEditor/ files into your project directory. (more on <a href="#adapters">Adapters</a>)</p>

              <p>Edit the index.html file you copied to check that the paths to javascript and css files are correct. (You might want to create your project directory directly in the examples/ folder so that the paths remain unchanged.)</p>

              <p>Setup a webserver to serve your files and launch the index.html file in your browser. You're ready to create your <a href="#visualLanguage">visual language</a> !</p>

              <div class="alert-message block-message info"><p>The <a href="#gearsAdapter">Gears Adapter</a> is handy for prototyping the interface since it doesn't require a backend. Make sure you have <a href="http://gears.google.com">Google Gears</a> installed.</p></div>





              <br /><br />

              <a name="visualLanguage"><h1>3 Create your visual language</h1></a>


              <a name="xtypeConvention"><h2>3.1 <i>xtype</i> convention</h2></a>

              <p>WireIt uses a convention to simplify extending widgets:<br />
                  <b style="font-size: 120%;">wires, terminals and containers are instantiated from the class specified by the <i>xtype</i> property</b>.</p>

              <p>It lets you create specialized widgets by creating a subclass and using it simply from your language definition.</p>

              <div class="alert-message block-message info"><p>This choice was made to transport the definition using JSON.</p></div>

              <a name="customizingWiresAndTerminals"><h2>3.2 Customizing Wires and Terminals</h2></a>

              <p>Many options are available to customize Wires and Terminals, but the general pattern is simple: you create a subclass of the Wire named <i>WeirdWire</i>, you use it using the xtype property :</p>

              <pre class="brush:js">
                  Terminal.prototype.wireConfig = {"xtype":"WeirdWire", "weirdness": 7};
              </pre>

              <p>The code above overrides the default Wire configuration for <b>all</b> terminals on the page.</p>

              <p>If you want to use this configuration only on specified wires, you can make it default for "some" terminals. You need to subclass the terminal to set your new config as default. An exemple is actually included in the library.</p>

              <p>For a concrete example, let's see how the TerminalOutput works :</p>

              <pre class="brush:js">
                  // use YUI class inheritance
                  Y.TerminalOutput = function(parentEl, options, container) {
                     Y.TerminalOutput.superclass.constructor.call(this,parentEl, options, container);
                  };
                  Y.extend(Y.TerminalOutput, Y.Terminal, {
                     xtype: "Y.TerminalOutput",

                       // override some options
                       direction: [0,1],
                       fakeDirection: [0,-1],
                       ddConfig: { type: "output", allowedTypes: ["input"] },
                         alwaysSrc: true
                  });</pre>

              <p>Simple enough. What this says is: Create a TerminalOutput class which extends the Terminal widget, set the direction from top to bottom, and connect only to "input" terminals. The <i>alwaysSrc</i> option force this terminal as being the "source" terminal in the wire definition.</p>


              <p><b>How do we handle the wire creation ? What are the options ?</b></p>

              <p>The idea is to create a Drag'n Drop proxy element (we do not move the original Terminal, but a copy of it).</p>

              <p>When we start dragging the proxy element, a <i>fake</i> terminal is created within, which we can move around. A wire is added between those two terminals.</p>

              <p>You can change the default wiring config using the <i>editingWireConfig</i> property :</p>

              <pre class="brush:js">
                  WeirdTerminal = function(parentEl, options, container) {
                     WeirdTerminal.superclass.constructor.call(this,parentEl, options, container);
                  };
                  Y.extend(WeirdTerminal, Y.Terminal, {
                     xtype: "WeirdTerminal",

                       wireConfig: {"xtype":"WeirdWire", "weirdness": 7},
                       editingWireConfig: {"xtype":"WeirdWire", "weirdness": 13},
                       direction: [1,1],
                       fakeDirection: [-1,-1]

                  });
              </pre>

              <div class="alert-message block-message info"><p>For a complete list of the properties, please refer to the API documentation for <a href="api/WireIt.Terminal.html">Terminal</a>, <a href="api/WireIt.Wire.html">Wire</a> or <a href="api/WireIt.Container.html">Container</a>.</p></div>


              <a name="visualLanguageDefinition"><h2>3.3 Visual Language Definition</h2></a>

              <p>Your visual language is defined by a JSON object :</p>

              <pre class="brush:js">
                  var myLanguageDef = {

                      // Set a unique name for your language
                      languageName: "myLanguage",


                      // modules: list of module type definitions
                      modules: [
                              {
                                  name: "module1",
                                  container: {"xtype":"Y.InOutContainer", ...}
                              },
                              ...
                      ]
                  };
              </pre>

              <p>This language definition is passed to the WiringEditor constructor :</p>

              <pre class="brush:js">
                YUI_config.groups.wireit.base = '../src/';
                YUI({filter: 'raw', combine: false}).use('wire', 'bezier-wire', 'terminal', function(Y) {
                      try {
                          logicGates = new Y.WiringEditor(myLanguageDef); 
                      }catch(ex) {
                          alert(ex);
                      }
                  });
              </pre>


              <a name="moduleDefinition"><h2>3.4 Module Definition</h2></a>

              <p>Here is the skeleton of a module definition :</p>

              <pre class="brush:js">
              {
               "name": "moduleName",

                // properties of the container
                "container": {

                      // which container class to use
                      "xtype":"Y.InOutContainer",

                      // The options depends of the container class used in xtype
                      "inputs": ["text1", "text2", "option1"],
                      "outputs": ["result", "error"]
                }
              }
              </pre>


              <p>To declare a module using a different <i>Container</i> class, you'll have to set the container <i>xtype</i> property.</p>

              <div class="alert-message block-message info"><p>The xtype property is a string representing the class. This had to be a string to remain JSON compliant.</p></div>

              <p>Of course, you can use containers provided in WireIt (ImageContainer, FormContainer, InOutContainer), or a <a href="#containers">custom container</a>.</p>


              <a name="BaseContainer"><h2>3.5 Using the basic Container</h2></a>


              <p>Set "xtype": "WireIt.Container" (optional). The parameters are :</p>

              <ul>
                  <li><i>icon</i> - url of the icon (relative or absolute)</li>
                  <li><i>terminals</i> - list of terminals configuration</li>
              </ul>

              <pre class="brush:js">
                  {
                     "name": "demoModule",
                     "container": {
                          "xtype":"Y.Container", 

                          "icon": "../../assets/application_edit.png",
                          "terminals": [
                              {"name": "_INPUT1", "direction": [-1,0], "offsetPosition": {"left": -3, "top": 2 }},
                              {"name": "_INPUT2", "direction": [-1,0], "offsetPosition": {"left": -3, "top": 37 }},
                              {"name": "_OUTPUT", "direction": [1,0], "offsetPosition": {"left": 103, "top": 20 }}
                          ]
                      }
                  }
              </pre>

              <div class="alert-message block-message info"><p>All other Container classes inherits from this base class, and therefore share the above options.</p></div>


              <a name="InOutContainer"><h2>3.6 Using InOutContainer</h2></a>

              <p>Set "xtype": "WireIt.InOutContainer". Additional parameters are :</p>

              <ul>
                  <li><i>inputs</i> - list of inputs as strings</li>
                  <li><i>outputs</i> - list of outputs as strings</li>
              </ul>

              <p>Example: </p>

              <pre class="brush:js">
              {
               "name": "InOut test",
               "container": {
                  "xtype":"Y.InOutContainer",
                  "inputs": ["text1", "text2", "option1"],
                  "outputs": ["result", "error"]
                }
              }
              </pre>


              <a name="FormContainer"><h2>3.7 Using FormContainer</h2></a>

              <p>Set "xtype": "Y.FormContainer". Additional parameters are all those used in inputEx.Group. (see <a href="http://neyric.github.com/inputex/">inputEx</a>)</p>


              <pre class="brush:js">
                  {
                    "name": "MyModule",
                    "container": {
                      "xtype": "Y.FormContainer",

                      // inputEx options :
                      "title": "Y.FormContainer demo",
                      "collapsible": true,
                      "fields": [ 
                          {"type": "select", "label": "Title", "name": "title", "selectValues": ["Mr","Mrs","Mme"] },
                          {"type": "string", "label": "Firstname", "name": "firstname", "required": true }, 
                          {"type": "string", "label": "Lastname", "name": "lastname", "value":"Dupont"}, 
                          {"type":"email", "label": "Email", "name": "email", "required": true, "wirable": true }, 
                          {"type":"boolean", "label": "Happy to be there ?", "name": "happy" }, 
                          {"type":"url", "label": "Website", "name":"website", "size": 25 } 
                      ],
                      "legend": "Tell us about yourself..."

                    }
                  }
              </pre>    


              <a name="ImageContainer"><h2>3.8 Using ImageContainer</h2></a>

              <p>Set "xtype": "WireIt.ImageContainer". Additional parameters are :</p>

              <ul>
                  <li><i>image</i> - url of the image (relative or absolute)</li>
              </ul>

              <pre class="brush:js">
                  {
                     "name": "AND gate",
                     "container": {
                          "xtype":"Y.ImageContainer", 
                          "image": "../logicGates/images/gate_and.png",
                          "terminals": [
                              {"name": "_INPUT1", "direction": [-1,0], "offsetPosition": {"left": -3, "top": 2 }},
                              {"name": "_INPUT2", "direction": [-1,0], "offsetPosition": {"left": -3, "top": 37 }},
                              {"name": "_OUTPUT", "direction": [1,0], "offsetPosition": {"left": 103, "top": 20 }}
                          ]
                      }
                  }
              </pre>





              <a name="propertiesForm"><h2>3.9 Edit the "Properties" form</h2></a>

              <p>To add properties to the <i>Wirings</i>, we configure the <i>propertiesFields</i> property of the language definition.<br />
                 This property defines the fields as they will appear in the "Properties" form on the right in the WiringEditor.</p>

              <p>The form is created using the <a href="http://neyric.github.com/inputex/">inputEx form library</a>. The <i>propertiesFields</i> array is directly used to instantiate a inputEx.Group class. Please refer to inputEx documentation to learn how to configure your fields.</p>

              <p>When you use the save/load fetures of the WiringEditor, the form values are automatically saved within your <i>wirings</i> before being sent back to the server.</p>

              <pre class="brush:js">
                  var demoLanguage = {

                      languageName: "meltingpotDemo",

                      // inputEx fields for pipes properties
                      propertiesFields: [
                          // default fields (the "name" field is required by the WiringEditor):
                          {"type": "string", "name": "name", label: "Title", typeInvite: "Enter a title" },
                          {"type": "text", "name": "description", label: "Description", cols: 30},

                          // Additional fields
                          {"type": "boolean", "name": "isTest", value: true, label: "Test"},
                          {"type": "select", "name": "category", label: "Category", selectValues: ["Demo", "Test", "Other"] }
                      ],

                      modules: [
                          //...
                      ]
                  };
              </pre>

              <div class="alert-message block-message info"><p>The HiddenField can be used to store additional wirings informations.</p></div>





              <a name="stylingContainers"><h2>3.10 Styling containers</h2></a>

              <p>The WiringEditor adds a CSS class for each module instance in your layer: <b>WiringEditor-module-<i>moduleName</i></b>.</p>

              <p>You can therefore style all the descending structure using cascaded style sheets. <br />
                 Here is an exemple for the "comment" module of the <a href="examples/WiringEditor/">WiringEditor demo</a>.</p>

              <pre class="brush:css">

              /* Comment Module */
              div.WireIt-Container.WiringEditor-module-comment { 
                  width: 200px; 
              }
              div.WireIt-Container.WiringEditor-module-comment div.body { 
                  background-color: #EEEE66; 
              }
              div.WireIt-Container.WiringEditor-module-comment div.body textarea { 
                  background-color: transparent; font-weight: bold; border: 0; 
              }

              </pre>






              <br /><br />

              <a name="adapters"><h1>4 Adapters - Connecting to another database or backend</h1></a>


              <!--a name="WiringEditorInstallation"><h2>2.2 WiringEditor installation</h2></a>

              <p>The WiringEditor requires a database connection to use the save/load features. <br />
                 The database connection can be adapted to your project though <a href="#adapters">adapters</a>.</p> 

              <p>Adapters themselves don't require any particular installation, however, they are connected to a <i>backend</i>, which often require a specific server environment.</p>

              <p>Please refer to the <a href="#adapters">adapters documentation</a> to install the associated backends.</p>

              <div class="alert-message block-message info"><p>You can <a href="#adaptersCreation">create your own adapters</a>.</p></div-->


              <a name="adaptersIntroduction"><h2>4.1 Introduction</h2></a>

              <p>Adapters are used by the WiringEditor to provide the loading/saving features. It makes it easy to "plug" the WiringEditor into your application. They usually connect to a database of some kind through Ajax calls to store the wirings and bring them back.</p>


              <p>WireIt provides default adapters to get you started :</p>


              <ul>
                  <li><a href="#ajaxAdapter">Ajax Adapter (no backend provided)</a></li>
                  <li><a href="#jsonRPCAdapter">Json-RPC Adapter + a sample PHP/MySQL backend</a></li>
                  <li><a href="#gearsAdapter">Gears Adapter (no backend required)</a></li>
              </ul>



              <a name="adaptersConfiguration"><h2>4.2 Configuring the adapter</h2></a>

              <pre class="brush:js">

                  // Override adapter default parameters
                  Y.WiringEditor.adapters.MyAdapter.config.configParam1 = value1;

                  // Instantiate the WiringEditor with a custom adapter
                  new Y.WiringEditor({
                      ...
                      adapter: Y.WiringEditor.adapters.MyAdapter
                      ...
                  })

              </pre>    



              <a name="ajaxAdapter"><h2>4.3 Ajax Adapter</h2></a>

              <p>This adapter is the general way to connect to a custom backend through Ajax (or XHR) calls. It uses a JSON representation.</p>

              <p>You can use it to connect to a REST resource store or any HTTP-based RPC backend.</p>

              <p>The <a href="examples/ajaxAdapter/">ajaxAdapter example</a> connects to a fake backend (the queried URLs are static files), but demonstrate how to configure the adapter :</p>

              <pre class="brush:js">

                  Y.WiringEditor.adapters.Ajax.config =     {
                      saveWiring: {
                          method: 'GET',
                          // The url can be hard-coded
                          url: 'fakeSaveDelete.json'
                      },
                      deleteWiring: {
                          method: 'GET',
                          /**
                           * 'url' can also be a function that returns the URL as a string.
                           * For exemple, to connect to a REST store, you might want to send a DELETE /resource/wirings/moduleName
                           * (moduleName is present in the "value" parameter)
                           */
                          url: function(value) {
                              return "fakeSaveDelete.json";
                          }
                      },
                      listWirings: {
                          method: 'GET',
                          url: 'listWirings.json'
                      }
                  };
              </pre>




              <a name="jsonRPCAdapter"><h2>4.4 Json-RPC Adapter</h2></a>

              <p>This adapter uses Ajax calls as the previous one, but wraps http requests in a JSON-RPC envelope.</p>

              <p>This adapter is used in the <a href="examples/WiringEditor/">WiringEditor demo</a>.</p>

              <p>It is connected to a sample PHP/MySQL backend, which requires the following installtion steps :</p>

              <ul>
                  <li>copy the backend/php directory to your wireit directory</li>
                  <li>edit the script with your database access config (backend/php/WiringEditor.php)</li>
                  <li>make sure the backend files are accessible by your webserver and that the php module is loaded </li>
              </ul>

              <p>The JSON-RPC adapter configuration resides in the single service url :</p>

              <pre class="brush:js">
                  Y.WiringEditor.adapters.JsonRpc.config.url = '/my/json-rpc/serviceUrl';
              </pre>



              <a name="gearsAdapter"><h2>4.5 Gears Adapter</h2></a>

              <p>This adapter uses the <i>database</i> component of Google Gears to store the <i>wirings</i> in a SQLite table <b>client-side</b> (in the browser).</p>

              <p>This adapter is very useful for prototyping your project, since it can be used without any server installation.</p>

              <p>To use this adapter, you must install <a href="http://gears.google.com">google gears</a>.</p>

              <p>A demo of this adapter is showed in the <a href="plugins/editor/examples/gearsAdapter/">gears adapter example</a>.</p>

              <p>This adapter doesn't have any noticeable configuration except <i>WireIt.WiringEditor.adapters.Gears.config.dbName</i> which contains the gears database name (default is 'database-test').</p>

              <div class="alert-message block-message info"><p>The gears adapter already includes gears-init.js</p></div>


              <a name="adaptersCreation"><h2>4.6 Create an adapter</h2></a>

              <p>Why would you build your own ?</p>

              <ul>
                  <li>You use a different server-side language</li>
                  <li>You probably use a framework to develop your website, which provides its own models (ex: Django,Rails,Symfony,...)</li>
                  <li>Convert the wirings into another workflow model. (ex: XProc XML)</li>
              </ul>

              <p>Here is the skeleton of an adapter :</p>

              <pre class="brush:js">

              Y.WiringEditor.adapters.MyAdapter = {

                  // adapter default options
                  config: {
                      // ...
                  },

                  // Initialization method called by the WiringEditor
                  init: function() {

                  },

                  /**
                   * save/list/delete asynchronous methods
                   */
                  saveWiring: function(val, callbacks) {
                      // ...
                      // don't forget to call the callbacks !
                  },

                  deleteWiring: function(val, callbacks) {
                      // ...
                      // don't forget to call the callbacks !
                  },

                  listWirings: function(val, callbacks) {
                      // ...
                      // don't forget to call the callbacks !
                  }

                  // + private methods or properties
              };

              })();
              </pre>

              <p>The main three methods use asynchronous callbacks to push back the results to the WiringEditor. Here is the structure of the callbacks that are passed to these methods : </p>

              <pre class="brush:js">
                  var callbacks = {
                      success: function() {
                      },
                      failure: function() {
                      },
                      scope: this
                  };
              </pre>


              <p>To call the callbacks, in a synchronous way, use something like :</p>

              <pre class="brush:js">
                  function(val, callbacks) {

                      if(everythingGoesFine) {
                          callbacks.success.call(callbacks.scope, results);
                      }
                      else {
                          callbacks.failure.call(callbacks.scope, results);
                      }

                  }
              </pre>


              <br /><br />

              <a name="advancedTopics"><h1>5 Working with Wirings</h1></a>


              <a name="outputFormat"><h2>5.1 WiringEditor ouput format</h2></a>

              <p>First, here is the JSON output of the WiringEditor :</p>

              <pre class="brush:js">
              var working = {
                  "modules":[
                      {
                          "config":{
                              "position":[166,195],
                              "xtype":"Y.ImageContainer"
                          },
                          "name":"AND gate",
                          "value":{}
                      },
                      {
                          "config":{
                              "position":[454,271],
                              "xtype":"Y.ImageContainer"
                          },
                          "name":"AND gate",
                          "value":{}
                      },
                      {
                          "config":{
                              "position":[149,403],
                              "xtype":"Y.ImageContainer"
                          },
                          "name":"AND gate",
                          "value":{}
                      }
                  ],

                  "wires":[
                      {
                          "src":{"moduleId":0,"terminal":"_OUTPUT"},
                          "tgt":{"moduleId":1,"terminal":"_INPUT1"}
                      },
                      {
                          "src":{"moduleId":2,"terminal":"_OUTPUT"},
                          "tgt":{"moduleId":1,"terminal":"_INPUT2"}
                      }
                  ],

                  "properties":{    
                      "name":"demo",
                      "description":"",
                      "isTest":true,
                      "category":"Demo"
                  }
              };
              </pre>

              <p>First comes the list of instantiated modules. The <i>name</i> is set to the module name, <i>config.xtype</i> indicates the container class, <i>config.position</i> is pretty self-explanatory, and <i>value</i> contains the exported value for this instance (in this case it is empty, but for a FormContainer, it will contain the form value.)</p>

              <p>Secondly, the wires instances, composed of a <i>src</i> (source) terminal and a <i>tgt</i> (target) terminal.<br /> 
                 Each terminal is referenced by its moduleId (module index in the above definition) and its name (terminal).</p>

              <p>Finally, the <i>properties</i> object contains the value of the "Properties" form on the right of the editor.</p>

              <a name="convertFormat"><h2>5.2 Converting the format</h2></a>

              <p>Usually, the WiringEditor is used as a visual editor for another kind of system.</p>

              <p>You can convert the Wiring JSON to any other format, as long as you're able to rebuild the Wiring JSON format to edit the wiring in the editor.</p>

              <p>This conversion can occur in two places :</p>

              <ul>
                  <li>Client-side: by writing a <a href="#adapters">custom Adapter</a></li>
                  <li>Server-side: parse the incoming JSON and convert it</li>
              </ul>

              <a name="storage"><h2>5.3 Storing wirings</h2></a>

              <p>The examples store directly the wiring JSON in a TEXT column in the database. It makes it impossible to query using standard SQL.</p>

              <p>If you need to query the wirings, two options are available :</p>

              <ul>
                  <li>Parse the JSON (all programming languages now have decent JSON stringify/parse methods) and convert the wiring to another format. <br /> You will also need to convert your model back to the WireIt format to load it in the editor.<br /><br />(The <a href="https://github.com/tomfarm/graphpipes">GraphPipes</a> application for example stored the wirings into 3 different tables: pipes, nodes and edges.)<br /><br /></li>
                  <li>Use a JSON-based document database, such as <a href="http://couchdb.apache.org/">CouchDB</a> or <a href="http://www.mongodb.org/">mongoDB</a>.</li>
              </ul>


              <p></p>



              <br /><br />

              <a name="containers"><h1>6 Creating custom Containers</h1></a>

              <a name="yuiInheritance"><h2>6.1 YUI Inheritance</h2></a>

              <p>YUI 3 is used all over the place in Y.WireIt. We especially use <a href="http://developer.yahoo.com/yui/yahoo/#extend">Y.extend</a> for setting up the prototype, constructor, and superclass properties for objects that are extending other objects.</p>

              <p>The pattern for this type of inheritance is quite easy :</p>

              <pre class="brush:js">
                  Class1 = function(info) {
                      alert("Class1: " + info);
                  };

                  Class1.prototype.testMethod = function(info) {
                      alert("Class1: " + info);
                  };

                  Class2 = function(info) {
                      // chain the constructors
                      Class2.superclass.constructor.call(this, info);
                      alert("Class2: " + info);
                  };

                  // Class2 extends Class1.  Must be done immediately after the Class2 constructor
                  Y.extend(Class2, Class1);

                  Class2.prototype.testMethod = function(info) {
                      // chain the method
                      Class2.superclass.testMethod.call(this, info);
                      alert("Class2: " + info);
                  };

                  var class2Instance = new Class2("constructor executed");
                  class2Instance.testMethod("testMethod invoked");
              </pre>


              <a name="createContainers"><h2>6.2 Creating new Containers / Extending existing containers</h2></a>

              <p>The general way to create a new <i>Container</i> class is to extend the Y.Container class. We do this YUI-style :</p>

              <pre class="brush:js">
                  Y.MyContainer = function(options, layer) {
                     Y.MyContainer.superclass.constructor.call(this, options, layer);
                  };
                  Y.extend(Y.MyContainer, Y.Container, {

                      setOptions: function(options) {
                        MyContainer.superclass.setOptions.call(this, options);
                        this.options.xtype = "MyContainer";
                     }

                      // Override other methods or add new ones...

                  });
              </pre>

              <div class="alert-message block-message info"><p><u>Important :</u> you must override the <i>xtype</i> option as above for the editor to save the wiring using the right container class.</p></div>

              <div class="alert-message block-message info"><p>You can extend from Y.Container, Y.InOutContainer, Y.ImageContainer or Y.FormContainer. For more details about <i>WireIt.Container</i> methods, please refer to the <a href="api/WireIt.Container.html">Container API Documentation</a>.</p></div>


              <a name="logicgates"><h2>6.3 Example - Logic Gates</h2></a>

              <p>The <a href="plugins/editor/examples/logicGates/index.html">logic gates</a> application is a great example to create custom containers. The goal here is to make an interactive logic circuit.</p>

              <p>First, we create the <i>LogicContainer</i> class, which inherits <i>ImageContainer</i> :</p>

              <pre class="brush:js">
                  LogicContainer = function(opts, layer) {
                      LogicContainer.superclass.constructor.call(this, opts, layer);
                      this.logicInputValues = [];
                  };
                  Y.extend(LogicContainer, Y.ImageContainer, {

                      setOptions: function(options) {
                        LogicContainer.superclass.setOptions.call(this, options);
                        this.options.xtype = "LogicContainer";
                     }
                  });
              </pre>

              <p>The <i>logicInputValues</i> variable will keep the values of the input terminals.</p>

              <p>Then we add 3 functions : <i>setInput</i> is used to set the logic state of an input terminal, <i>setLogic</i> updates the output of the container and calls setInput on each connected component, and <i>switchStatus</i> simply inverts the output status of the container :</p>

              <pre class="brush:js">

                  setInput: function(bStatus,term) {
                          this.logicInputValues[term.options.name] = bStatus;

                          if(this.options.title == "AND") {
                              this.setLogic( this.logicInputValues["_INPUT1"] && this.logicInputValues["_INPUT2"]  );
                          }
                          else if (this.options.title == "OR") {
                              this.setLogic( this.logicInputValues["_INPUT1"] || this.logicInputValues["_INPUT2"]  );
                          }
                          else if (this.options.title == "NOT") {
                              this.setLogic(!this.logicInputValues["_INPUT"]);
                          }
                          else if (this.options.title == "NAND") {
                              this.setLogic( !(this.logicInputValues["_INPUT1"] && this.logicInputValues["_INPUT2"])  );
                          }
                          else if (this.options.title == "XOR") {
                              this.setLogic( (!this.logicInputValues["_INPUT1"] && this.logicInputValues["_INPUT2"]) ||
                                                    (this.logicInputValues["_INPUT1"] && !this.logicInputValues["_INPUT2"]) );
                          }
                      },

                      setLogic: function(bStatus) {
                          this.status = bStatus;

                          // Set the image
                          if(this.imageName) {
                              var image = this.imageName+"_"+(bStatus ? "on" : "off")+".png";
                              Y.one(this.bodyEl).setStyle("backgroundImage", "url(images/"+image+")");
                          }

                          // trigger the output wires !
                          for(var i = 0 ; i < this.terminals.length ; i++) {
                              var term = this.terminals[i];
                              if(term.options.name == "_OUTPUT") {
                                  for(var j = 0 ; j < term.wires.length ; j++) {
                                      var wire = term.wires[j];
                                      var otherTerm = wire.getOtherTerminal(term);
                                      if(otherTerm.container) {
                                          otherTerm.container.setInput(bStatus, otherTerm);
                                      }
                                      wire.options.color = bStatus ? "rgb(173,216,230)" : "rgb(255,255,255)";
                                      wire.redraw();
                                  }
                              }
                          }
                      },
                      switchStatus: function() {
                          this.setLogic(!this.status);
                      }


              </pre>


              <p>Then, we create containers that will inherit the <i>LogicContainer</i> class :</p>

              <pre class="brush:js">

              /**
               * ClockContainer will call the switchStatus method every 800ms
               */
              ClockContainer = function(opts, layer) {
                  ClockContainer.superclass.constructor.call(this, opts, layer);
                  this.imageName = "clock";    
                  var that = this;
                  setInterval(function() { that.switchStatus();    }, 800);
              };
              Y.extend(ClockContainer, LogicContainer, {
                  setOptions: function(options) {
                    ClockContainer.superclass.setOptions.call(this, options);
                    this.options.xtype = "ClockContainer";
                 }
              });

              /**
               * SwitchContainer will call the switchStatus method when the user click on it
               */
              SwitchContainer = function(opts, layer) {
                  SwitchContainer.superclass.constructor.call(this, opts, layer);
                  this.imageName = "switch";
                  Y.one(this.bodyEl).on("click", this.switchStatus, this, true);
              };
              Y.extend(SwitchContainer, LogicContainer, {
                  setOptions: function(options) {
                    SwitchContainer.superclass.setOptions.call(this, options);
                    this.options.xtype = "SwitchContainer";
                 }
              });

              /**
               * LightBulb will call the setLogic method to update its image each time the input value changes
               */
              LightbulbContainer = function(opts, layer) {
                  LightbulbContainer.superclass.constructor.call(this, opts, layer);
                  this.imageName = "lightbulb";
              };
              Y.extend(LightbulbContainer, LogicContainer, {
                  setInput: function(bStatus,term) {
                      this.setLogic(bStatus);
                  },
                  setOptions: function(options) {
                    LightbulbContainer.superclass.setOptions.call(this, options);
                    this.options.xtype = "LightbulbContainer";
                 }
              });

              </pre>

              <p>We can now write our language definition using the created container classes using the <i>xtype</i> attribute :</p>

              <pre class="brush:js">
                  var logicGatesLang = {    
                      languageName: "logicGates",
                      modules: [
                          {
                              "name": "AND",
                              "category": "gate",
                              "description": "AND Gate with 2 inputs",
                              "container" : {
                                  "xtype":"LogicContainer", 
                                  "icon": "../logicGates/images/gate_and.png",
                                  "image": "../logicGates/images/gate_and.png",
                                    "terminals": [
                                        {"name": "_INPUT1", "direction": [-1,0], "offsetPosition": {"left": -16, "top": -2 },"ddConfig": {"type": "input","allowedTypes": ["output"]}, "nMaxWires": 1 },
                                        {"name": "_INPUT2", "direction": [-1,0], "offsetPosition": {"left": -16, "top": 25 },"ddConfig": {"type": "input","allowedTypes": ["output"]}},
                                        {"name": "_OUTPUT", "direction": [1,0], "offsetPosition": {"left": 65, "top": 12 },"ddConfig": {"type": "output","allowedTypes": ["input"]}}
                                    ]
                              }
                          },
                          {
                            "name": "OR",    
                              "category": "gate",
                              "description": "OR Gate with 2 inputs",
                              "container": {
                                     "xtype":"LogicContainer", 
                                     "icon": "../logicGates/images/gate_or.png",
                                     "image": "../logicGates/images/gate_or.png",
                                      "terminals": [
                                          {"name": "_INPUT1", "direction": [-1,0], "offsetPosition": {"left": -16, "top": -2 },"ddConfig": {"type": "input","allowedTypes": ["output"]}, "nMaxWires": 1 },
                                          {"name": "_INPUT2", "direction": [-1,0], "offsetPosition": {"left": -16, "top": 25 },"ddConfig": {"type": "input","allowedTypes": ["output"]}},
                                          {"name": "_OUTPUT", "direction": [1,0], "offsetPosition": {"left": 65, "top": 12 },"ddConfig": {"type": "output","allowedTypes": ["input"]}}
                                      ]
                              }
                          },
                          {
                            "name": "NOT",    
                              "category": "gate",
                              "description": "NOT Gate with 1 input",
                            "container": {
                                  "xtype":"LogicContainer", 
                                 "icon": "../logicGates/images/gate_not.png",
                                 "image": "../logicGates/images/gate_not.png",
                                  "terminals": [
                                      {"name": "_INPUT", "direction": [-1,0], "offsetPosition": {"left": -21, "top": 12 },"ddConfig": {"type": "input","allowedTypes": ["output"]}, "nMaxWires": 1 },
                                      {"name": "_OUTPUT", "direction": [1,0], "offsetPosition": {"left": 70, "top": 12 },"ddConfig": {"type": "output","allowedTypes": ["input"]}}
                                  ]
                              }
                          },
                          {
                             "name": "NAND",
                              "category": "gate",
                              "description": "NAND Gate with 2 inputs",
                             "container": {
                                 "xtype":"LogicContainer", 
                                 "icon": "../logicGates/images/gate_nand.png",
                                 "image": "../logicGates/images/gate_nand.png",
                                  "terminals": [
                                      {"name": "_INPUT1", "direction": [-1,0], "offsetPosition": {"left": -16, "top": -2 },"ddConfig": {"type": "input","allowedTypes": ["output"]}, "nMaxWires": 1 },
                                      {"name": "_INPUT2", "direction": [-1,0], "offsetPosition": {"left": -16, "top": 25 },"ddConfig": {"type": "input","allowedTypes": ["output"]}, "nMaxWires": 1 },
                                      {"name": "_OUTPUT", "direction": [1,0], "offsetPosition": {"left": 65, "top": 12 }, "ddConfig": {"type": "output","allowedTypes": ["input"]}}
                                  ]
                              }
                          },
                          {
                             "name": "XOR",
                              "category": "gate",
                              "description": "XOR Gate with 2 inputs",
                             "container": {
                                 "xtype":"LogicContainer", 
                                 "icon": "../logicGates/images/gate_xor.png",
                                 "image": "../logicGates/images/gate_xor.png",
                                  "terminals": [
                                      {"name": "_INPUT1", "direction": [-1,0], "offsetPosition": {"left": -16, "top": -2 },"ddConfig": {"type": "input","allowedTypes": ["output"]}, "nMaxWires": 1 },
                                      {"name": "_INPUT2", "direction": [-1,0], "offsetPosition": {"left": -16, "top": 25 },"ddConfig": {"type": "input","allowedTypes": ["output"]}, "nMaxWires": 1 },
                                      {"name": "_OUTPUT", "direction": [1,0], "offsetPosition": {"left": 65, "top": 12 },"ddConfig": {"type": "output","allowedTypes": ["input"]}}
                                  ]
                              }
                          },
                          {
                              "name": "Lightbulb",
                              "category": "output",
                              "description": "Lamp display",
                              "container" : {
                                  "xtype":"LightbulbContainer", 
                                  "icon": "../logicGates/images/lightbulb_off.png",
                                  "image": "../logicGates/images/lightbulb_off.png",
                                    "terminals": [ {"name": "_INPUT", "direction": [0,1], "offsetPosition": {"left": 5, "bottom": -10 },"ddConfig": {"type": "input","allowedTypes": ["output"]}, "nMaxWires": 1 } ]
                              }
                          },
                          {
                              "name": "Switch",
                              "category": "input",
                              "description": "Switch",
                              "container" : {
                                  "xtype":"SwitchContainer", 
                                  "icon": "../logicGates/images/switch_off.png",
                                  "image": "../logicGates/images/switch_off.png",
                                    "terminals": [ {"name": "_OUTPUT", "direction": [1,0], "offsetPosition": {"right": 6, "top": 11 },"ddConfig": {"type": "output","allowedTypes": ["input"]}} ]
                              }
                          },
                          {
                              "name": "Clock",
                              "category": "input",
                              "description": "Clock",
                              "container" : {
                                  "xtype":"ClockContainer", 
                                  "icon": "../logicGates/images/clock_off.png",
                                  "image": "../logicGates/images/clock_off.png",
                                    "terminals": [ {"name": "_OUTPUT", "direction": [1,0], "offsetPosition": {"right": 7, "top": 5 },"ddConfig": {"type": "output","allowedTypes": ["input"]}} ]
                              }
                          }
                      ]
                  };
              </pre>

              <p>Finally, we add some styling on the generated CSS classes :</p>

              <pre class="brush:css">
                  div.WireIt-Container-closebutton { top: -16px; }
                  div.WireIt-ImageContainer div.body { width: 85px; }

                  div.WiringEditor-module-Lamp { height:100px; width:55px; }
                  div.WiringEditor-module-Lamp div.body {    height:70px; width:50px; }

                  div.WiringEditor-module-Clock { height:100px; width:80px; }
                  div.WiringEditor-module-Clock div.body { height:70px; width:50px; }

                  div.WiringEditor-module-Switch { height:60px; width:74px; }
                  div.WiringEditor-module-Switch div.body { height:45px; width:80px; }

                  .WiringEditor-module span { display: none; }
                  .WiringEditor-module { float: left; }
              </pre>


              <br /><br />

              <a name="composablePlugin"><h1>7 The <i>Composable</i> plugin</h1></a>

              <a name="composableIntro"><h2>7.1 Introduction</h2></a>

              <p>The composable plugin is an extension to the editor plugin.</p>

              <p>It is meant to make <i>Wirings</i> re-usable in other <i>Wirings</i> as a single-module. Check out the <a href="plugins/composable/examples/jsBox/jsBox.html">jsBox example</a>, and try to compose some modules.</p>

              <p>This plugin adds two components: <i>ComposableWiringEditor</i> and <i>ComposedContainer</i>.</p>


              <a name="composableHow"><h2>7.2 How does it work</h2></a>

              <p>The first component, <i>ComposableWiringEditor</i>, extends the WiringEditor by :</p>

              <ul>
                  <li>Adding two <i>core</i> modules to the language: <i>input</i> and <i>output</i></li>
                  <li>Adding saved wirings to the module list as <i>ComposedContainer</i></li>
              </ul>

              <p>The input module takes advantage of the inputEx <a href="http://neyric.github.com/inputex/examples/typefield.html">TypeField</a>. The TypeField is an inputEx field, which output value is an inputEx field definition. (inputEx's <a href="http://en.wikipedia.org/wiki/Strange_loop">strange loop</a>)</p>

              <p>The second component, is the <i>ComposedContainer</i> :</p>

              <ul>
                  <li>inherits from FormContainer</li>
                  <li>The <i>"input" modules</i> of the wirings are combined into a form</li>
                  <li>The <i>"output" modules</i> are represented by terminals</li>
              </ul>





              <br /><br />

              <a name="advancedTopics"><h1>8 Advanced Topics</h1></a>


              <a name="autoload"><h2>8.1 WiringEditor autoload feature</h2></a>

              <p>The WiringEditor has an option called <i>autoload</i>. <br />
                 This is a parameter passed in the URL that tells the WiringEditor which <i>wiring</i> to open when the editor is displayed.</p>

              <pre>
                  http://myhost.com/editor/?autoload=myWiring
              </pre>

              <p>For example, here is a direct link to the "guideAutoloadDemo" wiring of the WiringEditor example :<br />
                  <a href="examples/WiringEditor/?autoload=guideAutoloadDemo">examples/WiringEditor/?autoload=guideAutoloadDemo</a></p>

              <a name="mouseEvents"><h2>8.2 Handling Wire mouse events</h2></a>

              <p>There are two methods to handle wire mouse events :</p>

              <ul>
                  <li>
                      <p>Listen to wire events (recommanded)</p>

                      <pre class="brush:js">
                      wire.on('eventMouseIn', wireRed, wire, true);
                      wire.on('eventMouseOut', wireBlue, wire, true);
                      wire.on('eventMouseClick', wireClick, wire, true);
                      </pre>

                  </li>
                  <li>
                      <p>Override Wire.prototype methods</p>
                      <pre class="brush:js">
                          Wire.prototype.onWireIn = function(x,y) {
                          };

                          Wire.prototype.onWireOut = function(x,y) {
                          };

                          Wire.prototype.onWireClick = function(x,y) {
                          };
                      </pre>
                  </li>
              </ul>


              <p>Here is an example to create a random layer and lister for wire events :</p>

              <pre class="brush:js">

                  // Functions executed with the scope of a wire
                  var wireRed = function() {
                          this.options.color = 'rgb(255, 0, 0)';
                            this.redraw();
                      },
                      wireBlue = function() {
                          this.options.color = 'rgb(173, 216, 230)';
                          this.redraw();
                      },
                      wireClick = function() {
                          alert("Hoho ! you clicked !");
                      };

                  // Generate a random layer
                  var layer = new Y.Layer({});
                  for(var i = 0 ; i &lt; 5 ; i++) {
                      layer.addContainer({
                          terminals: [ {direction: [0,1], offsetPosition: {bottom: -13, left: 25} }],
                          title: "Block #"+i,
                          position: [ Math.floor(Math.random()*800)+30, Math.floor(Math.random()*300)+30 ]
                      });
                  }

                  for(var i = 0 ; i &lt; 7 ; i++) {

                      var w = layer.addWire({
                          src: {moduleId: Math.floor(Math.random()*5), terminalId: 0},
                          tgt: {moduleId: Math.floor(Math.random()*5), terminalId: 0}
                      });

                      // Subscribe methods to mouse events for all wires
                      w.on('eventMouseIn', wireRed, w, true);
                      w.on('eventMouseOut', wireBlue, w, true);
                      w.on('eventMouseClick', wireClick, w, true);
                  }
              </pre>


              <a name="production"><h2>8.3 notes on production</h2></a>

              <p>In a production environment, it is preferable to use rollup files: The javascript files are concatenated into a single javascript file (to reduce the number of HTTP requests) then compressed using the YUI compressor (to reduce file size).</p>

              <p>Some rollup files are provided in the <i>wireit/build</i> directory :</p>

              <pre class="brush:html">
                  &lt;script type="text/javascript" src="lib/wireit/build/wireit-min.js"&gt;&lt;/script&gt;
              </pre>

              <p>or</p>

              <pre class="brush:html">
                  &lt;script type="text/javascript" src="lib/wireit/build/wiring-editor-min.js"&gt;&lt;/script&gt;
              </pre>

              <p><u>Warning :</u>The rollup files <b>don't</b> include the excanvas.js library <b>required by Internet Explorer</b>, because this file is conditionally loaded using the "if IE" hack :</p>

              <pre class="brush:html">
                  &lt;!--[if IE]&gt;&lt;script type="text/javascript" src="../../lib/excanvas.js"&gt;&lt;/script&gt;&lt;![endif]--&gt;
              </pre>

              <p><u>Warning :</u>The wiring-editor-min.js file <b>doesn't</b> include any adapter, and only includes <b>some</b> fields of the inputEx library.</p>

              <div class="alert-message block-message info"><p>It is strongly recommended to build your custom rollup file for production. You can then include the adapter you use, the visual language definition, or even the YUI library dependencies. The script to build those files is available at build/rollups.sh (only in source, not in the zipped library)</p></div>

              <div class="alert-message block-message info"><p>The YUI library is included in the zip file, but the YUI files can be served from Yahoo or Google servers.</p></div>

              <p>Moreover, the WireIt zip file contains example, guides, documentation, which are not necessary in a production environment. We recommend you to copy only the required files on your webserver :</p>

              <pre>
                  wireit/
                    - assets/
                    - build/
                    - js/
                    - lib/
                   - plugins/
              </pre>





              <br /><br />

              <a name="contribute"><h1>9 Contribute</h1></a>


              <a name="issues"><h2>9.1 Reporting an Issue</h2></a>

              <p>The issues/bugs and feature requests are managed through the <a href="https://github.com/neyric/wireit/issues">GitHub issue tracker</a>. Feel free to add new ones, vote for your favorites, comment on existing one, ...</p>

              <p>Then don’t get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kind of bug, you’re creating this ticket in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the ticket automatically will see any activity or that others will jump to fix it. Creating a ticket like this is mostly to help yourself start on the path of fixing the problem and for others to confirm it with a "I’m having this problem too" comment. <i>(shamelessly copied from Rails guide)</i></p>


              <a name="documentation"><h2>9.2 Contributing to the Documentation</h2></a>

              <p>This guide represents the biggest documentation effort of the library. The <a href="api/index.html">API documentation</a> is also a huge part of WireIt's documentation. How can you help ?</p>

              <ul>
                  <li>fix typos, spelling</li>
                  <li>improve code documentation (and therefore the auto-generated API documentation)</li>
                  <li>write new examples</li>
                  <li>write about uncovered topics</li>
              </ul>

              <a name="code"><h2>9.3 Contributing to the Code</h2></a>


              <p>You can contribute in a lot of different ways :</p>

              <ul>
                  <li>Design/Styling - images or css</li>
                  <li>Adapters/backend code</li>
                  <li>core contributions (see the <a href="#roadmap">roadmap</a>)</li>
              </ul>



              <a name="donate"><h2>9.4 Contributors</h2></a>

              <p>Special thanks to the major contributors :</p>

              <ul>
                  <li><a href="https://github.com/neyric">neyric</a> - creator</li>
                  <li><a href="https://github.com/jamesk">jamesk</a> and <a href="https://github.com/ciaranj">ciaranj</a> - grouping plugin</li>
                  <li>Barun - Left/Right square Arrow Wire</li>
                  <li><a href="http://tarpipe.com">Tarpipe</a> - bug fixes, css, images</li>
                  <li><a href="https://github.com/LeifW">LeifW</a> - bug reports, forum replies</li>
                  <li><a href="https://github.com/dlitz">dlitz</a> - bug fix</li>
                  <li><a href="https://github.com/piercus">piercus</a> - bug fix</li>
                  <li><a href="http://www.jaybyjayfresh.com">Jonathan L.</a> - feature requests, blog post</li>
                  <li><a href="https://github.com/maximerety">maximerety</a> - major contributor on the inputEx library</li>
              </ul>


              <a name="donate"><h2>9.5 Donate</h2></a>

              <p>If you use this project in a commercial application, or simply wish to see this project continue, you can donate on PayPal. Donations will be used for WireIt development and promotion.</p>

                  <a href='http://www.pledgie.com/campaigns/13031'><img alt='Click here to lend your support to: wireit and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/13031.png?skin_name=chrome' border='0' /></a>


              <a name="roadmap"><h2>9.6 Roadmap</h2></a>


              <p>Here is a list of the main requested features. Please note that this is a wish-list, it's not always what the developers are currently working on.</p>

              <ul>
                  <li>
                      <b>Improve Layout</b>
                      <p>WireIt has proven useful for graph editing, but it is also very good at data visualization.<br />
                         However, the current layout engine still has a long way to go...</p>
                  </li>
                  <li>
                      <b>Improve the WiringEditor</b>
                      <p>Keep improving this strong application framework.</p>
                  </li>
                  <li>
                      <b>Progressive enhancement</b>
                      <p>The idea is to generate containers/terminals/wires from existing HTML. This is especially useful for <i>wirings</i> to be <b>indexable by search engines</b>.</p>
                  </li>
                  <li>
                      <b>Provide more backends/adapters</b>
                      <p>New backends/code generators to increase development speed. <br />
                       Although the backend largely depends on your project, it would be nice to have one for each major framework: <b>Rails, Django, Symfony, AppEngine, ...</b></p>
                  </li>
              </ul>





              <br /><br />

              <a name="moreInformation"><h1>10 Other resources</h2></a>


              <a name="examples"><h2>10.1 All examples</h2></a>
                  <ul>
                      <li><a href="examples/presentation.html">Interactive presentation</a></li>
                      <li><a href="examples/creating_terminals.html">Creating terminals and wires</a></li>
                      <li><a href="examples/changing_directions.html">Changing terminal direction</a></li>
                      <li><a href="examples/wires_and_terminals.html">Wire and Terminals configuration</a></li>
                      <li><a href="examples/dd_and_animation.html">Using animation</a></li>
                      <li><a href="examples/planarGame/planarGame.html">Planar game</a></li>
                      <li><a href="examples/labels.html">Wire labels</a></li>
                      <li><a href="examples/label_containers.html">Label Containers</a></li>
                  </ul>

                  <p>WiringEditor :</p>
                  <ul>
                      <li><a href="examples/WiringEditor/">WiringEditor demo</a></li>
                      <li><a href="examples/jsBox/jsBox.html">jsBox</a></li>
                      <li><a href="examples/logicGates/index.html">Logic Gates demo</a></li>
                      <li><a href="examples/ajaxAdapter/">Ajax Adapter</a></li>
                      <li><a href="examples/gearsAdapter/">Gears Adapter</a></li>
                  </ul>

                  <p>Beta/Experimental :</p>
                  <ul>
                      <li><a href="examples/wire_events.html">Wire mouse events</a></li>
                      <li><a href="examples/wire_tooltips.html">Wire context menu</a></li>
                      <li><a href="examples/spring_layout.html">Spring Layout</a></li>
                      <li><a href="examples/dotparser/">Dot parser</a></li>
                  </ul>






              <a name="apiReferences"><h2>10.2 API References</h2></a>

              <p><a href="api/index.html" style="font-size: 130%;">WireIt API Documentation</a></p>

              <p>Deeper hacking into WireIt might require some knowledge in the libraries used :</p>

              <ul class="secondLevel">
                  <li><a href="http://neyric.github.com/inputex/">inputEx Documentation</a></li>
                  <li><a href="http://developer.yahoo.com/yui/">YUI Documentation</a></li>
                  <li><a href="http://www.i-marco.nl/weblog/yui-accordion/">yui-accordion</a></li>
              </ul>


              <a name="otherResources"><h2>10.3 Other resources</h2></a>

              <ul>
                  <li>You can get some help on the <a href="http://groups.google.com/group/wireit/">forum</a>.</li>
                  <li><a href="http://neyric.github.com/wireit/">Project home page</a></li>
                  <li><a href="https://github.com/neyric/wireit">Source code repository</a> on GitHub</li>
                  <li><a href="https://github.com/neyric/wireit/issues">Issue tracker</a></li>
                  <li><a href="http://neyric.com/category/wireit/">WireIt Blog</a></li>
                  <li><a href="https://twitter.com/wireit">WireIt changelog on twitter</a></li>
              </ul>

              <p>Blog Posts :</p>
              <ul>
                  <li><a href="http://jaybyjayfresh.com/2009/07/06/adapting-wireit-to-work-with-independent-data-stores/">Adapting WireIt to work with independent data stores</a> by Jay</li>
              </ul>

              <a name="projects"><h2>10.4 WireIt-based projects</h2></a>

              <ul>
                  <li><a href="http://tarpipe.com">Tarpipe</a> - share content across social applications</li>
                  <li><a href="https://github.com/LeifW/pipescape">Pipescape</a> - a WireIt interface to <a href="http://www.w3.org/TR/xproc/">XProc</a></li>
                  <li><a href="http://graphpipes.de/">Graphpipes</a> - easy way to aggregate semantic data</li>
                  <li><a href="http://www.talk-map.com/">TalkMap</a> - Online debating</li>
              </ul>

              <p>Email me your own: &lt;eric.abouaf at gmail&gt;</p>

              
          </div>
        </div>
        
        <footer>
          <p>&copy; Eric Abouaf 2012</p>
        </footer>
      </div>
    </div>

<script type="text/javascript">
document.write(unescape("%3Cscript src='https://www.google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-567557-2");
pageTracker._trackPageview();
</script>

  </body>
</html>