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

Revision 320, 6.0 KB checked in by niltonneto, 16 years ago (diff)

Versionamento 1.222
Ver changelog de alterações no Trac.

  • 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/default/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                this.timeout = setTimeout("InfoContact.search('"+email+"')",1000);
33        }       
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
72        //if(card.style.display != '')
73         {
74                card.style.left = findPosX(this.td) + 20;
75                var y = findPosY(this.td) + 20 - Element("divScrollMain_"+numBox).scrollTop;
76                var w_height = is_ie ? document.body.clientHeight + document.body.scrollTop : window.innerHeight + window.pageYOffset;
77                if(y + 160 > w_height)
78                        card.style.top =  y - 160;     
79                else
80                        card.style.top = y;             
81                card.style.display = '';
82                var cn = data.cn;
83                if(cn && cn.toString().length > 35)
84                        cn = cn.toString().substring(0,30) + "...";
85               
86                var phoneUser = data.telefone;
87                if(preferences.voip_enabled && phoneUser) {
88                        phoneUser = "<a title=\""+get_lang("Call to Comercial Number")+"\" href=\"#\" onclick=\"InfoContact.connectVoip('"+phoneUser+"', 'com')\">"+phoneUser+"</a>";
89                        if(data.mobile){
90                                phoneUser += " / <a title=\""+get_lang("Call to Mobile Number")+"\" href=\"#\" onclick=\"InfoContact.connectVoip('"+data.mobile+"', 'mob')\">"+data.mobile+"</a>";
91                        }
92                }
93
94                Element("card_cc_td").innerHTML = "<table cellpadding=0 cellspacing=0 border=0 height='100%' width='100%'><tr><td width='70' height='93' style='padding-top:5px;padding-left:6px' align='center' valign='center'>"+
95                                                                                        "<img src='./inc/show_img.php?email="+data.email+"'></td><td style='padding-left:2px' align='left' valign='top'>"+
96                                                                                        "<br><img align='center' src='templates/default/images/"+(data.type)+"_catalog.png'><font size=1 color=BLACK>&nbsp;<b>"+get_lang("Sender's Information")+"</b></font>"+
97                                                                                        _this.verifyIM(data.uid,data.email)+
98                                                                                        "<br><img align='center' src='templates/default/images/phone.gif'>&nbsp;<font  size=1  color=BLACK>"+(phoneUser ? phoneUser : get_lang("None") )+"</font>"+
99                                                                                        "</td></tr><tr><td valign='top' align='center' colspan='2'>"+
100                                                                                        "<font size=1 color=BLACK>"+cn+"</font>"+
101                                                                                        "<br><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>"+
102                                                                                        "</td></tr></table>";
103
104
105        this.timeout_hide = setTimeout("InfoContact.hide()",1000);
106        }
107}
108
109emInfoContact.prototype.search = function (email){
110        var _this = this;
111        var ldapSearched = false;
112        var handler_search = function(data){
113                if(data != null){                       
114                        _this.show(data);
115                }
116                else if(!ldapSearched) {
117                        ldapSearched = true;
118                        cExecute ("$this.ldap_functions.getUserByEmail&email="+email, handler_search);
119                }
120                else
121                        _this.label(email);
122                       
123        }
124
125        if(findPosX(_this.td) == 0) {
126                _this.hide();
127                return;
128        }
129
130        handler_search();
131        //cExecute ("$this.db_functions.getUserByEmail&email="+email, handler_search);
132}
133
134emInfoContact.prototype.hide = function(){
135        this.email = "";
136        clearTimeout(this.timeout);
137        if(Element("div_label"))
138                Element("div_label").style.display = 'none';
139
140        if(Element("card_cc"))
141                Element("card_cc").style.display = "none";     
142}
143
144emInfoContact.prototype.sendMail = function(name, email){
145        Element("msg_number").value = "\""+ name+"\" <"+email+">";
146        InfoContact.hide();
147        new_message("new","null");
148}
149
150emInfoContact.prototype.openChat = function(event, email){
151        IM.action_button(event, '1', email ,false);
152}
153
154emInfoContact.prototype.verifyIM = function(uid, email){
155
156        if ( !window.IM || !document.getElementById('myStatus') )
157                return  "<br/><br/>";
158
159        var status = IM.infoContact(uid);
160        var _return = '<br/>';
161
162        if ( status )
163        {
164                _return += '<img align="center" src="'+status.src+'" />';
165                _return += '<span onclick="IM.action_button(event,\''+status.jid+'\');"><font size="1" color=';
166               
167                if( status.src != img_unavailable.src)
168                        _return         += '"DARKBLUE"><u style="cursor:pointer;">'+get_lang("User connected")+"</u>";
169                else
170                        _return         += '"BLACK">'+get_lang("User not connected");
171
172                _return += "</font></span><br />";
173        }
174
175        return _return;
176}
177/* Build the Object */
178var emInfoContact;
179InfoContact = new emInfoContact();
Note: See TracBrowser for help on using the repository browser.