source: trunk/expressoMail1_2/js/InfoContact.js @ 6139

Revision 6139, 6.7 KB checked in by niltonneto, 12 years ago (diff)

Ticket #2230 - Correção da versão 2.2 replicada para o Trunk. Vide Ticket.

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