Skip to content

Commit 7cfeabd

Browse files
committed
update site
1 parent e086b5e commit 7cfeabd

File tree

2 files changed

+55
-22
lines changed

2 files changed

+55
-22
lines changed

flowchart-latest.js

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// flowchart, v1.1.3
1+
// flowchart, v1.2.0
22
// Copyright (c)2013 Adriano Raiano (adrai).
33
// Distributed under MIT license
44
// http://adrai.github.io/flowchart.js
@@ -83,7 +83,7 @@
8383
// global object or to jquery.
8484
if (typeof module !== 'undefined' && module.exports) {
8585
module.exports = flowchart;
86-
} else {
86+
} else {
8787
root.flowchart = root.flowchart || flowchart;
8888
}
8989
// defaults
@@ -808,6 +808,25 @@
808808
options = options || {};
809809
Symbol.call(this, chart, options);
810810

811+
if (options.yes.direction && !options.no.direction) {
812+
if (options.yes.direction === 'right') {
813+
options.no.direction = 'bottom';
814+
} else {
815+
options.no.direction = 'right';
816+
}
817+
} else if (!options.yes.direction && options.no.direction) {
818+
if (options.no.direction === 'right') {
819+
options.yes.direction = 'bottom';
820+
} else {
821+
options.yes.direction = 'right';
822+
}
823+
} else {
824+
options.yes.direction = 'bottom';
825+
options.no.direction = 'right';
826+
}
827+
828+
this.options = options;
829+
811830
this.text.attr({
812831
x: chart.options['text-margin'] * 2
813832
});
@@ -854,27 +873,31 @@
854873
f.inherits(Condition, Symbol);
855874

856875
Condition.prototype.render = function() {
857-
if (this.yes_symbol) {
876+
877+
this[this.options.yes.direction + '_symbol'] = this.yes_symbol;
878+
this[this.options.no.direction + '_symbol'] = this.no_symbol;
879+
880+
if (this.bottom_symbol) {
858881
var bottomPoint = this.getBottom();
859-
var topPoint = this.yes_symbol.getTop();
882+
var topPoint = this.bottom_symbol.getTop();
860883

861-
if (!this.yes_symbol.isPositioned) {
862-
this.yes_symbol.shiftY(this.getY() + this.height + this.chart.options['line-length']);
863-
this.yes_symbol.setX(bottomPoint.x - this.yes_symbol.width/2);
864-
this.yes_symbol.isPositioned = true;
884+
if (!this.bottom_symbol.isPositioned) {
885+
this.bottom_symbol.shiftY(this.getY() + this.height + this.chart.options['line-length']);
886+
this.bottom_symbol.setX(bottomPoint.x - this.bottom_symbol.width/2);
887+
this.bottom_symbol.isPositioned = true;
865888

866-
this.yes_symbol.render();
889+
this.bottom_symbol.render();
867890
}
868891
}
869892

870-
if (this.no_symbol) {
893+
if (this.right_symbol) {
871894
var rightPoint = this.getRight();
872-
var leftPoint = this.no_symbol.getLeft();
895+
var leftPoint = this.right_symbol.getLeft();
873896

874-
if (!this.no_symbol.isPositioned) {
897+
if (!this.right_symbol.isPositioned) {
875898

876-
this.no_symbol.setY(rightPoint.y - this.no_symbol.height/2);
877-
this.no_symbol.shiftX(this.group.getBBox().x + this.width + this.chart.options['line-length']);
899+
this.right_symbol.setY(rightPoint.y - this.right_symbol.height/2);
900+
this.right_symbol.shiftX(this.group.getBBox().x + this.width + this.chart.options['line-length']);
878901

879902
var self = this;
880903
(function shift() {
@@ -883,33 +906,33 @@
883906
for (var i = 0, len = self.chart.symbols.length; i < len; i++) {
884907
symb = self.chart.symbols[i];
885908

886-
var diff = Math.abs(symb.getCenter().x - self.no_symbol.getCenter().x);
887-
if (symb.getCenter().y > self.no_symbol.getCenter().y && diff <= self.no_symbol.width/2) {
909+
var diff = Math.abs(symb.getCenter().x - self.right_symbol.getCenter().x);
910+
if (symb.getCenter().y > self.right_symbol.getCenter().y && diff <= self.right_symbol.width/2) {
888911
hasSymbolUnder = true;
889912
break;
890913
}
891914
}
892915

893916
if (hasSymbolUnder) {
894-
self.no_symbol.setX(symb.getX() + symb.width + self.chart.options['line-length']);
917+
self.right_symbol.setX(symb.getX() + symb.width + self.chart.options['line-length']);
895918
shift();
896919
}
897920
})();
898921

899-
this.no_symbol.isPositioned = true;
922+
this.right_symbol.isPositioned = true;
900923

901-
this.no_symbol.render();
924+
this.right_symbol.render();
902925
}
903926
}
904927
};
905928

906929
Condition.prototype.renderLines = function() {
907930
if (this.yes_symbol) {
908-
this.drawLineTo(this.yes_symbol, this.chart.options['yes-text'], 'bottom');
931+
this.drawLineTo(this.yes_symbol, this.chart.options['yes-text'], this.options.yes.direction);
909932
}
910933

911934
if (this.no_symbol) {
912-
this.drawLineTo(this.no_symbol, this.chart.options['no-text'], 'right');
935+
this.drawLineTo(this.no_symbol, this.chart.options['no-text'], this.options.no.direction);
913936
}
914937
};
915938
function parse(input) {
@@ -1078,7 +1101,7 @@
10781101

10791102
chart.symbols[symbol.key] = symbol;
10801103

1081-
} else if(line.indexOf('->') >= 0) {
1104+
} else if (line.indexOf('->') >= 0) {
10821105
// flow
10831106
var flowSymbols = line.split('->');
10841107
for (var i = 0, lenS = flowSymbols.length; i < lenS; i++) {
@@ -1087,13 +1110,22 @@
10871110
var realSymb = getSymbol(flowSymb);
10881111
var next = getNextPath(flowSymb);
10891112

1113+
var direction;
1114+
if (next.indexOf(',') >= 0) {
1115+
var condOpt = next.split(',');
1116+
next = condOpt[0];
1117+
direction = condOpt[1].trim();
1118+
}
1119+
10901120
if (!chart.start) {
10911121
chart.start = realSymb;
10921122
}
10931123

10941124
if (i + 1 < lenS) {
10951125
var nextSymb = flowSymbols[i + 1];
10961126
realSymb[next] = getSymbol(nextSymb);
1127+
realSymb[next].direction = direction;
1128+
direction = undefined;
10971129
}
10981130
}
10991131

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ <h3>Demo. Try editing me below</h3>
6363

6464
</section>
6565

66+
<b>Conditions can also be redirected like cond(yes, bottom) or cond(yes, right)</b>
6667
<div class="inner">
6768
<section id="usage">
6869
<h3>Usage</h3>

0 commit comments

Comments
 (0)