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 | |
Simon Hunt | df8a640 | 2016-02-04 10:58:54 -0800 | [diff] [blame^] | 14 | 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 Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 28 | // our overlay definition |
| 29 | var overlay = { |
| 30 | // NOTE: this must match the ID defined in UiRefTopoOverlay |
| 31 | overlayId: 'ui-ref-overlay', |
Simon Hunt | df8a640 | 2016-02-04 10:58:54 -0800 | [diff] [blame^] | 32 | glyphId: '*smiley', |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 33 | 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 Hunt | df8a640 | 2016-02-04 10:58:54 -0800 | [diff] [blame^] | 40 | smiley: { |
| 41 | vb: '0 0 110 110', |
| 42 | d: smiley |
| 43 | }, |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 44 | 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 Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 58 | demo.stopDisplay(); |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 59 | $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 Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 67 | cb: function() { |
| 68 | demo.deviceDialog(); |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 69 | } |
| 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 Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 84 | cb: function () { demo.stopDisplay(); }, |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 85 | tt: 'Cancel Display Mode', |
| 86 | gid: 'xMark' |
| 87 | }, |
| 88 | V: { |
Simon Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 89 | cb: function () { demo.startDisplay('mouse'); }, |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 90 | tt: 'Start Mouse Mode', |
| 91 | gid: '*banner' |
| 92 | }, |
| 93 | F: { |
Simon Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 94 | cb: function () { demo.startDisplay('link'); }, |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 95 | tt: 'Start Link Mode', |
| 96 | gid: 'chain' |
| 97 | }, |
| 98 | G: { |
Simon Hunt | fb65867 | 2015-11-09 13:05:54 -0800 | [diff] [blame] | 99 | cb: function () { demo.listDialog(); }, |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 100 | 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 Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 114 | return demo.stopDisplay(); |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 115 | }, |
| 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 Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 132 | demo.updateDisplay(m); |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 133 | }, |
| 134 | mouseout: function () { |
| 135 | $log.debug('mouseout'); |
Simon Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 136 | demo.updateDisplay(); |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 137 | } |
| 138 | } |
| 139 | }; |
| 140 | |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 141 | 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 Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 149 | function (_$log_, _tov_, _demo_) { |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 150 | $log = _$log_; |
| 151 | tov = _tov_; |
Simon Hunt | 97f2dbb | 2015-11-06 13:39:58 -0800 | [diff] [blame] | 152 | demo = _demo_; |
Simon Hunt | b9c495e | 2015-11-05 15:08:06 -0800 | [diff] [blame] | 153 | tov.register(overlay); |
| 154 | }]); |
| 155 | |
| 156 | }()); |