Commit 1ad1cdba authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'remove-vendored-raphael-library' into 'master'

Refactor network graph bundle to ES module syntax

See merge request !9696
parents 34f3d899 536be744
/* eslint-disable func-names, space-before-function-paren */
/*= require raphael */
/*= require g.raphael */
/*= require g.bar */
(function() {
}).call(window);
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, quotes, comma-dangle, one-var, one-var-declaration-per-line, no-mixed-operators, new-cap, no-loop-func, no-floating-decimal, consistent-return, no-unused-vars, prefer-template, prefer-arrow-callback, camelcase, max-len */
/* global Raphael */
/* eslint-disable func-names, space-before-function-paren, no-var, wrap-iife, quotes, comma-dangle, one-var, one-var-declaration-per-line, no-mixed-operators, no-loop-func, no-floating-decimal, consistent-return, no-unused-vars, prefer-template, prefer-arrow-callback, camelcase, max-len */
(function() {
var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; };
import Raphael from './raphael';
this.BranchGraph = (function() {
export default (function() {
function BranchGraph(element1, options1) {
this.element = element1;
this.options = options1;
this.scrollTop = bind(this.scrollTop, this);
this.scrollBottom = bind(this.scrollBottom, this);
this.scrollRight = bind(this.scrollRight, this);
this.scrollLeft = bind(this.scrollLeft, this);
this.scrollUp = bind(this.scrollUp, this);
this.scrollDown = bind(this.scrollDown, this);
this.scrollTop = this.scrollTop.bind(this);
this.scrollBottom = this.scrollBottom.bind(this);
this.scrollRight = this.scrollRight.bind(this);
this.scrollLeft = this.scrollLeft.bind(this);
this.scrollUp = this.scrollUp.bind(this);
this.scrollDown = this.scrollDown.bind(this);
this.preparedCommits = {};
this.mtime = 0;
this.mspace = 0;
......@@ -346,79 +344,4 @@
};
return BranchGraph;
})();
Raphael.prototype.commitTooltip = function(x, y, commit) {
var boxHeight, boxWidth, icon, idText, messageText, nameText, rect, textSet, tooltip;
boxWidth = 300;
boxHeight = 200;
icon = this.image(gon.relative_url_root + commit.author.icon, x, y, 20, 20);
nameText = this.text(x + 25, y + 10, commit.author.name);
idText = this.text(x, y + 35, commit.id);
messageText = this.text(x, y + 50, commit.message.replace(/\r?\n/g, " \n "));
textSet = this.set(icon, nameText, idText, messageText).attr({
"text-anchor": "start",
font: "12px Monaco, monospace"
});
nameText.attr({
font: "14px Arial",
"font-weight": "bold"
});
idText.attr({
fill: "#AAA"
});
messageText.node.style["white-space"] = "pre";
this.textWrap(messageText, boxWidth - 50);
rect = this.rect(x - 10, y - 10, boxWidth, 100, 4).attr({
fill: "#FFF",
stroke: "#000",
"stroke-linecap": "round",
"stroke-width": 2
});
tooltip = this.set(rect, textSet);
rect.attr({
height: tooltip.getBBox().height + 10,
width: tooltip.getBBox().width + 10
});
tooltip.transform(["t", 20, 20]);
return tooltip;
};
Raphael.prototype.textWrap = function(t, width) {
var abc, b, content, h, j, len, letterWidth, s, word, words, x;
content = t.attr("text");
abc = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
t.attr({
text: abc
});
letterWidth = t.getBBox().width / abc.length;
t.attr({
text: content
});
words = content.split(" ");
x = 0;
s = [];
for (j = 0, len = words.length; j < len; j += 1) {
word = words[j];
if (x + (word.length * letterWidth) > width) {
s.push("\n");
x = 0;
}
if (word === "\n") {
s.push("\n");
x = 0;
} else {
s.push(word + " ");
x += word.length * letterWidth;
}
}
t.attr({
text: s.join("").trim()
});
b = t.getBBox();
h = Math.abs(b.y2) + 1;
return t.attr({
y: h
});
};
}).call(window);
})();
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, quotes, quote-props, prefer-template, comma-dangle, max-len */
/* global BranchGraph */
(function() {
this.Network = (function() {
import BranchGraph from './branch_graph';
export default (function() {
function Network(opts) {
var vph;
$("#filter_ref").click(function() {
......@@ -16,5 +16,4 @@
}
return Network;
})();
}).call(window);
})();
/* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, quotes, no-var, vars-on-top, camelcase, comma-dangle, consistent-return, max-len */
/* global Network */
/* global ShortcutsNetwork */
require('./branch_graph');
require('./network');
import Network from './network';
(function() {
$(function() {
$(function() {
if (!$(".network-graph").length) return;
var network_graph;
......@@ -17,5 +14,4 @@ require('./network');
commit_id: $(".network-graph").attr('data-commit-id')
});
return new ShortcutsNetwork(network_graph.branch_graph);
});
}).call(window);
});
import Raphael from 'raphael/raphael';
Raphael.prototype.commitTooltip = function commitTooltip(x, y, commit) {
const boxWidth = 300;
const icon = this.image(gon.relative_url_root + commit.author.icon, x, y, 20, 20);
const nameText = this.text(x + 25, y + 10, commit.author.name);
const idText = this.text(x, y + 35, commit.id);
const messageText = this.text(x, y + 50, commit.message.replace(/\r?\n/g, ' \n '));
const textSet = this.set(icon, nameText, idText, messageText).attr({
'text-anchor': 'start',
font: '12px Monaco, monospace',
});
nameText.attr({
font: '14px Arial',
'font-weight': 'bold',
});
idText.attr({
fill: '#AAA',
});
messageText.node.style['white-space'] = 'pre';
this.textWrap(messageText, boxWidth - 50);
const rect = this.rect(x - 10, y - 10, boxWidth, 100, 4).attr({
fill: '#FFF',
stroke: '#000',
'stroke-linecap': 'round',
'stroke-width': 2,
});
const tooltip = this.set(rect, textSet);
rect.attr({
height: tooltip.getBBox().height + 10,
width: tooltip.getBBox().width + 10,
});
tooltip.transform(['t', 20, 20]);
return tooltip;
};
Raphael.prototype.textWrap = function testWrap(t, width) {
const content = t.attr('text');
const abc = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
t.attr({
text: abc,
});
const letterWidth = t.getBBox().width / abc.length;
t.attr({
text: content,
});
const words = content.split(' ');
let x = 0;
const s = [];
for (let j = 0, len = words.length; j < len; j += 1) {
const word = words[j];
if (x + (word.length * letterWidth) > width) {
s.push('\n');
x = 0;
}
if (word === '\n') {
s.push('\n');
x = 0;
} else {
s.push(`${word} `);
x += word.length * letterWidth;
}
}
t.attr({
text: s.join('').trim(),
});
const b = t.getBBox();
const h = Math.abs(b.y2) + 1;
return t.attr({
y: h,
});
};
export default Raphael;
- page_title "Graph", @ref
- content_for :page_specific_javascripts do
= page_specific_javascript_tag('lib/raphael.js')
= page_specific_javascript_bundle_tag('network')
= render "projects/commits/head"
= render "head"
......
......@@ -101,7 +101,6 @@ module Gitlab
config.assets.precompile << "katex.js"
config.assets.precompile << "xterm/xterm.css"
config.assets.precompile << "lib/ace.js"
config.assets.precompile << "lib/raphael.js"
config.assets.precompile << "u2f.js"
config.assets.precompile << "vendor/assets/fonts/*"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -1746,6 +1746,10 @@ etag@~1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/etag/-/etag-1.7.0.tgz#03d30b5f67dd6e632d2945d30d6652731a34d5d8"
eve-raphael@0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/eve-raphael/-/eve-raphael-0.5.0.tgz#17c754b792beef3fa6684d79cf5a47c63c4cda30"
event-emitter@~0.3.4:
version "0.3.4"
resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.4.tgz#8d63ddfb4cfe1fae3b32ca265c4c720222080bb5"
......@@ -3554,6 +3558,12 @@ range-parser@^1.0.3, range-parser@^1.2.0, range-parser@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e"
raphael@^2.2.7:
version "2.2.7"
resolved "https://registry.yarnpkg.com/raphael/-/raphael-2.2.7.tgz#231b19141f8d086986d8faceb66f8b562ee2c810"
dependencies:
eve-raphael "0.5.0"
raw-body@~2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.2.0.tgz#994976cf6a5096a41162840492f0bdc5d6e7fb96"
......
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