reservation plugin - unbound request (unclean
[unfold.git] / portal / static / unbound_reservation_static / src / overlays-guidelines.js
1     // this is really just a test overlay, so its undocumented and doesnt take any parameters. but i was loth to delete it.
2     jsPlumb.Overlays.GuideLines = function() {
3         var self = this;
4         self.length = 50;
5         self.lineWidth = 5;
6         this.type = "GuideLines";
7                 AbstractOverlay.apply(this, arguments);
8         jsPlumb.jsPlumbUIComponent.apply(this, arguments);
9         this.draw = function(connector, currentConnectionPaintStyle, connectorDimensions) {
10
11             var head = connector.pointAlongPathFrom(self.loc, self.length / 2),
12                 mid = connector.pointOnPath(self.loc),
13                 tail = jsPlumbGeom.pointOnLine(head, mid, self.length),
14                 tailLine = jsPlumbGeom.perpendicularLineTo(head, tail, 40),
15                 headLine = jsPlumbGeom.perpendicularLineTo(tail, head, 20);
16
17             self.paint(connector, [head, tail, tailLine, headLine], self.lineWidth, "red", null, connectorDimensions);
18
19             return [Math.min(head.x, tail.x), Math.min(head.y, tail.y), Math.max(head.x, tail.x), Math.max(head.y,tail.y)];
20         };
21
22         this.computeMaxSize = function() { return 50; };
23
24         this.cleanup = function() { };  // nothing to clean up for GuideLines
25     };
26
27 // a test
28     jsPlumb.Overlays.svg.GuideLines = function() {
29         var path = null, self = this, path2 = null, p1_1, p1_2;
30         jsPlumb.Overlays.GuideLines.apply(this, arguments);
31         this.paint = function(connector, d, lineWidth, strokeStyle, fillStyle) {
32                 if (path == null) {
33                         path = _node("path");
34                         connector.svg.appendChild(path);
35                         self.attachListeners(path, connector);
36                         self.attachListeners(path, self);
37
38                 p1_1 = _node("path");
39                         connector.svg.appendChild(p1_1);
40                         self.attachListeners(p1_1, connector);
41                         self.attachListeners(p1_1, self);
42
43                 p1_2 = _node("path");
44                         connector.svg.appendChild(p1_2);
45                         self.attachListeners(p1_2, connector);
46                         self.attachListeners(p1_2, self);
47
48                 }
49
50                 _attr(path, {
51                         "d"             :       makePath(d[0], d[1]),
52                         stroke  :       "red",
53                         fill    :       null
54                 });
55
56             _attr(p1_1, {
57                         "d"             :       makePath(d[2][0], d[2][1]),
58                         stroke  :       "blue",
59                         fill    :       null
60                 });
61
62             _attr(p1_2, {
63                         "d"             :       makePath(d[3][0], d[3][1]),
64                         stroke  :       "green",
65                         fill    :       null
66                 });
67         };
68
69         var makePath = function(d1, d2) {
70             return "M " + d1.x + "," + d1.y +
71                    " L" + d2.x + "," + d2.y;
72         };
73     };