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