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 * Created by nnaffar on 1/28/16.
25 constructor($rootScope,$window,$log,userbarUpdateService) {
26 this.templateUrl = 'app/directives/right-menu/right-menu.tpl.html';
28 this.$rootScope = $rootScope;
29 this.userbarUpdateService = userbarUpdateService;
30 this.$window = $window;
32 this.link = this._link.bind(this);
43 scope.rightSideToggleBtn = 'Collapse';
45 scope.openInNewTab = (url) => {
47 alert("Cannot chat with self!");
49 var win = window.open(url, '_blank');
50 setCookie(url.split("chat_id=")[1], 'source', 1);
51 //window.localStorage.setItem(url.split("chat_id=")[1],'source');
58 function setCookie(cname,cvalue,exdays) {
60 d.setTime(d.getTime() + (exdays*24*60*60*1000));
61 var expires = "expires=" + d.toGMTString();
62 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
65 function getCookie(cname) {
66 var name = cname + "=";
67 var decodedCookie = decodeURIComponent(document.cookie);
68 var ca = decodedCookie.split(';');
69 for(var i = 0; i < ca.length; i++) {
71 while (c.charAt(0) == ' ') {
74 if (c.indexOf(name) == 0) {
75 return c.substring(name.length, c.length);
85 /***Getting the list of the users***/
86 scope.toggleSidebar = () => {
87 scope.isOpen = !scope.isOpen;
89 scope.rightSideToggleBtn = 'Collapse';
91 scope.rightSideToggleBtn = 'Expand';
95 scope.isBrowserInternetExplorer = false;
96 scope.browserName = bowser.name;
98 if (bowser.msie || bowser.msedge) {
99 scope.isBrowserInternetExplorer = true;
101 scope.isBrowserInternetExplorer = false;
107 scope.calculateUserBarHeight = () => {
108 var footerOff = $('#online-userbar').offset().top;
109 var headOff = $('#footer').offset().top;
110 var userbarHeight= parseInt($(".online-user-container").css('height'),10);
111 var defaultOffSet = 45;
112 // console.log(headOff - footerOff-defaultOffSet);
113 $(".online-user-container").css({
114 "height" : headOff - footerOff-defaultOffSet
120 this.userbarUpdateService.getWidthThresholdRightMenu().then(function (res) {
121 if (res.status=="ERROR") {
122 log.error('userbarUpdateService: failed to get window width threshold for collapsing right menu; please make sure "window_width_threshold_right_menu" is specified in system.properties file.');
124 var rightMenuCollapseWidthThreshold = parseInt(res.response.windowWidth);
125 if ($(window).width()<rightMenuCollapseWidthThreshold) {
126 scope.toggleSidebar();
129 })['catch'](function (err) {
130 log.error('LeftMenu Controller:: getWidthThresholdLeftMenu() failed: ' + err);
133 angular.element(this.$window).bind('resize', function(){
134 scope.calculateUserBarHeight();
139 angular.module('ecompApp').directive('rightMenu', ($rootScope,$window,$log,userbarUpdateService) => new RightMenu($rootScope,$window,$log,userbarUpdateService));