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