estimancy/projestimate

View on GitHub
app/views/module_projects/_estimation_paths.html.erb

Summary

Maintainability
Test Coverage
<script>
    $(document).ready(function() {
         jsPlumb.ready(function() {
            <% pmod.associated_module_projects.each do |amp| %>
                <% if pmod.associated_module_projects.map(&:id).include?(amp.id) %>
                    jsPlumb.setRenderMode(jsPlumb.SVG);
                    jsPlumb.importDefaults({
                        Connector:"Straight",
                        PaintStyle:{ lineWidth:1, strokeStyle:"#ffa500", "dashstyle":"2 4"  }, //PaintStyle:{ lineWidth:3, strokeStyle:"#ffa500", "dashstyle":"2 4"  },
                        EndpointStyle:{ fillStyle:"#ffa500"}
                    });

                    var anEndpointSource = {
                     endpoint:[ "Rectangle", { radius:4, width:4, height:4 } ],
                     isSource: true,
                     isTarget: false,
                     maxConnections: 1,

                     anchors:["BottomCenter"]
                    };

                    var anEndpointDestination = {
                     endpoint:[ "Rectangle", { radius:4, width:4, height:4 } ],
                     isSource: false,
                     isTarget: true,
                     maxConnections: 1,

                     anchors:["TopCenter"]
                    };

                    var e0 = jsPlumb.addEndpoint($(".<%= amp.pemodule.alias %>_<%= amp.position_x %>_<%= amp.position_y %>"), anEndpointSource);
                    var e1 = jsPlumb.addEndpoint($(".<%= pmod.pemodule.alias %>_<%= pmod.position_x %>_<%= pmod.position_y %>"), anEndpointDestination);

                    e0.setEnabled(false);
                    e1.setEnabled(false);

                    jsPlumb.connect({
                        source:e0,
                        target:e1,
                        connector:["Straight"]
                    });

                    jsPlumb.repaint($(".<%= amp.pemodule.alias %>_<%= amp.position_x %>_<%= amp.position_y %>"));
                    jsPlumb.repaint($(".<%= pmod.pemodule.alias %>_<%= pmod.position_x %>_<%= pmod.position_y %>"));

                <% end %>
            <% end %>
        });

        e0 = null;
        e1 = null;
    });
</script>