From ed19e4fa08ffd209ac2a14682038d5e580e4e603 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 8 Jan 2016 22:34:10 +0000 Subject: [PATCH] Splice nodes dragged from palette into links --- editor/js/history.js | 6 +++++ editor/js/ui/palette.js | 57 +++++++++++++++++++++++++++++++++++++++++ editor/js/ui/view.js | 24 ++++++++++++++++- editor/sass/flow.scss | 6 ++++- 4 files changed, 91 insertions(+), 2 deletions(-) diff --git a/editor/js/history.js b/editor/js/history.js index 2443109ad..5c822045b 100644 --- a/editor/js/history.js +++ b/editor/js/history.js @@ -80,6 +80,12 @@ RED.history = (function() { } } } + if (ev.removedLinks) { + for (i=0;i"; RED.sidebar.info.set(help); }); + var chart = $("#chart"); + var chartOffset = chart.offset(); + var chartSVG = $("#chart>svg").get(0); + var activeSpliceLink; + var mouseX; + var mouseY; + var spliceTimer; $(d).draggable({ helper: 'clone', appendTo: 'body', @@ -220,6 +227,56 @@ RED.palette = (function() { // TODO: this is the margin-left of palette node. Hard coding // it here makes me sad ui.position.left += 17.5; + if (def.inputs > 0 && def.outputs > 0) { + mouseX = e.clientX - chartOffset.left+chart.scrollLeft(); + mouseY = e.clientY-chartOffset.top +chart.scrollTop(); + + if (!spliceTimer) { + spliceTimer = setTimeout(function() { + + var svgRect = chartSVG.createSVGRect(); + svgRect.x = mouseX; + svgRect.y = mouseY; + svgRect.width = 1; + svgRect.height = 1; + var bestDistance = Infinity; + var bestLink = null; + var nodes = chartSVG.getIntersectionList(svgRect,chartSVG); + mouseX /= RED.view.scale(); + mouseY /= RED.view.scale(); + for (var i=0;i .link_line { + stroke-dasharray: 15,8; +} g.link_selected path.link_line { stroke: $node-selected-color;