From 838bbb2b3690b741a06c1c966cf26561301aea83 Mon Sep 17 00:00:00 2001 From: Alexey Kuleshov Date: Fri, 16 Aug 2013 14:36:34 +0300 Subject: [PATCH] Show tooltip when hovering issues on Gantt. --- assets/javascripts/raphael.arrow.coffee | 14 +++--- assets/javascripts/raphael.arrow.js | 66 +++++++++---------------- 2 files changed, 29 insertions(+), 51 deletions(-) diff --git a/assets/javascripts/raphael.arrow.coffee b/assets/javascripts/raphael.arrow.coffee index 83c8999..399dd81 100755 --- a/assets/javascripts/raphael.arrow.coffee +++ b/assets/javascripts/raphael.arrow.coffee @@ -2,7 +2,7 @@ This plugin draws arrows on Redmine gantt chart. ### -# Draws an arrow +# Draws an arrow # Original here: http://taitems.tumblr.com/post/549973287/drawing-arrows-in-raphaeljs Raphael.fn.ganttArrow = (coords, relationType = "follows") -> # Strokes for relation types @@ -11,7 +11,7 @@ Raphael.fn.ganttArrow = (coords, relationType = "follows") -> "duplicated": "- " "blocked": "-" "relates": "." - + # Shorthand functions for formatting SVG commands cmd = (cmd, a...) -> cmd.concat(" ", a.join(" "), " ") M = (x, y) -> cmd("M", x, y) @@ -30,13 +30,13 @@ Raphael.fn.ganttArrow = (coords, relationType = "follows") -> x1 += 3 arrow = @set() - + deltaX = 7 deltaY = 8 - + [x2, y2] = [x1 + deltaX - 3, y1] [x5, y5] = [x6 - deltaX, y6] - + if y1 < y6 [x3, y3] = [x2, y6 - deltaY] else @@ -63,11 +63,11 @@ window.redrawGanttArrows = () -> paper.clear window.paper = paper paper.canvas.style.position = "absolute" - paper.canvas.style.zIndex = "50" + paper.canvas.style.zIndex = "24" # Relation attributes relationAttrs = ["follows", "blocked", "duplicated", "relates"] - + # Calculates arrow coordinates calculateAnchors = (from, to) -> [fromOffsetX, fromOffsetY] = [from.position().left, from.position().top] diff --git a/assets/javascripts/raphael.arrow.js b/assets/javascripts/raphael.arrow.js index 28c864a..f2db329 100755 --- a/assets/javascripts/raphael.arrow.js +++ b/assets/javascripts/raphael.arrow.js @@ -1,15 +1,9 @@ -// Generated by CoffeeScript 1.4.0 - -/* -This plugin draws arrows on Redmine gantt chart. -*/ - - (function() { - var __slice = [].slice; - + /* + This plugin draws arrows on Redmine gantt chart. + */ var __slice = Array.prototype.slice; Raphael.fn.ganttArrow = function(coords, relationType) { - var L1, M, arrow, arrowhead, cmd, deltaX, deltaY, l2, line, m, relationDash, triangle, x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; + var L1, M, arrow, arrowhead, cmd, deltaX, deltaY, l2, line, m, relationDash, triangle, x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6, _ref, _ref2, _ref3, _ref4, _ref5, _ref6; if (relationType == null) { relationType = "follows"; } @@ -49,16 +43,16 @@ This plugin draws arrows on Redmine gantt chart. deltaX = 7; deltaY = 8; _ref = [x1 + deltaX - 3, y1], x2 = _ref[0], y2 = _ref[1]; - _ref1 = [x6 - deltaX, y6], x5 = _ref1[0], y5 = _ref1[1]; + _ref2 = [x6 - deltaX, y6], x5 = _ref2[0], y5 = _ref2[1]; if (y1 < y6) { - _ref2 = [x2, y6 - deltaY], x3 = _ref2[0], y3 = _ref2[1]; + _ref3 = [x2, y6 - deltaY], x3 = _ref3[0], y3 = _ref3[1]; } else { - _ref3 = [x2, y6 + deltaY], x3 = _ref3[0], y3 = _ref3[1]; + _ref4 = [x2, y6 + deltaY], x3 = _ref4[0], y3 = _ref4[1]; } if (x1 + deltaX + 7 < x6) { - _ref4 = [x3, y5], x4 = _ref4[0], y4 = _ref4[1]; + _ref5 = [x3, y5], x4 = _ref5[0], y4 = _ref5[1]; } else { - _ref5 = [x5, y3], x4 = _ref5[0], y4 = _ref5[1]; + _ref6 = [x5, y3], x4 = _ref6[0], y4 = _ref6[1]; } arrow.push(this.path(line(x1, y1, x2, y2))); arrow.push(this.path(line(x2, y2, x3, y3))); @@ -73,24 +67,21 @@ This plugin draws arrows on Redmine gantt chart. "stroke-dasharray": relationDash[relationType] }); }; - /* Draws connection arrows over the gantt chart */ - - window.redrawGanttArrows = function() { var calculateAnchors, paper, relationAttrs; paper = Raphael("gantt_lines", "100%", "100%"); paper.clear; window.paper = paper; paper.canvas.style.position = "absolute"; - paper.canvas.style.zIndex = "50"; + paper.canvas.style.zIndex = "24"; relationAttrs = ["follows", "blocked", "duplicated", "relates"]; calculateAnchors = function(from, to) { - var anchors, fromOffsetX, fromOffsetY, toOffsetX, toOffsetY, typeOffsetX, _ref, _ref1; + var anchors, fromOffsetX, fromOffsetY, toOffsetX, toOffsetY, typeOffsetX, _ref, _ref2; _ref = [from.position().left, from.position().top], fromOffsetX = _ref[0], fromOffsetY = _ref[1]; - _ref1 = [to.position().left, to.position().top], toOffsetX = _ref1[0], toOffsetY = _ref1[1]; + _ref2 = [to.position().left, to.position().top], toOffsetX = _ref2[0], toOffsetY = _ref2[1]; if (to.hasClass('parent')) { typeOffsetX = 10; } else { @@ -105,33 +96,20 @@ This plugin draws arrows on Redmine gantt chart. _results = []; for (_i = 0, _len = relationAttrs.length; _i < _len; _i++) { relationAttribute = relationAttrs[_i]; - if ((related = element.getAttribute(relationAttribute))) { - _results.push((function() { - var _j, _len1, _ref, _results1; + _results.push((function() { + var _i, _len, _ref, _results; + if ((related = element.getAttribute(relationAttribute))) { _ref = related.split(','); - _results1 = []; - for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { - id = _ref[_j]; - if ((item = $('#' + id))) { - from = item; - to = $('#' + element.id); - if ((from.position() != null) && (to.position() != null)) { - _results1.push(paper.ganttArrow(calculateAnchors(from, to), relationAttribute)); - } else { - _results1.push(void 0); - } - } else { - _results1.push(void 0); - } + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + id = _ref[_i]; + _results.push((item = $('#' + id)) ? (from = item, to = $('#' + element.id), (from.position() != null) && (to.position() != null) ? paper.ganttArrow(calculateAnchors(from, to), relationAttribute) : void 0) : void 0); } - return _results1; - })()); - } else { - _results.push(void 0); - } + return _results; + } + })()); } return _results; }); }; - }).call(this);