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

Revision 4974, 6.7 KB checked in by niltonneto, 13 years ago (diff)

Ticket #2231 - Corrigido problema de exibição de cartão com email extenso.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
RevLine 
[63]1 function emInfoContact()
[27]2{
3        this.email = "";
4        this.timeout = null;
[37]5        this.timeout_hide = null;
[27]6        this._mousemove = document.onmousemove;
7        this.td;
[37]8        this.createCard();
[27]9}
10
[37]11emInfoContact.prototype.createCard = function(){
12        var pic= new Image();
[790]13        pic.src="./templates/"+template+"/images/card.gif";
[37]14        card = document.createElement("DIV");
15        card.id = "card_cc";
16        card.style.display = "none";
17        card.style.width = "244px";
[4974]18        card.style.background = "url("+pic.src+") no-repeat";
[37]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
[27]26        var card = Element("card_cc");
[46]27       
28        if(this.td != td){
[27]29                this.email = email;
[37]30                this.td = td;
[27]31                clearTimeout(this.timeout);
[1445]32        }
33        this.timeout = setTimeout("InfoContact.search('"+email+"')",1000);             
[27]34}
35
36emInfoContact.prototype.label = function (text){
[37]37        InfoContact.hide();
[27]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;
[320]50        div_label.style.top = findPosY(this.td) + 20 - Element("divScrollMain_"+numBox).scrollTop;
[27]51        div_label.style.left = findPosX(this.td) + 20;
52        div_label.style.display = '';
[37]53        setTimeout("InfoContact.hide()",1000);
[27]54}
55
[72]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
[27]68emInfoContact.prototype.show = function (data){
69        var _this = this;
[29]70        var card = Element("card_cc");
[1445]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       
[4974]83        var email = data.email;
84        if(email && email.toString().length > 35)
85                email = email.toString().substring(0,30) + "...";
86
[3388]87                var phoneUser;
88
89                data.telefone ? phoneUser = data.telefone : phoneUser ="<br />";
90
91                data.mobile ? phoneUser += "<br />&nbsp;"+data.mobile :  phoneUser += "<br />";
92
93                data.employeeNumber ? employeeNumber = data.employeeNumber : employeeNumber ="";
94
95                data.ou ? ou = data.ou :  ou = "";
96
97
98
[4973]99        if(preferences.voip_enabled) {
100                phoneUser = '';
101                if(data.telefone)
102                        phoneUser = "<a title=\""+get_lang("Call to Comercial Number")+"\" href=\"#\" onclick=\"InfoContact.connectVoip('"+ data.telefone+"', 'com')\">"+ data.telefone+"</a>";
[1445]103                if(data.mobile){
[4973]104                        phoneUser += "<br>&nbsp;<a title=\""+get_lang("Call to Mobile Number")+"\" href=\"#\" onclick=\"InfoContact.connectVoip('"+data.mobile+"', 'mob')\">"+data.mobile+"</a>";
[72]105                }
[1445]106        }
[37]107
[3388]108                Element("card_cc_td").innerHTML =
109                                                "<table cellpadding=0 cellspacing=0 border=0 height='100%' width='100%'><tr>"+
110                                                "<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>"+
111
[4973]112                                                "<tr><td align='center' style='width:70px;height:93px;padding-left:6px' align='center' valign='center'>"+
[3388]113                                                "<img style='float:left' src='./inc/show_img.php?email="+data.email+"'></td>"+
[4973]114                                                "<td style='padding-left:2px' width='70%' align='left' valign='top'>"+
[3388]115                                                "<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 />"+
[4973]116                                                "<br><font size=1 color=BLACK>"+cn+"</font><br><b>"+employeeNumber+"</b>"+
[3388]117                                                "<br/>"+ou+"</td></tr>"+
[4974]118                                                "<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>"+email+"</u></font></span>"+
[1445]119                                                                                "</td></tr></table>";
[27]120
[37]121
[1445]122        this.timeout_hide = setTimeout("InfoContact.hide()",1000);     
[27]123}
124
125emInfoContact.prototype.search = function (email){
126        var _this = this;
[1445]127        var trustedDomain = false;
128        //      If "preferences.notification_domains" was setted, then verify if "mail" has a trusted domain.   
129        if (preferences.notification_domains != undefined && preferences.notification_domains != "") {
130                var domains = preferences.notification_domains.split(',');
131                for (var i = 0; i < domains.length; i++) {
132                        if (email.toString().match(domains[i]))
133                                trustedDomain = true;
134                }
135        }
136        else
137                trustedDomain = true;
138
[27]139        var handler_search = function(data){
[1445]140                if(data != null){
[27]141                        _this.show(data);
142                }
143                else
[1445]144                        _this.label(email);                     
[27]145        }
[1445]146       
147        if (trustedDomain)
148                cExecute ("$this.ldap_functions.getUserByEmail&email="+email, handler_search);
149        else
150                _this.label(email);
[27]151}
152
153emInfoContact.prototype.hide = function(){
154        this.email = "";
155        if(Element("div_label"))
156                Element("div_label").style.display = 'none';
157
158        if(Element("card_cc"))
159                Element("card_cc").style.display = "none";     
160}
161
[37]162emInfoContact.prototype.sendMail = function(name, email){
163        Element("msg_number").value = "\""+ name+"\" <"+email+">";
164        InfoContact.hide();
165        new_message("new","null");
166}
[27]167
[37]168emInfoContact.prototype.openChat = function(event, email){
169        IM.action_button(event, '1', email ,false);
170}
[27]171
[37]172emInfoContact.prototype.verifyIM = function(uid, email){
173
[54]174        if ( !window.IM || !document.getElementById('myStatus') )
[3388]175                return  "";
[37]176
[54]177        var status = IM.infoContact(uid);
[63]178        var _return = '<br/>';
[37]179
[54]180        if ( status )
181        {
182                _return += '<img align="center" src="'+status.src+'" />';
183                _return += '<span onclick="IM.action_button(event,\''+status.jid+'\');"><font size="1" color=';
[37]184               
[54]185                if( status.src != img_unavailable.src)
186                        _return         += '"DARKBLUE"><u style="cursor:pointer;">'+get_lang("User connected")+"</u>";
[37]187                else
[54]188                        _return         += '"BLACK">'+get_lang("User not connected");
[37]189
[54]190                _return += "</font></span><br />";
[37]191        }
192
193        return _return;
194}
195/* Build the Object */
196var emInfoContact;
[790]197InfoContact = new emInfoContact();
Note: See TracBrowser for help on using the repository browser.