blob: 2295fa118e41e7f0540f2751598574eb1d9e6dc0 [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
14 // our overlay definition
15 var overlay = {
16 // NOTE: this must match the ID defined in UiRefTopoOverlay
17 overlayId: 'ui-ref-overlay',
18 glyphId: '*star4',
19 tooltip: 'UI Reference Overlay',
20
21 // These glyphs get installed using the overlayId as a prefix.
22 // e.g. 'star4' is installed as 'ui-ref-overlay-star4'
23 // They can be referenced (from this overlay) as '*star4'
24 // That is, the '*' prefix stands in for 'ui-ref-overlay-'
25 glyphs: {
26 star4: {
27 vb: '0 0 8 8',
28 d: 'M1,4l2,-1l1,-2l1,2l2,1l-2,1l-1,2l-1,-2z'
29 },
30 banner: {
31 vb: '0 0 6 6',
32 d: 'M1,1v4l2,-2l2,2v-4z'
33 }
34 },
35
36 activate: function () {
37 $log.debug("UI Ref topology overlay ACTIVATED");
38 },
39 deactivate: function () {
Simon Hunt97f2dbb2015-11-06 13:39:58 -080040 demo.stopDisplay();
Simon Huntb9c495e2015-11-05 15:08:06 -080041 $log.debug("UI Ref topology overlay DEACTIVATED");
42 },
43
44 // detail panel button definitions
45 buttons: {
46 foo: {
47 gid: 'chain',
48 tt: 'A FOO action',
Simon Hunt97f2dbb2015-11-06 13:39:58 -080049 cb: function() {
50 demo.deviceDialog();
Simon Huntb9c495e2015-11-05 15:08:06 -080051 }
52 },
53 bar: {
54 gid: '*banner',
55 tt: 'A BAR action',
56 cb: function (data) {
57 $log.debug('BAR action invoked with data:', data);
58 }
59 }
60 },
61
62 // Key bindings for traffic overlay buttons
63 // NOTE: fully qual. button ID is derived from overlay-id and key-name
64 keyBindings: {
65 0: {
Simon Hunt97f2dbb2015-11-06 13:39:58 -080066 cb: function () { demo.stopDisplay(); },
Simon Huntb9c495e2015-11-05 15:08:06 -080067 tt: 'Cancel Display Mode',
68 gid: 'xMark'
69 },
70 V: {
Simon Hunt97f2dbb2015-11-06 13:39:58 -080071 cb: function () { demo.startDisplay('mouse'); },
Simon Huntb9c495e2015-11-05 15:08:06 -080072 tt: 'Start Mouse Mode',
73 gid: '*banner'
74 },
75 F: {
Simon Hunt97f2dbb2015-11-06 13:39:58 -080076 cb: function () { demo.startDisplay('link'); },
Simon Huntb9c495e2015-11-05 15:08:06 -080077 tt: 'Start Link Mode',
78 gid: 'chain'
79 },
80 G: {
Simon Huntfb658672015-11-09 13:05:54 -080081 cb: function () { demo.listDialog(); },
Simon Huntb9c495e2015-11-05 15:08:06 -080082 tt: 'Uses the G key',
83 gid: 'crown'
84 },
85
86 _keyOrder: [
87 '0', 'V', 'F', 'G'
88 ]
89 },
90
91 hooks: {
92 // hook for handling escape key
93 // Must return true to consume ESC, false otherwise.
94 escape: function () {
95 // Must return true to consume ESC, false otherwise.
Simon Hunt97f2dbb2015-11-06 13:39:58 -080096 return demo.stopDisplay();
Simon Huntb9c495e2015-11-05 15:08:06 -080097 },
98
99 // hooks for when the selection changes...
100 empty: function () {
101 selectionCallback('empty');
102 },
103 single: function (data) {
104 selectionCallback('single', data);
105 },
106 multi: function (selectOrder) {
107 selectionCallback('multi', selectOrder);
108 tov.addDetailButton('foo');
109 tov.addDetailButton('bar');
110 },
111 mouseover: function (m) {
112 // m has id, class, and type properties
113 $log.debug('mouseover:', m);
Simon Hunt97f2dbb2015-11-06 13:39:58 -0800114 demo.updateDisplay(m);
Simon Huntb9c495e2015-11-05 15:08:06 -0800115 },
116 mouseout: function () {
117 $log.debug('mouseout');
Simon Hunt97f2dbb2015-11-06 13:39:58 -0800118 demo.updateDisplay();
Simon Huntb9c495e2015-11-05 15:08:06 -0800119 }
120 }
121 };
122
Simon Huntb9c495e2015-11-05 15:08:06 -0800123 function selectionCallback(x, d) {
124 $log.debug('Selection callback', x, d);
125 }
126
127 // invoke code to register with the overlay service
128 angular.module('ovUiRefTopov')
129 .run(['$log', 'TopoOverlayService', 'UiRefTopovDemoService',
130
Simon Hunt97f2dbb2015-11-06 13:39:58 -0800131 function (_$log_, _tov_, _demo_) {
Simon Huntb9c495e2015-11-05 15:08:06 -0800132 $log = _$log_;
133 tov = _tov_;
Simon Hunt97f2dbb2015-11-06 13:39:58 -0800134 demo = _demo_;
Simon Huntb9c495e2015-11-05 15:08:06 -0800135 tov.register(overlay);
136 }]);
137
138}());