Changeset 7147 for trunk/calendar/templates/default/js/edit_exmail.js
- Timestamp:
- 09/03/12 16:20:49 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/calendar/templates/default/js/edit_exmail.js
r5143 r7147 18 18 } 19 19 20 // Verifica vers ão do Firefox20 // Verifica versão do Firefox 21 21 var agt = navigator.userAgent.toLowerCase(); 22 22 var is_firefox_0 = agt.indexOf('firefox/1.0') != -1 && agt.indexOf('firefox/0.') ? true : false; … … 154 154 function submitValues(button){ 155 155 loadScript("expressoMail1_2/js/common_functions.js"); 156 button.disabled = true; //Desabilita Bot ão para evitar varios clicks156 button.disabled = true; //Desabilita Botão para evitar varios clicks 157 157 158 158 var typeField = document.getElementById('cal[type]'); … … 177 177 178 178 if( !isChecked && !document.getElementsByName( "cal[rpt_use_end]" )[0].checked && !(document.getElementsByName( "cal[recur_type]" )[0].value === "0")){ 179 alert("Agendamentos recorrentes precisam de data final da repeti ção");179 alert("Agendamentos recorrentes precisam de data final da repetição"); 180 180 button.disabled = false; 181 181 return false; … … 190 190 if(document.getElementsByName( "cal[rpt_use_end]" )[0].checked){ 191 191 if(!validate_date_order(document.getElementById('start[str]').value, document.getElementById('recur_enddate[str]').value)){ 192 alert("A data final n ão pode ser menor que a data inicial.");192 alert("A data final não pode ser menor que a data inicial."); 193 193 button.disabled = false; 194 194 return false; … … 197 197 //Valida data inicio nao nula 198 198 if(document.getElementById('start[str]').value == ''){ 199 alert("Necessario preencher a data de in ício.");199 alert("Necessario preencher a data de inÃcio."); 200 200 document.getElementById('start[str]').focus(); 201 201 button.disabled = false; … … 207 207 document.getElementById('start[str]').value = ''; 208 208 document.getElementById('start[str]').focus(); 209 alert("A data de in ício não é válida.");209 alert("A data de inÃcio não é válida."); 210 210 button.disabled = false; 211 211 return false; … … 217 217 document.getElementById('end[str]').value = ''; 218 218 document.getElementById('end[str]').focus(); 219 alert("A data de t érmino não é válida.");219 alert("A data de término não é válida."); 220 220 button.disabled = false; 221 221 return false; … … 227 227 document.getElementById('start_hour').value = ''; 228 228 document.getElementById('start_hour').focus(); 229 alert("A hora de in ício deve ser números.");229 alert("A hora de inÃcio deve ser números."); 230 230 button.disabled = false; 231 231 return false; … … 235 235 document.getElementById('start_minute').value = ''; 236 236 document.getElementById('start_minute').focus(); 237 alert("A hora de in ício deve ser números.");237 alert("A hora de inÃcio deve ser números."); 238 238 button.disabled = false; 239 239 return false; … … 243 243 document.getElementById('end_hour').value = ''; 244 244 document.getElementById('end_hour').focus(); 245 alert("A hora do t érmino deve ser números.");245 alert("A hora do término deve ser números."); 246 246 button.disabled = false; 247 247 return false; … … 251 251 document.getElementById('end_minute').value = ''; 252 252 document.getElementById('end_minute').focus(); 253 alert("A hora do t érmino deve ser números.");253 alert("A hora do término deve ser números."); 254 254 button.disabled = false; 255 255 return false; … … 265 265 document.getElementById('end_minute').value = ''; 266 266 document.getElementById('start_hour').focus(); 267 alert("A hora final n ão pode ser menor que a hora inicial.");267 alert("A hora final não pode ser menor que a hora inicial."); 268 268 button.disabled = false; 269 269 return false; … … 276 276 document.getElementById('end_minute').value = ''; 277 277 document.getElementById('start_hour').focus(); 278 alert("A hora final n ão pode ser menor que a hora inicial.");278 alert("A hora final não pode ser menor que a hora inicial."); 279 279 button.disabled = false; 280 280 return false; … … 318 318 } 319 319 320 321 function controlInputBinds(){ 322 var div = $('#tbl_ext_participants').find('textarea'); 323 div.bind('keydown',function(e){ 324 //SELECIONA O CONTATO E EVITA OUTROS COMANDOS 325 if ( e.keyCode === $.ui.keyCode.TAB && $( this ).data( "catcomplete" ).menu.active ) { 326 e.preventDefault(); 327 return false; 328 } 329 330 //FECHA OS CONTATOS DINï¿œMICOS 331 if( (e.keyCode == 27) && $( this ).data( "catcomplete" ).menu.active ){ 332 e.stopPropagation(); 333 e.preventDefault(); 334 } 335 336 //SELECIONA O CONTATO E EVITA OUTROS COMANDOS 337 if(e.keyCode == $.ui.keyCode.ENTER && $( this ).data( "catcomplete" ).menu.active){ 338 e.preventDefault(); 339 return false; 340 } 341 //BUSCA COM A TECLA F9 342 if((e.keyCode) == 120){ 343 344 e.preventDefault(); 345 return false; 346 } 347 }); 348 } 349 350 var cache = new Array(); 351 var dynamicPersonalContacts = new Array(); 352 var dynamicContacts = new Array(); 353 var topContact = 0; 354 355 function split( val ) { 356 return val.split( /,\s*/ ); 357 } 358 359 function extractLast( term ) { 360 return split( term ).pop(); 361 } 362 363 function updateDynamicContact(){ 364 dynamicContacts = new Array(); 365 var dynamicData = REST.get("/dynamiccontacts").collection.itens; 366 if(dynamicData){ 367 $.each(dynamicData, function(index, value){ 368 if(index ==0){ 369 topContact = parseInt(value.data[2].value); 370 } 371 var dynamic = { 372 name : value.data[0].value, 373 mail : value.data[1].value, 374 value: value.data[0].value + " - " + value.data[1].value, 375 type: "", 376 id: parseInt(value.data[3].value), 377 qtd : parseInt(value.data[2].value) 378 }; 379 dynamicContacts.push(dynamic); 380 }); 381 } 382 } 383 384 385 function updateDynamicPersonalContacts(){ 386 dynamicPersonalContacts = new Array(); 387 var contactsData = REST.get("/contacts").collection.itens; 388 if(contactsData){ 389 $.each(contactsData, function(index, value){ 390 var contact = { 391 id : parseInt(value.data[0].value), 392 name : value.data[1].value, 393 email : value.data[2].value, 394 value: value.data[1].value + " - " + value.data[2].value, 395 type: "P" 396 }; 397 dynamicPersonalContacts.push(contact); 398 }); 399 } 400 } 401 402 /*Adiciona um novo contato selecionado*/ 403 function update_mailField(email){ 404 var mailList = $('#tbl_ext_participants').find('textarea'); 405 var newList = ""; 406 if (mailList.val().indexOf(email) != -1){ 407 $.Zebra_Dialog('O email <b>'+ email +'</b> já consta na lista!'); 408 } 409 if (mailList.val().indexOf(',') > 0){ 410 var ctcList = mailList.val().split(','); 411 for(var ii=0; ii<ctcList.length - 1;ii++){ 412 newList += ctcList[ii] + ","; 413 } 414 newList += email + ","; 415 } 416 else{ 417 newList += email+","; 418 } 419 mailList.val(newList); 420 } 421 320 422 function showExParticipants(el,path){ 423 updateDynamicContact(); 424 updateDynamicPersonalContacts(); 425 REST.load(""); 426 controlInputBinds(); 321 427 Element('tbl_ext_participants').style.display=''; 322 428 el.style.display='none'; 323 loadScript(path+"/js/common_functions.js"); 324 get_lang = function( key ){ 325 var translator = Element( "txt_" + key.replace(/ /g, "_") ); 326 if (translator == null) 327 return "Failed translating string."; 328 var value = translator.value; 329 if(arguments.length > 1) { 330 for(j = 1; typeof(arguments[j]) != 'undefined'; j++) 331 value = value.replace("%"+j,arguments[j]); 332 } 333 return value; 334 }; 335 loadScript(path+"/js/DropDownContacts.js"); 336 loadScript(path+"/js/QuickCatalogSearch.js"); 337 loadScript("calendar/templates/default/js/over_fn_exmail.js"); 338 if(!contacts) 339 cExecute (path+'.db_functions.get_dropdown_contacts', save_contacts); 340 } 429 $.widget( "custom.catcomplete", $.ui.autocomplete, { 430 _renderMenu: function( ul, items ) { 431 var self = this, 432 currentType = ""; 433 $.each( items, function( index, item ) { 434 if ( item.typel != currentType) { 435 if(item.typel == "/groups" && $(ul).find(".dynamic-recent").length) 436 self._renderItem( ul, {name:"", value:"", type:"linha"} ); 437 if(item.typel == "/contacts" && ($(ul).find(".dynamic-group").length || $(ul).find(".dynamic-recent").length)) 438 self._renderItem( ul, {name:"", value:"", type:"linha"} ); 439 currentType = item.typel; 440 } 441 self._renderItem( ul, item ); 442 $(ul).find("li:last").find(".dynamic-stars").raty({ 443 readOnly : true, 444 half : true, 445 hints : ['','','','',''], 446 score : ((item.number_of_messages*5)/topContact) > 0.5 ? ((item.number_of_messages*5)/topContact) : 0.5, 447 starOn : '../prototype/plugins/jq-raty/img/star-on.png', 448 starOff : '../prototype/plugins/jq-raty/img/star-off.png', 449 starHalf : '../prototype/plugins/jq-raty/img/star-half.png' 450 }); 451 }); 452 453 if($(ul).find("li:last").hasClass("dynamic-separator")){ 454 $(ul).find("li:last").remove(); 455 } 456 $(ul).scroll(function(){ 457 canMakeBox = false; 458 }); 459 } 460 }); 461 $('#tbl_ext_participants').find('textarea').catcomplete({ 462 minLength: 1, 463 source: function(request, response){ 464 request.term = extractLast( request.term ); 465 if ( request.term in cache ) { 466 response( cache[ request.term ] ); 467 return; 468 } 469 dynamicContactsList = new Array(); 470 REST.get("/usercontacts", false, function(data){ 471 dynamicData = data.collection.itens; 472 if(dynamicData){ 473 $.each(dynamicData, function(index, value){ 474 dynamic = {}; 475 $.each(value.data, function(index, value){ 476 dynamic[value.name] = value.value; 477 }); 478 dynamic['value'] = (dynamic.name ? dynamic.name +' - ': '') + dynamic.mail; 479 dynamic['type'] = value.dataType; 480 dynamic['typel'] = (value.dataType.substring(0,7) == "/shared" ? "/"+value.dataType.substring(7,value.dataType.length)+"s" : value.dataType) ; 481 dynamicContactsList.push(dynamic); 482 }); 483 } 484 var data = $.ui.autocomplete.filter(dynamicContactsList, request.term ); 485 cache[ request.term ] = data; 486 response( data ); 487 }); 488 }, 489 focus: function() { 490 return false; 491 }, 492 493 //EVENTO AO SELECIONAR UM CONTATO DINï¿œMICO 494 select: function( event, ui ) { 495 event.preventDefault(); 496 update_mailField(ui.item.mail); 497 }, 498 position : { my: "left top", at: "left bottom", collision: "fit" } 499 }).bind('catcompleteopen', function(event, ui) { 500 $(this).data('is_open',true); 501 }).bind('catcompleteclose', function(event, ui) { 502 $(this).data('is_open',false); 503 }) 504 505 //MONTAGEM DA LISTA DE CONTATOS DINï¿œMICOS DO AUTO COMPLETE 506 .data( "catcomplete" )._renderItem = function( ul, item ) { 507 if($(ul).find("li").length < 50){ 508 var autocomplete = $(this)[0].element; 509 //cï¿œlculo dinï¿œmico da largura da lista 510 var width = (item.label ? item.label.length : (item.value ? item.value.length : (item.email ? item.email.length : 20 ))); 511 width = width*5 + (is_ie ? 170 : 200) + 16; 512 if (width < $(ul).width()) 513 width = $(ul).width(); 514 ul.css({"min-width":width,"max-width":$('#tbl_ext_participants').find('textarea').width(),"max-height" : "180px", "overflow-y" : "auto", "min-height": "30px"}); 515 var listContacts = DataLayer.render("calendar/templates/default/listContacts.ejs", item); 516 return $(listContacts).data( "item.autocomplete", item ).appendTo( ul ).find("span:last").button({ 517 icons : { 518 primary : "ui-icon-close" 519 }, 520 text: false 521 }).click(function(event){ 522 var removeLi = $(this).parents("li:first"); 523 if(!event.keyCode) 524 autocomplete.catcomplete( "close" ); 525 canMakeBox = false; 526 $.Zebra_Dialog('Deseja remover <b>'+(item.name ? item.name+" - " : "")+ item.mail+'</b>?', { 527 'type': 'question', 528 'custom_class': (is_ie ? 'configure-zebra-dialog' : ''), 529 'title': 'Atenção', 530 'buttons': ['Sim','Não'], 531 'overlay_opacity': '0.5', 532 'onClose': function(caption) { 533 if(caption == 'Sim'){ 534 $(removeLi).remove(); 535 REST['delete']("/dynamiccontact/"+item.id); 536 updateDynamicContact(); 537 cache = new Array(); 538 }else if(caption == 'Não'){ 539 $(focusIn).focus(); 540 } 541 } 542 }); 543 }); 544 } 545 return; 546 }; 547 } 341 548 342 549 function hideExParticipants(el,path){ … … 397 604 function fixBugInnerSelect(objeto,innerHTML){ 398 605 /****** 399 * select_innerHTML - altera o innerHTML de um select independente se éFF ou IE400 * Corrige o problema de n ão ser possível usar o innerHTML no IE corretamente606 * select_innerHTML - altera o innerHTML de um select independente se é FF ou IE 607 * Corrige o problema de não ser possÃvel usar o innerHTML no IE corretamente 401 608 * Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228 402 * Use a vontade mas coloque meu nome nos cr éditos. Dúvidas, me mande um email.403 * Vers ão: 1.0 - 06/04/2006404 * Autor: Micox - N áiron José C. Guimarães - micoxjcg@yahoo.com.br609 * Use a vontade mas coloque meu nome nos créditos. Dúvidas, me mande um email. 610 * Versão: 1.0 - 06/04/2006 611 * Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br 405 612 * Parametros: 406 613 * objeto(tipo object): o select a ser alterado … … 414 621 selTemp = document.getElementById("micoxselect1") 415 622 selTemp.style.display="none" 416 if(innerHTML.toLowerCase().indexOf("<option")<0){//se n ão éoption eu converto623 if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto 417 624 innerHTML = "<option>" + innerHTML + "</option>" 418 625 }
Note: See TracChangeset
for help on using the changeset viewer.