Committed by
Gerrit Code Review
GUI -- Implemented "Show Traffic on hover" toggle button in masthead.
- also included sample *Instance events. Change-Id: Ibdee2b6c54a0a192361d269dbe69128d44604838
Showing
5 changed files
with
92 additions
and
1 deletions
... | @@ -91,3 +91,47 @@ | ... | @@ -91,3 +91,47 @@ |
91 | border: 1px solid #eee; | 91 | border: 1px solid #eee; |
92 | color: #aaf; | 92 | color: #aaf; |
93 | } | 93 | } |
94 | + | ||
95 | +/* Button Bar */ | ||
96 | + | ||
97 | +#bb { | ||
98 | + margin: 0 30px; | ||
99 | + padding: 0 2px; | ||
100 | +} | ||
101 | + | ||
102 | +#bb .btn { | ||
103 | + padding: 2px 6px; | ||
104 | + font-size: 9pt; | ||
105 | + cursor: pointer; | ||
106 | +} | ||
107 | + | ||
108 | +.light #bb .btn { | ||
109 | + border: 1px solid #fff; | ||
110 | + border-right-color: #444; | ||
111 | + border-bottom-color: #444; | ||
112 | + color: #222; | ||
113 | +} | ||
114 | + | ||
115 | +.light #bb .btn.active { | ||
116 | + border: 1px solid #444; | ||
117 | + border-right-color: #fff; | ||
118 | + border-bottom-color: #fff; | ||
119 | + background-color: #888; | ||
120 | + color: #ddf; | ||
121 | +} | ||
122 | + | ||
123 | +.dark #bb .btn { | ||
124 | + border: 1px solid #888; | ||
125 | + border-right-color: #111; | ||
126 | + border-bottom-color: #111; | ||
127 | + color: #888; | ||
128 | +} | ||
129 | + | ||
130 | +.dark #bb .btn.active { | ||
131 | + border: 1px solid #111; | ||
132 | + border-right-color: #888; | ||
133 | + border-bottom-color: #888; | ||
134 | + background-color: #555; | ||
135 | + color: #bbd; | ||
136 | +} | ||
137 | + | ... | ... |
... | @@ -1385,11 +1385,33 @@ | ... | @@ -1385,11 +1385,33 @@ |
1385 | 1385 | ||
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | - | ||
1389 | function para(sel, text) { | 1388 | function para(sel, text) { |
1390 | sel.append('p').text(text); | 1389 | sel.append('p').text(text); |
1391 | } | 1390 | } |
1392 | 1391 | ||
1392 | + // TODO: toggle button (and other widgets in the masthead) should be provided | ||
1393 | + // by the framework; not generated by the view. | ||
1394 | + | ||
1395 | + var showTrafficOnHover; | ||
1396 | + | ||
1397 | + function addButtonBar(view) { | ||
1398 | + var bb = d3.select('#mast') | ||
1399 | + .append('span').classed('right', true).attr('id', 'bb'); | ||
1400 | + | ||
1401 | + showTrafficOnHover = bb.append('div') | ||
1402 | + .classed('btn', true) | ||
1403 | + .text('Show traffic on hover') | ||
1404 | + .on('click', toggleShowTraffic); | ||
1405 | + } | ||
1406 | + | ||
1407 | + function toggleShowTraffic() { | ||
1408 | + showTrafficOnHover.classed('active', !trafficHover()); | ||
1409 | + } | ||
1410 | + | ||
1411 | + function trafficHover() { | ||
1412 | + return showTrafficOnHover.classed('active'); | ||
1413 | + } | ||
1414 | + | ||
1393 | // ============================== | 1415 | // ============================== |
1394 | // View life-cycle callbacks | 1416 | // View life-cycle callbacks |
1395 | 1417 | ||
... | @@ -1496,6 +1518,10 @@ | ... | @@ -1496,6 +1518,10 @@ |
1496 | view.setRadio(btnSet); | 1518 | view.setRadio(btnSet); |
1497 | view.setKeys(keyDispatch); | 1519 | view.setKeys(keyDispatch); |
1498 | 1520 | ||
1521 | + // patch in our "button bar" for now | ||
1522 | + // TODO: implement a more official frameworky way of doing this.. | ||
1523 | + addButtonBar(view); | ||
1524 | + | ||
1499 | // Load map data asynchronously; complete startup after that.. | 1525 | // Load map data asynchronously; complete startup after that.. |
1500 | loadGeoJsonData(); | 1526 | loadGeoJsonData(); |
1501 | } | 1527 | } | ... | ... |
-
Please register or login to post a comment