2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
40 constructor($rootScope,$window,$timeout) {
41 this.templateUrl = 'app/directives/right-menu/right-menu.tpl.html';
43 this.$rootScope = $rootScope;
44 this.$window = $window;
45 this.$timeout=$timeout;
46 this.link = this._link.bind(this);
55 scope.rightSideToggleBtn = 'Collapse';
57 scope.openInNewTab = (url) => {
59 alert("Cannot chat with self!");
61 var win = window.open(url, '_blank');
62 setCookie(url.split("chat_id=")[1], 'source', 1);
63 //window.localStorage.setItem(url.split("chat_id=")[1],'source');
73 scope.toggleSidebar = () => {
74 scope.isOpen = !scope.isOpen;
76 scope.rightSideToggleBtn = 'Collapse';
78 scope.rightSideToggleBtn = 'Expand';
82 scope.scrollbarWidth =function(){
83 var $outer = $('<div>').css({visibility: 'hidden', width: 100, overflow: 'scroll'}).appendTo('body'),
84 widthWithScroll = $('<div>').css({width: '100%'}).appendTo($outer).outerWidth();
86 return 100 - widthWithScroll;
89 scope.calculateUserbarOffset = function(){
90 var userbarWid = $("#online-userbar").width()==0?75:$("#online-userbar").width();
91 var scrollbarWid = scope.scrollbarWidth();
92 var userbarOffset = scrollbarWid+userbarWid-1;
93 /*Setting the offset for userbar*/
94 $("#online-userbar").css("left",-userbarOffset);
95 /*Setting the offset for user bar toggle button*/
96 $(".ecomp-right-sidebar-toggle-btn").css("right",scrollbarWid);
98 this.$timeout(scope.calculateUserbarOffset, 0);
100 scope.isBrowserInternetExplorer = false;
101 scope.browserName = bowser.name;
103 if (bowser.msie || bowser.msedge) {
104 scope.isBrowserInternetExplorer = true;
106 scope.isBrowserInternetExplorer = false;
109 scope.calculateUserBarHeight = () => {
110 var footerOff = $('#online-userbar').offset().top;
111 var headOff = $('#footer').offset().top;
112 var userbarHeight= parseInt($(".online-user-container").css('height'),10);
113 var defaultOffSet = 45;
114 // console.log(headOff - footerOff-defaultOffSet);
115 $(".online-user-container").css({
116 "height" : headOff - footerOff-defaultOffSet
119 angular.element(this.$window).bind('resize', function(){
120 scope.calculateUserBarHeight();
125 angular.module('ecompApp').directive('rightMenu', ($rootScope,$window,$timeout) => new RightMenu($rootScope,$window,$timeout));