Permalink
Browse files

click wire brings it to top, top wire gets dragged from port when unp…

…lugging #25 closes #32
  • Loading branch information...
1 parent 3cf522b commit 78f94c01d610505c9bbf244971fe918cbe903bca @forresto forresto committed Apr 20, 2012
Showing with 33 additions and 1 deletion.
  1. +1 −1 iframework-min.js
  2. +27 −0 js/iframework-edge-view.js
  3. +1 −0 js/iframework-graph.js
  4. +4 −0 js/iframework-port-view.js
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -21,6 +21,19 @@ $(function(){
this._color = this.model._color;
}
this.render();
+
+ if (this.model) {
+ // Used to know which wire is on top when pulling from plugend
+ this._z = this.model.graph.edgeCount++;
+
+ $(this.elementWire)
+ .data({
+ "model": this.model
+ })
+ .click( function(event){
+ $(event.target).data("model").view.click(event);
+ });
+ }
},
render: function () {
this.calcPositions();
@@ -150,6 +163,20 @@ $(function(){
},
undim: function(){
$(this.elementGroup).attr("opacity", 1);
+ },
+ click: function(event) {
+ // If not on top already
+ if (this._z < this.model.graph.edgeCount-1) {
+ // Bring to top (z-order of SVG can't be done with CSS)
+ this.graphSVGElement.appendChild(this.elementGroup);
+ this._z = this.model.graph.edgeCount++;
+ }
+ // Highlight edge and plugends
+ var shadow = $(this.elementShadow);
+ shadow.attr("class", "wire-shadow highlight");
+ setTimeout(function(){
+ shadow.attr("class", "wire-shadow");
+ }, 500);
}
View
@@ -14,6 +14,7 @@ $(function(){
edges: []
},
usedIds: [],
+ edgeCount: 0,
eventsHistory: [],
initialize: function () {
this.usedIds = [];
@@ -196,9 +196,13 @@ $(function(){
// Find top connected wire
var lastConnected;
var countConnected = 0;
+ var topZ = 0;
this.model.graph.get("edges").each(function(edge){
if (edge.source === this.model || edge.target === this.model) {
countConnected++;
+ }
+ if (edge.view._z >= topZ) {
+ topZ = edge.view._z;
lastConnected = edge;
}
}, this);

0 comments on commit 78f94c0

Please sign in to comment.