2 * ================================================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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 * ================================================================================
21 app.directive('qMenu', function () {
23 restrict: 'A', //This menas that it will be used as an attribute and NOT as an element. I don't like creating custom HTML elements
25 templateUrl: "app/fusion/scripts/view-models/left_menu.html",
26 controller: ['$scope', '$filter','$http','$timeout','$cookies','LeftMenuService', function ($scope, $filter, $http,$timeout,$cookies,LeftMenuService) {
28 $scope.leftChildData=[];
29 $scope.leftParentData=[];
30 $scope.leftMenuItems = [];
33 LeftMenuService.getLeftMenu().then(function(response){
36 if(j && j !== "null" && j!== "undefined"){
37 $scope.leftParentData = JSON.parse(j.data);
38 $scope.leftChildData = JSON.parse(j.data2);
40 throw "Get Left Menu respsone is not an object/is empty";
43 var leftChildItemList = $scope.leftChildData;
44 var pageUrl = window.location.href.split('/')[window.location.href.split('/').length-1];
45 var leftParentList =$scope.leftParentData;
46 for (var i = 0; i < leftParentList.length; i++) {
48 parentLabel : leftParentList[i].label,
49 parentAction : leftParentList[i].action,
50 parentImageSrc : leftParentList[i].imageSrc,
51 open:pageUrl==leftParentList[i].action?true:false,
52 childItemList : leftChildItemList[i]
54 $scope.leftMenuItems.push($scope.item);
57 console.log("error happened while trying to set left menu structure"+err);
60 console.log("error happened while trying to get left menu items"+e);
65 console.log("error happened while calling getLeftMenu"+error);
68 LeftMenuService.getAppName().then(function(response){
71 if(j && j !== "null" && j!== "undefined"){
72 console.log("app name is " + $scope.app_name);
73 $scope.app_name_full = j.data;
74 var processed_app_name = j.data;
75 var n = processed_app_name.length;
79 $scope.app_name = processed_app_name.substr(0, n);
81 throw "Get app_name respsone is not an object/is empty";
84 console.log("error happened while trying to get app name "+e);
88 console.log("error happened while calling getAppName "+error);
91 $scope.adjustHeader=function() {
92 $scope.showHeader = ($cookies.show_app_header == undefined ? true : $cookies.show_app_header);
94 if($scope.showHeader == true) {
95 $scope.drawer_margin_top = 50;
96 $scope.drawer_custom_top = 20;
97 $scope.toggle_drawer_top = 55;
101 $scope.drawer_margin_top = 0;
102 $scope.drawer_custom_top = 0;
103 $scope.toggle_drawer_top = 0;
109 $scope.adjustHLeftMenu = function (type){
110 $scope.showHeader = ($cookies.show_app_header == undefined ? true : $cookies.show_app_header);
112 if($scope.showHeader == true) {
113 $scope.drawer_margin_top = 60;
114 $scope.drawer_custom_top = 54;
115 $scope.toggle_drawer_top = 55;
119 $scope.drawer_margin_top = 50;
120 $scope.drawer_custom_top = 0;
121 $scope.toggle_drawer_top = 10;
123 if(type=='burgerIcon'){
124 return { "top": $scope.toggle_drawer_top+"px"};
125 }else if(type=='leftMenu'){
126 return { "margin-top": $scope.drawer_margin_top+"px"};
130 $scope.adjustHeader();
131 $scope.drawerOpen = true;
133 $scope.toggleDrawer = function() {
134 $scope.drawerOpen = !($scope.drawerOpen);
135 if ($scope.drawerOpen) {
136 // setCookie('drawerOpen','open',30);
137 $scope.arrowShow = true;
140 if (document.getElementById('fnMenueContent')!=null)
141 document.getElementById('fnMenueContent').style.marginLeft = "0px";
143 if (document.getElementById('rightContentAdmin')!=null)
144 document.getElementById('rightContentAdmin').style.marginLeft = "210px";
146 else if (document.getElementById('rightContentProfile')!=null)
147 document.getElementById('rightContentProfile').style.marginLeft = "210px";
153 $scope.arrowShow = false;
155 if (document.getElementById('fnMenueContent')!=null)
156 document.getElementById('fnMenueContent').style.marginLeft = "-150px";
158 if (document.getElementById('rightContentAdmin')!=null) {
159 document.getElementById('rightContentAdmin').style.marginLeft = "50px";
163 else if (document.getElementById('rightContentProfile')!=null)
164 document.getElementById('rightContentProfile').style.marginLeft = "50px";
172 $timeout(function() {
179 $(window).scroll(function() {
180 if ($('.att-drawer').is(':visible')) {
186 function detectScrollEvent() {
188 var footerOff = $('#footerContainer').offset().top;
189 var headOff = $('#headerContainer').offset().top;
190 var winHeight = $(window).height();
191 if ((footerOff - headOff) <= winHeight) {
192 $('.att-drawer').css({
193 "height" : footerOff - headOff - 55
196 $('.att-drawer').css({