Changeset 7437 for trunk/calendar/templates/default
- Timestamp:
- 10/17/12 17:40:10 (12 years ago)
- Location:
- trunk/calendar/templates/default
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/calendar/templates/default/app.css
r5132 r7437 289 289 font-style: italic; 290 290 } 291 292 div.line-separator{ 293 background: url("../../../expressoMail1_2/templates/default/images/linha.png") repeat-x scroll 0 8px transparent; 294 clear: both; 295 } -
trunk/calendar/templates/default/js/edit_exmail.js
r7336 r7437 323 323 div.bind('keydown',function(e){ 324 324 //SELECIONA O CONTATO E EVITA OUTROS COMANDOS 325 if ( e.keyCode === $.ui.keyCode.TAB && $( this ).data( " catcomplete" ).menu.active ) {325 if ( e.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) { 326 326 e.preventDefault(); 327 327 return false; … … 329 329 330 330 //FECHA OS CONTATOS DINÂMICOS 331 if( (e.keyCode == 27) && $( this ).data( " catcomplete" ).menu.active ){331 if( (e.keyCode == 27) && $( this ).data( "autocomplete" ).menu.active ){ 332 332 e.stopPropagation(); 333 333 e.preventDefault(); … … 335 335 336 336 //SELECIONA O CONTATO E EVITA OUTROS COMANDOS 337 if(e.keyCode == $.ui.keyCode.ENTER && $( this ).data( " catcomplete" ).menu.active){337 if(e.keyCode == $.ui.keyCode.ENTER && $( this ).data( "autocomplete" ).menu.active){ 338 338 e.preventDefault(); 339 339 return false; … … 361 361 } 362 362 363 function updateDynamicContact(){ 364 dynamicContacts = new Array(); 365 var dynamicUsers = REST.get("/dynamiccontacts"); 366 if(dynamicUsers.collection && !dynamicUsers.collection.error){ 367 var dynamicData = normalizeContacts(dynamicUsers.collection.itens) 368 369 $.each(dynamicData, function(index, value){ 370 if(index ==0){ 371 topContact = parseInt(value['number_of_messages']); 372 } 373 var dynamic = { 374 name : value.name, 375 mail : value.mail, 376 value: value.name + " - " + value.mail, 377 type: "", 378 id: value.id, 379 qtd : value['number_of_messages'] 380 }; 381 dynamicContacts.push(dynamic); 382 }); 383 } 363 function updateDynamicContact(userContacts){ 364 if(!userContacts) 365 userContacts = REST.get("/usercontacts", false); 366 367 if(userContacts.collection && !userContacts.collection.error){ 368 dynamicData = normalizeContacts(userContacts.collection.itens); 369 }else{ 370 dynamicData = []; 371 } 372 373 if(dynamicData){ 374 var dynamicContactsList = []; 375 $.each(dynamicData, function(index, dynamic){ 376 377 var dataType = userContacts.collection.itens[index].dataType; 378 379 dynamic['value'] = (dynamic.name ? dynamic.name +' - ': '') + dynamic.mail; 380 dynamic['type'] = dataType 381 dynamic['typel'] = (dataType.substring(0,7) == "/shared" ? "/"+dataType.substring(7,dataType.length)+"s" : dataType) ; 382 dynamicContactsList.push(dynamic); 383 }); 384 } 385 386 dynamicData = dynamicContactsList; 384 387 } 385 388 … … 469 472 470 473 function showExParticipants(el,path){ 471 updateDynamicContact(); 472 updateDynamicPersonalContacts(); 473 REST.load(""); 474 //updateDynamicPersonalContacts(); 475 //REST.load(""); 474 476 controlInputBinds(); 475 477 Element('tbl_ext_participants').style.display=''; 476 478 el.style.display='none'; 477 $.widget( "custom.catcomplete", $.ui.autocomplete, { 478 _renderMenu: function( ul, items ) { 479 var self = this, 480 currentType = ""; 481 $.each( items, function( index, item ) { 482 if ( item.typel != currentType) { 483 if(item.typel == "/groups" && $(ul).find(".dynamic-recent").length) 484 self._renderItem( ul, {name:"", value:"", type:"linha"} ); 485 if(item.typel == "/contacts" && ($(ul).find(".dynamic-group").length || $(ul).find(".dynamic-recent").length)) 486 self._renderItem( ul, {name:"", value:"", type:"linha"} ); 487 currentType = item.typel; 488 } 489 self._renderItem( ul, item ); 490 $(ul).find("li:last").find(".dynamic-stars").raty({ 491 readOnly : true, 492 half : true, 493 hints : ['','','','',''], 494 score : ((item.number_of_messages*5)/topContact) > 0.5 ? ((item.number_of_messages*5)/topContact) : 0.5, 495 starOn : '../prototype/plugins/jq-raty/img/star-on.png', 496 starOff : '../prototype/plugins/jq-raty/img/star-off.png', 497 starHalf : '../prototype/plugins/jq-raty/img/star-half.png' 498 }); 499 }); 500 501 if($(ul).find("li:last").hasClass("dynamic-separator")){ 502 $(ul).find("li:last").remove(); 503 } 504 $(ul).scroll(function(){ 505 canMakeBox = false; 506 }); 507 } 508 }); 509 $('#tbl_ext_participants').find('textarea').catcomplete({ 510 minLength: 1, 511 source: function(request, response){ 512 request.term = extractLast( request.term ); 513 if ( request.term in cache ) { 514 response( cache[ request.term ] ); 515 return; 516 } 517 dynamicContactsList = new Array(); 518 REST.get("/usercontacts", false, function(data){ 519 dynamicData = data.collection.itens; 520 if(dynamicData){ 521 $.each(dynamicData, function(index, value){ 522 dynamic = {}; 523 $.each(value.data, function(index, value){ 524 dynamic[value.name] = value.value; 525 }); 526 dynamic['value'] = (dynamic.name ? dynamic.name +' - ': '') + dynamic.mail; 527 dynamic['type'] = value.dataType; 528 dynamic['typel'] = (value.dataType.substring(0,7) == "/shared" ? "/"+value.dataType.substring(7,value.dataType.length)+"s" : value.dataType) ; 529 dynamicContactsList.push(dynamic); 530 }); 531 } 532 var data = $.ui.autocomplete.filter(dynamicContactsList, request.term ); 533 cache[ request.term ] = data; 534 response( data ); 535 }); 536 }, 537 focus: function() { 538 return false; 539 }, 540 541 //EVENTO AO SELECIONAR UM CONTATO DINÂMICO 542 select: function( event, ui ) { 543 event.preventDefault(); 544 update_mailField((ui.item.name ? ui.item.name : ""),ui.item.mail); 545 }, 546 position : { my: "left top", at: "left bottom", collision: "fit" } 547 }).bind('catcompleteopen', function(event, ui) { 548 $(this).data('is_open',true); 549 }).bind('catcompleteclose', function(event, ui) { 550 $(this).data('is_open',false); 551 }) 552 553 //MONTAGEM DA LISTA DE CONTATOS DINÂMICOS DO AUTO COMPLETE 554 .data( "catcomplete" )._renderItem = function( ul, item ) { 555 if($(ul).find("li").length < 50){ 556 var autocomplete = $(this)[0].element; 557 //cálculo dinâmico da largura da lista 558 var width = (item.label ? item.label.length : (item.value ? item.value.length : (item.email ? item.email.length : 20 ))); 559 width = width*5 + (is_ie ? 170 : 200) + 16; 560 if (width < $(ul).width()) 561 width = $(ul).width(); 562 ul.css({"min-width":width,"max-width":$('#tbl_ext_participants').find('textarea').width(),"max-height" : "180px", "overflow-y" : "auto", "min-height": "30px"}); 563 var listContacts = DataLayer.render("calendar/templates/default/listContacts.ejs", item); 564 return $(listContacts).data( "item.autocomplete", item ).appendTo( ul ).find("span:last").button({ 565 icons : { 566 primary : "ui-icon-close" 567 }, 568 text: false 569 }).click(function(event){ 570 var removeLi = $(this).parents("li:first"); 571 if(!event.keyCode) 572 autocomplete.catcomplete( "close" ); 573 canMakeBox = false; 574 $.Zebra_Dialog('Deseja remover <b>'+(item.name ? item.name+" - " : "")+ item.mail+'</b>?', { 575 'type': 'question', 576 'custom_class': (is_ie ? 'configure-zebra-dialog' : ''), 577 'title': 'Atenção', 578 'buttons': ['Sim','Não'], 579 'overlay_opacity': '0.5', 580 'onClose': function(caption) { 581 if(caption == 'Sim'){ 582 $(removeLi).remove(); 583 REST['delete']("/dynamiccontact/"+item.id); 584 updateDynamicContact(); 585 cache = new Array(); 586 }else if(caption == 'Não'){ 587 $(focusIn).focus(); 588 } 589 } 590 }); 591 }); 592 } 593 return; 594 }; 595 } 479 480 //PREPARAÇÃO DA ARRAY DOS CONTATOS DINÂMICOS 481 482 var decodeType = { 483 '/dynamiccontacts': { 484 css: 'recent', 485 img: 'recent', 486 text: 'Contato Recente' 487 }, 488 '/personalContact':{ 489 css: 'personal', 490 img: 'personal', 491 text: 'Contato pessoal' 492 }, 493 '/sharedcontact':{ 494 css: 'personal', 495 img: 'sharedcontact', 496 text: 'Contato compartilhado' 497 }, 498 '/groups':{ 499 css: 'group', 500 img: 'group', 501 text: 'Grupo pessoal' 502 }, 503 '/sharedgroup':{ 504 css: 'group', 505 img: 'sharedgroup', 506 text: 'Grupo compartilhado' 507 } 508 } 509 510 $('#tbl_ext_participants').find('textarea').autocomplete({ 511 source: function(request, response){ 512 if ( request.term in cache ) { 513 response( cache[ request.term ] ); 514 return; 515 } 516 517 if(dynamicData === false){ 518 updateDynamicContact(); 519 } 520 521 var data = $.ui.autocomplete.filter(dynamicData, extractLast( request.term ) ).slice(0, 50); 522 cache[ request.term ] = data; 523 response( data ); 524 }, 525 focus: function() { 526 return false; 527 }, 528 529 //EVENTO AO SELECIONAR UM CONTATO DINÂMICO 530 select: function( event, ui ) { 531 event.preventDefault(); 532 update_mailField((ui.item.name ? ui.item.name : ""),ui.item.mail); 533 }, 534 autoFocus: true, 535 position : { my: "left top", at: "left bottom", collision: "fit" }, 536 delay : 120, 537 minLength: 0 538 }).bind('autocompleteopen', function(event, ui) { 539 540 $(this).data('is_open',true); 541 542 }).bind('autocompleteclose', function(event, ui) { 543 544 canMakeBox = true; 545 $(this).data('is_open',false); 546 547 }).data( "autocomplete" )._renderItem = function( ul, item ) { 548 549 if(item.typel == "/groups") 550 return true; 551 552 var autocomplete = $(this)[0].element; 553 554 //cálculo dinâmico da largura da lista 555 var width = (item.label ? item.label.length : (item.value ? item.value.length : (item.mail ? item.mail.length : 20 ))); 556 width = width*5 + (is_ie ? 170 : 200) + 16; 557 558 width = (width < $(ul).width()) ? $(ul).width() : width; 559 560 ul.css({"min-width":width,"max-width":$('#tbl_ext_participants').find('textarea').width(),"max-height" : "180px", "overflow-y" : "auto", "min-height": "30px"}); 561 562 item.raty = ((item.number_of_messages*10)/topContact) > 1 ? ((item.number_of_messages*10)/topContact) : 1; 563 564 if ( item.typel != currentTypeContact) { 565 if((item.typel == "/groups" && $(ul).find(".dynamic-recent").length) || (item.typel == "/personalContact" && ($(ul).find(".dynamic-group").length || $(ul).find(".dynamic-recent").length))){ 566 currentTypeContact = item.typel; 567 item.asDiv = true; 568 }else{ 569 currentTypeContact = item.typel; 570 } 571 } 572 573 var li = ''; 574 if(item.asDiv){ 575 li = '<li class="dynamic-separator"><div class="line-separator"> </div></li>'; 576 } 577 li += '<li class="dynamic-'+ decodeType[item.type].css +'">'; 578 li += '<a style="width:'+(item.type == '/dynamiccontacts' ? '91%' : '97.5%')+'; display: inline-block; background: none;">'; 579 li += '<img style="position:relative; top:2px; "src="prototype/modules/mail/img/'+ decodeType[item.type].img +'.png" title="'+ decodeType[item.type].text +'"/>'; 580 li += ($.trim(item.name) != "" ? ((item.name.length > 20 ? item.name.substring(0,17)+"..." : item.name) + " - " ) : '') + item.mail; 581 li += item.type == '/dynamiccontacts' ? '<div class="dynamic-stars" style="display: inline-block;float: right;" id="'+item.raty+'_'+item.id+'"/>' : '' 582 li += '</a>'; 583 li += '<span style="width:16px; height:16px; top:1px; left:7px; '+ (item.type == '/dynamiccontacts' ? '': 'display:none') +'">Excluir contato recente</span>'; 584 li += '</li>'; 585 586 587 li = $( li ) 588 .data( "item.autocomplete", item ) 589 //.append( li ) 590 .appendTo( ul ); 591 592 li.find("span").button({ 593 icons : { 594 primary : "ui-icon-close" 595 }, 596 text: false 597 }).click(function(event){ 598 if(!event.keyCode) 599 autocomplete.autocomplete( "close" ); 600 601 canMakeBox = false; 602 $.Zebra_Dialog('Deseja remover <b>'+(item.name ? (item.name.length <= 30 ? item.name: item.name.substr(0,27)+"...")+" - " : "")+ item.mail+'</b>?', { 603 'type': 'question', 604 'custom_class': (is_ie ? 'configure-zebra-dialog' : ''), 605 'buttons': ['Sim','Não'], 606 'overlay_opacity': '0.5', 607 'onClose': function(caption) { 608 if(caption == 'Sim'){ 609 610 REST['delete']("/dynamiccontact/"+item.id); 611 updateDynamicContact(); 612 cache = new Array(); 613 }else if(caption == 'Não'){ 614 $(focusIn).focus(); 615 } 616 } 617 }); 618 }); 619 620 li.find(".dynamic-stars").jRating({ 621 step:true, 622 length : 5, // nb of stars 623 decimalLength: 2, // number of decimal in the rate 624 rateMax: 10, 625 isDisabled:true, 626 bigStarsPath : 'prototype/plugins/jquery.jrating/icons/stars.png', // path of the icon stars.png 627 smallStarsPath : 'prototype/plugins/jquery.jrating/icons/small.png' // path of the icon small.png 628 }); 629 630 if($(ul).find("li:last").hasClass("dynamic-separator")){ 631 $(ul).find("li:last").remove(); 632 } 633 634 $(ul).scroll(function(){ 635 canMakeBox = false; 636 }); 637 638 return li; 639 }; 640 } 596 641 597 642 function hideExParticipants(el,path){
Note: See TracChangeset
for help on using the changeset viewer.