Simon Hunt
Committed by Gerrit Code Review

GUI -- Navigation Pane canceled with Escape key.

- Also, fixed color of drop shadow on .dark navigation pane.

Change-Id: I43fa58923158ad3f637e9f8c3dbd50043e89176e
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
34 } 34 }
35 .dark #nav { 35 .dark #nav {
36 background-color: #444; 36 background-color: #444;
37 - box-shadow: 0 2px 8px #555; 37 + box-shadow: 0 2px 8px #111;
38 } 38 }
39 39
40 #nav a { 40 #nav a {
......
...@@ -44,6 +44,13 @@ ...@@ -44,6 +44,13 @@
44 navShown = !navShown; 44 navShown = !navShown;
45 updatePane(); 45 updatePane();
46 } 46 }
47 + function hideIfShown() {
48 + if (navShown) {
49 + hideNav();
50 + return true;
51 + }
52 + return false;
53 + }
47 54
48 angular.module('onosNav', []) 55 angular.module('onosNav', [])
49 .controller('NavCtrl', [ 56 .controller('NavCtrl', [
...@@ -61,7 +68,8 @@ ...@@ -61,7 +68,8 @@
61 return { 68 return {
62 showNav: showNav, 69 showNav: showNav,
63 hideNav: hideNav, 70 hideNav: hideNav,
64 - toggleNav: toggleNav 71 + toggleNav: toggleNav,
72 + hideIfShown: hideIfShown
65 }; 73 };
66 }]); 74 }]);
67 75
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
21 'use strict'; 21 'use strict';
22 22
23 // references to injected services 23 // references to injected services
24 - var $log, fs, ts, qhs; 24 + var $log, fs, ts, ns, qhs;
25 25
26 // internal state 26 // internal state
27 var enabled = true, 27 var enabled = true,
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
33 viewGestures: [] 33 viewGestures: []
34 }; 34 };
35 35
36 - // TODO: we need to have the concept of view token here.. 36 + // TODO: do we still need to have the concept of view token here..?
37 function getViewToken() { 37 function getViewToken() {
38 return 'NotYetAViewToken'; 38 return 'NotYetAViewToken';
39 } 39 }
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
121 121
122 // returns true if we 'consumed' the ESC keypress, false otherwise 122 // returns true if we 'consumed' the ESC keypress, false otherwise
123 function escapeKey(view, key, code, ev) { 123 function escapeKey(view, key, code, ev) {
124 - return qhs.hideQuickHelp(); 124 + return ns.hideIfShown() || qhs.hideQuickHelp();
125 } 125 }
126 126
127 function toggleTheme(view, key, code, ev) { 127 function toggleTheme(view, key, code, ev) {
...@@ -168,12 +168,13 @@ ...@@ -168,12 +168,13 @@
168 168
169 angular.module('onosUtil') 169 angular.module('onosUtil')
170 .factory('KeyService', 170 .factory('KeyService',
171 - ['$log', 'FnService', 'ThemeService', 171 + ['$log', 'FnService', 'ThemeService', 'NavService',
172 172
173 - function (_$log_, _fs_, _ts_) { 173 + function (_$log_, _fs_, _ts_, _ns_) {
174 $log = _$log_; 174 $log = _$log_;
175 fs = _fs_; 175 fs = _fs_;
176 ts = _ts_; 176 ts = _ts_;
177 + ns = _ns_;
177 178
178 return { 179 return {
179 bindQhs: function (_qhs_) { 180 bindQhs: function (_qhs_) {
......
1 +/*
2 + * Copyright 2014,2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +/*
18 + ONOS GUI -- Util -- Theme Service - Unit Tests
19 + */
20 +describe('factory: fw/nav/nav.js', function() {
21 + var ns, $log, fs;
22 + var d3Elem;
23 +
24 + beforeEach(module('onosNav', 'onosUtil'));
25 +
26 + beforeEach(inject(function (NavService, _$log_, FnService) {
27 + ns = NavService;
28 + $log = _$log_;
29 + fs = FnService;
30 + d3Elem = d3.select('body').append('div').attr('id', 'nav');
31 + ns.hideNav();
32 + }));
33 +
34 + afterEach(function () {
35 + d3.select('#nav').remove();
36 + });
37 +
38 + it('should define NavService', function () {
39 + expect(ns).toBeDefined();
40 + });
41 +
42 + it('should define api functions', function () {
43 + expect(fs.areFunctions(ns, [
44 + 'showNav', 'hideNav', 'toggleNav', 'hideIfShown'
45 + ])).toBeTruthy();
46 + });
47 +
48 + function checkHidden(b) {
49 + var what = b ? 'hidden' : 'visible';
50 + expect(d3.select('#nav').style('visibility')).toEqual(what);
51 + }
52 +
53 + it('should start hidden', function () {
54 + checkHidden(true);
55 + });
56 +
57 + it('should be shown then hidden', function () {
58 + ns.showNav();
59 + checkHidden(false);
60 + ns.hideNav();
61 + checkHidden(true);
62 + });
63 +
64 + it('should toggle hidden', function () {
65 + ns.toggleNav();
66 + checkHidden(false);
67 + ns.toggleNav();
68 + checkHidden(true);
69 + });
70 +
71 + it('should show idempotently', function () {
72 + checkHidden(true);
73 + ns.showNav();
74 + checkHidden(false);
75 + ns.showNav();
76 + checkHidden(false);
77 + });
78 +
79 + it('should hide idempotently', function () {
80 + checkHidden(true);
81 + ns.hideNav();
82 + checkHidden(true);
83 + });
84 +
85 + it('should be a noop if already hidden', function () {
86 + checkHidden(true);
87 + expect(ns.hideIfShown()).toBe(false);
88 + checkHidden(true);
89 + });
90 +
91 + it('should hide if shown', function () {
92 + ns.showNav();
93 + checkHidden(false);
94 + expect(ns.hideIfShown()).toBe(true);
95 + checkHidden(true);
96 + });
97 +
98 +});
...@@ -22,7 +22,7 @@ describe('factory: fw/util/keys.js', function() { ...@@ -22,7 +22,7 @@ describe('factory: fw/util/keys.js', function() {
22 d3Elem, elem, last; 22 d3Elem, elem, last;
23 23
24 24
25 - beforeEach(module('onosUtil', 'onosSvg', 'onosLayer')); 25 + beforeEach(module('onosUtil', 'onosSvg', 'onosLayer', 'onosNav'));
26 26
27 beforeEach(inject(function (_$log_, KeyService, FnService, QuickHelpService) { 27 beforeEach(inject(function (_$log_, KeyService, FnService, QuickHelpService) {
28 $log = _$log_; 28 $log = _$log_;
......
...@@ -38,7 +38,8 @@ describe('Controller: OvDeviceCtrl', function () { ...@@ -38,7 +38,8 @@ describe('Controller: OvDeviceCtrl', function () {
38 }; 38 };
39 39
40 // instantiate the Device module 40 // instantiate the Device module
41 - beforeEach(module('ovDevice', 'onosRemote', 'onosLayer', 'onosSvg', 'ngRoute')); 41 + beforeEach(module('ovDevice', 'onosRemote', 'onosLayer', 'onosSvg',
42 + 'onosNav', 'ngRoute'));
42 43
43 beforeEach(inject(function(_$log_, $rootScope, _$controller_, $httpBackend) { 44 beforeEach(inject(function(_$log_, $rootScope, _$controller_, $httpBackend) {
44 $log = _$log_; 45 $log = _$log_;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
20 describe('factory: view/topo/topoEvent.js', function() { 20 describe('factory: view/topo/topoEvent.js', function() {
21 var $log, fs, tes; 21 var $log, fs, tes;
22 22
23 - beforeEach(module('ovTopo', 'onosUtil', 'onosLayer', 'ngRoute')); 23 + beforeEach(module('ovTopo', 'onosNav', 'onosUtil', 'onosLayer', 'ngRoute'));
24 24
25 beforeEach(inject(function (_$log_, FnService, TopoEventService) { 25 beforeEach(inject(function (_$log_, FnService, TopoEventService) {
26 $log = _$log_; 26 $log = _$log_;
......