b60ffb2771fb92e88564ce689e352c57e45d6654
[portal.git] / ecomp-portal-FE-common / client / app / directives / b2b-leftnav-ext / b2b-leftnav-ext.directive.js
1 /*-
2  * ================================================================================
3  * ECOMP Portal
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20 (function () {
21         /*
22          * Custom version of b2b-left-navigation directive:
23          * 1. Make parent menu a link if no child menus.
24          * 2. Add unique IDs to all items.
25          * 3. Hide icon if no child menus.
26          * 4. Add arrow toggle button.
27          * 5. Adjust the page on collapse/expand.
28          */
29     class B2BLeftMenu {
30         constructor($rootScope) {
31             this.templateUrl = 'app/directives/b2b-leftnav-ext/b2b-leftnav-ext.tpl.html';
32             this.restrict = 'EA';
33             this.$rootScope = $rootScope;
34             this.link = this._link.bind(this);
35             this.scope = {
36                 menuData: '='
37             }
38         }
39         _link(scope) {
40                 scope.idx = -1;
41             scope.itemIdx = -1;
42             scope.navIdx = -1;
43             scope.toggleNav = function (val,link) {
44                 if (val === scope.idx) {
45                     scope.idx = -1;
46                     return;
47                 }
48                 scope.idx = val;
49             };
50             /*New function for ECOMP sdk*/
51             scope.toggleDrawer = function(showmenu){
52                 scope.idx=-1; /*hide the sunmenus*/
53                 if(showmenu){
54                                 document.getElementById('page-content').style.paddingLeft = "50px";
55                         }
56                         else
57                                 document.getElementById('page-content').style.paddingLeft = "230px";            
58             };
59             scope.liveLink = function (evt, val1, val2) {
60                 scope.itemIdx = val1;
61                 scope.navIdx = val2;
62                 evt.stopPropagation();
63             };
64         }
65     }
66     angular.module('ecompApp').directive('leftMenuEcomp', ($rootScope) => new B2BLeftMenu($rootScope));
67 })();
68