@jhuix/showdowns 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1210 +0,0 @@
1
- // flowchart.js, v1.12.3
2
- // Copyright (c)2019 Adriano Raiano (adrai).
3
- // Distributed under MIT license
4
- // http://adrai.github.io/flowchart.js
5
-
6
- !function(root, factory) {
7
- if ("object" == typeof exports && "object" == typeof module) module.exports = factory(require("Raphael")); else if ("function" == typeof define && define.amd) define([ "Raphael" ], factory); else {
8
- var a = factory("object" == typeof exports ? require("Raphael") : root.Raphael);
9
- for (var i in a) ("object" == typeof exports ? exports : root)[i] = a[i];
10
- }
11
- }(this, function(__WEBPACK_EXTERNAL_MODULE_16__) {
12
- /******/
13
- return function(modules) {
14
- /******/
15
- /******/
16
- // The require function
17
- /******/
18
- function __webpack_require__(moduleId) {
19
- /******/
20
- /******/
21
- // Check if module is in cache
22
- /******/
23
- if (installedModules[moduleId]) /******/
24
- return installedModules[moduleId].exports;
25
- /******/
26
- /******/
27
- // Create a new module (and put it into the cache)
28
- /******/
29
- var module = installedModules[moduleId] = {
30
- /******/
31
- exports: {},
32
- /******/
33
- id: moduleId,
34
- /******/
35
- loaded: !1
36
- };
37
- /******/
38
- /******/
39
- // Return the exports of the module
40
- /******/
41
- /******/
42
- /******/
43
- // Execute the module function
44
- /******/
45
- /******/
46
- /******/
47
- // Flag the module as loaded
48
- /******/
49
- return modules[moduleId].call(module.exports, module, module.exports, __webpack_require__),
50
- module.loaded = !0, module.exports;
51
- }
52
- // webpackBootstrap
53
- /******/
54
- // The module cache
55
- /******/
56
- var installedModules = {};
57
- /******/
58
- /******/
59
- // Load entry module and return exports
60
- /******/
61
- /******/
62
- /******/
63
- /******/
64
- // expose the modules object (__webpack_modules__)
65
- /******/
66
- /******/
67
- /******/
68
- // expose the module cache
69
- /******/
70
- /******/
71
- /******/
72
- // __webpack_public_path__
73
- /******/
74
- return __webpack_require__.m = modules, __webpack_require__.c = installedModules,
75
- __webpack_require__.p = "", __webpack_require__(0);
76
- }([ /* 0 */
77
- /*!******************!*\
78
- !*** ./index.js ***!
79
- \******************/
80
- /***/
81
- function(module, exports, __webpack_require__) {
82
- __webpack_require__(/*! ./src/flowchart.shim */ 9);
83
- var parse = __webpack_require__(/*! ./src/flowchart.parse */ 4);
84
- __webpack_require__(/*! ./src/jquery-plugin */ 15);
85
- var FlowChart = {
86
- parse: parse
87
- };
88
- "undefined" != typeof window && (window.flowchart = FlowChart), module.exports = FlowChart;
89
- }, /* 1 */
90
- /*!**********************************!*\
91
- !*** ./src/flowchart.helpers.js ***!
92
- \**********************************/
93
- /***/
94
- function(module, exports) {
95
- function _defaults(options, defaultOptions) {
96
- if (!options || "function" == typeof options) return defaultOptions;
97
- var merged = {};
98
- for (var attrname in defaultOptions) merged[attrname] = defaultOptions[attrname];
99
- for (attrname in options) options[attrname] && ("object" == typeof merged[attrname] ? merged[attrname] = _defaults(merged[attrname], options[attrname]) : merged[attrname] = options[attrname]);
100
- return merged;
101
- }
102
- function _inherits(ctor, superCtor) {
103
- if ("function" == typeof Object.create) // implementation from standard node.js 'util' module
104
- ctor.super_ = superCtor, ctor.prototype = Object.create(superCtor.prototype, {
105
- constructor: {
106
- value: ctor,
107
- enumerable: !1,
108
- writable: !0,
109
- configurable: !0
110
- }
111
- }); else {
112
- // old school shim for old browsers
113
- ctor.super_ = superCtor;
114
- var TempCtor = function() {};
115
- TempCtor.prototype = superCtor.prototype, ctor.prototype = new TempCtor(), ctor.prototype.constructor = ctor;
116
- }
117
- }
118
- // move dependent functions to a container so that
119
- // they can be overriden easier in no jquery environment (node.js)
120
- module.exports = {
121
- defaults: _defaults,
122
- inherits: _inherits
123
- };
124
- }, /* 2 */
125
- /*!*********************************!*\
126
- !*** ./src/flowchart.symbol.js ***!
127
- \*********************************/
128
- /***/
129
- function(module, exports, __webpack_require__) {
130
- function Symbol(chart, options, symbol) {
131
- this.chart = chart, this.group = this.chart.paper.set(), this.symbol = symbol, this.connectedTo = [],
132
- this.symbolType = options.symbolType, this.flowstate = options.flowstate || "future",
133
- this.lineStyle = options.lineStyle || {}, this.key = options.key || "", this.next_direction = options.next && options.direction_next ? options.direction_next : void 0,
134
- this.text = this.chart.paper.text(0, 0, options.text), //Raphael does not support the svg group tag so setting the text node id to the symbol node id plus t
135
- options.key && (this.text.node.id = options.key + "t"), this.text.node.setAttribute("class", this.getAttr("class") + "t"),
136
- this.text.attr({
137
- "text-anchor": "start",
138
- x: this.getAttr("text-margin"),
139
- fill: this.getAttr("font-color"),
140
- "font-size": this.getAttr("font-size")
141
- });
142
- var font = this.getAttr("font"), fontF = this.getAttr("font-family"), fontW = this.getAttr("font-weight");
143
- font && this.text.attr({
144
- font: font
145
- }), fontF && this.text.attr({
146
- "font-family": fontF
147
- }), fontW && this.text.attr({
148
- "font-weight": fontW
149
- }), options.link && this.text.attr("href", options.link), //ndrqu Add click function with event and options params
150
- options["function"] && (this.text.attr({
151
- cursor: "pointer"
152
- }), this.text.node.addEventListener("click", function(evt) {
153
- window[options["function"]](evt, options);
154
- }, !1)), options.target && this.text.attr("target", options.target);
155
- var maxWidth = this.getAttr("maxWidth");
156
- if (maxWidth) {
157
- for (var words = options.text.split(" "), tempText = "", i = 0, ii = words.length; ii > i; i++) {
158
- var word = words[i];
159
- this.text.attr("text", tempText + " " + word), tempText += this.text.getBBox().width > maxWidth ? "\n" + word : " " + word;
160
- }
161
- this.text.attr("text", tempText.substring(1));
162
- }
163
- if (this.group.push(this.text), symbol) {
164
- var tmpMargin = this.getAttr("text-margin");
165
- symbol.attr({
166
- fill: this.getAttr("fill"),
167
- stroke: this.getAttr("element-color"),
168
- "stroke-width": this.getAttr("line-width"),
169
- width: this.text.getBBox().width + 2 * tmpMargin,
170
- height: this.text.getBBox().height + 2 * tmpMargin
171
- }), symbol.node.setAttribute("class", this.getAttr("class")), options.link && symbol.attr("href", options.link),
172
- options.target && symbol.attr("target", options.target), //ndrqu Add click function with event and options params
173
- options["function"] && (symbol.node.addEventListener("click", function(evt) {
174
- window[options["function"]](evt, options);
175
- }, !1), symbol.attr({
176
- cursor: "pointer"
177
- })), options.key && (symbol.node.id = options.key), this.group.push(symbol), symbol.insertBefore(this.text),
178
- this.text.attr({
179
- y: symbol.getBBox().height / 2
180
- }), this.initialize();
181
- }
182
- }
183
- var drawAPI = __webpack_require__(/*! ./flowchart.functions */ 3), drawLine = drawAPI.drawLine, checkLineIntersection = drawAPI.checkLineIntersection;
184
- /* Gets the attribute based on Flowstate, Symbol-Name and default, first found wins */
185
- Symbol.prototype.getAttr = function(attName) {
186
- if (this.chart) {
187
- var opt1, opt3 = this.chart.options ? this.chart.options[attName] : void 0, opt2 = this.chart.options.symbols ? this.chart.options.symbols[this.symbolType][attName] : void 0;
188
- return this.chart.options.flowstate && this.chart.options.flowstate[this.flowstate] && (opt1 = this.chart.options.flowstate[this.flowstate][attName]),
189
- opt1 || opt2 || opt3;
190
- }
191
- }, Symbol.prototype.initialize = function() {
192
- this.group.transform("t" + this.getAttr("line-width") + "," + this.getAttr("line-width")),
193
- this.width = this.group.getBBox().width, this.height = this.group.getBBox().height;
194
- }, Symbol.prototype.getCenter = function() {
195
- return {
196
- x: this.getX() + this.width / 2,
197
- y: this.getY() + this.height / 2
198
- };
199
- }, Symbol.prototype.getX = function() {
200
- return this.group.getBBox().x;
201
- }, Symbol.prototype.getY = function() {
202
- return this.group.getBBox().y;
203
- }, Symbol.prototype.shiftX = function(x) {
204
- this.group.transform("t" + (this.getX() + x) + "," + this.getY());
205
- }, Symbol.prototype.setX = function(x) {
206
- this.group.transform("t" + x + "," + this.getY());
207
- }, Symbol.prototype.shiftY = function(y) {
208
- this.group.transform("t" + this.getX() + "," + (this.getY() + y));
209
- }, Symbol.prototype.setY = function(y) {
210
- this.group.transform("t" + this.getX() + "," + y);
211
- }, Symbol.prototype.getTop = function() {
212
- var y = this.getY(), x = this.getX() + this.width / 2;
213
- return {
214
- x: x,
215
- y: y
216
- };
217
- }, Symbol.prototype.getBottom = function() {
218
- var y = this.getY() + this.height, x = this.getX() + this.width / 2;
219
- return {
220
- x: x,
221
- y: y
222
- };
223
- }, Symbol.prototype.getLeft = function() {
224
- var y = this.getY() + this.group.getBBox().height / 2, x = this.getX();
225
- return {
226
- x: x,
227
- y: y
228
- };
229
- }, Symbol.prototype.getRight = function() {
230
- var y = this.getY() + this.group.getBBox().height / 2, x = this.getX() + this.group.getBBox().width;
231
- return {
232
- x: x,
233
- y: y
234
- };
235
- }, Symbol.prototype.render = function() {
236
- if (this.next) {
237
- var self = this, lineLength = this.getAttr("line-length");
238
- if ("right" === this.next_direction) {
239
- var rightPoint = this.getRight();
240
- this.next.isPositioned || (this.next.setY(rightPoint.y - this.next.height / 2),
241
- this.next.shiftX(this.group.getBBox().x + this.width + lineLength), function shift() {
242
- for (var symb, hasSymbolUnder = !1, i = 0, len = self.chart.symbols.length; len > i; i++) {
243
- symb = self.chart.symbols[i];
244
- var diff = Math.abs(symb.getCenter().x - self.next.getCenter().x);
245
- if (symb.getCenter().y > self.next.getCenter().y && diff <= self.next.width / 2) {
246
- hasSymbolUnder = !0;
247
- break;
248
- }
249
- }
250
- if (hasSymbolUnder) {
251
- if ("end" === self.next.symbolType) return;
252
- self.next.setX(symb.getX() + symb.width + lineLength), shift();
253
- }
254
- }(), this.next.isPositioned = !0, this.next.render());
255
- } else if ("left" === this.next_direction) {
256
- var leftPoint = this.getLeft();
257
- this.next.isPositioned || (this.next.setY(leftPoint.y - this.next.height / 2), this.next.shiftX(-(this.group.getBBox().x + this.width + lineLength)),
258
- function shift() {
259
- for (var symb, hasSymbolUnder = !1, i = 0, len = self.chart.symbols.length; len > i; i++) {
260
- symb = self.chart.symbols[i];
261
- var diff = Math.abs(symb.getCenter().x - self.next.getCenter().x);
262
- if (symb.getCenter().y > self.next.getCenter().y && diff <= self.next.width / 2) {
263
- hasSymbolUnder = !0;
264
- break;
265
- }
266
- }
267
- if (hasSymbolUnder) {
268
- if ("end" === self.next.symbolType) return;
269
- self.next.setX(symb.getX() + symb.width + lineLength), shift();
270
- }
271
- }(), this.next.isPositioned = !0, this.next.render());
272
- } else {
273
- var bottomPoint = this.getBottom();
274
- this.next.isPositioned || (this.next.shiftY(this.getY() + this.height + lineLength),
275
- this.next.setX(bottomPoint.x - this.next.width / 2), this.next.isPositioned = !0,
276
- this.next.render());
277
- }
278
- }
279
- }, Symbol.prototype.renderLines = function() {
280
- this.next && (this.next_direction ? this.drawLineTo(this.next, this.getAttr("arrow-text") || "", this.next_direction) : this.drawLineTo(this.next, this.getAttr("arrow-text") || ""));
281
- }, Symbol.prototype.drawLineTo = function(symbol, text, origin) {
282
- this.connectedTo.indexOf(symbol) < 0 && this.connectedTo.push(symbol);
283
- var line, x = this.getCenter().x, y = this.getCenter().y, right = this.getRight(), bottom = this.getBottom(), top = this.getTop(), left = this.getLeft(), symbolX = symbol.getCenter().x, symbolY = symbol.getCenter().y, symbolTop = symbol.getTop(), symbolRight = symbol.getRight(), symbolLeft = symbol.getLeft(), isOnSameColumn = x === symbolX, isOnSameLine = y === symbolY, isUnder = symbolY > y, isUpper = y > symbolY || this === symbol, isLeft = x > symbolX, isRight = symbolX > x, maxX = 0, lineLength = this.getAttr("line-length"), lineWith = this.getAttr("line-width");
284
- if (origin && "bottom" !== origin || !isOnSameColumn || !isUnder) if (origin && "right" !== origin || !isOnSameLine || !isRight) if (origin && "left" !== origin || !isOnSameLine || !isLeft) if (origin && "right" !== origin || !isOnSameColumn || !isUpper) if (origin && "right" !== origin || !isOnSameColumn || !isUnder) if (origin && "bottom" !== origin || !isLeft) if (origin && "bottom" !== origin || !isRight || !isUnder) if (origin && "bottom" !== origin || !isRight) if (origin && "right" === origin && isLeft) line = drawLine(this.chart, right, [ {
285
- x: right.x + lineLength / 2,
286
- y: right.y
287
- }, {
288
- x: right.x + lineLength / 2,
289
- y: symbolTop.y - lineLength / 2
290
- }, {
291
- x: symbolTop.x,
292
- y: symbolTop.y - lineLength / 2
293
- }, {
294
- x: symbolTop.x,
295
- y: symbolTop.y
296
- } ], text), this.rightStart = !0, symbol.topEnd = !0, maxX = right.x + lineLength / 2; else if (origin && "right" === origin && isRight) line = drawLine(this.chart, right, [ {
297
- x: symbolTop.x,
298
- y: right.y
299
- }, {
300
- x: symbolTop.x,
301
- y: symbolTop.y
302
- } ], text), this.rightStart = !0, symbol.topEnd = !0, maxX = right.x + lineLength / 2; else if (origin && "bottom" === origin && isOnSameColumn && isUpper) line = drawLine(this.chart, bottom, [ {
303
- x: bottom.x,
304
- y: bottom.y + lineLength / 2
305
- }, {
306
- x: right.x + lineLength / 2,
307
- y: bottom.y + lineLength / 2
308
- }, {
309
- x: right.x + lineLength / 2,
310
- y: symbolTop.y - lineLength / 2
311
- }, {
312
- x: symbolTop.x,
313
- y: symbolTop.y - lineLength / 2
314
- }, {
315
- x: symbolTop.x,
316
- y: symbolTop.y
317
- } ], text), this.bottomStart = !0, symbol.topEnd = !0, maxX = bottom.x + lineLength / 2; else if ("left" === origin && isOnSameColumn && isUpper) {
318
- var diffX = left.x - lineLength / 2;
319
- symbolLeft.x < left.x && (diffX = symbolLeft.x - lineLength / 2), line = drawLine(this.chart, left, [ {
320
- x: diffX,
321
- y: left.y
322
- }, {
323
- x: diffX,
324
- y: symbolTop.y - lineLength / 2
325
- }, {
326
- x: symbolTop.x,
327
- y: symbolTop.y - lineLength / 2
328
- }, {
329
- x: symbolTop.x,
330
- y: symbolTop.y
331
- } ], text), this.leftStart = !0, symbol.topEnd = !0, maxX = left.x;
332
- } else "left" === origin ? (line = drawLine(this.chart, left, [ {
333
- x: symbolTop.x + (left.x - symbolTop.x) / 2,
334
- y: left.y
335
- }, {
336
- x: symbolTop.x + (left.x - symbolTop.x) / 2,
337
- y: symbolTop.y - lineLength / 2
338
- }, {
339
- x: symbolTop.x,
340
- y: symbolTop.y - lineLength / 2
341
- }, {
342
- x: symbolTop.x,
343
- y: symbolTop.y
344
- } ], text), this.leftStart = !0, symbol.topEnd = !0, maxX = left.x) : "top" === origin && (line = drawLine(this.chart, top, [ {
345
- x: top.x,
346
- y: symbolTop.y - lineLength / 2
347
- }, {
348
- x: symbolTop.x,
349
- y: symbolTop.y - lineLength / 2
350
- }, {
351
- x: symbolTop.x,
352
- y: symbolTop.y
353
- } ], text), this.topStart = !0, symbol.topEnd = !0, maxX = top.x); else line = drawLine(this.chart, bottom, [ {
354
- x: bottom.x,
355
- y: bottom.y + lineLength / 2
356
- }, {
357
- x: bottom.x + (bottom.x - symbolTop.x) / 2,
358
- y: bottom.y + lineLength / 2
359
- }, {
360
- x: bottom.x + (bottom.x - symbolTop.x) / 2,
361
- y: symbolTop.y - lineLength / 2
362
- }, {
363
- x: symbolTop.x,
364
- y: symbolTop.y - lineLength / 2
365
- }, {
366
- x: symbolTop.x,
367
- y: symbolTop.y
368
- } ], text), this.bottomStart = !0, symbol.topEnd = !0, maxX = bottom.x + (bottom.x - symbolTop.x) / 2; else line = drawLine(this.chart, bottom, [ {
369
- x: bottom.x,
370
- y: symbolTop.y - lineLength / 2
371
- }, {
372
- x: symbolTop.x,
373
- y: symbolTop.y - lineLength / 2
374
- }, {
375
- x: symbolTop.x,
376
- y: symbolTop.y
377
- } ], text), this.bottomStart = !0, symbol.topEnd = !0, maxX = bottom.x, symbolTop.x > maxX && (maxX = symbolTop.x); else line = this.leftEnd && isUpper ? drawLine(this.chart, bottom, [ {
378
- x: bottom.x,
379
- y: bottom.y + lineLength / 2
380
- }, {
381
- x: bottom.x + (bottom.x - symbolTop.x) / 2,
382
- y: bottom.y + lineLength / 2
383
- }, {
384
- x: bottom.x + (bottom.x - symbolTop.x) / 2,
385
- y: symbolTop.y - lineLength / 2
386
- }, {
387
- x: symbolTop.x,
388
- y: symbolTop.y - lineLength / 2
389
- }, {
390
- x: symbolTop.x,
391
- y: symbolTop.y
392
- } ], text) : drawLine(this.chart, bottom, [ {
393
- x: bottom.x,
394
- y: symbolTop.y - lineLength / 2
395
- }, {
396
- x: symbolTop.x,
397
- y: symbolTop.y - lineLength / 2
398
- }, {
399
- x: symbolTop.x,
400
- y: symbolTop.y
401
- } ], text), this.bottomStart = !0, symbol.topEnd = !0, maxX = bottom.x + (bottom.x - symbolTop.x) / 2; else line = drawLine(this.chart, right, [ {
402
- x: right.x + lineLength / 2,
403
- y: right.y
404
- }, {
405
- x: right.x + lineLength / 2,
406
- y: symbolTop.y - lineLength / 2
407
- }, {
408
- x: symbolTop.x,
409
- y: symbolTop.y - lineLength / 2
410
- }, {
411
- x: symbolTop.x,
412
- y: symbolTop.y
413
- } ], text), this.rightStart = !0, symbol.topEnd = !0, maxX = right.x + lineLength / 2; else line = drawLine(this.chart, right, [ {
414
- x: right.x + lineLength / 2,
415
- y: right.y
416
- }, {
417
- x: right.x + lineLength / 2,
418
- y: symbolTop.y - lineLength / 2
419
- }, {
420
- x: symbolTop.x,
421
- y: symbolTop.y - lineLength / 2
422
- }, {
423
- x: symbolTop.x,
424
- y: symbolTop.y
425
- } ], text), this.rightStart = !0, symbol.topEnd = !0, maxX = right.x + lineLength / 2; else line = drawLine(this.chart, left, symbolRight, text),
426
- this.leftStart = !0, symbol.rightEnd = !0, maxX = symbolRight.x; else line = drawLine(this.chart, right, symbolLeft, text),
427
- this.rightStart = !0, symbol.leftEnd = !0, maxX = symbolLeft.x; else line = drawLine(this.chart, bottom, symbolTop, text),
428
- this.bottomStart = !0, symbol.topEnd = !0, maxX = bottom.x;
429
- if (//update line style
430
- this.lineStyle[symbol.key] && line && line.attr(this.lineStyle[symbol.key]), line) {
431
- for (var l = 0, llen = this.chart.lines.length; llen > l; l++) for (var otherLine = this.chart.lines[l], ePath = otherLine.attr("path"), lPath = line.attr("path"), iP = 0, lenP = ePath.length - 1; lenP > iP; iP++) {
432
- var newPath = [];
433
- newPath.push([ "M", ePath[iP][1], ePath[iP][2] ]), newPath.push([ "L", ePath[iP + 1][1], ePath[iP + 1][2] ]);
434
- for (var line1_from_x = newPath[0][1], line1_from_y = newPath[0][2], line1_to_x = newPath[1][1], line1_to_y = newPath[1][2], lP = 0, lenlP = lPath.length - 1; lenlP > lP; lP++) {
435
- var newLinePath = [];
436
- newLinePath.push([ "M", lPath[lP][1], lPath[lP][2] ]), newLinePath.push([ "L", lPath[lP + 1][1], lPath[lP + 1][2] ]);
437
- var line2_from_x = newLinePath[0][1], line2_from_y = newLinePath[0][2], line2_to_x = newLinePath[1][1], line2_to_y = newLinePath[1][2], res = checkLineIntersection(line1_from_x, line1_from_y, line1_to_x, line1_to_y, line2_from_x, line2_from_y, line2_to_x, line2_to_y);
438
- if (res.onLine1 && res.onLine2) {
439
- var newSegment;
440
- line2_from_y === line2_to_y ? line2_from_x > line2_to_x ? (newSegment = [ "L", res.x + 2 * lineWith, line2_from_y ],
441
- lPath.splice(lP + 1, 0, newSegment), newSegment = [ "C", res.x + 2 * lineWith, line2_from_y, res.x, line2_from_y - 4 * lineWith, res.x - 2 * lineWith, line2_from_y ],
442
- lPath.splice(lP + 2, 0, newSegment), line.attr("path", lPath)) : (newSegment = [ "L", res.x - 2 * lineWith, line2_from_y ],
443
- lPath.splice(lP + 1, 0, newSegment), newSegment = [ "C", res.x - 2 * lineWith, line2_from_y, res.x, line2_from_y - 4 * lineWith, res.x + 2 * lineWith, line2_from_y ],
444
- lPath.splice(lP + 2, 0, newSegment), line.attr("path", lPath)) : line2_from_y > line2_to_y ? (newSegment = [ "L", line2_from_x, res.y + 2 * lineWith ],
445
- lPath.splice(lP + 1, 0, newSegment), newSegment = [ "C", line2_from_x, res.y + 2 * lineWith, line2_from_x + 4 * lineWith, res.y, line2_from_x, res.y - 2 * lineWith ],
446
- lPath.splice(lP + 2, 0, newSegment), line.attr("path", lPath)) : (newSegment = [ "L", line2_from_x, res.y - 2 * lineWith ],
447
- lPath.splice(lP + 1, 0, newSegment), newSegment = [ "C", line2_from_x, res.y - 2 * lineWith, line2_from_x + 4 * lineWith, res.y, line2_from_x, res.y + 2 * lineWith ],
448
- lPath.splice(lP + 2, 0, newSegment), line.attr("path", lPath)), lP += 2;
449
- }
450
- }
451
- }
452
- this.chart.lines.push(line), (void 0 === this.chart.minXFromSymbols || this.chart.minXFromSymbols > left.x) && (this.chart.minXFromSymbols = left.x);
453
- }
454
- (!this.chart.maxXFromLine || this.chart.maxXFromLine && maxX > this.chart.maxXFromLine) && (this.chart.maxXFromLine = maxX);
455
- }, module.exports = Symbol;
456
- }, /* 3 */
457
- /*!************************************!*\
458
- !*** ./src/flowchart.functions.js ***!
459
- \************************************/
460
- /***/
461
- function(module, exports) {
462
- function drawPath(chart, location, points) {
463
- var i, len, path = "M{0},{1}";
464
- for (i = 2, len = 2 * points.length + 2; len > i; i += 2) path += " L{" + i + "},{" + (i + 1) + "}";
465
- var pathValues = [ location.x, location.y ];
466
- for (i = 0, len = points.length; len > i; i++) pathValues.push(points[i].x), pathValues.push(points[i].y);
467
- var symbol = chart.paper.path(path, pathValues);
468
- symbol.attr("stroke", chart.options["element-color"]), symbol.attr("stroke-width", chart.options["line-width"]);
469
- var font = chart.options.font, fontF = chart.options["font-family"], fontW = chart.options["font-weight"];
470
- return font && symbol.attr({
471
- font: font
472
- }), fontF && symbol.attr({
473
- "font-family": fontF
474
- }), fontW && symbol.attr({
475
- "font-weight": fontW
476
- }), symbol;
477
- }
478
- function drawLine(chart, from, to, text) {
479
- var i, len;
480
- "[object Array]" !== Object.prototype.toString.call(to) && (to = [ to ]);
481
- var path = "M{0},{1}";
482
- for (i = 2, len = 2 * to.length + 2; len > i; i += 2) path += " L{" + i + "},{" + (i + 1) + "}";
483
- var pathValues = [ from.x, from.y ];
484
- for (i = 0, len = to.length; len > i; i++) pathValues.push(to[i].x), pathValues.push(to[i].y);
485
- var line = chart.paper.path(path, pathValues);
486
- line.attr({
487
- stroke: chart.options["line-color"],
488
- "stroke-width": chart.options["line-width"],
489
- "arrow-end": chart.options["arrow-end"]
490
- });
491
- var font = chart.options.font, fontF = chart.options["font-family"], fontW = chart.options["font-weight"];
492
- if (font && line.attr({
493
- font: font
494
- }), fontF && line.attr({
495
- "font-family": fontF
496
- }), fontW && line.attr({
497
- "font-weight": fontW
498
- }), text) {
499
- var centerText = !1, textPath = chart.paper.text(0, 0, text), isHorizontal = !1, firstTo = to[0];
500
- from.y === firstTo.y && (isHorizontal = !0);
501
- var x = 0, y = 0;
502
- centerText ? (x = from.x > firstTo.x ? from.x - (from.x - firstTo.x) / 2 : firstTo.x - (firstTo.x - from.x) / 2,
503
- y = from.y > firstTo.y ? from.y - (from.y - firstTo.y) / 2 : firstTo.y - (firstTo.y - from.y) / 2,
504
- isHorizontal ? (x -= textPath.getBBox().width / 2, y -= chart.options["text-margin"]) : (x += chart.options["text-margin"],
505
- y -= textPath.getBBox().height / 2)) : (x = from.x, y = from.y, isHorizontal ? (x += chart.options["text-margin"] / 2,
506
- y -= chart.options["text-margin"]) : (x += chart.options["text-margin"] / 2, y += chart.options["text-margin"],
507
- from.y > firstTo.y && (y -= 2 * chart.options["text-margin"]))), textPath.attr({
508
- "text-anchor": "start",
509
- "font-size": chart.options["font-size"],
510
- fill: chart.options["font-color"],
511
- x: x,
512
- y: y
513
- }), font && textPath.attr({
514
- font: font
515
- }), fontF && textPath.attr({
516
- "font-family": fontF
517
- }), fontW && textPath.attr({
518
- "font-weight": fontW
519
- });
520
- }
521
- return line;
522
- }
523
- function checkLineIntersection(line1StartX, line1StartY, line1EndX, line1EndY, line2StartX, line2StartY, line2EndX, line2EndY) {
524
- // if the lines intersect, the result contains the x and y of the intersection (treating the lines as infinite) and booleans for whether line segment 1 or line segment 2 contain the point
525
- var denominator, a, b, numerator1, numerator2, result = {
526
- x: null,
527
- y: null,
528
- onLine1: !1,
529
- onLine2: !1
530
- };
531
- // if we cast these lines infinitely in both directions, they intersect here:
532
- /*
533
- // it is worth noting that this should be the same as:
534
- x = line2StartX + (b * (line2EndX - line2StartX));
535
- y = line2StartX + (b * (line2EndY - line2StartY));
536
- */
537
- // if line1 is a segment and line2 is infinite, they intersect if:
538
- // if line2 is a segment and line1 is infinite, they intersect if:
539
- return denominator = (line2EndY - line2StartY) * (line1EndX - line1StartX) - (line2EndX - line2StartX) * (line1EndY - line1StartY),
540
- 0 === denominator ? result : (a = line1StartY - line2StartY, b = line1StartX - line2StartX,
541
- numerator1 = (line2EndX - line2StartX) * a - (line2EndY - line2StartY) * b, numerator2 = (line1EndX - line1StartX) * a - (line1EndY - line1StartY) * b,
542
- a = numerator1 / denominator, b = numerator2 / denominator, result.x = line1StartX + a * (line1EndX - line1StartX),
543
- result.y = line1StartY + a * (line1EndY - line1StartY), a > 0 && 1 > a && (result.onLine1 = !0),
544
- b > 0 && 1 > b && (result.onLine2 = !0), result);
545
- }
546
- module.exports = {
547
- drawPath: drawPath,
548
- drawLine: drawLine,
549
- checkLineIntersection: checkLineIntersection
550
- };
551
- }, /* 4 */
552
- /*!********************************!*\
553
- !*** ./src/flowchart.parse.js ***!
554
- \********************************/
555
- /***/
556
- function(module, exports, __webpack_require__) {
557
- function parse(input) {
558
- function getStyle(s) {
559
- var startIndex = s.indexOf("(") + 1, endIndex = s.indexOf(")");
560
- return startIndex >= 0 && endIndex >= 0 ? s.substring(startIndex, endIndex) : "{}";
561
- }
562
- function getSymbValue(s) {
563
- var startIndex = s.indexOf("(") + 1, endIndex = s.indexOf(")");
564
- return startIndex >= 0 && endIndex >= 0 ? s.substring(startIndex, endIndex) : "";
565
- }
566
- function getSymbol(s) {
567
- var startIndex = s.indexOf("(") + 1, endIndex = s.indexOf(")");
568
- return startIndex >= 0 && endIndex >= 0 ? chart.symbols[s.substring(0, startIndex - 1)] : chart.symbols[s];
569
- }
570
- function getNextPath(s) {
571
- var next = "next", startIndex = s.indexOf("(") + 1, endIndex = s.indexOf(")");
572
- return startIndex >= 0 && endIndex >= 0 && (next = flowSymb.substring(startIndex, endIndex),
573
- next.indexOf(",") < 0 && "yes" !== next && "no" !== next && (next = "next, " + next)),
574
- next;
575
- }
576
- input = input || "", input = input.trim();
577
- for (var chart = {
578
- symbols: {},
579
- start: null,
580
- drawSVG: function(container, options) {
581
- function getDisplaySymbol(s) {
582
- if (dispSymbols[s.key]) return dispSymbols[s.key];
583
- switch (s.symbolType) {
584
- case "start":
585
- dispSymbols[s.key] = new Start(diagram, s);
586
- break;
587
-
588
- case "end":
589
- dispSymbols[s.key] = new End(diagram, s);
590
- break;
591
-
592
- case "operation":
593
- dispSymbols[s.key] = new Operation(diagram, s);
594
- break;
595
-
596
- case "inputoutput":
597
- dispSymbols[s.key] = new InputOutput(diagram, s);
598
- break;
599
-
600
- case "subroutine":
601
- dispSymbols[s.key] = new Subroutine(diagram, s);
602
- break;
603
-
604
- case "condition":
605
- dispSymbols[s.key] = new Condition(diagram, s);
606
- break;
607
-
608
- case "parallel":
609
- dispSymbols[s.key] = new Parallel(diagram, s);
610
- break;
611
-
612
- default:
613
- return new Error("Wrong symbol type!");
614
- }
615
- return dispSymbols[s.key];
616
- }
617
- var self = this;
618
- this.diagram && this.diagram.clean();
619
- var diagram = new FlowChart(container, options);
620
- this.diagram = diagram;
621
- var dispSymbols = {};
622
- !function constructChart(s, prevDisp, prev) {
623
- var dispSymb = getDisplaySymbol(s);
624
- return self.start === s ? diagram.startWith(dispSymb) : prevDisp && prev && !prevDisp.pathOk && (prevDisp instanceof Condition ? (prev.yes === s && prevDisp.yes(dispSymb),
625
- prev.no === s && prevDisp.no(dispSymb)) : prevDisp instanceof Parallel ? (prev.path1 === s && prevDisp.path1(dispSymb),
626
- prev.path2 === s && prevDisp.path2(dispSymb), prev.path3 === s && prevDisp.path3(dispSymb)) : prevDisp.then(dispSymb)),
627
- dispSymb.pathOk ? dispSymb : (dispSymb instanceof Condition ? (s.yes && constructChart(s.yes, dispSymb, s),
628
- s.no && constructChart(s.no, dispSymb, s)) : dispSymb instanceof Parallel ? (s.path1 && constructChart(s.path1, dispSymb, s),
629
- s.path2 && constructChart(s.path2, dispSymb, s), s.path3 && constructChart(s.path3, dispSymb, s)) : s.next && constructChart(s.next, dispSymb, s),
630
- dispSymb);
631
- }(this.start), diagram.render();
632
- },
633
- clean: function() {
634
- this.diagram.clean();
635
- },
636
- options: function() {
637
- return this.diagram.options;
638
- }
639
- }, lines = [], prevBreak = 0, i0 = 1, i0len = input.length; i0len > i0; i0++) if ("\n" === input[i0] && "\\" !== input[i0 - 1]) {
640
- var line0 = input.substring(prevBreak, i0);
641
- prevBreak = i0 + 1, lines.push(line0.replace(/\\\n/g, "\n"));
642
- }
643
- prevBreak < input.length && lines.push(input.substr(prevBreak));
644
- for (var l = 1, len = lines.length; len > l; ) {
645
- var currentLine = lines[l];
646
- currentLine.indexOf("->") < 0 && currentLine.indexOf("=>") < 0 && currentLine.indexOf("@>") < 0 ? (lines[l - 1] += "\n" + currentLine,
647
- lines.splice(l, 1), len--) : l++;
648
- }
649
- for (;lines.length > 0; ) {
650
- var line = lines.splice(0, 1)[0].trim();
651
- if (line.indexOf("=>") >= 0) {
652
- // definition
653
- var parts = line.split("=>"), symbol = {
654
- key: parts[0].replace(/\(.*\)/, ""),
655
- symbolType: parts[1],
656
- text: null,
657
- link: null,
658
- target: null,
659
- flowstate: null,
660
- "function": null,
661
- lineStyle: {},
662
- params: {}
663
- }, params = parts[0].match(/\((.*)\)/);
664
- if (params && params.length > 1) for (var entries = params[1].split(","), i = 0; i < entries.length; i++) {
665
- var entry = entries[i].split("=");
666
- 2 == entry.length && (symbol.params[entry[0]] = entry[1]);
667
- }
668
- var sub;
669
- /* adding support for links */
670
- if (symbol.symbolType.indexOf(": ") >= 0 && (sub = symbol.symbolType.split(": "),
671
- symbol.symbolType = sub.shift(), symbol.text = sub.join(": ")), symbol.text && symbol.text.indexOf(":$") >= 0 ? (sub = symbol.text.split(":$"),
672
- symbol.text = sub.shift(), symbol["function"] = sub.join(":$")) : symbol.symbolType.indexOf(":$") >= 0 ? (sub = symbol.symbolType.split(":$"),
673
- symbol.symbolType = sub.shift(), symbol["function"] = sub.join(":$")) : symbol.text && symbol.text.indexOf(":>") >= 0 ? (sub = symbol.text.split(":>"),
674
- symbol.text = sub.shift(), symbol.link = sub.join(":>")) : symbol.symbolType.indexOf(":>") >= 0 && (sub = symbol.symbolType.split(":>"),
675
- symbol.symbolType = sub.shift(), symbol.link = sub.join(":>")), symbol.symbolType.indexOf("\n") >= 0 && (symbol.symbolType = symbol.symbolType.split("\n")[0]),
676
- symbol.link) {
677
- var startIndex = symbol.link.indexOf("[") + 1, endIndex = symbol.link.indexOf("]");
678
- startIndex >= 0 && endIndex >= 0 && (symbol.target = symbol.link.substring(startIndex, endIndex),
679
- symbol.link = symbol.link.substring(0, startIndex - 1));
680
- }
681
- /* end of link support */
682
- /* adding support for flowstates */
683
- if (symbol.text && symbol.text.indexOf("|") >= 0) {
684
- var txtAndState = symbol.text.split("|");
685
- symbol.flowstate = txtAndState.pop().trim(), symbol.text = txtAndState.join("|");
686
- }
687
- /* end of flowstate support */
688
- chart.symbols[symbol.key] = symbol;
689
- } else if (line.indexOf("->") >= 0) for (var flowSymbols = line.split("->"), iS = 0, lenS = flowSymbols.length; lenS > iS; iS++) {
690
- var flowSymb = flowSymbols[iS], symbVal = getSymbValue(flowSymb);
691
- ("true" === symbVal || "false" === symbVal) && (flowSymb = flowSymb.replace("true", "yes"),
692
- flowSymb = flowSymb.replace("false", "no"));
693
- var realSymb = getSymbol(flowSymb), next = getNextPath(flowSymb), direction = null;
694
- if (next.indexOf(",") >= 0) {
695
- var condOpt = next.split(",");
696
- next = condOpt[0], direction = condOpt[1].trim();
697
- }
698
- if (chart.start || (chart.start = realSymb), lenS > iS + 1) {
699
- var nextSymb = flowSymbols[iS + 1];
700
- realSymb[next] = getSymbol(nextSymb), realSymb["direction_" + next] = direction,
701
- direction = null;
702
- }
703
- } else if (line.indexOf("@>") >= 0) for (var lineStyleSymbols = line.split("@>"), iSS = 0, lenSS = lineStyleSymbols.length; lenSS > iSS; iSS++) if (iSS + 1 !== lenSS) {
704
- var curSymb = getSymbol(lineStyleSymbols[iSS]), nextSymbol = getSymbol(lineStyleSymbols[iSS + 1]);
705
- curSymb.lineStyle[nextSymbol.key] = JSON.parse(getStyle(lineStyleSymbols[iSS + 1]));
706
- }
707
- }
708
- return chart;
709
- }
710
- var FlowChart = __webpack_require__(/*! ./flowchart.chart */ 7), Start = __webpack_require__(/*! ./flowchart.symbol.start */ 13), End = __webpack_require__(/*! ./flowchart.symbol.end */ 10), Operation = __webpack_require__(/*! ./flowchart.symbol.operation */ 12), InputOutput = __webpack_require__(/*! ./flowchart.symbol.inputoutput */ 11), Subroutine = __webpack_require__(/*! ./flowchart.symbol.subroutine */ 14), Condition = __webpack_require__(/*! ./flowchart.symbol.condition */ 5), Parallel = __webpack_require__(/*! ./flowchart.symbol.parallel */ 6);
711
- module.exports = parse;
712
- }, /* 5 */
713
- /*!*******************************************!*\
714
- !*** ./src/flowchart.symbol.condition.js ***!
715
- \*******************************************/
716
- /***/
717
- function(module, exports, __webpack_require__) {
718
- function Condition(chart, options) {
719
- options = options || {}, Symbol.call(this, chart, options), this.textMargin = this.getAttr("text-margin"),
720
- this.yes_direction = "bottom", this.no_direction = "right", this.params = options.params,
721
- options.yes && options.direction_yes && options.no && !options.direction_no ? "right" === options.direction_yes ? (this.no_direction = "bottom",
722
- this.yes_direction = "right") : "top" === options.direction_yes ? (this.no_direction = "right",
723
- this.yes_direction = "top") : (this.no_direction = "right", this.yes_direction = "bottom") : options.yes && !options.direction_yes && options.no && options.direction_no ? "right" === options.direction_no ? (this.yes_direction = "bottom",
724
- this.no_direction = "right") : (this.yes_direction = "right", this.no_direction = "bottom") : options.yes && options.direction_yes && options.no && options.direction_no && options.direction_no !== options.direction_yes ? "right" === options.direction_yes ? (this.no_direction = "bottom",
725
- this.yes_direction = "right") : "top" === options.direction_yes ? (this.no_direction = "right",
726
- this.yes_direction = "top") : (this.no_direction = "right", this.yes_direction = "bottom") : (this.yes_direction = "bottom",
727
- this.no_direction = "right"), this.yes_direction = this.yes_direction || "bottom",
728
- this.no_direction = this.no_direction || "right", this.text.attr({
729
- x: 2 * this.textMargin
730
- });
731
- var width = this.text.getBBox().width + 3 * this.textMargin;
732
- width += width / 2;
733
- var height = this.text.getBBox().height + 2 * this.textMargin;
734
- height += height / 2, height = Math.max(.5 * width, height);
735
- var startX = width / 4, startY = height / 4;
736
- this.text.attr({
737
- x: startX + this.textMargin / 2
738
- });
739
- var start = {
740
- x: startX,
741
- y: startY
742
- }, points = [ {
743
- x: startX - width / 4,
744
- y: startY + height / 4
745
- }, {
746
- x: startX - width / 4 + width / 2,
747
- y: startY + height / 4 + height / 2
748
- }, {
749
- x: startX - width / 4 + width,
750
- y: startY + height / 4
751
- }, {
752
- x: startX - width / 4 + width / 2,
753
- y: startY + height / 4 - height / 2
754
- }, {
755
- x: startX - width / 4,
756
- y: startY + height / 4
757
- } ], symbol = drawPath(chart, start, points);
758
- symbol.attr({
759
- stroke: this.getAttr("element-color"),
760
- "stroke-width": this.getAttr("line-width"),
761
- fill: this.getAttr("fill")
762
- }), options.link && symbol.attr("href", options.link), options.target && symbol.attr("target", options.target),
763
- options.key && (symbol.node.id = options.key), symbol.node.setAttribute("class", this.getAttr("class")),
764
- this.text.attr({
765
- y: symbol.getBBox().height / 2
766
- }), this.group.push(symbol), symbol.insertBefore(this.text), this.initialize();
767
- }
768
- var Symbol = __webpack_require__(/*! ./flowchart.symbol */ 2), inherits = __webpack_require__(/*! ./flowchart.helpers */ 1).inherits, drawAPI = __webpack_require__(/*! ./flowchart.functions */ 3), drawPath = drawAPI.drawPath;
769
- inherits(Condition, Symbol), Condition.prototype.render = function() {
770
- this.yes_direction && (this[this.yes_direction + "_symbol"] = this.yes_symbol),
771
- this.no_direction && (this[this.no_direction + "_symbol"] = this.no_symbol);
772
- var lineLength = this.getAttr("line-length");
773
- if (this.bottom_symbol) {
774
- var bottomPoint = this.getBottom();
775
- this.bottom_symbol.isPositioned || (this.bottom_symbol.shiftY(this.getY() + this.height + lineLength),
776
- this.bottom_symbol.setX(bottomPoint.x - this.bottom_symbol.width / 2), this.bottom_symbol.isPositioned = !0,
777
- this.bottom_symbol.render());
778
- }
779
- if (this.right_symbol) {
780
- var rightPoint = this.getRight();
781
- if (!this.right_symbol.isPositioned) {
782
- this.right_symbol.setY(rightPoint.y - this.right_symbol.height / 2), this.right_symbol.shiftX(this.group.getBBox().x + this.width + lineLength);
783
- var self = this;
784
- !function shift() {
785
- for (var symb, hasSymbolUnder = !1, i = 0, len = self.chart.symbols.length; len > i; i++) if (symb = self.chart.symbols[i],
786
- !self.params["align-next"] || "no" !== self.params["align-next"]) {
787
- var diff = Math.abs(symb.getCenter().x - self.right_symbol.getCenter().x);
788
- if (symb.getCenter().y > self.right_symbol.getCenter().y && diff <= self.right_symbol.width / 2) {
789
- hasSymbolUnder = !0;
790
- break;
791
- }
792
- }
793
- if (hasSymbolUnder) {
794
- if ("end" === self.right_symbol.symbolType) return;
795
- self.right_symbol.setX(symb.getX() + symb.width + lineLength), shift();
796
- }
797
- }(), this.right_symbol.isPositioned = !0, this.right_symbol.render();
798
- }
799
- }
800
- }, Condition.prototype.renderLines = function() {
801
- this.yes_symbol && this.drawLineTo(this.yes_symbol, this.getAttr("yes-text"), this.yes_direction),
802
- this.no_symbol && this.drawLineTo(this.no_symbol, this.getAttr("no-text"), this.no_direction);
803
- }, module.exports = Condition;
804
- }, /* 6 */
805
- /*!******************************************!*\
806
- !*** ./src/flowchart.symbol.parallel.js ***!
807
- \******************************************/
808
- /***/
809
- function(module, exports, __webpack_require__) {
810
- function Parallel(chart, options) {
811
- var symbol = chart.paper.rect(0, 0, 0, 0);
812
- options = options || {}, Symbol.call(this, chart, options, symbol), this.textMargin = this.getAttr("text-margin"),
813
- this.path1_direction = "bottom", this.path2_direction = "right", this.path3_direction = "top",
814
- this.params = options.params, "path1" === options.direction_next && !options[options.direction_next] && options.next && (options[options.direction_next] = options.next),
815
- "path2" === options.direction_next && !options[options.direction_next] && options.next && (options[options.direction_next] = options.next),
816
- "path3" === options.direction_next && !options[options.direction_next] && options.next && (options[options.direction_next] = options.next),
817
- options.path1 && options.direction_path1 && options.path2 && !options.direction_path2 && options.path3 && !options.direction_path3 ? "right" === options.direction_path1 ? (this.path2_direction = "bottom",
818
- this.path1_direction = "right", this.path3_direction = "top") : "top" === options.direction_path1 ? (this.path2_direction = "right",
819
- this.path1_direction = "top", this.path3_direction = "bottom") : "left" === options.direction_path1 ? (this.path2_direction = "right",
820
- this.path1_direction = "left", this.path3_direction = "bottom") : (this.path2_direction = "right",
821
- this.path1_direction = "bottom", this.path3_direction = "top") : options.path1 && !options.direction_path1 && options.path2 && options.direction_path2 && options.path3 && !options.direction_path3 ? "right" === options.direction_path2 ? (this.path1_direction = "bottom",
822
- this.path2_direction = "right", this.path3_direction = "top") : "left" === options.direction_path2 ? (this.path1_direction = "bottom",
823
- this.path2_direction = "left", this.path3_direction = "right") : (this.path1_direction = "right",
824
- this.path2_direction = "bottom", this.path3_direction = "top") : options.path1 && !options.direction_path1 && options.path2 && !options.direction_path2 && options.path3 && options.direction_path3 ? "right" === options.direction_path2 ? (this.path1_direction = "bottom",
825
- this.path2_direction = "top", this.path3_direction = "right") : "left" === options.direction_path2 ? (this.path1_direction = "bottom",
826
- this.path2_direction = "right", this.path3_direction = "left") : (this.path1_direction = "right",
827
- this.path2_direction = "bottom", this.path3_direction = "top") : (this.path1_direction = options.direction_path1,
828
- this.path2_direction = options.direction_path2, this.path3_direction = options.direction_path3),
829
- this.path1_direction = this.path1_direction || "bottom", this.path2_direction = this.path2_direction || "right",
830
- this.path3_direction = this.path3_direction || "top", this.initialize();
831
- }
832
- var Symbol = __webpack_require__(/*! ./flowchart.symbol */ 2), inherits = __webpack_require__(/*! ./flowchart.helpers */ 1).inherits;
833
- inherits(Parallel, Symbol), Parallel.prototype.render = function() {
834
- this.path1_direction && (this[this.path1_direction + "_symbol"] = this.path1_symbol),
835
- this.path2_direction && (this[this.path2_direction + "_symbol"] = this.path2_symbol),
836
- this.path3_direction && (this[this.path3_direction + "_symbol"] = this.path3_symbol);
837
- var lineLength = this.getAttr("line-length");
838
- if (this.bottom_symbol) {
839
- var bottomPoint = this.getBottom();
840
- this.bottom_symbol.isPositioned || (this.bottom_symbol.shiftY(this.getY() + this.height + lineLength),
841
- this.bottom_symbol.setX(bottomPoint.x - this.bottom_symbol.width / 2), this.bottom_symbol.isPositioned = !0,
842
- this.bottom_symbol.render());
843
- }
844
- if (this.top_symbol) {
845
- var topPoint = this.getTop();
846
- this.top_symbol.isPositioned || (this.top_symbol.shiftY(this.getY() - this.top_symbol.height - lineLength),
847
- this.top_symbol.setX(topPoint.x + this.top_symbol.width), this.top_symbol.isPositioned = !0,
848
- this.top_symbol.render());
849
- }
850
- var self = this;
851
- if (this.left_symbol) {
852
- var leftPoint = this.getLeft();
853
- this.left_symbol.isPositioned || (this.left_symbol.setY(leftPoint.y - this.left_symbol.height / 2),
854
- this.left_symbol.shiftX(-(this.group.getBBox().x + this.width + lineLength)), function shift() {
855
- for (var symb, hasSymbolUnder = !1, i = 0, len = self.chart.symbols.length; len > i; i++) if (symb = self.chart.symbols[i],
856
- !self.params["align-next"] || "no" !== self.params["align-next"]) {
857
- var diff = Math.abs(symb.getCenter().x - self.left_symbol.getCenter().x);
858
- if (symb.getCenter().y > self.left_symbol.getCenter().y && diff <= self.left_symbol.width / 2) {
859
- hasSymbolUnder = !0;
860
- break;
861
- }
862
- }
863
- if (hasSymbolUnder) {
864
- if ("end" === self.left_symbol.symbolType) return;
865
- self.left_symbol.setX(symb.getX() + symb.width + lineLength), shift();
866
- }
867
- }(), this.left_symbol.isPositioned = !0, this.left_symbol.render());
868
- }
869
- if (this.right_symbol) {
870
- var rightPoint = this.getRight();
871
- this.right_symbol.isPositioned || (this.right_symbol.setY(rightPoint.y - this.right_symbol.height / 2),
872
- this.right_symbol.shiftX(this.group.getBBox().x + this.width + lineLength), function shift() {
873
- for (var symb, hasSymbolUnder = !1, i = 0, len = self.chart.symbols.length; len > i; i++) if (symb = self.chart.symbols[i],
874
- !self.params["align-next"] || "no" !== self.params["align-next"]) {
875
- var diff = Math.abs(symb.getCenter().x - self.right_symbol.getCenter().x);
876
- if (symb.getCenter().y > self.right_symbol.getCenter().y && diff <= self.right_symbol.width / 2) {
877
- hasSymbolUnder = !0;
878
- break;
879
- }
880
- }
881
- if (hasSymbolUnder) {
882
- if ("end" === self.right_symbol.symbolType) return;
883
- self.right_symbol.setX(symb.getX() + symb.width + lineLength), shift();
884
- }
885
- }(), this.right_symbol.isPositioned = !0, this.right_symbol.render());
886
- }
887
- }, Parallel.prototype.renderLines = function() {
888
- this.path1_symbol && this.drawLineTo(this.path1_symbol, "", this.path1_direction),
889
- this.path2_symbol && this.drawLineTo(this.path2_symbol, "", this.path2_direction),
890
- this.path3_symbol && this.drawLineTo(this.path3_symbol, "", this.path3_direction);
891
- }, module.exports = Parallel;
892
- }, /* 7 */
893
- /*!********************************!*\
894
- !*** ./src/flowchart.chart.js ***!
895
- \********************************/
896
- /***/
897
- function(module, exports, __webpack_require__) {
898
- function FlowChart(container, options) {
899
- options = options || {}, this.paper = new Raphael(container), this.options = defaults(options, defaultOptions),
900
- this.symbols = [], this.lines = [], this.start = null;
901
- }
902
- var Raphael = __webpack_require__(/*! raphael */ 16), defaults = __webpack_require__(/*! ./flowchart.helpers */ 1).defaults, defaultOptions = __webpack_require__(/*! ./flowchart.defaults */ 8), Condition = __webpack_require__(/*! ./flowchart.symbol.condition */ 5), Parallel = __webpack_require__(/*! ./flowchart.symbol.parallel */ 6);
903
- FlowChart.prototype.handle = function(symbol) {
904
- this.symbols.indexOf(symbol) <= -1 && this.symbols.push(symbol);
905
- var flowChart = this;
906
- return symbol instanceof Condition ? (symbol.yes = function(nextSymbol) {
907
- return symbol.yes_symbol = nextSymbol, symbol.no_symbol && (symbol.pathOk = !0),
908
- flowChart.handle(nextSymbol);
909
- }, symbol.no = function(nextSymbol) {
910
- return symbol.no_symbol = nextSymbol, symbol.yes_symbol && (symbol.pathOk = !0),
911
- flowChart.handle(nextSymbol);
912
- }) : symbol instanceof Parallel ? (symbol.path1 = function(nextSymbol) {
913
- return symbol.path1_symbol = nextSymbol, symbol.path2_symbol && (symbol.pathOk = !0),
914
- flowChart.handle(nextSymbol);
915
- }, symbol.path2 = function(nextSymbol) {
916
- return symbol.path2_symbol = nextSymbol, symbol.path3_symbol && (symbol.pathOk = !0),
917
- flowChart.handle(nextSymbol);
918
- }, symbol.path3 = function(nextSymbol) {
919
- return symbol.path3_symbol = nextSymbol, symbol.path1_symbol && (symbol.pathOk = !0),
920
- flowChart.handle(nextSymbol);
921
- }) : symbol.then = function(nextSymbol) {
922
- return symbol.next = nextSymbol, symbol.pathOk = !0, flowChart.handle(nextSymbol);
923
- }, symbol;
924
- }, FlowChart.prototype.startWith = function(symbol) {
925
- return this.start = symbol, this.handle(symbol);
926
- }, FlowChart.prototype.render = function() {
927
- var symbol, line, maxWidth = 0, maxHeight = 0, i = 0, len = 0, maxX = 0, maxY = 0, minX = 0, minY = 0;
928
- for (i = 0, len = this.symbols.length; len > i; i++) symbol = this.symbols[i], symbol.width > maxWidth && (maxWidth = symbol.width),
929
- symbol.height > maxHeight && (maxHeight = symbol.height);
930
- for (i = 0, len = this.symbols.length; len > i; i++) symbol = this.symbols[i], symbol.shiftX(this.options.x + (maxWidth - symbol.width) / 2 + this.options["line-width"]),
931
- symbol.shiftY(this.options.y + (maxHeight - symbol.height) / 2 + this.options["line-width"]);
932
- // for (i = 0, len = this.symbols.length; i < len; i++) {
933
- // symbol = this.symbols[i];
934
- // symbol.render();
935
- // }
936
- for (this.start.render(), i = 0, len = this.symbols.length; len > i; i++) symbol = this.symbols[i],
937
- symbol.renderLines();
938
- maxX = this.maxXFromLine;
939
- var x, y;
940
- for (i = 0, len = this.symbols.length; len > i; i++) symbol = this.symbols[i], x = symbol.getX() + symbol.width,
941
- y = symbol.getY() + symbol.height, x > maxX && (maxX = x), y > maxY && (maxY = y);
942
- for (i = 0, len = this.lines.length; len > i; i++) {
943
- line = this.lines[i].getBBox(), x = line.x, y = line.y;
944
- var x2 = line.x2, y2 = line.y2;
945
- minX > x && (minX = x), minY > y && (minY = y), x2 > maxX && (maxX = x2), y2 > maxY && (maxY = y2);
946
- }
947
- var scale = this.options.scale, lineWidth = this.options["line-width"];
948
- this.minXFromSymbols < minX && (minX = this.minXFromSymbols), 0 > minX && (minX -= lineWidth),
949
- 0 > minY && (minY -= lineWidth);
950
- var width = maxX + lineWidth - minX, height = maxY + lineWidth - minY;
951
- this.paper.setSize(width * scale, height * scale), this.paper.setViewBox(minX, minY, width, height, !0);
952
- }, FlowChart.prototype.clean = function() {
953
- if (this.paper) {
954
- var paperDom = this.paper.canvas;
955
- paperDom.parentNode && paperDom.parentNode.removeChild(paperDom);
956
- }
957
- }, module.exports = FlowChart;
958
- }, /* 8 */
959
- /*!***********************************!*\
960
- !*** ./src/flowchart.defaults.js ***!
961
- \***********************************/
962
- /***/
963
- function(module, exports) {
964
- // defaults
965
- module.exports = {
966
- x: 0,
967
- y: 0,
968
- "line-width": 3,
969
- "line-length": 50,
970
- "text-margin": 10,
971
- "font-size": 14,
972
- "font-color": "black",
973
- // 'font': 'normal',
974
- // 'font-family': 'calibri',
975
- // 'font-weight': 'normal',
976
- "line-color": "black",
977
- "element-color": "black",
978
- fill: "white",
979
- "yes-text": "yes",
980
- "no-text": "no",
981
- "arrow-end": "block",
982
- "class": "flowchart",
983
- scale: 1,
984
- symbols: {
985
- start: {},
986
- end: {},
987
- condition: {},
988
- inputoutput: {},
989
- operation: {},
990
- subroutine: {},
991
- parallel: {}
992
- }
993
- };
994
- }, /* 9 */
995
- /*!*******************************!*\
996
- !*** ./src/flowchart.shim.js ***!
997
- \*******************************/
998
- /***/
999
- function(module, exports) {
1000
- // add indexOf to non ECMA-262 standard compliant browsers
1001
- Array.prototype.indexOf || (Array.prototype.indexOf = function(searchElement) {
1002
- "use strict";
1003
- if (null === this) throw new TypeError();
1004
- var t = Object(this), len = t.length >>> 0;
1005
- if (0 === len) return -1;
1006
- var n = 0;
1007
- if (arguments.length > 0 && (n = Number(arguments[1]), n != n ? n = 0 : 0 !== n && n != 1 / 0 && n != -(1 / 0) && (n = (n > 0 || -1) * Math.floor(Math.abs(n)))),
1008
- n >= len) return -1;
1009
- for (var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); len > k; k++) if (k in t && t[k] === searchElement) return k;
1010
- return -1;
1011
- }), // add lastIndexOf to non ECMA-262 standard compliant browsers
1012
- Array.prototype.lastIndexOf || (Array.prototype.lastIndexOf = function(searchElement) {
1013
- "use strict";
1014
- if (null === this) throw new TypeError();
1015
- var t = Object(this), len = t.length >>> 0;
1016
- if (0 === len) return -1;
1017
- var n = len;
1018
- arguments.length > 1 && (n = Number(arguments[1]), n != n ? n = 0 : 0 !== n && n != 1 / 0 && n != -(1 / 0) && (n = (n > 0 || -1) * Math.floor(Math.abs(n))));
1019
- for (var k = n >= 0 ? Math.min(n, len - 1) : len - Math.abs(n); k >= 0; k--) if (k in t && t[k] === searchElement) return k;
1020
- return -1;
1021
- }), String.prototype.trim || (String.prototype.trim = function() {
1022
- return this.replace(/^\s+|\s+$/g, "");
1023
- });
1024
- }, /* 10 */
1025
- /*!*************************************!*\
1026
- !*** ./src/flowchart.symbol.end.js ***!
1027
- \*************************************/
1028
- /***/
1029
- function(module, exports, __webpack_require__) {
1030
- function End(chart, options) {
1031
- var symbol = chart.paper.rect(0, 0, 0, 0, 20);
1032
- options = options || {}, options.text = options.text || "End", Symbol.call(this, chart, options, symbol);
1033
- }
1034
- var Symbol = __webpack_require__(/*! ./flowchart.symbol */ 2), inherits = __webpack_require__(/*! ./flowchart.helpers */ 1).inherits;
1035
- inherits(End, Symbol), module.exports = End;
1036
- }, /* 11 */
1037
- /*!*********************************************!*\
1038
- !*** ./src/flowchart.symbol.inputoutput.js ***!
1039
- \*********************************************/
1040
- /***/
1041
- function(module, exports, __webpack_require__) {
1042
- function InputOutput(chart, options) {
1043
- options = options || {}, Symbol.call(this, chart, options), this.textMargin = this.getAttr("text-margin"),
1044
- this.text.attr({
1045
- x: 3 * this.textMargin
1046
- });
1047
- var width = this.text.getBBox().width + 4 * this.textMargin, height = this.text.getBBox().height + 2 * this.textMargin, startX = this.textMargin, startY = height / 2, start = {
1048
- x: startX,
1049
- y: startY
1050
- }, points = [ {
1051
- x: startX - this.textMargin,
1052
- y: height
1053
- }, {
1054
- x: startX - this.textMargin + width,
1055
- y: height
1056
- }, {
1057
- x: startX - this.textMargin + width + 2 * this.textMargin,
1058
- y: 0
1059
- }, {
1060
- x: startX - this.textMargin + 2 * this.textMargin,
1061
- y: 0
1062
- }, {
1063
- x: startX,
1064
- y: startY
1065
- } ], symbol = drawPath(chart, start, points);
1066
- symbol.attr({
1067
- stroke: this.getAttr("element-color"),
1068
- "stroke-width": this.getAttr("line-width"),
1069
- fill: this.getAttr("fill")
1070
- }), options.link && symbol.attr("href", options.link), options.target && symbol.attr("target", options.target),
1071
- options.key && (symbol.node.id = options.key), symbol.node.setAttribute("class", this.getAttr("class")),
1072
- this.text.attr({
1073
- y: symbol.getBBox().height / 2
1074
- }), this.group.push(symbol), symbol.insertBefore(this.text), this.initialize();
1075
- }
1076
- var Symbol = __webpack_require__(/*! ./flowchart.symbol */ 2), inherits = __webpack_require__(/*! ./flowchart.helpers */ 1).inherits, drawAPI = __webpack_require__(/*! ./flowchart.functions */ 3), drawPath = drawAPI.drawPath;
1077
- inherits(InputOutput, Symbol), InputOutput.prototype.getLeft = function() {
1078
- var y = this.getY() + this.group.getBBox().height / 2, x = this.getX() + this.textMargin;
1079
- return {
1080
- x: x,
1081
- y: y
1082
- };
1083
- }, InputOutput.prototype.getRight = function() {
1084
- var y = this.getY() + this.group.getBBox().height / 2, x = this.getX() + this.group.getBBox().width - this.textMargin;
1085
- return {
1086
- x: x,
1087
- y: y
1088
- };
1089
- }, module.exports = InputOutput;
1090
- }, /* 12 */
1091
- /*!*******************************************!*\
1092
- !*** ./src/flowchart.symbol.operation.js ***!
1093
- \*******************************************/
1094
- /***/
1095
- function(module, exports, __webpack_require__) {
1096
- function Operation(chart, options) {
1097
- var symbol = chart.paper.rect(0, 0, 0, 0);
1098
- options = options || {}, Symbol.call(this, chart, options, symbol);
1099
- }
1100
- var Symbol = __webpack_require__(/*! ./flowchart.symbol */ 2), inherits = __webpack_require__(/*! ./flowchart.helpers */ 1).inherits;
1101
- inherits(Operation, Symbol), module.exports = Operation;
1102
- }, /* 13 */
1103
- /*!***************************************!*\
1104
- !*** ./src/flowchart.symbol.start.js ***!
1105
- \***************************************/
1106
- /***/
1107
- function(module, exports, __webpack_require__) {
1108
- function Start(chart, options) {
1109
- var symbol = chart.paper.rect(0, 0, 0, 0, 20);
1110
- options = options || {}, options.text = options.text || "Start", Symbol.call(this, chart, options, symbol);
1111
- }
1112
- var Symbol = __webpack_require__(/*! ./flowchart.symbol */ 2), inherits = __webpack_require__(/*! ./flowchart.helpers */ 1).inherits;
1113
- inherits(Start, Symbol), module.exports = Start;
1114
- }, /* 14 */
1115
- /*!********************************************!*\
1116
- !*** ./src/flowchart.symbol.subroutine.js ***!
1117
- \********************************************/
1118
- /***/
1119
- function(module, exports, __webpack_require__) {
1120
- function Subroutine(chart, options) {
1121
- var symbol = chart.paper.rect(0, 0, 0, 0);
1122
- options = options || {}, Symbol.call(this, chart, options, symbol), symbol.attr({
1123
- width: this.text.getBBox().width + 4 * this.getAttr("text-margin")
1124
- }), this.text.attr({
1125
- x: 2 * this.getAttr("text-margin")
1126
- });
1127
- var innerWrap = chart.paper.rect(0, 0, 0, 0);
1128
- innerWrap.attr({
1129
- x: this.getAttr("text-margin"),
1130
- stroke: this.getAttr("element-color"),
1131
- "stroke-width": this.getAttr("line-width"),
1132
- width: this.text.getBBox().width + 2 * this.getAttr("text-margin"),
1133
- height: this.text.getBBox().height + 2 * this.getAttr("text-margin"),
1134
- fill: this.getAttr("fill")
1135
- }), options.key && (innerWrap.node.id = options.key + "i");
1136
- var font = this.getAttr("font"), fontF = this.getAttr("font-family"), fontW = this.getAttr("font-weight");
1137
- font && innerWrap.attr({
1138
- font: font
1139
- }), fontF && innerWrap.attr({
1140
- "font-family": fontF
1141
- }), fontW && innerWrap.attr({
1142
- "font-weight": fontW
1143
- }), options.link && innerWrap.attr("href", options.link), options.target && innerWrap.attr("target", options.target),
1144
- this.group.push(innerWrap), innerWrap.insertBefore(this.text), this.initialize();
1145
- }
1146
- var Symbol = __webpack_require__(/*! ./flowchart.symbol */ 2), inherits = __webpack_require__(/*! ./flowchart.helpers */ 1).inherits;
1147
- inherits(Subroutine, Symbol), module.exports = Subroutine;
1148
- }, /* 15 */
1149
- /*!******************************!*\
1150
- !*** ./src/jquery-plugin.js ***!
1151
- \******************************/
1152
- /***/
1153
- function(module, exports, __webpack_require__) {
1154
- if ("undefined" != typeof jQuery) {
1155
- var parse = __webpack_require__(/*! ./flowchart.parse */ 4);
1156
- !function($) {
1157
- function paramFit(needle, haystack) {
1158
- return needle == haystack || Array.isArray(haystack) && (haystack.includes(needle) || haystack.includes(Number(needle)));
1159
- }
1160
- var methods = {
1161
- init: function(options) {
1162
- return this.each(function() {
1163
- var $this = $(this);
1164
- this.chart = parse($this.text()), $this.html(""), this.chart.drawSVG(this, options);
1165
- });
1166
- },
1167
- setFlowStateByParam: function(param, paramValue, newFlowState) {
1168
- return this.each(function() {
1169
- var chart = this.chart, nextSymbolKeys = [ "next", "yes", "no", "path1", "path2", "path3" ];
1170
- for (var property in chart.symbols) if (chart.symbols.hasOwnProperty(property)) {
1171
- var symbol = chart.symbols[property], val = symbol.params[param];
1172
- if (paramFit(val, paramValue)) {
1173
- symbol.flowstate = newFlowState;
1174
- for (var nski = 0; nski < nextSymbolKeys.length; nski++) {
1175
- var nextSymbolKey = nextSymbolKeys[nski];
1176
- symbol[nextSymbolKey] && symbol[nextSymbolKey].params && symbol[nextSymbolKey].params[param] && paramFit(symbol[nextSymbolKey].params[param], paramValue) && (symbol.lineStyle[symbol[nextSymbolKey].key] = {
1177
- stroke: chart.options().flowstate[newFlowState].fill
1178
- });
1179
- }
1180
- }
1181
- }
1182
- chart.clean(), chart.drawSVG(this);
1183
- });
1184
- },
1185
- clearFlowState: function() {
1186
- return this.each(function() {
1187
- var chart = this.chart;
1188
- for (var property in chart.symbols) if (chart.symbols.hasOwnProperty(property)) {
1189
- var node = chart.symbols[property];
1190
- node.flowstate = "";
1191
- }
1192
- chart.clean(), chart.drawSVG(this);
1193
- });
1194
- }
1195
- };
1196
- $.fn.flowChart = function(methodOrOptions) {
1197
- return methods[methodOrOptions] ? methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1)) : "object" != typeof methodOrOptions && methodOrOptions ? void $.error("Method " + methodOrOptions + " does not exist on jQuery.flowChart") : methods.init.apply(this, arguments);
1198
- };
1199
- }(jQuery);
1200
- }
1201
- }, /* 16 */
1202
- /*!**************************!*\
1203
- !*** external "Raphael" ***!
1204
- \**************************/
1205
- /***/
1206
- function(module, exports) {
1207
- module.exports = __WEBPACK_EXTERNAL_MODULE_16__;
1208
- } ]);
1209
- });
1210
- //# sourceMappingURL=flowchart.js.map