Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 1 | // 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 Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 10 | var $log, tov, demo; |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 11 | |
| 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 Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 40 | demo.stopDisplay(); |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 41 | $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 Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 49 | cb: function() { |
| 50 | demo.deviceDialog(); |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 51 | } |
| 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 Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 66 | cb: function () { demo.stopDisplay(); }, |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 67 | tt: 'Cancel Display Mode', |
| 68 | gid: 'xMark' |
| 69 | }, |
| 70 | V: { |
Simon Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 71 | cb: function () { demo.startDisplay('mouse'); }, |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 72 | tt: 'Start Mouse Mode', |
| 73 | gid: '*banner' |
| 74 | }, |
| 75 | F: { |
Simon Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 76 | cb: function () { demo.startDisplay('link'); }, |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 77 | tt: 'Start Link Mode', |
| 78 | gid: 'chain' |
| 79 | }, |
| 80 | G: { |
Simon Hunt | fb65867 | 2015-11-09 13:05:54 -0800 | [diff] [blame] | 81 | cb: function () { demo.listDialog(); }, |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 82 | 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 Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 96 | return demo.stopDisplay(); |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 97 | }, |
| 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 Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 114 | demo.updateDisplay(m); |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 115 | }, |
| 116 | mouseout: function () { |
| 117 | $log.debug('mouseout'); |
Simon Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 118 | demo.updateDisplay(); |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 119 | } |
| 120 | } |
| 121 | }; |
| 122 | |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 123 | 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 Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 131 | function (_$log_, _tov_, _demo_) { |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 132 | $log = _$log_; |
| 133 | tov = _tov_; |
Simon Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 134 | demo = _demo_; |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 135 | tov.register(overlay); |
| 136 | }]); |
| 137 | |
| 138 | }()); |