Fixing lint warning that came with the new version of JSCS
Also some other minor code cleanup
This commit is contained in:
1 parent
1bd3df524a
commit
6efa287c4e
11 files changed
+35
-45
No files matched your search
@@ -78,7 +78,7 @@ export default class Parser {
|
||||
|
||||
// Render the parsed expression to an SVG.
|
||||
render() {
|
||||
var svg = Snap(this.container.querySelector('svg'));
|
||||
let svg = Snap(this.container.querySelector('svg'));
|
||||
|
||||
return this.parsed.render(svg.group())
|
||||
// Once rendering is complete, the rendered expression is positioned and
|
||||
|
||||
@@ -9,7 +9,7 @@ export default {
|
||||
|
||||
// Renders the charset range into the currently set container
|
||||
_render() {
|
||||
var contents = [
|
||||
let contents = [
|
||||
this.first,
|
||||
this.container.text(0, 0, '-'),
|
||||
this.last
|
||||
|
||||
@@ -30,7 +30,7 @@ export default {
|
||||
},
|
||||
|
||||
setup() {
|
||||
var addHex;
|
||||
let addHex;
|
||||
|
||||
// The escape code. For an escape such as `\b` it would be "b".
|
||||
this.code = this.properties.esc.properties.code.textValue;
|
||||
@@ -69,7 +69,7 @@ export default {
|
||||
7: ['Back reference (group = 7)', -1, false],
|
||||
8: ['Back reference (group = 8)', -1, false],
|
||||
9: ['Back reference (group = 9)', -1, false],
|
||||
0() {
|
||||
0: function() {
|
||||
if (this.arg) {
|
||||
return [`octal: ${this.arg}`, parseInt(this.arg, 8), true];
|
||||
} else {
|
||||
|
||||
@@ -29,13 +29,9 @@ export default {
|
||||
|
||||
// Renders the match into the currently set container.
|
||||
_render() {
|
||||
var partPromises,
|
||||
items;
|
||||
|
||||
// Render each of the match fragments.
|
||||
partPromises = _.map(this.parts, part => part.render(this.container.group()));
|
||||
|
||||
items = _(partPromises).compact().value();
|
||||
let partPromises = _.map(this.parts, part => part.render(this.container.group())),
|
||||
items = _(partPromises).compact().value();
|
||||
|
||||
// Handle the situation where a regular expression of `()` is rendered.
|
||||
// This leads to a Match node with no fragments. Something must be rendered
|
||||
@@ -66,7 +62,7 @@ export default {
|
||||
// Returns an array of SVG path strings between each item.
|
||||
// - __items__ - Array of SVG elements or nodes.
|
||||
connectorPaths(items) {
|
||||
var prev, next;
|
||||
let prev, next;
|
||||
|
||||
prev = util.normalizeBBox(_.first(items).getBBox());
|
||||
return _.map(items.slice(1), item => {
|
||||
|
||||
@@ -52,22 +52,21 @@ export default {
|
||||
// Renders label for the loop path indicating how many times the content may
|
||||
// be matched.
|
||||
loopLabel() {
|
||||
var labelStr = this.repeat.label,
|
||||
tooltipStr = this.repeat.tooltip,
|
||||
label, tooltip, labelBox, box;
|
||||
let labelStr = this.repeat.label,
|
||||
tooltipStr = this.repeat.tooltip;
|
||||
|
||||
if (labelStr) {
|
||||
label = this.container.text(0, 0, [labelStr])
|
||||
.addClass('repeat-label');
|
||||
let label = this.container.text(0, 0, [labelStr])
|
||||
.addClass('repeat-label'),
|
||||
labelBox = label.getBBox(),
|
||||
box = this.getBBox();
|
||||
|
||||
if (tooltipStr) {
|
||||
tooltip = this.container.el('title')
|
||||
let tooltip = this.container.el('title')
|
||||
.append(this.container.text(0, 0, tooltipStr));
|
||||
label.append(tooltip);
|
||||
}
|
||||
|
||||
box = this.getBBox();
|
||||
labelBox = label.getBBox();
|
||||
label.transform(Snap.matrix().translate(
|
||||
box.x2 - labelBox.width - (this.repeat.hasSkip ? 5 : 0),
|
||||
box.y2 + labelBox.height));
|
||||
|
||||
@@ -116,17 +116,17 @@ export default class Node {
|
||||
//
|
||||
// - __text__ - String or array of strings to render as a label.
|
||||
renderLabel(text) {
|
||||
var group = this.container.group()
|
||||
let group = this.container.group()
|
||||
.addClass('label'),
|
||||
rect = group.rect(),
|
||||
text = group.text(0, 0, _.flatten([text]));
|
||||
label = group.text(0, 0, _.flatten([text]));
|
||||
|
||||
return this.deferredStep()
|
||||
.then(() => {
|
||||
let box = text.getBBox(),
|
||||
let box = label.getBBox(),
|
||||
margin = 5;
|
||||
|
||||
text.transform(Snap.matrix()
|
||||
label.transform(Snap.matrix()
|
||||
.translate(margin, box.height / 2 + 2 * margin));
|
||||
|
||||
rect.attr({
|
||||
@@ -140,12 +140,12 @@ export default class Node {
|
||||
|
||||
// Renders a labeled box around another SVG element. Returns a Promise.
|
||||
//
|
||||
// - __label__ - String or array of strings to label the box with.
|
||||
// - __text__ - String or array of strings to label the box with.
|
||||
// - __content__ - SVG element to wrap in the box.
|
||||
// - __options.padding__ - Pixels of padding to place between the content and
|
||||
// the box.
|
||||
renderLabeledBox(label, content, options) {
|
||||
var label = this.container.text(0, 0, _.flatten([label]))
|
||||
renderLabeledBox(text, content, options) {
|
||||
let label = this.container.text(0, 0, _.flatten([text]))
|
||||
.addClass(`${this.type}-label`),
|
||||
box = this.container.rect()
|
||||
.addClass(`${this.type}-box`)
|
||||
|
||||
@@ -9,7 +9,7 @@ export default {
|
||||
|
||||
// Renders the regexp into the currently set container.
|
||||
_render() {
|
||||
var matchContainer = this.container.group()
|
||||
let matchContainer = this.container.group()
|
||||
.addClass('regexp-matches')
|
||||
.transform(Snap.matrix()
|
||||
.translate(20, 0));
|
||||
@@ -56,7 +56,7 @@ export default {
|
||||
// - __containerBox__ - Bounding box of the container.
|
||||
// - __match__ - Match node that the line will be drawn to.
|
||||
makeSide(containerBox, match) {
|
||||
var box = match.getBBox(),
|
||||
let box = match.getBBox(),
|
||||
distance = Math.abs(box.ay - containerBox.cy);
|
||||
|
||||
// Only need to draw side lines if the match is more than 15 pixels from
|
||||
@@ -79,7 +79,7 @@ export default {
|
||||
// - __containerBox__ - Bounding box of the container.
|
||||
// - __match__ - Match node that the line will be drawn to.
|
||||
makeCurve(containerBox, match) {
|
||||
var box = match.getBBox(),
|
||||
let box = match.getBBox(),
|
||||
distance = Math.abs(box.ay - containerBox.cy);
|
||||
|
||||
if (distance >= 15) {
|
||||
@@ -109,7 +109,7 @@ export default {
|
||||
// - __containerBox__ - Bounding box of the container.
|
||||
// - __match__ - Match node that the line will be drawn to.
|
||||
makeConnector(containerBox, match) {
|
||||
var box = match.getBBox();
|
||||
let box = match.getBBox();
|
||||
|
||||
return `M0,${box.ay}h${box.ax}M${box.ax2},${box.ay}H${containerBox.width}`;
|
||||
},
|
||||
|
||||
@@ -76,7 +76,7 @@ export default {
|
||||
// Returns the path spec to render the line that skips over the content for
|
||||
// fragments that are optionally matched.
|
||||
skipPath(box) {
|
||||
var paths = [];
|
||||
let paths = [];
|
||||
|
||||
if (this.hasSkip) {
|
||||
let vert = Math.max(0, box.ay - box.y - 10),
|
||||
@@ -96,7 +96,7 @@ export default {
|
||||
// Returns the path spec to render the line that repeats the content for
|
||||
// fragments that are matched more than once.
|
||||
loopPath(box) {
|
||||
var paths = [];
|
||||
let paths = [];
|
||||
|
||||
if (this.hasLoop) {
|
||||
let vert = box.y2 - box.ay - 10;
|
||||
|
||||
@@ -14,7 +14,7 @@ export default {
|
||||
|
||||
// Renders the root into the currently set container.
|
||||
_render() {
|
||||
var flagText;
|
||||
let flagText;
|
||||
|
||||
// Render a label for any flags that have been set of the expression.
|
||||
if (this.flags.length > 0) {
|
||||
@@ -24,8 +24,6 @@ export default {
|
||||
// Render the content of the regular expression.
|
||||
return this.regexp.render(this.container.group())
|
||||
.then(() => {
|
||||
let box;
|
||||
|
||||
// Move rendered regexp to account for flag label and to allow for
|
||||
// decorative elements.
|
||||
if (flagText) {
|
||||
@@ -36,7 +34,7 @@ export default {
|
||||
.translate(10, 0));
|
||||
}
|
||||
|
||||
box = this.regexp.getBBox();
|
||||
let box = this.regexp.getBBox();
|
||||
|
||||
// Render decorative elements.
|
||||
this.container.path(`M${box.ax},${box.ay}H0M${box.ax2},${box.ay}H${box.x2 + 10}`);
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
// **NOTE:** `this.label()` **MUST** be called here, in _render, and before
|
||||
// any child nodes are rendered. This is to keep the group numbers in the
|
||||
// correct order.
|
||||
var label = this.label();
|
||||
let label = this.label();
|
||||
|
||||
// Render the contained regexp.
|
||||
return this.regexp.render(this.container.group())
|
||||
|
||||
Reference in new issue
Block a user