Commit 62ef763a80271b58e0c0f6e51891828f22689daa

Authored by Sato Hiroyuki
1 parent 6e152848

Refector: clean up code.

Showing 1 changed file with 9 additions and 13 deletions   Show diff stats
app/assets/javascripts/branch-graph.js.coffee
@@ -131,7 +131,7 @@ class BranchGraph @@ -131,7 +131,7 @@ class BranchGraph
131 shortrefs = refs 131 shortrefs = refs
132 # Truncate if longer than 15 chars 132 # Truncate if longer than 15 chars
133 shortrefs = shortrefs.substr(0, 15) + "…" if shortrefs.length > 17 133 shortrefs = shortrefs.substr(0, 15) + "…" if shortrefs.length > 17
134 - text = r.text(x + 8, y, shortrefs).attr( 134 + text = r.text(x + 4, y, shortrefs).attr(
135 "text-anchor": "start" 135 "text-anchor": "start"
136 font: "10px Monaco, monospace" 136 font: "10px Monaco, monospace"
137 fill: "#FFF" 137 fill: "#FFF"
@@ -139,7 +139,7 @@ class BranchGraph @@ -139,7 +139,7 @@ class BranchGraph
139 ) 139 )
140 textbox = text.getBBox() 140 textbox = text.getBBox()
141 # Create rectangle based on the size of the textbox 141 # Create rectangle based on the size of the textbox
142 - rect = r.rect(x, y - 7, textbox.width + 15, textbox.height + 5, 4).attr( 142 + rect = r.rect(x, y - 7, textbox.width + 5, textbox.height + 5, 4).attr(
143 fill: "#000" 143 fill: "#000"
144 "fill-opacity": .5 144 "fill-opacity": .5
145 stroke: "none" 145 stroke: "none"
@@ -206,22 +206,19 @@ class BranchGraph @@ -206,22 +206,19 @@ class BranchGraph
206 206
207 # Build line shape 207 # Build line shape
208 if parent[1] is commit.space 208 if parent[1] is commit.space
209 - d1 = [0, 5]  
210 - d2 = [0, 10]  
211 - arrow = "l-2,5,4,0,-2,-5" 209 + offset = [0, 5]
  210 + arrow = "l-2,5,4,0,-2,-5,0,5"
212 211
213 else if parent[1] < commit.space 212 else if parent[1] < commit.space
214 - d1 = [3, 3]  
215 - d2 = [7, 5]  
216 - arrow = "l5,0,-2,4,-3,-4" 213 + offset = [3, 3]
  214 + arrow = "l5,0,-2,4,-3,-4,4,2"
217 215
218 else 216 else
219 - d1 = [-3, 3]  
220 - d2 = [-7, 5]  
221 - arrow = "l-5,0,2,4,3,-4" 217 + offset = [-3, 3]
  218 + arrow = "l-5,0,2,4,3,-4,-4,2"
222 219
223 # Start point 220 # Start point
224 - route = ["M", x + d1[0], y + d1[1]] 221 + route = ["M", x + offset[0], y + offset[1]]
225 222
226 # Add arrow if not first parent 223 # Add arrow if not first parent
227 if i > 0 224 if i > 0
@@ -230,7 +227,6 @@ class BranchGraph @@ -230,7 +227,6 @@ class BranchGraph
230 # Circumvent if overlap 227 # Circumvent if overlap
231 if commit.space isnt parentCommit.space or commit.space isnt parent[1] 228 if commit.space isnt parentCommit.space or commit.space isnt parent[1]
232 route.push( 229 route.push(
233 - "L", x + d2[0], y + d2[1],  
234 "L", parentX2, y + 10, 230 "L", parentX2, y + 10,
235 "L", parentX2, parentY - 5, 231 "L", parentX2, parentY - 5,
236 ) 232 )