blob: bf9e484aada052ef3205e6e9bc213338bf77f44b [file] [log] [blame]
Simon Huntb9c495e2015-11-05 15:08:06 -08001// UI Reference App - topology overlay - client side
2//
3// This is the glue that binds our business logic (in uiRefTopovDemo.js)
4// to the overlay framework.
5
6(function () {
7 'use strict';
8
9 // injected refs
Simon Hunt97f2dbb2015-11-06 13:39:58 -080010 var $log, tov, demo;
Simon Huntb9c495e2015-11-05 15:08:06 -080011
12 // internal state should be kept in the service module (not here)
13
Simon Huntdf8a6402016-02-04 10:58:54 -080014 var smiley = "M97,20.3A9.3,9.3,0,0,0,87.7,11H24.3A9.3,9.3,0,0,0,15,20.3" +
15 "V64.7A9.3,9.3,0,0,0,24.3,74H87.7A9.3,9.3,0,0,0,97,64.7V20.3Z" +
16 "M54.5,19.1A24.3,24.3,0,1,1,30.2,43.3,24.3,24.3,0,0,1,54.5,19.1Z" +
17 "M104.7,94.9L97.6,82.8c-0.9-1.6-3.7-2.8-6.1-2.8H18.9" +
18 "c-2.5,0-5.2,1.3-6.1,2.8L5.6,94.9C4.3,97.1,5.7,99,8.9,99h92.6" +
19 "C104.6,99,106.1,97.1,104.7,94.9ZM54.5,56.5" +
20 "c-7.3,0-17.2-8.6-13.3-7.4,13,3.9,13.7,3.9,26.5,0" +
21 "C71.7,48,61.9,56.6,54.5,56.6Z" +
22 "M38,33.9C38,32,40.2,31,42.1,31h7.3" +
23 "a3.2,3.2,0,0,1,3.1,1.7,13.1,13.1,0,0,1,2.1-.3,12.9,12.9,0,0,1,2.1.4" +
24 "A3.3,3.3,0,0,1,59.7,31H67c1.9,0,4,1,4,2.9v3.2A4.4,4.4,0,0,1,67,41" +
25 "H59.7A4,4,0,0,1,56,37.1V33.9h0a4.4,4.4,0,0,0-1.6-.2l-1.5.2H53v3.2" +
26 "A4,4,0,0,1,49.4,41H42.1A4.4,4.4,0,0,1,38,37.1V33.9Z";
27
Simon Huntb9c495e2015-11-05 15:08:06 -080028 // our overlay definition
29 var overlay = {
30 // NOTE: this must match the ID defined in UiRefTopoOverlay
31 overlayId: 'ui-ref-overlay',
Simon Huntdf8a6402016-02-04 10:58:54 -080032 glyphId: '*smiley',
Simon Huntb9c495e2015-11-05 15:08:06 -080033 tooltip: 'UI Reference Overlay',
34
35 // These glyphs get installed using the overlayId as a prefix.
36 // e.g. 'star4' is installed as 'ui-ref-overlay-star4'
37 // They can be referenced (from this overlay) as '*star4'
38 // That is, the '*' prefix stands in for 'ui-ref-overlay-'
39 glyphs: {
Simon Huntdf8a6402016-02-04 10:58:54 -080040 smiley: {
41 vb: '0 0 110 110',
42 d: smiley
43 },
Simon Huntb9c495e2015-11-05 15:08:06 -080044 star4: {
45 vb: '0 0 8 8',
46 d: 'M1,4l2,-1l1,-2l1,2l2,1l-2,1l-1,2l-1,-2z'
47 },
48 banner: {
49 vb: '0 0 6 6',
50 d: 'M1,1v4l2,-2l2,2v-4z'
51 }
52 },
53
54 activate: function () {
55 $log.debug("UI Ref topology overlay ACTIVATED");
56 },
57 deactivate: function () {
Simon Hunt97f2dbb2015-11-06 13:39:58 -080058 demo.stopDisplay();
Simon Huntb9c495e2015-11-05 15:08:06 -080059 $log.debug("UI Ref topology overlay DEACTIVATED");
60 },
61
62 // detail panel button definitions
63 buttons: {
64 foo: {
65 gid: 'chain',
66 tt: 'A FOO action',
Simon Hunt97f2dbb2015-11-06 13:39:58 -080067 cb: function() {
68 demo.deviceDialog();
Simon Huntb9c495e2015-11-05 15:08:06 -080069 }
70 },
71 bar: {
72 gid: '*banner',
73 tt: 'A BAR action',
74 cb: function (data) {
75 $log.debug('BAR action invoked with data:', data);
76 }
77 }
78 },
79
80 // Key bindings for traffic overlay buttons
81 // NOTE: fully qual. button ID is derived from overlay-id and key-name
82 keyBindings: {
83 0: {
Simon Hunt97f2dbb2015-11-06 13:39:58 -080084 cb: function () { demo.stopDisplay(); },
Simon Huntb9c495e2015-11-05 15:08:06 -080085 tt: 'Cancel Display Mode',
86 gid: 'xMark'
87 },
88 V: {
Simon Hunt97f2dbb2015-11-06 13:39:58 -080089 cb: function () { demo.startDisplay('mouse'); },
Simon Huntb9c495e2015-11-05 15:08:06 -080090 tt: 'Start Mouse Mode',
91 gid: '*banner'
92 },
93 F: {
Simon Hunt97f2dbb2015-11-06 13:39:58 -080094 cb: function () { demo.startDisplay('link'); },
Simon Huntb9c495e2015-11-05 15:08:06 -080095 tt: 'Start Link Mode',
96 gid: 'chain'
97 },
98 G: {
Simon Huntfb658672015-11-09 13:05:54 -080099 cb: function () { demo.listDialog(); },
Simon Huntb9c495e2015-11-05 15:08:06 -0800100 tt: 'Uses the G key',
101 gid: 'crown'
102 },
103
104 _keyOrder: [
105 '0', 'V', 'F', 'G'
106 ]
107 },
108
109 hooks: {
110 // hook for handling escape key
111 // Must return true to consume ESC, false otherwise.
112 escape: function () {
113 // Must return true to consume ESC, false otherwise.
Simon Hunt97f2dbb2015-11-06 13:39:58 -0800114 return demo.stopDisplay();
Simon Huntb9c495e2015-11-05 15:08:06 -0800115 },
116
117 // hooks for when the selection changes...
118 empty: function () {
119 selectionCallback('empty');
120 },
121 single: function (data) {
122 selectionCallback('single', data);
123 },
124 multi: function (selectOrder) {
125 selectionCallback('multi', selectOrder);
126 tov.addDetailButton('foo');
127 tov.addDetailButton('bar');
128 },
129 mouseover: function (m) {
130 // m has id, class, and type properties
131 $log.debug('mouseover:', m);
Simon Hunt97f2dbb2015-11-06 13:39:58 -0800132 demo.updateDisplay(m);
Simon Huntb9c495e2015-11-05 15:08:06 -0800133 },
134 mouseout: function () {
135 $log.debug('mouseout');
Simon Hunt97f2dbb2015-11-06 13:39:58 -0800136 demo.updateDisplay();
Simon Huntb9c495e2015-11-05 15:08:06 -0800137 }
138 }
139 };
140
Simon Huntb9c495e2015-11-05 15:08:06 -0800141 function selectionCallback(x, d) {
142 $log.debug('Selection callback', x, d);
143 }
144
145 // invoke code to register with the overlay service
146 angular.module('ovUiRefTopov')
147 .run(['$log', 'TopoOverlayService', 'UiRefTopovDemoService',
148
Simon Hunt97f2dbb2015-11-06 13:39:58 -0800149 function (_$log_, _tov_, _demo_) {
Simon Huntb9c495e2015-11-05 15:08:06 -0800150 $log = _$log_;
151 tov = _tov_;
Simon Hunt97f2dbb2015-11-06 13:39:58 -0800152 demo = _demo_;
Simon Huntb9c495e2015-11-05 15:08:06 -0800153 tov.register(overlay);
154 }]);
155
156}());