summaryrefslogtreecommitdiffstats
path: root/epsdk-app-onap/src/main/webapp/app/fusion/external/ebz/js/attHeaderSnippet.js
blob: fd803efe722333df5efb853af2430c74a7f8710b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/* Popup Box function */
(function(){

  $.fn.popbox = function(options){
    settings = $.extend({
      selector          : this.selector,
      open              : '.openpopbox',
      box               : '.box1',
      arrow             : '.arrow',
      arrow_border      : '.arrow-border',
      close             : '.close'
    }, options);

    var methods = {
      open: function(event){
        event.preventDefault();
        var pop = $(this);
        var box = $(this).parent().find(settings['box']);
        box.find(settings['arrow']).css({'left': box.width()/2 - 10 + 46});
        box.find(settings['arrow_border']).css({'left': box.width()/2 - 10 - 63});
        if(box.css('display') == 'block'){
          /* methods.close();
          setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','999'); },200);
        // $(".btn-panel-vertical,#actionsDropDown").css('z-index','999');
            if($(window).scrollTop() > 20){
                 setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999'); },200);
                  // $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999');
            };*/
			 $('.box1').fadeIn('slow');
        } else {
           $('.chatBox').fadeOut('fast');
          $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999');
        	if(box.attr('target') == 'auth'){
        		box.find(settings['arrow']).css({'left': box.width()/2 + 36});
        		box.css({'display': 'block', 'top': 0, 'left': ((pop.parent().parent().width()/2) -box.width()/2 ) - 90});
        	}
        	else{
        		box.find(settings['arrow']).css({'left': box.width()/2 - 42});
        		box.css({'display': 'block', 'top': 0, 'left': ((pop.parent().parent().width()/2) -box.width()/2-15 )});
        		box.find("#header_login_id").focus();
        		box.find('#header_password').val('');
        		}
        }
      },

      close: function(){
        $(settings['box']).fadeOut("fast");
      }
    };
    
    $(document).bind('keyup', function(event){
      if(event.keyCode == 27){
        setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','999'); },200);
        // $(".btn-panel-vertical,#actionsDropDown").css('z-index','999');
        if($(window).scrollTop() > 20){
           // setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999'); },200);
          $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999');
        };
        methods.close();
      }
    });
 // Close chat-box and popup on clicking out of chat-box
    $(document).bind('click', function(event){
      if(!($(event.target).closest('.chatBox').length || $(event.target).hasClass('chatIcon') || $(event.target).closest(settings['selector']).length)){
        methods.close();
         if ($("#actionsDropDown").css('z-index')=='-999'){
           setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','999'); },200);
        }
        if($(window).scrollTop() > 20){
           setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999'); },200);
           // $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999');
        };
       
          $('.chatBox').fadeOut('fast');
        
      }
    });

    return this.each(function(){

      $(this).css({'width': $(settings['box']).width()}); // Width needs to be set otherwise popbox will not move when window resized.
      $(settings['open'], this).bind('click', methods.open);
      $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999');
      $(settings['open'], this).parent().find(settings['close']).bind('click', function(event){
        // $(".btn-panel-vertical,#actionsDropDown").css('z-index','999');
        setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','999'); },200);
        methods.close();
      });
    });
  }

}).call(this);


$('.popbox').popbox();

$(function(){
	var displayName = "";
	if($("#reg-fn-ln-id").length > 0){
		var fnln = $("#reg-fn-ln-id").val().length; 
		if(fnln > 0){
			var fnVar = $("#reg-fname-id").val();
			var lnVar = $("#reg-lname-id").val();
			var numChars = 13;
			var nameLen = fnVar.length + lnVar.length + 1; // 1 for space between the first name and the last name
			if(fnVar != " " && lnVar != " "){
				if(nameLen <= numChars){
					displayName = fnVar+" "+lnVar;
				}else if(nameLen <= (numChars * 2)){
						displayName = fnVar+"<br/>"+lnVar;
					}else
						{
							if(fnVar.length < numChars && lnVar.length > numChars){ //Smaller first name and longer last name							
								displayName = fnVar+"<br/>"+lnVar.substring(0,numChars-1)+"...";
							}
							
							if(fnVar.length >= numChars ){ //Longer first name
								// 2 = 1 for elipses, 1 for space between the first name and last name
								longLName = numChars - ((fnVar.substring(numChars,fnVar.length)).length + 2); 
								displayName = fnVar.substring(0,numChars)+"<br/>"+fnVar.substring(numChars,fnVar.length)+" "+lnVar.substring(0,longLName)+"...";
							}
						}		
			}
			else{
				displayName = fnVar+" "+lnVar;
			}
		}	
		
		$("#reg-userName").html(displayName);
	}
});

/* ClickToChat ANONYMOUS FUNCTION DEFINITION       *
 * =============================================== *
 * On clicking the chat icon displays the chat box */
(function(){

  var chatbox = $('.chatBox'); 

  // var actionsDropDown = $('#actionsDropDown');
  var methods = {
    open: function(){chatbox.css('display','block');},
    close: function(){chatbox.fadeOut('fast');}
  };
  $('.chatIcon').click(function(){
    if (chatbox.css('display') == 'block'){
      methods.close();
      setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','999'); },200);
       // $(".btn-panel-vertical,#actionsDropDown").css('z-index','999');
      if($(window).scrollTop() > 20){
           setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999'); },200);
            // $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999');
      };
    } else {
       $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999');
      methods.open();
      $(settings['box']).fadeOut("fast");
    }
  });

  // Close chat-box on clicking cross icon
  $('.circle_close_chat').click(function(){
    // $(".btn-panel-vertical,#actionsDropDown").css('z-index','999');
    setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','999'); },200);
    methods.close();
    if($(window).scrollTop() > 20){
       setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999'); },200);
       // $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999');
    };
  });

  // Close chat-box on Escape key press
  $(document).bind('keyup', function(event){
    if(event.keyCode == 27){ 
      setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','999'); },200);
      methods.close();
      if($(window).scrollTop() > 20){
           setTimeout(function(){ $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999'); },200);
           //$(".btn-panel-vertical,#actionsDropDown").css('z-index','-999');
      };
    }
  });

  // Close chat-box on clicking out of chat-box
  // $(document).bind('click', function(event){

  //   console.log(event.target,"2");
  //   if(!($(event.target).closest('.chatBox').length || $(event.target).hasClass('chatIcon'))) {
  //     event.preventDefault();
  //   // console.log($(event.target).closest(settings['selector']).length);
  //   console.log($(event.target).closest('.	').length);
  //   console.log($(event.target).hasClass('chatIcon'));


  //     // $(".btn-panel-vertical,#actionsDropDown").css('z-index','999');
  //     methods.close();
  //     if ($("#actionsDropDown").css('z-index')=='-999') {
  //       $(".btn-panel-vertical,#actionsDropDown").css('z-index','999');
  //     };
  //     // if (flag!="clicked") {
  //     //   if ($('.box').css('display') == 'block' || $('.chatBox').css('display') == 'block' ){
  //     //     $(".btn-panel-vertical,#actionsDropDown").css('z-index','-999');
  //     //   } else {
  //     //     $(".btn-panel-vertical,#actionsDropDown").css('z-index','999');
  //     //   }
  //     // }
  //    }
  // });

})();