blob: ad85d9043c490d62eb1b2404cd994a5fbd1b5eef [file] [log] [blame]
Simon Hunt86388b12015-01-09 14:23:26 -08001/*
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 -- Navigation Module
Simon Hunt86388b12015-01-09 14:23:26 -080019 */
20(function () {
21 'use strict';
22
23 // injected dependencies
24 var $log;
25
26 // internal state
27 var navShown = false;
28
29 function updatePane() {
30 var vis = navShown ? 'visible' : 'hidden';
31 d3.select('#nav').style('visibility', vis);
32 }
33
34
35 function showNav() {
36 navShown = true;
37 updatePane();
38 }
39 function hideNav() {
40 navShown = false;
41 updatePane();
42 }
43 function toggleNav() {
44 navShown = !navShown;
45 updatePane();
46 }
Simon Hunt9d286562015-03-09 13:53:50 -070047 function hideIfShown() {
48 if (navShown) {
49 hideNav();
50 return true;
51 }
52 return false;
53 }
Simon Hunt86388b12015-01-09 14:23:26 -080054
55 angular.module('onosNav', [])
56 .controller('NavCtrl', [
57 '$log', function (_$log_) {
58 var self = this;
59 $log = _$log_;
60
61 self.hideNav = hideNav;
62 $log.log('NavCtrl has been created');
63 }
64 ])
65 .factory('NavService', ['$log', function (_$log_) {
66 $log = _$log_;
67
68 return {
69 showNav: showNav,
70 hideNav: hideNav,
Simon Hunt9d286562015-03-09 13:53:50 -070071 toggleNav: toggleNav,
72 hideIfShown: hideIfShown
Simon Hunt86388b12015-01-09 14:23:26 -080073 };
74 }]);
75
76}());