neyric/wireit

View on GitHub
sandbox/labels.html

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="UTF-8"?>
<html>
 <head>
  <title>WireIt Example, Move and Animate elements containing terminals</title>
  
  
<!-- YUI -->
<link rel="stylesheet" href="https://yui-s.yahooapis.com/combo?3.6.0/build/cssreset/reset-min.css&3.6.0/build/cssfonts/fonts-min.css">
<script src="https://yui-s.yahooapis.com/3.6.0/build/yui/yui.js"></script>

<script type="text/javascript" src="../lib/excanvas.js"></script>

<!-- WireIt -->
<link rel="stylesheet" type="text/css" href="../assets/WireIt.css" />
<script src="../src/loader.js"  type='text/javascript'></script>

<!-- TODO: inputEx loader !-->
<script src="../../inputex/master/src/loader.js"  type='text/javascript'></script>

<style>

div.blockBox {
    /* WireIt */
    position: absolute;
    z-index: 5;
    opacity: 0.8;
    
    /* Others */
    width: 100px;
    height: 100px;
    background-color: rgb(255,200,200);
    cursor: move;
}

</style>

<script>

YUI_config.groups.wireit.base = '../src/';
YUI_config.groups.inputex.base = '../../inputex/master/src/';

YUI({filter: 'raw', combine: false}).use('wire', 'bezier-wire', 'terminal', 'inputex', 'inputex-inplaceedit', 'inputex-select', function(Y) {
    
    // Create 2 terminals into Block1
    var block1 = Y.one('#block1');
    var terminals1 = [new Y.Terminal(block1, {direction: [-1,0], offsetPosition: [-14,35]}), 
                            new Y.Terminal(block1, {direction: [1,0], offsetPosition: [85,35]})];
    
    // Make the block1 draggable
    var drag = new Y.DD.Drag({ 
        node: block1
    });
    var that = this;
    drag.on('drag:drag', function(ev) {
        Y.Array.each(terminals1, function(t) {
          t.redrawAllWires();
        });
    });
    
    // Create 2 terminals into Block2
    var block2 = Y.one('#block2');
    var terminals2 = [new Y.Terminal(block2, {direction: [-1,0], offsetPosition: [-14,35]}), 
                            new Y.Terminal(block2, {direction: [1,0], offsetPosition: [85,35]})];
    
    // Make the block2 draggable
    var drag = new Y.DD.Drag({ 
        node: block2
    });
    var that = this;
    drag.on('drag:drag', function(ev) {
        Y.Array.each(terminals2, function(t) {
          t.redrawAllWires();
        });
    });
    
    // Create a wire between some terminals
    var w1 = new Y.BezierWire(terminals1[0], terminals2[0], document.body, {label: "Hello world !", labelStyle: {fontSize: "16pt", fontWeight: "bold", color: "yellow", backgroundColor: "black", border: "2px solid red"} });
    w1.redraw();
    
    var w2 = new Y.BezierWire(terminals1[1], terminals2[1], document.body, {
        
        label: 'test',
        labelEditor: /*{type: 'string', value: "Testst"}*/
        { 
                    type:'select',  
                    name: 'pagerank', 
                    choices: ['0','1','2','3','4','5','6','7','8','9','10'] 
            }
        
    });
    w2.redraw();
    
});


</script>

 </head>
 <body>
    
    <p style="margin: 15px;"><a href="../index.html">&lt; Back</a></p>
    <p style="margin: 15px;">TODO labels description</p>
    
    <div id='block1' class="blockBox" style="left: 300px; top: 100px;">Move Me !</div>
    
    <div id='block2' class="blockBox" style="left: 500px; top: 200px;">Move Me !</div>
    
 </body>
</html>