Commit 9f6660b1 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'refactor-graphs-bundle' into 'master'

Refactor graphs bundle to ES module syntax

See merge request !9502
parents c49ee361 52426c65
require('./stat_graph_contributors_graph'); import ContributorsStatGraph from './stat_graph_contributors';
require('./stat_graph_contributors_util');
require('./stat_graph_contributors'); // export to global scope
require('./stat_graph'); window.ContributorsStatGraph = ContributorsStatGraph;
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-return-assign, max-len */
(function() {
this.StatGraph = (function() {
function StatGraph() {}
StatGraph.log = {};
StatGraph.get_log = function() {
return this.log;
};
StatGraph.set_log = function(data) {
return this.log = data;
};
return StatGraph;
})();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, camelcase, one-var-declaration-per-line, quotes, no-param-reassign, quote-props, comma-dangle, prefer-template, max-len, no-return-assign */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, camelcase, one-var-declaration-per-line, quotes, no-param-reassign, quote-props, comma-dangle, prefer-template, max-len, no-return-assign, no-shadow */
/* global ContributorsGraph */
/* global ContributorsAuthorGraph */
/* global ContributorsMasterGraph */
/* global ContributorsStatGraphUtil */
/* global d3 */
window.d3 = require('d3'); import d3 from 'd3';
import { ContributorsGraph, ContributorsAuthorGraph, ContributorsMasterGraph } from './stat_graph_contributors_graph';
import ContributorsStatGraphUtil from './stat_graph_contributors_util';
(function() { export default (function() {
this.ContributorsStatGraph = (function() {
function ContributorsStatGraph() {} function ContributorsStatGraph() {}
ContributorsStatGraph.prototype.init = function(log) { ContributorsStatGraph.prototype.init = function(log) {
...@@ -112,5 +108,4 @@ window.d3 = require('d3'); ...@@ -112,5 +108,4 @@ window.d3 = require('d3');
}; };
return ContributorsStatGraph; return ContributorsStatGraph;
})(); })();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, one-var, no-var, prefer-rest-params, max-len, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, comma-dangle, no-return-assign, prefer-arrow-callback, quotes, prefer-template, newline-per-chained-call, no-else-return */ /* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, max-len, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, comma-dangle, no-return-assign, prefer-arrow-callback, quotes, prefer-template, newline-per-chained-call, no-else-return, no-shadow */
/* global d3 */
/* global ContributorsGraph */
window.d3 = require('d3'); import d3 from 'd3';
(function() { const bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; };
var bind = function(fn, me) { return function() { return fn.apply(me, arguments); }; }, const extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, const hasProp = {}.hasOwnProperty;
hasProp = {}.hasOwnProperty;
this.ContributorsGraph = (function() { export const ContributorsGraph = (function() {
function ContributorsGraph() {} function ContributorsGraph() {}
ContributorsGraph.prototype.MARGIN = { ContributorsGraph.prototype.MARGIN = {
...@@ -91,9 +88,9 @@ window.d3 = require('d3'); ...@@ -91,9 +88,9 @@ window.d3 = require('d3');
}; };
return ContributorsGraph; return ContributorsGraph;
})(); })();
this.ContributorsMasterGraph = (function(superClass) { export const ContributorsMasterGraph = (function(superClass) {
extend(ContributorsMasterGraph, superClass); extend(ContributorsMasterGraph, superClass);
function ContributorsMasterGraph(data1) { function ContributorsMasterGraph(data1) {
...@@ -195,9 +192,9 @@ window.d3 = require('d3'); ...@@ -195,9 +192,9 @@ window.d3 = require('d3');
}; };
return ContributorsMasterGraph; return ContributorsMasterGraph;
})(ContributorsGraph); })(ContributorsGraph);
this.ContributorsAuthorGraph = (function(superClass) { export const ContributorsAuthorGraph = (function(superClass) {
extend(ContributorsAuthorGraph, superClass); extend(ContributorsAuthorGraph, superClass);
function ContributorsAuthorGraph(data1) { function ContributorsAuthorGraph(data1) {
...@@ -272,5 +269,4 @@ window.d3 = require('d3'); ...@@ -272,5 +269,4 @@ window.d3 = require('d3');
}; };
return ContributorsAuthorGraph; return ContributorsAuthorGraph;
})(ContributorsGraph); })(ContributorsGraph);
}).call(window);
/* eslint-disable func-names, space-before-function-paren, object-shorthand, no-var, one-var, camelcase, one-var-declaration-per-line, comma-dangle, no-param-reassign, no-return-assign, quotes, prefer-arrow-callback, wrap-iife, consistent-return, no-unused-vars, max-len, no-cond-assign, no-else-return, max-len */ /* eslint-disable func-names, space-before-function-paren, object-shorthand, no-var, one-var, camelcase, one-var-declaration-per-line, comma-dangle, no-param-reassign, no-return-assign, quotes, prefer-arrow-callback, wrap-iife, consistent-return, no-unused-vars, max-len, no-cond-assign, no-else-return, max-len */
(function() {
window.ContributorsStatGraphUtil = { export default {
parse_log: function(log) { parse_log: function(log) {
var by_author, by_email, data, entry, i, len, total, normalized_email; var by_author, by_email, data, entry, i, len, total, normalized_email;
total = {}; total = {};
...@@ -134,5 +134,4 @@ ...@@ -134,5 +134,4 @@
return false; return false;
} }
} }
}; };
}).call(window);
/* eslint-disable quotes, jasmine/no-suite-dupes, vars-on-top, no-var, max-len */ /* eslint-disable quotes, jasmine/no-suite-dupes, vars-on-top, no-var */
/* global d3 */
/* global ContributorsGraph */
/* global ContributorsMasterGraph */
require('~/graphs/stat_graph_contributors_graph'); import d3 from 'd3';
import { ContributorsGraph, ContributorsMasterGraph } from '~/graphs/stat_graph_contributors_graph';
describe("ContributorsGraph", function () { describe("ContributorsGraph", function () {
describe("#set_x_domain", function () { describe("#set_x_domain", function () {
......
/* eslint-disable quotes, no-var, camelcase, object-property-newline, comma-dangle, max-len, vars-on-top, quote-props */ /* eslint-disable quotes, no-var, camelcase, object-property-newline, comma-dangle, max-len, vars-on-top, quote-props */
/* global ContributorsStatGraphUtil */
require('~/graphs/stat_graph_contributors_util'); import ContributorsStatGraphUtil from '~/graphs/stat_graph_contributors_util';
describe("ContributorsStatGraphUtil", function () { describe("ContributorsStatGraphUtil", function () {
describe("#parse_log", function () { describe("#parse_log", function () {
......
/* eslint-disable quotes */
/* global StatGraph */
require('~/graphs/stat_graph');
describe("StatGraph", function () {
describe("#get_log", function () {
it("returns log", function () {
StatGraph.log = "test";
expect(StatGraph.get_log()).toBe("test");
});
});
describe("#set_log", function () {
it("sets the log", function () {
StatGraph.set_log("test");
expect(StatGraph.log).toBe("test");
});
});
});
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