jqSimpleConnect
Basic example for Issue #1
HTML
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
<h2>jqSimpleConnect - Select demo</h2>
<p>
Hide elements on click. <br> Please note the importance of assigning z-index values (otherwhise 'click' events are never triggered).
</p>
<br><br><br>
<div>
<div style="position:relative; height: 80px;">
<div id="div_a" style="position:absolute; top:5px; left:5px; border:1px solid black; background-color:white; padding:5px;">Div A</div>
<div id="div_b" style="position:absolute; top:50px; left:150px; border:1px solid black; background-color:white; padding:5px;">Div B</div>
<div id="div_c" style="position:absolute; top:25px; left:250px; border:1px solid black; background-color:white; padding:5px;">Div C</div>
<div id="div_d" style="position:absolute; top:25px; left:400px; border:1px solid black; background-color:white; padding:5px;">Div D</div>
</div>
</div>
<br>
<div>
<div style="position:relative; height: 110px;">
<div id="div_e" style="position:absolute; top:5px; left:5px; border:1px solid black; background-color:white; padding:5px;">Div E</div>
<div id="div_f" style="position:absolute; top:75px; left:150px; border:1px solid black; background-color:white; padding:5px;">Div F</div>
<div id="div_g" style="position:absolute; top:5px; left:250px; border:1px solid black; background-color:white; padding:5px;">Div G</div>
<div id="div_h" style="position:absolute; top:75px; left:400px; border:1px solid black; background-color:white; padding:5px;">Div H</div>
</div>
</div>
<br>
<div>
<div style="position:relative; height: 110px;">
<div id="div_i" style="position:absolute; top:5px; left:5px; border:1px solid black;...
CSS
div > div > div {
z-index: 5;
}
.jqSimpleConnect {
z-index: 4;
}
JavaScript
// jqSimpleConnect
jqSimpleConnect=new Object;jqSimpleConnect._idGenerator=0;jqSimpleConnect._connections=new Object;jqSimpleConnect._positionConnection=function(a){var b=a.elementA.offset();b.left=parseInt(b.left,10)+parseInt(a.elementA.outerWidth()/2,10);b.top=parseInt(b.top,10)+parseInt(a.elementA.outerHeight()/2,10);var c=a.elementB.offset();c.left=parseInt(c.left,10)+parseInt(a.elementB.outerWidth()/2,10);c.top=parseInt(c.top,10)+parseInt(a.elementB.outerHeight()/2,10);var d=jQuery("#"+a.id+"_1");var e=jQuery("#"+a.id+"_2");var f=jQuery("#"+a.id+"_3");if(b.left==c.left||b.top==c.top){d.show();e.hide();f.hide();if(b.left==c.left){jqSimpleConnect._positionVerticalLine(d,b,c,a.radius,a.roundedCorners)}else{jqSimpleConnect._positionHorizontalLine(d,b,c,a.radius,a.roundedCorners)}}else{if(a.anchorA!=a.anchorB){d.show();e.show();f.hide();var g=new Object;if(a.anchorA=="vertical"){g.left=b.left;g.top=c.top;jqSimpleConnect._positionVerticalLine(d,b,g,a.radius,a.roundedCorners);jqSimpleConnect._positionHorizontalLine(e,c,g,a.radius,a.roundedCorners)}else{g.left=c.left;g.top=b.top;jqSimpleConnect._positionVerticalLine(d,c,g,a.radius,a.roundedCorners);jqSimpleConnect._positionHorizontalLine(e,b,g,a.radius,a.roundedCorners)}}else{d.show();e.show();f.show();var h=new Object;var i=new Object;if(a.anchorA=="vertical"){h.top=parseInt((b.top+c.top)/2,10);i.top=h.top;h.left=b.left;i.left=c.left;jqSimpleConnect._positionVerticalLine(d,b,h,a.radius,a.roundedCorners);jqSimpleConnect._positionVerticalLine(e,c,i,a.radius,a.roundedCorners);jqSimpleConnect._positionHorizontalLine(f,h,i,a.radius,a.roundedCorners)}else{h.left=parseInt((b.left+c.left)/2,10);i.left=h.left;h.top=b.top;i.top=c.top;jqSimpleConnect._positionHorizontalLine(d,b,h,a.radius,a.roundedCorners);jqSimpleConnect._positionHorizontalLine(e,c,i,a.radius,a.roundedCorners);jqSimpleConnect._positionVerticalLine(f,h,i,a.radius,a.roundedCorners)}}}};jqSimpleConnect._positionVerticalLine=function(a,b,c,d,e){var...