|
1 |
| -// flowchart, v1.2.7 |
| 1 | +// flowchart, v1.2.8 |
2 | 2 | // Copyright (c)2014 Adriano Raiano (adrai).
|
3 | 3 | // Distributed under MIT license
|
4 | 4 | // http://adrai.github.io/flowchart.js
|
|
408 | 408 | this.connectedTo = [];
|
409 | 409 | this.symbolType = options.symbolType;
|
410 | 410 |
|
| 411 | + this.next_direction = options.next && options.next.direction ? options.next.direction : undefined; |
| 412 | + |
411 | 413 | this.text = this.chart.paper.text(0, 0, options.text);
|
412 | 414 | this.text.attr({
|
413 | 415 | 'text-anchor': 'start',
|
|
519 | 521 |
|
520 | 522 | Symbol.prototype.render = function() {
|
521 | 523 | if (this.next) {
|
522 |
| - var bottomPoint = this.getBottom(); |
523 |
| - var topPoint = this.next.getTop(); |
524 | 524 |
|
525 |
| - if (!this.next.isPositioned) { |
526 |
| - this.next.shiftY(this.getY() + this.height + (this.chart.options.symbols[this.symbolType]['line-length'] || this.chart.options['line-length'])); |
527 |
| - this.next.setX(bottomPoint.x - this.next.width/2); |
528 |
| - this.next.isPositioned = true; |
| 525 | + var lineLength = this.chart.options.symbols[this.symbolType]['line-length'] || this.chart.options['line-length']; |
529 | 526 |
|
530 |
| - this.next.render(); |
| 527 | + if (this.next_direction === 'right') { |
| 528 | + |
| 529 | + var rightPoint = this.getRight(); |
| 530 | + var leftPoint = this.next.getLeft(); |
| 531 | + |
| 532 | + if (!this.next.isPositioned) { |
| 533 | + |
| 534 | + this.next.setY(rightPoint.y - this.next.height/2); |
| 535 | + this.next.shiftX(this.group.getBBox().x + this.width + lineLength); |
| 536 | + |
| 537 | + var self = this; |
| 538 | + (function shift() { |
| 539 | + var hasSymbolUnder = false; |
| 540 | + var symb; |
| 541 | + for (var i = 0, len = self.chart.symbols.length; i < len; i++) { |
| 542 | + symb = self.chart.symbols[i]; |
| 543 | + |
| 544 | + var diff = Math.abs(symb.getCenter().x - self.next.getCenter().x); |
| 545 | + if (symb.getCenter().y > self.next.getCenter().y && diff <= self.next.width/2) { |
| 546 | + hasSymbolUnder = true; |
| 547 | + break; |
| 548 | + } |
| 549 | + } |
| 550 | + |
| 551 | + if (hasSymbolUnder) { |
| 552 | + self.next.setX(symb.getX() + symb.width + lineLength); |
| 553 | + shift(); |
| 554 | + } |
| 555 | + })(); |
| 556 | + |
| 557 | + this.next.isPositioned = true; |
| 558 | + |
| 559 | + this.next.render(); |
| 560 | + } |
| 561 | + } else { |
| 562 | + var bottomPoint = this.getBottom(); |
| 563 | + var topPoint = this.next.getTop(); |
| 564 | + |
| 565 | + if (!this.next.isPositioned) { |
| 566 | + this.next.shiftY(this.getY() + this.height + lineLength); |
| 567 | + this.next.setX(bottomPoint.x - this.next.width/2); |
| 568 | + this.next.isPositioned = true; |
| 569 | + |
| 570 | + this.next.render(); |
| 571 | + } |
531 | 572 | }
|
532 | 573 | }
|
533 | 574 | };
|
534 | 575 |
|
535 | 576 | Symbol.prototype.renderLines = function() {
|
536 | 577 | if (this.next) {
|
537 |
| - this.drawLineTo(this.next); |
| 578 | + if (this.next_direction) { |
| 579 | + this.drawLineTo(this.next, '', this.next_direction); |
| 580 | + } else { |
| 581 | + this.drawLineTo(this.next); |
| 582 | + } |
538 | 583 | }
|
539 | 584 | };
|
540 | 585 |
|
|
665 | 710 | this.bottomStart = true;
|
666 | 711 | symbol.topEnd = true;
|
667 | 712 | maxX = bottom.x + lineLength/2;
|
| 713 | + } else if ((origin === 'left')) { |
| 714 | + line = drawLine(this.chart, left, [ |
| 715 | + {x: symbolTop.x + (left.x - symbolTop.x)/ 2, y: left.y}, |
| 716 | + {x: symbolTop.x + (left.x - symbolTop.x)/ 2, y: symbolTop.y - lineLength/2}, |
| 717 | + {x: symbolTop.x, y: symbolTop.y - lineLength/2}, |
| 718 | + {x: symbolTop.x, y: symbolTop.y} |
| 719 | + ], text); |
| 720 | + this.leftStart = true; |
| 721 | + symbol.topEnd = true; |
| 722 | + maxX = left.x; |
668 | 723 | }
|
669 | 724 |
|
670 | 725 | if (line) {
|
|
754 | 809 | Symbol.call(this, chart, options, symbol);
|
755 | 810 | }
|
756 | 811 | f.inherits(Start, Symbol);
|
| 812 | + |
| 813 | + |
| 814 | + Start.prototype.render = function() { |
| 815 | + if (this.next) { |
| 816 | + var lineLength = this.chart.options.symbols[this.symbolType]['line-length'] || this.chart.options['line-length']; |
| 817 | + |
| 818 | + var bottomPoint = this.getBottom(); |
| 819 | + var topPoint = this.next.getTop(); |
| 820 | + |
| 821 | + if (!this.next.isPositioned) { |
| 822 | + this.next.shiftY(this.getY() + this.height + lineLength); |
| 823 | + this.next.setX(bottomPoint.x - this.next.width/2); |
| 824 | + this.next.isPositioned = true; |
| 825 | + |
| 826 | + this.next.render(); |
| 827 | + } |
| 828 | + } |
| 829 | + }; |
| 830 | + |
| 831 | + Start.prototype.renderLines = function() { |
| 832 | + if (this.next) { |
| 833 | + this.drawLineTo(this.next); |
| 834 | + } |
| 835 | + }; |
757 | 836 | function End(chart, options) {
|
758 | 837 | var symbol = chart.paper.rect(0, 0, 0, 0, 20);
|
759 | 838 | options = options || {};
|
|
1091 | 1170 |
|
1092 | 1171 | var lines = [];
|
1093 | 1172 | var prevBreak = 0;
|
1094 |
| - for(var i=1, ii = input.length; i<ii; i++) { |
1095 |
| - if(input[i] === '\n' && input[i-1] !== '\\') { |
1096 |
| - var line = input.substring(prevBreak, i); |
1097 |
| - prevBreak = i + 1; |
1098 |
| - lines.push(line.replace(/\\\n/g, '\n')); |
| 1173 | + for (var i0 = 1, i0len = input.length; i0 < i0len; i0++) { |
| 1174 | + if(input[i0] === '\n' && input[i0 - 1] !== '\\') { |
| 1175 | + var line0 = input.substring(prevBreak, i0); |
| 1176 | + prevBreak = i0 + 1; |
| 1177 | + lines.push(line0.replace(/\\\n/g, '\n')); |
1099 | 1178 | }
|
1100 | 1179 | }
|
| 1180 | + |
1101 | 1181 | if(prevBreak < input.length) {
|
1102 | 1182 | lines.push(input.substr(prevBreak));
|
1103 | 1183 | }
|
|
1129 | 1209 | var endIndex = s.indexOf(')');
|
1130 | 1210 | if (startIndex >= 0 && endIndex >= 0) {
|
1131 | 1211 | next = flowSymb.substring(startIndex, endIndex);
|
| 1212 | + if (next.indexOf(',') < 0) { |
| 1213 | + if (next !== 'yes' && next !== 'no') { |
| 1214 | + next = 'next, ' + next; |
| 1215 | + } |
| 1216 | + } |
1132 | 1217 | }
|
1133 | 1218 | return next;
|
1134 | 1219 | }
|
|
0 commit comments