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,$timeout) {
26 this.templateUrl = 'app/directives/right-menu/right-menu.tpl.html';
28 this.$rootScope = $rootScope;
29 this.$window = $window;
30 this.$timeout=$timeout;
31 this.link = this._link.bind(this);
40 scope.rightSideToggleBtn = 'Collapse';
42 scope.openInNewTab = (url) => {
44 alert("Cannot chat with self!");
46 var win = window.open(url, '_blank');
47 setCookie(url.split("chat_id=")[1], 'source', 1);
48 //window.localStorage.setItem(url.split("chat_id=")[1],'source');
58 scope.toggleSidebar = () => {
59 scope.isOpen = !scope.isOpen;
61 scope.rightSideToggleBtn = 'Collapse';
63 scope.rightSideToggleBtn = 'Expand';
67 scope.scrollbarWidth =function(){
68 var $outer = $('<div>').css({visibility: 'hidden', width: 100, overflow: 'scroll'}).appendTo('body'),
69 widthWithScroll = $('<div>').css({width: '100%'}).appendTo($outer).outerWidth();
71 return 100 - widthWithScroll;
74 scope.calculateUserbarOffset = function(){
75 var userbarWid = $("#online-userbar").width()==0?75:$("#online-userbar").width();
76 var scrollbarWid = scope.scrollbarWidth();
77 var userbarOffset = scrollbarWid+userbarWid-1;
78 /*Setting the offset for userbar*/
79 $("#online-userbar").css("left",-userbarOffset);
80 /*Setting the offset for user bar toggle button*/
81 $(".ecomp-right-sidebar-toggle-btn").css("right",scrollbarWid);
83 this.$timeout(scope.calculateUserbarOffset, 0);
85 scope.isBrowserInternetExplorer = false;
86 scope.browserName = bowser.name;
88 if (bowser.msie || bowser.msedge) {
89 scope.isBrowserInternetExplorer = true;
91 scope.isBrowserInternetExplorer = false;
94 scope.calculateUserBarHeight = () => {
95 var footerOff = $('#online-userbar').offset().top;
96 var headOff = $('#footer').offset().top;
97 var userbarHeight= parseInt($(".online-user-container").css('height'),10);
98 var defaultOffSet = 45;
99 // console.log(headOff - footerOff-defaultOffSet);
100 $(".online-user-container").css({
101 "height" : headOff - footerOff-defaultOffSet
104 angular.element(this.$window).bind('resize', function(){
105 scope.calculateUserBarHeight();
110 angular.module('ecompApp').directive('rightMenu', ($rootScope,$window,$timeout) => new RightMenu($rootScope,$window,$timeout));