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

Revision 37, 7.0 KB checked in by niltonneto, 17 years ago (diff)

Vide arquivo change_log.txt

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1function 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").scrollTop;
51        div_label.style.left = findPosX(this.td) + 20;
52        div_label.style.display = '';
53        setTimeout("InfoContact.hide()",1000);
54}
55
56emInfoContact.prototype.show = function (data){
57        var _this = this;
58        var card = Element("card_cc");
59
60        //if(card.style.display != '')
61         {
62                card.style.left = findPosX(this.td) + 20;
63                var y = findPosY(this.td) + 20 - Element("divScrollMain").scrollTop;
64                var w_height = is_ie ? document.body.clientHeight + document.body.scrollTop : window.innerHeight + window.pageYOffset;
65                if(y + 160 > w_height)
66                        card.style.top =  y - 160;     
67                else
68                        card.style.top = y;             
69                card.style.display = '';
70                var cn = data.cn;
71                if(cn && cn.toString().length > 35)
72                        cn = cn.toString().substring(0,30) + "...";
73               
74
75                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'>"+
76                                                                                        "<img src='./inc/show_img.php?email="+data.email+"'></td><td style='padding-left:2px' align='left' valign='top'>"+
77                                                                                        "<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>"+
78                                                                                        _this.verifyIM(data.uid,data.email)+
79                                                                                        "<br><img align='center' src='templates/default/images/phone.gif'>&nbsp;<font  size=1  color=BLACK>"+(data.telefone ? data.telefone : get_lang("None") )+"</font>"+
80                                                                                        "</td></tr><tr><td valign='top' align='center' colspan='2'>"+
81                                                                                        "<font size=1 color=BLACK>"+cn+"</font>"+
82                                                                                        "<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>"+
83                                                                                        "</td></tr></table>";
84
85
86        this.timeout_hide = setTimeout("InfoContact.hide()",1000);
87        }
88}
89
90emInfoContact.prototype.search = function (email){
91        var _this = this;
92        var ldapSearched = false;
93        var handler_search = function(data){
94                if(data != null){                       
95                        _this.show(data);
96                }
97                else if(!ldapSearched) {
98                        ldapSearched = true;
99                        cExecute ("$this.ldap_functions.getUserByEmail&email="+email, handler_search);
100                }
101                else
102                        _this.label(email);
103                       
104        }
105
106        if(findPosX(_this.td) == 0) {
107                _this.hide();
108                return;
109        }
110
111        handler_search();
112        //cExecute ("$this.db_functions.getUserByEmail&email="+email, handler_search);
113}
114
115emInfoContact.prototype.hide = function(){
116        this.email = "";
117        clearTimeout(this.timeout);
118        if(Element("div_label"))
119                Element("div_label").style.display = 'none';
120
121        if(Element("card_cc"))
122                Element("card_cc").style.display = "none";     
123}
124
125emInfoContact.prototype.sendMail = function(name, email){
126        Element("msg_number").value = "\""+ name+"\" <"+email+">";
127        InfoContact.hide();
128        new_message("new","null");
129}
130
131emInfoContact.prototype.openChat = function(event, email){
132        IM.action_button(event, '1', email ,false);
133}
134emInfoContact.prototype.verifyPermissionIM = function(uid, domain, email){
135
136        var handler_verifyPermissionIM = function(data){
137                if(!data){
138                        alert("Esse usuário ("+uid+") não possui o módulo Expresso IM habilitado");
139                }
140                else
141                        Preferences.updateLoad(''+uid+"@"+domain+'');
142        }
143
144        IM.UserPermission(uid,handler_verifyPermissionIM);
145
146}
147
148emInfoContact.prototype.verifyIM = function(uid, email){
149        if(!window.IM)
150                return  "<br><br>";
151
152        if(!IM.array_users || !IM.array_users.length)
153                return  "<br><br>";
154
155        var status  = "Not Registered";
156        var subscription = "";
157        var _return      = ""; 
158        var jid                  = ""; 
159        var array_jid    = null;
160
161        for(i = 1; i <= IM.array_users.length; i++){
162                if(!IM.array_users[i] || !IM.array_users[i].jid)
163                        continue;
164
165                jid = IM.array_users[i].jid;
166                array_jid  = jid.split("@");
167               
168                if(array_jid[0] == uid){
169                        status           = IM.array_users[i].online;
170                        subscription = IM.array_users[i].subscription;
171                        break;
172                }
173                else
174                        jid = uid +"@"+array_jid[1];
175
176        }
177       
178        if(subscription == 'both') {
179                if(status == 1) {
180                        _return = "<br><img align='center' src='../instant_messenger/templates/default/images/online.gif'>";
181                        _return         += "<span title='"+get_lang("Open chat window")+"' style='cursor:pointer' onclick='InfoContact.openChat(event,\""+jid+"\");InfoContact.hide()'><font size=1 color=DARKBLUE><u>"+get_lang("User connected")+"</u></font></span><br>";
182                }
183                else if(status == 0) {
184                        _return = "<br><img align='center' src='../instant_messenger/templates/default/images/offline.gif'>";
185                        _return         += "<span style='cursor:pointer' onclick='InfoContact.hide()'><font size=1 color=BLACK>"+get_lang("User not connected")+"</font></span><br>";
186                }
187       
188        }
189        else if(array_jid != null){
190                _return = "<br><img align='center' src='../instant_messenger/templates/default/images/not_authorized.gif'>";
191                if(subscription == 'from')
192                        _return += "<font size=1 color=BLACK><u>"+ get_lang("User didn't allow you")+"</u></font><br>";
193                else if(subscription == 'to') {
194                        _return += "<span title='"+get_lang("Authorize")+"' style='cursor:pointer' onclick='Preferences.updateLoad(\""+email+"\");InfoContact.hide()'><font size=1 color=BLACK><u>"+ get_lang("You didn't allow")+"</u></font></span><br>";
195                }
196                else
197                        _return += "<span title='"+get_lang("Register user into my IM")+"' style='cursor:pointer' onclick='InfoContact.verifyPermissionIM(\""+ uid +"\",\""+array_jid[1]+"\");InfoContact.hide()'><font size=1 color=BLACK><u>" + get_lang("User not registered")+"</u></font></span><br>";     
198        }
199
200        return _return;
201}
202/* Build the Object */
203var emInfoContact;
204InfoContact = new emInfoContact();
Note: See TracBrowser for help on using the repository browser.