[2] | 1 | function emQuickCatalogSearch () |
---|
| 2 | { |
---|
| 3 | this.arrayWin = new Array(); |
---|
| 4 | this.el; |
---|
| 5 | this.cc_contacts = new Array(); |
---|
| 6 | this.cc_groups = new Array(); |
---|
| 7 | } |
---|
[5231] | 8 | |
---|
| 9 | $(document).ready(function(){ |
---|
| 10 | $('#combobox option').each(function(){ |
---|
| 11 | if($(this).val() == preferences.catalog_search){ |
---|
| 12 | $(this).attr('selected',true); |
---|
| 13 | } |
---|
| 14 | }); |
---|
| 15 | }); |
---|
[5134] | 16 | /* showlist */ |
---|
[5075] | 17 | emQuickCatalogSearch.prototype.showList = function(data, begin, end, ID, field) |
---|
| 18 | { |
---|
[5172] | 19 | data_ = data; |
---|
| 20 | id_ = ID; |
---|
| 21 | field_ = field; |
---|
| 22 | begin_ = begin; |
---|
| 23 | end_ = end; |
---|
[5911] | 24 | content = $("#content_id_"+ID); |
---|
| 25 | |
---|
[5172] | 26 | keypress_read(data); |
---|
| 27 | configure_slider(data); |
---|
[5134] | 28 | create_list(data, true); |
---|
[5172] | 29 | details_results(data); |
---|
| 30 | |
---|
[5404] | 31 | this.showWindow(); |
---|
[5075] | 32 | } |
---|
[5172] | 33 | |
---|
| 34 | |
---|
[5134] | 35 | /* Leitura das teclas de atalho */ |
---|
| 36 | function keypress_read(data) { |
---|
[5172] | 37 | $("#dialog-modal").unbind('keydown').keydown(function (e) { |
---|
[5134] | 38 | var keyCode = e.keyCode; |
---|
[5172] | 39 | arrow = {left: 37, up: 38, right: 39, down: 40, enter: 13, esc: 27, space: 32}; |
---|
| 40 | var slider = $( "#slider" ); |
---|
[5075] | 41 | switch (keyCode) |
---|
| 42 | { |
---|
[5172] | 43 | case arrow.enter: |
---|
[5134] | 44 | if(!search_focus){ |
---|
| 45 | i = $(".ui-selected:last").attr("value") + 1; |
---|
[5172] | 46 | if($("#actions_"+i).clone().find(".ui-button-text").text() == '+') |
---|
| 47 | add_contact_field(document.getElementById("contact_"+i).innerHTML, document.getElementById("actions_"+i), "contact_"+i); |
---|
| 48 | else{ |
---|
| 49 | remove_contact_field(document.getElementById("contact_"+i).innerHTML, document.getElementById("actions_"+i), "contact_"+i); |
---|
| 50 | } |
---|
[5134] | 51 | document.getElementById("busca").value = ""; |
---|
[5395] | 52 | //Evita que o campo "para" receba o enter |
---|
| 53 | e.preventDefault(); |
---|
[5172] | 54 | $("#dialog-modal").dialog("close"); |
---|
[5134] | 55 | } |
---|
[5402] | 56 | if (is_webkit){ |
---|
| 57 | //Posiciona o cursor no final do texto no Chrome |
---|
| 58 | var txt_area = document.getElementById('to_'+id_); |
---|
| 59 | var len = txt_area.value.length; |
---|
| 60 | txt_area.setSelectionRange(len, len); |
---|
| 61 | } |
---|
[5075] | 62 | break; |
---|
| 63 | case arrow.left: |
---|
[5172] | 64 | if(!search_focus){ |
---|
| 65 | slider.slider("value", $( "#slider" ).slider( "value" ) - 1); |
---|
| 66 | create_list(data_, false); |
---|
| 67 | } |
---|
[5075] | 68 | break; |
---|
| 69 | case arrow.right: |
---|
[5172] | 70 | if(!search_focus){ |
---|
| 71 | if((($( "#slider" ).slider( "value" ))) == Math.ceil(data_.length/6)) |
---|
| 72 | break; |
---|
| 73 | slider.slider( "value", $( "#slider" ).slider( "value" ) + 1); |
---|
| 74 | create_list(data_, false); |
---|
| 75 | } |
---|
[5075] | 76 | break; |
---|
| 77 | case arrow.up: |
---|
[5172] | 78 | if(!search_focus){ |
---|
| 79 | show_detail(data_, "up"); |
---|
| 80 | } |
---|
[5134] | 81 | break; |
---|
| 82 | case arrow.down: |
---|
[5172] | 83 | if(!search_focus){ |
---|
| 84 | show_detail(data_, "down"); |
---|
| 85 | } |
---|
| 86 | break; |
---|
| 87 | case arrow.space: |
---|
| 88 | |
---|
| 89 | if(!search_focus){ |
---|
| 90 | i = $(".ui-selected:last").attr("value") + 1; |
---|
| 91 | if($("#actions_"+i).clone().find(".ui-button-text").text() == '+') |
---|
| 92 | { |
---|
| 93 | add_contact_field(document.getElementById("contact_"+i).innerHTML, document.getElementById("actions_"+i), "contact_"+i); |
---|
| 94 | }else{ |
---|
| 95 | remove_contact_field(document.getElementById("contact_"+i).innerHTML, document.getElementById("actions_"+i), "contact_"+i); |
---|
| 96 | } |
---|
| 97 | document.getElementById("busca").value = ""; |
---|
| 98 | } |
---|
| 99 | break; |
---|
| 100 | } |
---|
[5134] | 101 | }); |
---|
[5172] | 102 | } |
---|
[5134] | 103 | |
---|
| 104 | |
---|
| 105 | /* Mostra os detalhes do contato selecionado */ |
---|
| 106 | function show_detail(data_, direction) { |
---|
| 107 | id_contact = $(".ui-selected:last").attr("value"); |
---|
| 108 | if(direction == "down") { |
---|
| 109 | if((id_contact == (((((parseInt($( "#slider" ).slider( "value" )) - 1)*6))+6)-1)) || id_contact == data_.length - 1 || data_.length == 1) |
---|
| 110 | return; |
---|
| 111 | var line_contact = $('li.ui-selected'); |
---|
| 112 | $('li.ui-selected').next().addClass("ui-selected"); |
---|
| 113 | id_contact++; |
---|
[5172] | 114 | } |
---|
[5134] | 115 | else { |
---|
| 116 | if(id_contact == (($( "#slider" ).slider( "value" ) -1)*6)) |
---|
| 117 | return; |
---|
| 118 | var line_contact = $('li.ui-selected'); |
---|
| 119 | $('li.ui-selected').prev().addClass("ui-selected"); |
---|
| 120 | id_contact--; |
---|
[5172] | 121 | } |
---|
[5134] | 122 | line_contact.removeClass("ui-selected").addClass("ui-selectee"); |
---|
[5172] | 123 | var details = $("#detalhes_contato").empty(); |
---|
[5134] | 124 | switch(data_['type_catalog']) { |
---|
| 125 | case 'G': |
---|
[6480] | 126 | if(data_['extra_ldap_fields'] != undefined){ |
---|
| 127 | if(data_['extra_ldap_fields'].length != 0) |
---|
| 128 | var extra_fields = (data_['extra_ldap_fields']).split("#"); |
---|
[5466] | 129 | else |
---|
| 130 | var extra_fields = []; |
---|
| 131 | }else |
---|
| 132 | var extra_fields = []; |
---|
[5134] | 133 | if(preferences.default_fields_quick_search != 0) { |
---|
[5466] | 134 | details.append('<p><label class="attribute">' + utf8_decoder(data_[id_contact].cn[0]) + "</label>" + '<span class="value">' + (data_[id_contact].mail ? data_[id_contact].mail[0] : "") + '</span></p>'); |
---|
| 135 | if((data_[id_contact].telephonenumber ? data_[id_contact].telephonenumber[0] : "")) |
---|
| 136 | details.append('<p><label class="attribute">Telefone </label>' + '<span class="value">' + (data_[id_contact].telephonenumber ? data_[id_contact].telephonenumber[0] : "") + '</span></p>'); |
---|
[5172] | 137 | } |
---|
[5134] | 138 | for (var i=0; i<=extra_fields.length-1; i++) |
---|
[5172] | 139 | { |
---|
| 140 | var campo = extra_fields[i].substr(extra_fields[i].indexOf("|")+1); |
---|
| 141 | var valor = extra_fields[i].substr(0, (extra_fields[i].indexOf("|"))); |
---|
[5134] | 142 | if(data_[id_contact][valor.toLowerCase()] != undefined) { |
---|
| 143 | var tmp_campo = '<p><label class="attribute">' + campo + "</label>" ; |
---|
| 144 | for(j=0; j<data_[id_contact][valor.toLowerCase()].length; j++) { |
---|
| 145 | details.append(tmp_campo + '<span class="value">' + data_[id_contact][valor.toLowerCase()][j] + "</span></p>"); |
---|
| 146 | tmp_campo = ""; |
---|
[5172] | 147 | } |
---|
| 148 | } |
---|
| 149 | } |
---|
[6459] | 150 | if (data_[id_contact].vacationactive == "TRUE"){ |
---|
| 151 | details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>'); |
---|
| 152 | if ( data_[id_contact].vacationinfo ){ |
---|
| 153 | details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data_[id_contact].vacationinfo +'</span></div></div>'); |
---|
| 154 | if ( $('.outoffice-inner').height() > $('.outoffice').height() ){ |
---|
| 155 | var link = $('<a>').html('Ver mais'); |
---|
| 156 | link.attr('id','more'); |
---|
| 157 | link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();}); |
---|
| 158 | details.append(link); |
---|
| 159 | } |
---|
| 160 | } |
---|
| 161 | } |
---|
[5172] | 162 | break; |
---|
[5134] | 163 | case 'P': |
---|
[5172] | 164 | if(utf8_decoder(data_[id_contact].cn) == 'undefined') |
---|
| 165 | details.append('<p><label class="attribute">' + utf8_decoder(data_[id_contact].title) + '</label>' + '<span class="value">' + data_[id_contact].short_name + '</span></p>'); |
---|
| 166 | else |
---|
| 167 | details.append('<p><label class="attribute">' + utf8_decoder(data_[id_contact].cn) + '</label>' + '<span class="value">' + data_[id_contact].mail + '</span></p>'); |
---|
[5134] | 168 | if(data_[id_contact].telephonenumber != null) |
---|
| 169 | details.append('<p><label class="attribute">Telefone</label>' + '<span class="value">' + data_[id_contact].telephonenumber + '</span></p>'); |
---|
[6459] | 170 | if (data_[id_contact].vacationactive == "TRUE"){ |
---|
| 171 | details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>'); |
---|
| 172 | if (data_[id_contact].vacationinfo){ |
---|
| 173 | details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data_[id_contact].vacationinfo +'</span></div></div>'); |
---|
| 174 | if ( $('.outoffice-inner').height() > $('.outoffice').height() ){ |
---|
| 175 | var link = $('<a>').html('Ver mais'); |
---|
| 176 | link.attr('id','more'); |
---|
| 177 | link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();}); |
---|
| 178 | details.append(link); |
---|
| 179 | } |
---|
| 180 | } |
---|
| 181 | } |
---|
[5172] | 182 | break; |
---|
[5134] | 183 | default: |
---|
[6480] | 184 | if(data_['extra_ldap_fields'] != undefined){ |
---|
| 185 | if(data_['extra_ldap_fields'].length != 0) |
---|
| 186 | var extra_fields = (data_['extra_ldap_fields']).split("#"); |
---|
[5466] | 187 | else |
---|
| 188 | var extra_fields = []; |
---|
| 189 | }else{ |
---|
[5456] | 190 | var extra_fields = []; |
---|
[5466] | 191 | } |
---|
[6417] | 192 | if(preferences.default_fields_quick_search != 0 || data_[id_contact].type_contact == "P" || data_[id_contact].type_contact == "G") { |
---|
[5172] | 193 | if(utf8_decoder(data_[id_contact].cn) == 'undefined') |
---|
| 194 | details.append('<p><label class="attribute">' + utf8_decoder(data_[id_contact].title) + '</label>' + '<span class="value">' + data_[id_contact].short_name + '</span></p>'); |
---|
| 195 | else |
---|
| 196 | details.append('<p><label class="attribute">' + utf8_decoder(data_[id_contact].cn) + '</label>' + '<span class="value">' + data_[id_contact].mail + '</span></p>'); |
---|
[5134] | 197 | if(data_[id_contact].telephonenumber != null) |
---|
| 198 | details.append('<p><label class="attribute">Telefone</label>' + '<span class="value">' + data_[id_contact].telephonenumber + '</span></p>'); |
---|
[5172] | 199 | } |
---|
| 200 | if(data_[id_contact].mail[0] == 'undefined') |
---|
| 201 | break; |
---|
[5134] | 202 | if(data_[id_contact].mail[0].length > 1) { |
---|
| 203 | for (var i=0; i<=extra_fields.length-1; i++) { |
---|
[5172] | 204 | var campo = extra_fields[i].substr(extra_fields[i].indexOf("|")+1); |
---|
| 205 | var valor = extra_fields[i].substr(0, (extra_fields[i].indexOf("|"))); |
---|
[5134] | 206 | if(data_[id_contact][valor.toLowerCase()] != undefined) { |
---|
| 207 | var tmp_campo = '<p><label class="attribute">' + campo + "</label>" ; |
---|
| 208 | for(j=0; j<data_[id_contact][valor.toLowerCase()].length; j++) { |
---|
| 209 | details.append(tmp_campo + '<span class="value">' + data_[id_contact][valor.toLowerCase()][j] + "</span></p>"); |
---|
| 210 | tmp_campo = ""; |
---|
[5172] | 211 | } |
---|
| 212 | } |
---|
| 213 | } |
---|
| 214 | } |
---|
[6459] | 215 | if (data_[id_contact].vacationactive == "TRUE"){ |
---|
| 216 | details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>'); |
---|
| 217 | if (data_[id_contact].vacationinfo){ |
---|
| 218 | details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data_[id_contact].vacationinfo +'</span></div></div>'); |
---|
| 219 | if ( $('.outoffice-inner').height() > $('.outoffice').height() ){ |
---|
| 220 | var link = $('<a>').html('Ver mais'); |
---|
| 221 | link.attr('id','more'); |
---|
| 222 | link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();}); |
---|
| 223 | details.append(link); |
---|
| 224 | } |
---|
| 225 | } |
---|
| 226 | } |
---|
[5172] | 227 | break; |
---|
| 228 | } |
---|
[5075] | 229 | } |
---|
[5172] | 230 | |
---|
[3718] | 231 | |
---|
[5172] | 232 | /* |
---|
| 233 | * Método que cria a lista de contatos |
---|
| 234 | */ |
---|
[5134] | 235 | function create_list(data, begin, uiValue) { |
---|
| 236 | var sliderValue = 1; |
---|
| 237 | if(typeof($( "#slider" ).slider( "value" )) != "object") |
---|
| 238 | sliderValue = $( "#slider" ).slider( "value" ); |
---|
| 239 | if(uiValue) |
---|
| 240 | sliderValue = uiValue; |
---|
[5172] | 241 | $("#detalhes_contato").empty(); |
---|
[5134] | 242 | var paginas = Math.ceil(data.length/6); |
---|
[5172] | 243 | $("#title_usuarios").html( get_lang("Results") ); |
---|
| 244 | var selectable = $("#selectable"); |
---|
| 245 | selectable.empty(); |
---|
| 246 | var acento = data.search_for; |
---|
| 247 | var Ul = document.createElement("ul"); |
---|
| 248 | var caracteresInvalidos = 'àèìòùâêîôûäëïöüáéíóúãõÀÈÌÒÙÂÊÎÔÛÄËÏÖÜÁÉÍÓÚÃÕ'; |
---|
| 249 | var caracteresValidos = 'aeiouaeiouaeiouaeiouaoAEIOUAEIOUAEIOUAEIOUAO'; |
---|
| 250 | |
---|
| 251 | var i = new Number(); |
---|
| 252 | var j = new Number(); |
---|
| 253 | var cString = new String(); |
---|
| 254 | var varRes = ''; |
---|
| 255 | |
---|
| 256 | for (i = 0; i < data.search_for.length; i++) { |
---|
| 257 | cString = data.search_for.substring(i, i + 1); |
---|
| 258 | for (j = 0; j < caracteresInvalidos.length; j++) { |
---|
| 259 | if (caracteresInvalidos.substring(j, j + 1) == cString){ |
---|
| 260 | cString = caracteresValidos.substring(j, j + 1); |
---|
| 261 | } |
---|
| 262 | } |
---|
| 263 | varRes += cString; |
---|
| 264 | } |
---|
| 265 | data.search_for = varRes; |
---|
| 266 | |
---|
[5134] | 267 | for (i=((sliderValue -1)*6)+1; i<(((sliderValue -1)*6)+1)+6; i++) { |
---|
[5172] | 268 | var Op = document.createElement("li"); |
---|
[5134] | 269 | if(i > data.length) |
---|
[5172] | 270 | break; |
---|
| 271 | if (data['type_catalog'] != 'G' && (data[i-1].mail == null || data[i-1].mail == "")) |
---|
| 272 | data[i-1].mail = get_lang("No mail"); |
---|
[5134] | 273 | |
---|
| 274 | if(i == (((sliderValue -1)*6)+1)) { |
---|
[5172] | 275 | Op.setAttribute("class", "ui-selected"); |
---|
[5134] | 276 | Op.setAttribute("className", "ui-selected"); |
---|
[5172] | 277 | } |
---|
| 278 | else { |
---|
| 279 | Op.setAttribute("class", "ui-selectee"); |
---|
[5134] | 280 | Op.setAttribute("className", "ui-selectee"); |
---|
[5172] | 281 | } |
---|
| 282 | var contact_name = utf8_decoder(data[i-1].cn); |
---|
| 283 | if(contact_name == 'undefined'){ |
---|
| 284 | contact_name = utf8_decoder(data[i-1].title); |
---|
| 285 | if(contact_name != 'undefined'){ |
---|
| 286 | data[i-1].mail = data[i-1].short_name; |
---|
| 287 | } |
---|
| 288 | } |
---|
| 289 | var exist = "add_contact_field"; |
---|
| 290 | var signal = "+"; |
---|
| 291 | var btnClass = "add"; |
---|
[5911] | 292 | var emailList = content.find(field_).val(); |
---|
[5172] | 293 | var emails_adicionados = emailList.split(","); |
---|
| 294 | for(aux=0; aux<emails_adicionados.length -1; aux++) { |
---|
[5258] | 295 | if(emails_adicionados[aux].match(/<([^<]*)>[\s]*$/)){ |
---|
| 296 | if(emails_adicionados[aux].match(/<([^<]*)>[\s]*$/)[1].toLowerCase() == (utf8_decoder(data[i-1].mail)).toLowerCase()){ |
---|
| 297 | emails_adicionados[aux] = "%"; |
---|
| 298 | exist = "remove_contact_field"; |
---|
| 299 | signal = "x"; |
---|
| 300 | btnClass = "remove"; |
---|
| 301 | } |
---|
| 302 | }else{ |
---|
| 303 | if(emails_adicionados[aux].toLowerCase() == (utf8_decoder(data[i-1].mail)).toLowerCase()){ |
---|
| 304 | emails_adicionados[aux] = "%"; |
---|
| 305 | exist = "remove_contact_field"; |
---|
| 306 | signal = "x"; |
---|
| 307 | btnClass = "remove"; |
---|
| 308 | } |
---|
[5172] | 309 | } |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | if(contact_name.toLowerCase().indexOf(acento.toLowerCase()) != -1 && acento.indexOf(" ") == -1 && acento.indexOf("@") == -1) |
---|
| 313 | contact_name = contact_name.substring(0, contact_name.toLowerCase().indexOf(acento.toLowerCase())) + "<u>" + contact_name.substr(contact_name.toLowerCase().indexOf(acento.toLowerCase()), acento.length) + "</u>" + contact_name.substring(contact_name.toLowerCase().indexOf(acento.toLowerCase()) + acento.length); |
---|
| 314 | else if(contact_name.toLowerCase().indexOf(data.search_for.toLowerCase()) != -1 && data.search_for.indexOf(" ") == -1 && data.search_for.indexOf("@") == -1) |
---|
| 315 | contact_name = contact_name.substring(0, contact_name.toLowerCase().indexOf(data.search_for.toLowerCase())) + "<u>" + contact_name.substr(contact_name.toLowerCase().indexOf(data.search_for.toLowerCase()), data.search_for.length) + "</u>" + contact_name.substring(contact_name.toLowerCase().indexOf(data.search_for.toLowerCase()) + data.search_for.length); |
---|
[6459] | 316 | var vacationImg = ''; |
---|
| 317 | if (data[i-1].vacationactive == "TRUE") |
---|
| 318 | vacationImg = '<img src="templates/default/images/mala-small.png"/>'; |
---|
| 319 | var line = '<span class="menu-control"><button class="'+btnClass+'" id="actions_'+i+'" onClick="'+exist+'(document.getElementById(\'contact_' + i + '\').innerHTML, this, \'contact_' + i + '\')">'+ signal +'</button></span><div id="contact_' + i + '" onDblClick="'+exist+'(this.innerHTML, document.getElementById(\'actions_'+i+'\'), \'contact_' + i + '\')"><div class="name_contact"><strong class="name">' + contact_name +' '+ vacationImg +'</strong><em class="email">' + ((utf8_decoder(data[i-1].mail) != undefined)? (utf8_decoder(data[i-1].mail) == 'undefined' ? get_lang("No mail") : utf8_decoder(data[i-1].mail)) : get_lang("No mail")) + '</em></div></div>'; |
---|
[5172] | 320 | Op.innerHTML = line; |
---|
| 321 | $(Op).val(i - 1); |
---|
[5134] | 322 | selectable.append(Op); |
---|
[5172] | 323 | $("#contact_"+i).click(function(){ |
---|
| 324 | document.getElementById("amount-text").focus(); |
---|
| 325 | }); |
---|
| 326 | } |
---|
[5134] | 327 | selectable.append(Ul); |
---|
| 328 | var first_contact; |
---|
| 329 | begin ? first_contact = 0 : first_contact = ((sliderValue* 6) -6); |
---|
[5172] | 330 | var details = $("#detalhes_contato").empty(); |
---|
| 331 | |
---|
[5134] | 332 | switch (data['type_catalog']) { |
---|
| 333 | case 'G': |
---|
[5466] | 334 | if(data['extra_ldap_fields']){ |
---|
| 335 | if(data['extra_ldap_fields'].length != 0) |
---|
| 336 | var extra_fields = (data['extra_ldap_fields']).split("#"); |
---|
| 337 | else |
---|
| 338 | var extra_fields = []; |
---|
| 339 | }else |
---|
[5456] | 340 | var extra_fields = []; |
---|
[5134] | 341 | if(preferences.default_fields_quick_search != 0) { |
---|
[5466] | 342 | details.append('<p><label class="attribute">' + utf8_decoder(data[first_contact].cn[0]) + "</label>" + '<span class="value">' + (data[first_contact].mail ? data[first_contact].mail[0] : "") + "</span></p>"); |
---|
| 343 | if(data[first_contact].telephonenumber) |
---|
| 344 | details.append('<p><label class="attribute">Telefone</label>' + '<span class="value">' + (data[first_contact].telephonenumber ? data[first_contact].telephonenumber[0] : "") + '</span></p>'); |
---|
[5456] | 345 | } |
---|
[5134] | 346 | for (var i=0; i<=extra_fields.length-1; i++) { |
---|
| 347 | var campo = extra_fields[i].substr(extra_fields[i].indexOf("|")+1); |
---|
| 348 | var valor = extra_fields[i].substr(0, (extra_fields[i].indexOf("|"))); |
---|
| 349 | if(data[0][valor.toLowerCase()] != undefined) |
---|
| 350 | { |
---|
| 351 | var tmp_campo = '<p><label class="attribute">' + campo + "</label>" ; |
---|
| 352 | for(j=0; j<data[first_contact][valor.toLowerCase()].length; j++) { |
---|
[5251] | 353 | details.append(tmp_campo + '<span class="value">' + utf8_decoder(data[first_contact][valor.toLowerCase()][j]) + "</span></p>"); |
---|
[5134] | 354 | tmp_campo = ""; |
---|
| 355 | } |
---|
| 356 | } |
---|
[6459] | 357 | } |
---|
| 358 | if (data[first_contact].vacationactive == "TRUE"){ |
---|
| 359 | details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>'); |
---|
| 360 | if ( data[first_contact].vacationinfo ){ |
---|
| 361 | details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data[first_contact].vacationinfo +'</span></div></div>'); |
---|
| 362 | if ( $('.outoffice-inner').height() > $('.outoffice').height() ){ |
---|
| 363 | var link = $('<a>').html('Ver mais'); |
---|
| 364 | link.attr('id','more'); |
---|
| 365 | link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();}); |
---|
| 366 | details.append(link); |
---|
| 367 | } |
---|
| 368 | } |
---|
| 369 | } |
---|
[5134] | 370 | break; |
---|
| 371 | case 'P': |
---|
[5172] | 372 | if(utf8_decoder(data[first_contact].cn) != 'undefined') |
---|
| 373 | details.append('<p><label class="attribute">' + utf8_decoder(data[first_contact].cn) + '</label>' + '<span class="value">' + data[first_contact].mail + '</span></p>'); |
---|
| 374 | else |
---|
| 375 | details.append('<p><label class="attribute">' + utf8_decoder(data[first_contact].title) + '</label>' + '<span class="value">' + data[first_contact].short_name + '</span></p>'); |
---|
[5134] | 376 | if(data[first_contact].telephonenumber != null) |
---|
| 377 | details.append('<p><label class="attribute">Telefone</label>' + '<span class="value">' + data[first_contact].telephonenumber + '</span></p>'); |
---|
[6459] | 378 | if (data[first_contact].vacationactive == "TRUE"){ |
---|
| 379 | details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>'); |
---|
| 380 | if ( data[first_contact].vacationinfo ){ |
---|
| 381 | details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data[first_contact].vacationinfo +'</span></div></div>'); |
---|
| 382 | if ( $('.outoffice-inner').height() > $('.outoffice').height() ){ |
---|
| 383 | var link = $('<a>').html('Ver mais'); |
---|
| 384 | link.attr('id','more'); |
---|
| 385 | link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();}); |
---|
| 386 | details.append(link); |
---|
| 387 | } |
---|
| 388 | } |
---|
| 389 | } |
---|
[5134] | 390 | break; |
---|
[5456] | 391 | default: |
---|
[5466] | 392 | if(data['extra_ldap_fields']){ |
---|
| 393 | if(data['extra_ldap_fields'].length != 0) |
---|
| 394 | var extra_fields = (data['extra_ldap_fields']).split("#"); |
---|
| 395 | else |
---|
| 396 | var extra_fields = []; |
---|
| 397 | }else |
---|
[5456] | 398 | var extra_fields = []; |
---|
[6417] | 399 | if(preferences.default_fields_quick_search != 0 || data[first_contact].type_contact == "P" || data[first_contact].type_contact == "G") { |
---|
[5172] | 400 | if(utf8_decoder(data[first_contact].cn) != 'undefined') |
---|
| 401 | details.append('<p><label class="attribute">' + utf8_decoder(data[first_contact].cn) + '</label>' + '<span class="value">' + data[first_contact].mail + '</span></p>'); |
---|
| 402 | else |
---|
| 403 | details.append('<p><label class="attribute">' + utf8_decoder(data[first_contact].title) + '</label>' + '<span class="value">' + data[first_contact].short_name + '</span></p>'); |
---|
[5134] | 404 | if(data[first_contact].telephonenumber != null) |
---|
| 405 | details.append('<p><label class="attribute">Telefone</label>' + '<span class="value">' + data[first_contact].telephonenumber + "</span></p>"); |
---|
| 406 | } |
---|
[5251] | 407 | if( data[first_contact].type_contact == "G") { |
---|
| 408 | if(data[first_contact].mail[0].length > 1) { |
---|
[5134] | 409 | for (var i=0; i<=extra_fields.length-1; i++) { |
---|
| 410 | var campo = extra_fields[i].substr(extra_fields[i].indexOf("|")+1); |
---|
| 411 | var valor = extra_fields[i].substr(0, (extra_fields[i].indexOf("|"))); |
---|
| 412 | if(data[first_contact][valor.toLowerCase()] != undefined) { |
---|
| 413 | var tmp_campo = '<p><label class="attribute">' + campo + "</label>" ; |
---|
| 414 | for(j=0; j<data[first_contact][valor.toLowerCase()].length; j++) { |
---|
[5251] | 415 | details.append(tmp_campo + '<span class="value">' + utf8_decoder(data[first_contact][valor.toLowerCase()][j]) + "</span></p>"); |
---|
[5134] | 416 | tmp_campo = ""; |
---|
| 417 | } |
---|
| 418 | } |
---|
| 419 | } |
---|
| 420 | } |
---|
| 421 | } |
---|
[6459] | 422 | if (data[first_contact].vacationactive == "TRUE"){ |
---|
| 423 | details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>'); |
---|
| 424 | if ( data[first_contact].vacationinfo ){ |
---|
| 425 | details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data[first_contact].vacationinfo +'</span></div></div>'); |
---|
| 426 | if ( $('.outoffice-inner').height() > $('.outoffice').height() ){ |
---|
| 427 | var link = $('<a>').html('Ver mais'); |
---|
| 428 | link.attr('id','more'); |
---|
| 429 | link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();}); |
---|
| 430 | details.append(link); |
---|
| 431 | } |
---|
| 432 | } |
---|
| 433 | } |
---|
[5134] | 434 | break; |
---|
| 435 | } |
---|
| 436 | var string_results = sliderValue + " " + get_lang("of") + " " + paginas + " (" + data.length + " " + get_lang("Results") + ")"; |
---|
| 437 | $( "#amount-text" ).val( string_results ); |
---|
| 438 | $("button").button(); |
---|
[5172] | 439 | //$("button.remove").button({icons:{primary:"ui-icon-close"}, text: false}); |
---|
| 440 | //$("button.add").button({icons:{primary:"ui-icon-plus"}, text: false}); |
---|
[5134] | 441 | if(!is_ie) |
---|
| 442 | document.getElementById("amount-text").focus(); |
---|
[5172] | 443 | $("#selectable li:first").focus(); |
---|
[5134] | 444 | removeFocus(); |
---|
[5172] | 445 | } |
---|
[3305] | 446 | |
---|
[5075] | 447 | |
---|
[5134] | 448 | /* Método que configura os detalhes do resultado da busca */ |
---|
| 449 | function details_results(data) { |
---|
[5172] | 450 | $(function() { |
---|
| 451 | $( "#selectable" ).selectable({ |
---|
| 452 | stop: function() { |
---|
| 453 | var details = $("#detalhes_contato").empty(); |
---|
| 454 | $( ".ui-selected", this ).each(function() { |
---|
| 455 | if(data.length > 0){ |
---|
| 456 | switch(data['type_catalog']) { |
---|
| 457 | case 'G': |
---|
[5466] | 458 | if(data['extra_ldap_fields'] != undefined){ |
---|
| 459 | if(data['extra_ldap_fields'].length != 0) |
---|
| 460 | var extra_fields = (data['extra_ldap_fields']).split("#"); |
---|
| 461 | else |
---|
| 462 | var extra_fields = []; |
---|
| 463 | }else |
---|
[5456] | 464 | var extra_fields = []; |
---|
[6459] | 465 | if(preferences.default_fields_quick_search != 0 && data[this.value] ) { |
---|
| 466 | details.append('<p><label class="attribute">' + utf8_decoder(data[this.value].cn[0]) + "</label>" + '<span class="value">' + (data[this.value].mail ? data[this.value].mail[0] : "")+ "</span></p>"); |
---|
| 467 | if(data[this.value].telephonenumber ) |
---|
[5466] | 468 | details.append('<p><label class="attribute">Telefone</label>' + '<span class="value">' + (data[this.value].telephonenumber ? data[this.value].telephonenumber[0] : "")+ "</span></p>"); |
---|
[5172] | 469 | } |
---|
[5134] | 470 | for (var i=0; i<=extra_fields.length-1; i++) { |
---|
[5172] | 471 | var campo = extra_fields[i].substr(extra_fields[i].indexOf("|")+1); |
---|
| 472 | var valor = extra_fields[i].substr(0, (extra_fields[i].indexOf("|"))); |
---|
[6290] | 473 | if( data[this.value] && data[this.value][valor.toLowerCase()] != undefined) { |
---|
[5134] | 474 | var tmp_campo = '<p><label class="attribute">' + campo + "</label>" ; |
---|
| 475 | for(j=0; j<data[this.value][valor.toLowerCase()].length; j++) { |
---|
[5251] | 476 | details.append(tmp_campo + '<span class="value">' + utf8_decoder(data[this.value][valor.toLowerCase()][j]) + "</span></p>"); |
---|
[5134] | 477 | tmp_campo = ""; |
---|
[5172] | 478 | } |
---|
| 479 | } |
---|
| 480 | } |
---|
[6459] | 481 | if (data[this.value].vacationactive == "TRUE"){ |
---|
| 482 | details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>'); |
---|
| 483 | if ( data[this.value].vacationinfo ){ |
---|
| 484 | details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data[this.value].vacationinfo +'</span></div></div>'); |
---|
| 485 | if ( $('.outoffice-inner').height() > $('.outoffice').height() ){ |
---|
| 486 | var link = $('<a>').html('Ver mais'); |
---|
| 487 | link.attr('id','more'); |
---|
| 488 | link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();}); |
---|
| 489 | details.append(link); |
---|
| 490 | } |
---|
| 491 | } |
---|
| 492 | } |
---|
[5172] | 493 | break; |
---|
| 494 | case 'P': |
---|
| 495 | if(utf8_decoder(data[this.value].cn) == 'undefined') |
---|
| 496 | details.append('<p><label class="attribute">' + utf8_decoder(data[this.value].title) + "</label>" + '<span class="value">' + data[this.value].short_name + "</span></p>"); |
---|
| 497 | else |
---|
| 498 | details.append('<p><label class="attribute">' + utf8_decoder(data[this.value].cn) + "</label>" + '<span class="value">' + data[this.value].mail + "</span></p>"); |
---|
| 499 | if(data[this.value].telephonenumber != null) |
---|
| 500 | details.append('<p><label class="attribute">Telefone</label>' + '<span class="value">' + data[this.value].telephonenumber + "</span></p>"); |
---|
[6459] | 501 | if (data[this.value].vacationactive == "TRUE"){ |
---|
| 502 | details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>'); |
---|
| 503 | if ( data[this.value].vacationinfo ){ |
---|
| 504 | details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data[this.value].vacationinfo +'</span></div></div>'); |
---|
| 505 | if ( $('.outoffice-inner').height() > $('.outoffice').height() ){ |
---|
| 506 | var link = $('<a>').html('Ver mais'); |
---|
| 507 | link.attr('id','more'); |
---|
| 508 | link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();}); |
---|
| 509 | details.append(link); |
---|
| 510 | } |
---|
| 511 | } |
---|
| 512 | } |
---|
[5172] | 513 | break; |
---|
| 514 | default: |
---|
[6480] | 515 | if(this.value == undefined) |
---|
| 516 | break; |
---|
| 517 | |
---|
[5456] | 518 | if(data['extra_ldap_fields'].length != 0) |
---|
| 519 | var extra_fields = (data['extra_ldap_fields']).split("#"); |
---|
| 520 | else |
---|
| 521 | var extra_fields = []; |
---|
[6417] | 522 | if(preferences.default_fields_quick_search != 0 || data[this.value].type_contact == "P" || data[this.value].type_contact == "G") { |
---|
[5172] | 523 | if(utf8_decoder(data[this.value].cn) == 'undefined') |
---|
| 524 | details.append('<p><label class="attribute">' + utf8_decoder(data[this.value].title) + "</label>" + '<span class="value">' + data[this.value].short_name + "</span></p>"); |
---|
| 525 | else |
---|
| 526 | details.append('<p><label class="attribute">' + utf8_decoder(data[this.value].cn) + "</label>" + '<span class="value">' + data[this.value].mail + "</span></p>"); |
---|
| 527 | if(data[this.value].telephonenumber != null) |
---|
| 528 | details.append('<p><label class="attribute">Telefone</label>' + '<span class="value">' + data[this.value].telephonenumber + "</span></p>"); |
---|
| 529 | } |
---|
| 530 | if(data[this.value].mail[0] == 'undefined') |
---|
| 531 | break; |
---|
| 532 | if(data[this.value].mail[0] != get_lang("No mail")) { |
---|
| 533 | if(data[this.value].mail[0].length > 1) { |
---|
| 534 | for (var i=0; i<=extra_fields.length-1; i++) { |
---|
| 535 | var campo = extra_fields[i].substr(extra_fields[i].indexOf("|")+1); |
---|
| 536 | var valor = extra_fields[i].substr(0, (extra_fields[i].indexOf("|"))); |
---|
| 537 | if(data[this.value][valor.toLowerCase()] != undefined) { |
---|
| 538 | var tmp_campo = '<p><label class="attribute">' + campo + "</label>" ; |
---|
| 539 | for(j=0; j<data[this.value][valor.toLowerCase()].length; j++) { |
---|
[5251] | 540 | details.append(tmp_campo + '<span class="value">' + utf8_decoder(data[this.value][valor.toLowerCase()][j]) + "</span></p>"); |
---|
[5172] | 541 | tmp_campo = ""; |
---|
| 542 | } |
---|
| 543 | } |
---|
| 544 | } |
---|
| 545 | } |
---|
| 546 | } |
---|
[6459] | 547 | if (data[this.value].vacationactive == "TRUE"){ |
---|
| 548 | details.append('<p><img src="templates/default/images/mala-big.png"/><span class="title-outoffice">Filtro "Fora do Escritório" ativo.</span></p>'); |
---|
| 549 | if ( data[this.value].vacationinfo ){ |
---|
| 550 | details.append('<div class="outoffice"><div class="outoffice-inner"><span>'+ data[this.value].vacationinfo +'</span></div></div>') |
---|
| 551 | if ( $('.outoffice-inner').height() > $('.outoffice').height() ){ |
---|
| 552 | var link = $('<a>').html('Ver mais'); |
---|
| 553 | link.attr('id','more'); |
---|
| 554 | link.bind('click',function(){$('.outoffice').animate({height: $('.outoffice-inner').height(),width: '-=15px'},800); $('#more').unbind('click').hide();}); |
---|
| 555 | details.append(link); |
---|
| 556 | } |
---|
| 557 | } |
---|
| 558 | } |
---|
[5172] | 559 | break; |
---|
| 560 | } |
---|
[5075] | 561 | } |
---|
[5172] | 562 | }); |
---|
| 563 | } |
---|
| 564 | }); |
---|
| 565 | }); |
---|
| 566 | } |
---|
| 567 | |
---|
| 568 | |
---|
| 569 | /* |
---|
| 570 | * Método que configura o slider e os resultados |
---|
| 571 | */ |
---|
[5134] | 572 | function configure_slider(data) { |
---|
| 573 | var paginas = (Math.ceil(data.length/6)); |
---|
[5172] | 574 | $("#title_usuarios").html( get_lang("Results") ); |
---|
| 575 | $(function() { |
---|
| 576 | $( "#slider" ).slider({ |
---|
| 577 | value:1, |
---|
| 578 | min: 1, |
---|
| 579 | max: paginas, |
---|
| 580 | step: 1, |
---|
[5134] | 581 | slide: function( event, ui ) { |
---|
| 582 | create_list(data, false, ui.value); |
---|
[5172] | 583 | var string_results = ui.value + " " + get_lang("of") + " " + paginas + " (" + data.length + " " + get_lang("Results") + ")"; |
---|
[5134] | 584 | $( "#amount-text" ).val( string_results ); |
---|
[5172] | 585 | } |
---|
| 586 | }); |
---|
[5134] | 587 | $("#selectable li:first button:first").focus(); |
---|
[5172] | 588 | }); |
---|
| 589 | } |
---|
[5075] | 590 | |
---|
[5134] | 591 | var search_focus = false; |
---|
[5172] | 592 | |
---|
[5134] | 593 | function setFocus() {search_focus = true;return;} |
---|
[5172] | 594 | |
---|
[5134] | 595 | function removeFocus() {search_focus = false;return;} |
---|
| 596 | |
---|
| 597 | function checkEnter(e) { |
---|
[5172] | 598 | var kC = window.event ? event.keyCode : |
---|
| 599 | e && e.keyCode ? e.keyCode : |
---|
| 600 | e && e.which ? e.which : null; |
---|
[5134] | 601 | if (kC) |
---|
[5172] | 602 | return kC == 13; |
---|
[5134] | 603 | else |
---|
[5172] | 604 | return false; |
---|
| 605 | } |
---|
[5075] | 606 | |
---|
[5172] | 607 | |
---|
| 608 | /* |
---|
| 609 | * Faz a busca direto da tela modal |
---|
| 610 | */ |
---|
[5134] | 611 | function buscaContato(param) { |
---|
| 612 | $("#busca, #detalhes_contato, #selectable").empty(); |
---|
| 613 | if(param.length == 0) { |
---|
| 614 | alert(get_lang("Please enter a parameter to search")); |
---|
| 615 | return; |
---|
[5172] | 616 | } |
---|
[5134] | 617 | if(param.length < preferences.search_characters_number) { |
---|
[5172] | 618 | alert(get_lang("parameter must be at least") + " " + preferences.search_characters_number + " " + get_lang("characters")); |
---|
| 619 | return false; |
---|
| 620 | } |
---|
| 621 | var catalog = $("#combobox").val(); |
---|
| 622 | var handler_emQuickSearch = function(data) { |
---|
| 623 | data_ = data; |
---|
| 624 | if(data_.length > 0) { |
---|
| 625 | configure_slider(data_); |
---|
| 626 | create_list(data, true); |
---|
| 627 | details_results(data_); |
---|
[5075] | 628 | } |
---|
[5134] | 629 | else { |
---|
[5172] | 630 | $("#detalhes_contato, #selectable").empty(); |
---|
| 631 | var selectable = $("#selectable"); |
---|
| 632 | var Ul = document.createElement("ul"); |
---|
| 633 | Ul.onclick = function(){ |
---|
| 634 | }; |
---|
| 635 | var Op = document.createElement("li"); |
---|
| 636 | Op.innerHTML = '<span class="menu-control"></span><div id="no_results"><div class="name_contact"><strong class="name">Nenhum Resultado Encontrado</strong></div></div>'; |
---|
| 637 | selectable.append(Op); |
---|
| 638 | selectable.append(Ul); |
---|
| 639 | var string_results = "0 " + get_lang("of") + " 0 (0 " + get_lang("Results") + ")"; |
---|
| 640 | $( "#amount-text" ).val( string_results ); |
---|
| 641 | details_results(data); |
---|
| 642 | configure_slider(data); |
---|
[5075] | 643 | } |
---|
| 644 | } |
---|
[5172] | 645 | cExecute ("$this.ldap_functions.quicksearchcontact&search_for="+param+"&field=TO&ID=0&catalog="+catalog, handler_emQuickSearch); |
---|
| 646 | } |
---|
[5075] | 647 | |
---|
[5172] | 648 | function verifyEmails(emailAux, contato) { |
---|
| 649 | var contact_id = contato.split("_"); |
---|
| 650 | if(contact_id[1] != 0) |
---|
| 651 | { |
---|
| 652 | var ini = parseInt((contact_id[1]/6).toFixed(0)); |
---|
| 653 | if(ini != 0 && ini != 1){ |
---|
| 654 | ini = ini * 6; |
---|
| 655 | var fim = ini+1; |
---|
| 656 | } |
---|
| 657 | else{ |
---|
| 658 | ini = 1; |
---|
| 659 | var fim = ini; |
---|
| 660 | } |
---|
| 661 | fim = fim +5; |
---|
| 662 | var contact2 = ""; |
---|
| 663 | for(aux = ini; aux <= fim; aux++){ |
---|
| 664 | if(contact_id[1] != aux){ |
---|
| 665 | if($("#"+contact_id[0]+"_"+aux).find('.email').text() == emailAux){ |
---|
| 666 | contact2 = contact_id[0]+"_"+aux; |
---|
| 667 | var button = document.getElementById("actions_"+aux); |
---|
| 668 | var div = document.getElementById(contact2); |
---|
| 669 | if($("#actions_"+aux).find('.ui-button-text').text() == '+'){ |
---|
| 670 | button.onclick = function(){ |
---|
| 671 | remove_contact_field(div.innerHTML, button, contact2); |
---|
| 672 | }; |
---|
| 673 | div.ondblclick = function(){ |
---|
| 674 | remove_contact_field(div.innerHTML, button, contact2); |
---|
| 675 | }; |
---|
| 676 | $("#actions_"+aux).find('.ui-button-text').text('x'); |
---|
| 677 | } |
---|
| 678 | else{ |
---|
| 679 | button.onclick = function(){ |
---|
| 680 | add_contact_field(div.innerHTML, button, contact2); |
---|
| 681 | }; |
---|
| 682 | div.ondblclick = function(){ |
---|
| 683 | add_contact_field(div.innerHTML, button, contact2); |
---|
| 684 | }; |
---|
| 685 | $("#actions_"+aux).find('.ui-button-text').text('+'); |
---|
| 686 | } |
---|
| 687 | } |
---|
| 688 | } |
---|
| 689 | } |
---|
| 690 | } |
---|
| 691 | } |
---|
| 692 | /* |
---|
| 693 | * Método que adiciona o contato selecionado no campo do email (To, CC, CCo) |
---|
| 694 | */ |
---|
| 695 | function add_contact_field(contact, button, divs) { |
---|
| 696 | |
---|
| 697 | var nome = $(contact).clone().find('.name').text(); |
---|
| 698 | var email = $(contact).clone().find('.email').text(); |
---|
| 699 | |
---|
| 700 | if(email == get_lang("No mail")){ |
---|
| 701 | alert(get_lang("It is not possible to add this contact as a recipient because it does not have email")); |
---|
| 702 | if(!is_ie) |
---|
| 703 | document.getElementById("amount-text").focus(); |
---|
| 704 | return; |
---|
| 705 | } |
---|
| 706 | |
---|
| 707 | verifyEmails(email, divs); |
---|
| 708 | |
---|
| 709 | final_contact = "\""+nome +"\" <"+email+">, "; |
---|
| 710 | |
---|
[5911] | 711 | var emailList = content.find(field_).val(); |
---|
[5395] | 712 | //remove os caracteres da busca |
---|
| 713 | emailList = emailList.substr(0,emailList.lastIndexOf(',')+1); |
---|
[5172] | 714 | |
---|
[5134] | 715 | if (emailList[0] != '"' && emailList.indexOf(",") < 0) |
---|
[5172] | 716 | emailList = emailList.substr(end_); |
---|
[5383] | 717 | if(emailList.lastIndexOf(",") > 0){ |
---|
[5382] | 718 | if(emailList.substr(emailList.length-1, emailList.length) == "," || emailList.substr(emailList.length-2, 1) == ","){ |
---|
[5134] | 719 | emailList = emailList.substr(0, emailList.lastIndexOf(",") + 1); |
---|
[5382] | 720 | } else { |
---|
| 721 | emailList = emailList.substr(0, emailList.lastIndexOf("") + 1); |
---|
| 722 | final_contact = ","+final_contact; |
---|
| 723 | } |
---|
[5383] | 724 | } |
---|
[5382] | 725 | |
---|
[5134] | 726 | final_contact = final_contact.replace(/\/n/, ""); |
---|
[5172] | 727 | new_emailList = emailList + final_contact; |
---|
[5911] | 728 | content.find(field_).val(new_emailList); |
---|
[5134] | 729 | |
---|
[5911] | 730 | content.find(field_).trigger("update"); |
---|
[5423] | 731 | |
---|
[5172] | 732 | button.onclick = function(){ |
---|
| 733 | remove_contact_field(document.getElementById(divs).innerHTML, button, divs); |
---|
| 734 | }; |
---|
| 735 | var div = document.getElementById(divs); |
---|
[5134] | 736 | |
---|
[5172] | 737 | div.ondblclick = function(){ |
---|
| 738 | remove_contact_field(div.innerHTML, button, divs); |
---|
| 739 | }; |
---|
[5134] | 740 | |
---|
[5172] | 741 | button.innerHTML = '<span class="ui-button-text" style="">x</span>'; |
---|
| 742 | } |
---|
[5134] | 743 | |
---|
[5075] | 744 | |
---|
[5172] | 745 | /* |
---|
| 746 | * Método que remove o contato selecionado no campo do email (To, CC, CCo) |
---|
| 747 | */ |
---|
| 748 | function remove_contact_field(contact, button, divs) { |
---|
| 749 | var email = $(contact).clone().find('.email').text(); |
---|
[5134] | 750 | var exist = false; |
---|
[5172] | 751 | |
---|
[5911] | 752 | var emailList = content.find(field_).val(); |
---|
[5172] | 753 | var emails_adicionados = emailList.split(","); |
---|
| 754 | |
---|
| 755 | verifyEmails(email, divs); |
---|
| 756 | |
---|
[5134] | 757 | for(i=0; i<emails_adicionados.length -1; i++) { |
---|
[5172] | 758 | |
---|
[5258] | 759 | if(emails_adicionados[i].match(/<([^<]*)>[\s]*$/)){ |
---|
| 760 | if(emails_adicionados[i].match(/<([^<]*)>[\s]*$/)[1].toLowerCase() == email.toLowerCase()) { |
---|
| 761 | emails_adicionados[i] = "%"; |
---|
| 762 | exist = true; |
---|
| 763 | } |
---|
| 764 | }else{ |
---|
| 765 | if(emails_adicionados[i].toLowerCase() == email.toLowerCase()) { |
---|
| 766 | emails_adicionados[i] = "%"; |
---|
| 767 | exist = true; |
---|
| 768 | } |
---|
[5075] | 769 | } |
---|
[5172] | 770 | } |
---|
| 771 | |
---|
[5134] | 772 | if (exist == false) |
---|
[5172] | 773 | return false; |
---|
| 774 | var novos_contatos = emails_adicionados.join(","); |
---|
| 775 | novos_contatos = novos_contatos.replace(/%,/g, ""); |
---|
[5911] | 776 | content.find(field_).val(novos_contatos); |
---|
[5172] | 777 | |
---|
| 778 | button.onclick = function(){ |
---|
| 779 | add_contact_field(document.getElementById(divs).innerHTML, button, divs); |
---|
| 780 | }; |
---|
| 781 | |
---|
| 782 | var div = document.getElementById(divs); |
---|
| 783 | |
---|
| 784 | div.ondblclick = function(){ |
---|
| 785 | add_contact_field(div.innerHTML, button, divs); |
---|
| 786 | }; |
---|
| 787 | |
---|
[5911] | 788 | content.find(field_).trigger("update"); |
---|
[5172] | 789 | button.innerHTML = '<span class="ui-button-text" style="">+</span>'; |
---|
| 790 | } |
---|
[5075] | 791 | |
---|
[5172] | 792 | |
---|
[5134] | 793 | /* Decoder utf8 */ |
---|
| 794 | function utf8_decoder ( str_data ) { |
---|
[5172] | 795 | var tmp_arr = [], i = 0, ac = 0, c1 = 0, c2 = 0, c3 = 0; |
---|
| 796 | str_data += ''; |
---|
[5134] | 797 | while ( i < str_data.length ) { |
---|
[5172] | 798 | c1 = str_data.charCodeAt(i); |
---|
[5134] | 799 | if (c1 < 128) { |
---|
[5172] | 800 | tmp_arr[ac++] = String.fromCharCode(c1); |
---|
| 801 | i++; |
---|
[5134] | 802 | } else if ((c1 > 191) && (c1 < 224)) { |
---|
[5172] | 803 | c2 = str_data.charCodeAt(i+1); |
---|
| 804 | tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63)); |
---|
| 805 | i += 2; |
---|
| 806 | } else { |
---|
| 807 | c2 = str_data.charCodeAt(i+1); |
---|
| 808 | c3 = str_data.charCodeAt(i+2); |
---|
| 809 | tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); |
---|
| 810 | i += 3; |
---|
| 811 | } |
---|
[5075] | 812 | } |
---|
[5172] | 813 | return tmp_arr.join(''); |
---|
| 814 | } |
---|
[5075] | 815 | |
---|
[5172] | 816 | |
---|
[5134] | 817 | /* Mostra tela de help */ |
---|
| 818 | function show_help() { |
---|
[5075] | 819 | $(function() { |
---|
| 820 | $( "#dialog-modal_help" ).dialog({ |
---|
| 821 | resizable: false, |
---|
| 822 | width: 540, |
---|
| 823 | modal: true, |
---|
[5172] | 824 | closeOnEscape: true, |
---|
| 825 | close : function (event, ui) { |
---|
| 826 | $( "#amount-text" ).focus(); |
---|
| 827 | event.stopPropagation(); |
---|
| 828 | } |
---|
[5075] | 829 | }); |
---|
| 830 | }); |
---|
| 831 | } |
---|
[5172] | 832 | |
---|
| 833 | $("#dialog-modal_help").live("dialogclose", function(){ |
---|
| 834 | if(!is_ie) |
---|
| 835 | $( "#amount-text" ).focus(); |
---|
| 836 | }); |
---|
| 837 | |
---|
| 838 | |
---|
[5404] | 839 | emQuickCatalogSearch.prototype.showWindow = function () { |
---|
[5134] | 840 | $(this).bind('keydown'); |
---|
[5172] | 841 | $(function() { |
---|
| 842 | $( "#dialog:ui-dialog" ).dialog( "destroy" ); |
---|
| 843 | $( "#dialog-modal" ).dialog({ |
---|
| 844 | resizable: false, |
---|
[5134] | 845 | // height: "auto", |
---|
| 846 | width: 780, |
---|
[5172] | 847 | modal: true, |
---|
[5134] | 848 | position: 'bottom', |
---|
[5172] | 849 | closeOnEscape: true, |
---|
| 850 | close: function (event, ui) { |
---|
| 851 | event.stopPropagation(); |
---|
[5134] | 852 | $(this).unbind('keydown'); |
---|
| 853 | if (is_ie) { |
---|
[5911] | 854 | var range= content.find(field_).createTextRange(); |
---|
[5134] | 855 | range.collapse(false); |
---|
| 856 | range.select(); |
---|
| 857 | } else { |
---|
[5911] | 858 | content.find(field_).focus(); |
---|
[5134] | 859 | } |
---|
| 860 | }, |
---|
| 861 | open: function () { |
---|
[5172] | 862 | removeFocus(); |
---|
| 863 | $("#selectable li:first").focus(); |
---|
| 864 | document.getElementById("amount-text").focus(); |
---|
| 865 | }, |
---|
| 866 | focus: function (event, ui) { |
---|
[5134] | 867 | //$(this).unbind('keydown'); |
---|
[5172] | 868 | }, |
---|
| 869 | beforeClose: function (event, ui) { |
---|
[5134] | 870 | $(this).unbind('keydown'); |
---|
[5172] | 871 | }, |
---|
[5134] | 872 | buttons:[ |
---|
| 873 | { |
---|
| 874 | text: "Fechar", |
---|
| 875 | click: function(){ |
---|
[5172] | 876 | $("#detalhes_contato, #selectable, #busca").empty(); |
---|
| 877 | $(this).dialog("close"); |
---|
[5134] | 878 | if (is_ie) { |
---|
[5911] | 879 | var range= content.find(field_).createTextRange(); |
---|
[5134] | 880 | range.collapse(false); |
---|
| 881 | range.select(); |
---|
| 882 | } else { |
---|
[5911] | 883 | content.find(field_).focus(); |
---|
[5172] | 884 | } |
---|
[5134] | 885 | }, |
---|
| 886 | style: "margin-top: -2.1em" |
---|
[5075] | 887 | } |
---|
[5134] | 888 | ] |
---|
[5172] | 889 | }); |
---|
| 890 | }); |
---|
[5134] | 891 | $(".ui-dialog .ui-dialog-titlebar") |
---|
| 892 | .append('<a href="#" class="ui-dialog-titlebar-minimize ui-corner-all" role="button"><span class="ui-icon ui-icon-minusthick">minimize</span></a>') |
---|
| 893 | .find('.ui-dialog-titlebar-minimize').click(function() { |
---|
| 894 | $(".ui-dialog-buttonpane, .ui-dialog-content").toggle(); |
---|
| 895 | $(".ui-icon-minusthick, .ui-icon-newwin").toggleClass('ui-icon-minusthick').toggleClass('ui-icon-newwin'); |
---|
| 896 | }); |
---|
[5786] | 897 | $("#dialog-modal .ui-icon-search").click(function (){buscaContato($('#busca').val());}); |
---|
| 898 | $("#dialog-modal button, input.button").button(); |
---|
| 899 | } |
---|
[4034] | 900 | |
---|
[2] | 901 | |
---|
[5134] | 902 | /* Build the Object */ |
---|
[4761] | 903 | //QuickCatalogSearch; |
---|
[6459] | 904 | QuickCatalogSearch = new emQuickCatalogSearch(); |
---|