Commit f04597d9 authored by Koen Punt's avatar Koen Punt

updated raphael

better labels
parent e6c0673e
...@@ -108,7 +108,7 @@ group :assets do ...@@ -108,7 +108,7 @@ group :assets do
gem "jquery-rails", "2.1.3" gem "jquery-rails", "2.1.3"
gem "jquery-ui-rails", "2.0.2" gem "jquery-ui-rails", "2.0.2"
gem "modernizr", "2.6.2" gem "modernizr", "2.6.2"
gem "raphael-rails", "1.5.2" gem "raphael-rails", git: "https://github.com/koenpunt/raphael-rails.git"
gem 'bootstrap-sass', "2.2.1.1" gem 'bootstrap-sass', "2.2.1.1"
gem "font-awesome-sass-rails", "~> 2.0.0" gem "font-awesome-sass-rails", "~> 2.0.0"
gem "gemoji", "~> 1.2.1", require: 'emoji/railtie' gem "gemoji", "~> 1.2.1", require: 'emoji/railtie'
......
...@@ -71,6 +71,12 @@ GIT ...@@ -71,6 +71,12 @@ GIT
http_parser.rb (~> 0.5.3) http_parser.rb (~> 0.5.3)
multi_json (~> 1.0) multi_json (~> 1.0)
GIT
remote: https://github.com/koenpunt/raphael-rails.git
revision: cb2c92a040b9b941a5f1aa1ea866cc26e944fe58
specs:
raphael-rails (2.1.0)
GEM GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
...@@ -344,7 +350,6 @@ GEM ...@@ -344,7 +350,6 @@ GEM
thor (>= 0.14.6, < 2.0) thor (>= 0.14.6, < 2.0)
raindrops (0.10.0) raindrops (0.10.0)
rake (10.0.1) rake (10.0.1)
raphael-rails (1.5.2)
rb-fsevent (0.9.2) rb-fsevent (0.9.2)
rb-inotify (0.8.8) rb-inotify (0.8.8)
ffi (>= 0.5.0) ffi (>= 0.5.0)
...@@ -512,7 +517,7 @@ DEPENDENCIES ...@@ -512,7 +517,7 @@ DEPENDENCIES
rack-mini-profiler rack-mini-profiler
rails (= 3.2.9) rails (= 3.2.9)
rails-dev-tweaks rails-dev-tweaks
raphael-rails (= 1.5.2) raphael-rails!
rb-fsevent rb-fsevent
rb-inotify rb-inotify
redcarpet (~> 2.2.2) redcarpet (~> 2.2.2)
......
...@@ -108,22 +108,10 @@ ...@@ -108,22 +108,10 @@
fill: this.colors[this.commits[i].space], fill: this.colors[this.commits[i].space],
stroke: "none" stroke: "none"
}); });
if (this.commits[i].refs != null && this.commits[i].refs != "") {
var longrefs = this.commits[i].refs
, shortrefs = this.commits[i].refs;
if (shortrefs.length > 15){
shortrefs = shortrefs.substr(0,13) + "...";
}
var t = r.text(x+5, y+8, shortrefs).attr({
font: "12px Monaco, Arial",
fill: "#666",
title: longrefs,
cursor: "pointer",
rotation: "90"
});
var textbox = t.getBBox();
t.translate(textbox.height/-4, textbox.width/2); if (this.commits[i].refs) {
this.appendLabel(x, y, this.commits[i].refs);
} }
var c; var c;
for (var j = 0, jj = this.commits[i].parents.length; j < jj; j++) { for (var j = 0, jj = this.commits[i].parents.length; j < jj; j++) {
...@@ -208,6 +196,45 @@ ...@@ -208,6 +196,45 @@
}); });
}; };
BranchGraph.prototype.appendLabel = function(x, y, refs){
var r = this.raphael
, shortrefs = refs
, text, textbox, rect;
if (shortrefs.length > 15){
// Truncate if longer than 15 chars
shortrefs = shortrefs.substr(0,13) + "...";
}
text = r.text(x+5, y+8, shortrefs).attr({
font: "12px Monaco, Arial",
fill: "#FFF",
title: refs
});
textbox = text.getBBox();
text.transform([
't', textbox.height/-4, textbox.width/2 + 5,
'r90'
]);
// Create rectangle based on the size of the textbox
rect = r.rect(x, y, textbox.width + 15, textbox.height + 5, 4).attr({
fill: "#000",
"fill-opacity": .5,
stroke: "none"
});
// Rotate and reposition rectangle over text
rect.transform([
'r', 90, x, y,
't', 5, -10
]);
// Set text to front
text.toFront();
};
BranchGraph.prototype.appendAnchor = function(top, c, x, y) { BranchGraph.prototype.appendAnchor = function(top, c, x, y) {
var r = this.raphael var r = this.raphael
, options = this.options , options = this.options
...@@ -252,6 +279,6 @@ Raphael.fn.tooltip = function (x, y, set, dir, size) { ...@@ -252,6 +279,6 @@ Raphael.fn.tooltip = function (x, y, set, dir, size) {
"l", 0, mmax(h - size, 0), (dir == 1) * size, size, (dir == 1) * -size, size, 0, mmax(h - size, 0), "a", size, size, 0, 0, 1, -size, size, "l", 0, mmax(h - size, 0), (dir == 1) * size, size, (dir == 1) * -size, size, 0, mmax(h - size, 0), "a", size, size, 0, 0, 1, -size, size,
"l", -mmax(w - size, 0), 0, "z"].join(",") "l", -mmax(w - size, 0), 0, "z"].join(",")
, xy = [{x: x, y: y + size * 2 + h}, {x: x - size * 2 - w, y: y}, {x: x, y: y - size * 2 - h}, {x: x + size * 2 + w, y: y}][dir]; , xy = [{x: x, y: y + size * 2 + h}, {x: x - size * 2 - w, y: y}, {x: x, y: y - size * 2 - h}, {x: x + size * 2 + w, y: y}][dir];
set.translate(xy.x - w - bb.x, xy.y - h - bb.y); set.transform(['t', xy.x - w - bb.x, xy.y - h - bb.y]);
return this.set(this.path(p).attr({fill: "#234", stroke: "none"}).insertBefore(set.node ? set : set[0]), set); return this.set(this.path(p).attr({fill: "#234", stroke: "none"}).insertBefore(set.node ? set : set[0]), set);
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment