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

Revision 7923, 6.9 KB checked in by angelo, 11 years ago (diff)

Ticket #3362 - Problema ao abrir mensagem da caixa de entrada

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