Skip to content

Commit 1053ac8

Browse files
committed
Added preliminary class support
1 parent 48536fb commit 1053ac8

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

example/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
<div><textarea id="code" style="width: 100%;" rows="11">
6060
st=>start: Start:>http://www.google.com[blank]
6161
e=>end:>http://www.google.com
62-
op1=>operation: My Operation
63-
sub1=>subroutine: My Subroutine
62+
op1=>operation: My Operation|Test
63+
sub1=>subroutine: My Subroutine|Demo
6464
cond=>condition: Yes
6565
or No?:>http://www.google.com
6666
io=>inputoutput: catch something...

src/flowchart.parse.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ function parse(input) {
151151
symbolType: parts[1],
152152
text: null,
153153
link: null,
154+
class : null,
154155
target: null
155156
};
156157

@@ -164,7 +165,17 @@ function parse(input) {
164165

165166
if (symbol.text && symbol.text.indexOf(':>') >= 0) {
166167
sub = symbol.text.split(':>');
167-
symbol.text = sub[0];
168+
/* adding support for classes */
169+
var tmpText = sub[0];
170+
if (tmpText.indexOf('|') >= 0 {
171+
var txtAndClass = tmpText.split('|');
172+
symbol.text = txtAndClass[0];
173+
symbol.class = txtAndClass[1];
174+
} else {
175+
symbol.text = tmpText;
176+
}
177+
/* end of class support */
178+
168179
symbol.link = sub[1];
169180
} else if (symbol.symbolType.indexOf(':>') >= 0) {
170181
sub = symbol.symbolType.split(':>');
@@ -218,4 +229,4 @@ function parse(input) {
218229

219230
}
220231
return chart;
221-
}
232+
}

src/flowchart.symbol.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ function Symbol(chart, options, symbol) {
66
this.symbolType = options.symbolType;
77

88
this.next_direction = options.next && options['direction_next'] ? options['direction_next'] : undefined;
9+
var class = (this.options.class) || (this.chart.options.symbols[this.symbolType]['class'] || this.chart.options['class']);
910

1011
this.text = this.chart.paper.text(0, 0, options.text);
1112
//Raphael does not support the svg group tag so setting the text node id to the symbol node id plus t
@@ -24,6 +25,7 @@ function Symbol(chart, options, symbol) {
2425
if (font) this.text.attr({ 'font': font });
2526
if (fontF) this.text.attr({ 'font-family': fontF });
2627
if (fontW) this.text.attr({ 'font-weight': fontW });
28+
if (class) this.text.attr({ 'class': class });
2729

2830
if (options.link) { this.text.attr('href', options.link); }
2931
if (options.target) { this.text.attr('target', options.target); }
@@ -56,6 +58,7 @@ function Symbol(chart, options, symbol) {
5658
if (options.link) { symbol.attr('href', options.link); }
5759
if (options.target) { symbol.attr('target', options.target); }
5860
if (options.key) { symbol.node.id = options.key; }
61+
if (class) { symbol.attr('class',class); }
5962

6063
this.group.push(symbol);
6164
symbol.insertBefore(this.text);
@@ -408,4 +411,4 @@ Symbol.prototype.drawLineTo = function(symbol, text, origin) {
408411
if (!this.chart.maxXFromLine || (this.chart.maxXFromLine && maxX > this.chart.maxXFromLine)) {
409412
this.chart.maxXFromLine = maxX;
410413
}
411-
};
414+
};

0 commit comments

Comments
 (0)