source: branches/2.2/expressoMail1_2/js/InfoContact.js @ 3388

Revision 3388, 6.5 KB checked in by brunocosta, 14 years ago (diff)

Ticket #619 - Implementadas informações extendidas nas buscas do email.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1 function emInfoContact()
2{
3        this.email = "";
4        this.timeout = null;
5        this.timeout_hide = null;
6        this._mousemove = document.onmousemove;
7        this.td;
8        this.createCard();
9}
10
11emInfoContact.prototype.createCard = function(){
12        var pic= new Image();
13        pic.src="./templates/"+template+"/images/card.gif";
14        card = document.createElement("DIV");
15        card.id = "card_cc";
16        card.style.display = "none";
17        card.style.width = "244px";
18        card.style.backgroundImage = "url("+pic.src+")";
19        card.style.height = "134px";
20        card.style.position = "absolute";
21        card.innerHTML = "<table onmouseout='InfoContact.timeout_hide=setTimeout(\"InfoContact.hide()\",50);' onmouseover='clearTimeout(InfoContact.timeout_hide);' cellpadding=0 cellspacing=0 width='100%' height='100%'><tr><td valign='center' align='center' id='card_cc_td'></td></tr></table>";
22        document.body.appendChild(card);
23}
24emInfoContact.prototype.begin = function(td, email){
25
26        var card = Element("card_cc");
27       
28        if(this.td != td){
29                this.email = email;
30                this.td = td;
31                clearTimeout(this.timeout);
32        }
33        this.timeout = setTimeout("InfoContact.search('"+email+"')",1000);             
34}
35
36emInfoContact.prototype.label = function (text){
37        InfoContact.hide();
38        var div_label = Element("div_label");
39        if(!div_label) {
40                div_label = document.createElement("DIV");
41                div_label.id = "div_label";
42                div_label.style.padding = "2px";
43                div_label.style.display = "none";
44                div_label.style.position = "absolute";
45                div_label.style.border = "1px solid black";
46                div_label.style.backgroundColor="#FFFFDC";
47                document.body.appendChild(div_label);
48        }
49        div_label.innerHTML = text;
50        div_label.style.top = findPosY(this.td) + 20 - Element("divScrollMain_"+numBox).scrollTop;
51        div_label.style.left = findPosX(this.td) + 20;
52        div_label.style.display = '';
53        setTimeout("InfoContact.hide()",1000);
54}
55
56emInfoContact.prototype.connectVoip = function (phoneUser, typePhone){
57        var handler_connectVoip = function(data){
58                if(!data) {
59                        alert(get_lang("Error contacting VoIP server."));
60                }
61                else{
62                        alert(get_lang("Requesting a VoIP call")+":\n"+data);
63                }
64        }
65        cExecute ("$this.functions.callVoipConnect&to="+phoneUser+"&typePhone="+typePhone, handler_connectVoip);
66}
67
68emInfoContact.prototype.show = function (data){
69        var _this = this;
70        var card = Element("card_cc");
71        card.style.left = findPosX(this.td) + 20;
72        var y = findPosY(this.td) + 20 - Element("divScrollMain_"+numBox).scrollTop;
73        var w_height = is_ie ? document.body.clientHeight + document.body.scrollTop : window.innerHeight + window.pageYOffset;
74        if(y + 160 > w_height)
75                card.style.top =  y - 160;     
76        else
77                card.style.top = y;             
78        card.style.display = '';
79        var cn = data.cn;
80        if(cn && cn.toString().length > 35)
81                cn = cn.toString().substring(0,30) + "...";
82       
83                var phoneUser;
84
85                data.telefone ? phoneUser = data.telefone : phoneUser ="<br />";
86
87                data.mobile ? phoneUser += "<br />&nbsp;"+data.mobile :  phoneUser += "<br />";
88
89                data.employeeNumber ? employeeNumber = data.employeeNumber : employeeNumber ="";
90
91                data.ou ? ou = data.ou :  ou = "";
92
93
94
95        if(preferences.voip_enabled && phoneUser) {
96                phoneUser = "<a title=\""+get_lang("Call to Comercial Number")+"\" href=\"#\" onclick=\"InfoContact.connectVoip('"+phoneUser+"', 'com')\">"+phoneUser+"</a>";
97                if(data.mobile){
98                        phoneUser += " / <a title=\""+get_lang("Call to Mobile Number")+"\" href=\"#\" onclick=\"InfoContact.connectVoip('"+data.mobile+"', 'mob')\">"+data.mobile+"</a>";
99                }
100        }
101
102                Element("card_cc_td").innerHTML =
103                                                "<table cellpadding=0 cellspacing=0 border=0 height='100%' width='100%'><tr>"+
104                                                "<td  style='padding-top:4px' align='center' valign='center' colspan ='2'><img src='templates/"+template+"/images/"+(data.type)+"_catalog.png' /><font size=1 color=BLACK>&nbsp;<b>"+get_lang("Sender's Information")+"</b></font>"+_this.verifyIM(data.uid,data.email)+"</td></tr>"+
105
106                                                "<tr><td align='center' width='70' height='93' style='padding-left:6px' align='center' valign='center'>"+
107                                                "<img style='float:left' src='./inc/show_img.php?email="+data.email+"'></td>"+
108                                                "<td style='padding-left:2px' align='left' valign='top'>"+
109                                                "<br><img style='float:left'align='center' src='templates/"+template+"/images/phone.gif' />&nbsp;<font  size=1  color=BLACK>"+(phoneUser ? phoneUser : get_lang("None") )+"</font><br />"+
110                                                "<font size=1 color=BLACK>"+employeeNumber+"<br/>"+cn+"</font>"+
111                                                "<br/>"+ou+"</td></tr>"+
112
113                                                "<tr><td  style='padding-bottom:4px' align='center' valign='center' colspan ='2'><span title='"+get_lang("Write message")+"' style='cursor:pointer' onclick='InfoContact.sendMail(\""+cn+"\",\""+data.email+"\")'><font size=1 color=DARKBLUE><u>"+data.email+"</u></font></span>"+
114                                                                                "</td></tr></table>";
115
116
117        this.timeout_hide = setTimeout("InfoContact.hide()",1000);     
118}
119
120emInfoContact.prototype.search = function (email){
121        var _this = this;
122        var trustedDomain = false;
123        //      If "preferences.notification_domains" was setted, then verify if "mail" has a trusted domain.   
124        if (preferences.notification_domains != undefined && preferences.notification_domains != "") {
125                var domains = preferences.notification_domains.split(',');
126                for (var i = 0; i < domains.length; i++) {
127                        if (email.toString().match(domains[i]))
128                                trustedDomain = true;
129                }
130        }
131        else
132                trustedDomain = true;
133
134        var handler_search = function(data){
135                if(data != null){
136                        _this.show(data);
137                }
138                else
139                        _this.label(email);                     
140        }
141       
142        if (trustedDomain)
143                cExecute ("$this.ldap_functions.getUserByEmail&email="+email, handler_search);
144        else
145                _this.label(email);
146}
147
148emInfoContact.prototype.hide = function(){
149        this.email = "";
150        if(Element("div_label"))
151                Element("div_label").style.display = 'none';
152
153        if(Element("card_cc"))
154                Element("card_cc").style.display = "none";     
155}
156
157emInfoContact.prototype.sendMail = function(name, email){
158        Element("msg_number").value = "\""+ name+"\" <"+email+">";
159        InfoContact.hide();
160        new_message("new","null");
161}
162
163emInfoContact.prototype.openChat = function(event, email){
164        IM.action_button(event, '1', email ,false);
165}
166
167emInfoContact.prototype.verifyIM = function(uid, email){
168
169        if ( !window.IM || !document.getElementById('myStatus') )
170                return  "";
171
172        var status = IM.infoContact(uid);
173        var _return = '<br/>';
174
175        if ( status )
176        {
177                _return += '<img align="center" src="'+status.src+'" />';
178                _return += '<span onclick="IM.action_button(event,\''+status.jid+'\');"><font size="1" color=';
179               
180                if( status.src != img_unavailable.src)
181                        _return         += '"DARKBLUE"><u style="cursor:pointer;">'+get_lang("User connected")+"</u>";
182                else
183                        _return         += '"BLACK">'+get_lang("User not connected");
184
185                _return += "</font></span><br />";
186        }
187
188        return _return;
189}
190/* Build the Object */
191var emInfoContact;
192InfoContact = new emInfoContact();
Note: See TracBrowser for help on using the repository browser.