Index: /branches/2.4/index.php
===================================================================
--- /branches/2.4/index.php (revision 7191)
+++ /branches/2.4/index.php (revision 7444)
@@ -153,6 +153,5 @@
-
-
+
@@ -161,6 +160,10 @@
';
- if($modulo[0] == 'calendar')
- echo '';
+ if($modulo[0] == 'calendar'){
+ echo '
+
+
+ ';
+ }
}
}
Index: /branches/2.4/calendar/templates/default/app.css
===================================================================
--- /branches/2.4/calendar/templates/default/app.css (revision 5132)
+++ /branches/2.4/calendar/templates/default/app.css (revision 7444)
@@ -289,2 +289,7 @@
font-style: italic;
}
+
+div.line-separator{
+ background: url("../../../expressoMail1_2/templates/default/images/linha.png") repeat-x scroll 0 8px transparent;
+ clear: both;
+}
Index: /branches/2.4/calendar/templates/default/js/edit_exmail.js
===================================================================
--- /branches/2.4/calendar/templates/default/js/edit_exmail.js (revision 7339)
+++ /branches/2.4/calendar/templates/default/js/edit_exmail.js (revision 7444)
@@ -322,5 +322,5 @@
div.bind('keydown',function(e){
//SELECIONA O CONTATO E EVITA OUTROS COMANDOS
- if ( e.keyCode === $.ui.keyCode.TAB && $( this ).data( "catcomplete" ).menu.active ) {
+ if ( e.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) {
e.preventDefault();
return false;
@@ -328,5 +328,5 @@
//FECHA OS CONTATOS DINÂMICOS
- if( (e.keyCode == 27) && $( this ).data( "catcomplete" ).menu.active ){
+ if( (e.keyCode == 27) && $( this ).data( "autocomplete" ).menu.active ){
e.stopPropagation();
e.preventDefault();
@@ -334,5 +334,5 @@
//SELECIONA O CONTATO E EVITA OUTROS COMANDOS
- if(e.keyCode == $.ui.keyCode.ENTER && $( this ).data( "catcomplete" ).menu.active){
+ if(e.keyCode == $.ui.keyCode.ENTER && $( this ).data( "autocomplete" ).menu.active){
e.preventDefault();
return false;
@@ -361,25 +361,28 @@
}
-function updateDynamicContact(){
- dynamicContacts = new Array();
- var dynamicUsers = REST.get("/dynamiccontacts");
- if(dynamicUsers.collection && !dynamicUsers.collection.error){
- var dynamicData = normalizeContacts(dynamicUsers.collection.itens)
-
- $.each(dynamicData, function(index, value){
- if(index ==0){
- topContact = parseInt(value['number_of_messages']);
- }
- var dynamic = {
- name : value.name,
- mail : value.mail,
- value: value.name + " - " + value.mail,
- type: "",
- id: value.id,
- qtd : value['number_of_messages']
- };
- dynamicContacts.push(dynamic);
- });
- }
+function updateDynamicContact(userContacts){
+ if(!userContacts)
+ userContacts = REST.get("/usercontacts", false);
+
+ if(userContacts.collection && !userContacts.collection.error){
+ dynamicData = normalizeContacts(userContacts.collection.itens);
+ }else{
+ dynamicData = [];
+ }
+
+ if(dynamicData){
+ var dynamicContactsList = [];
+ $.each(dynamicData, function(index, dynamic){
+
+ var dataType = userContacts.collection.itens[index].dataType;
+
+ dynamic['value'] = (dynamic.name ? dynamic.name +' - ': '') + dynamic.mail;
+ dynamic['type'] = dataType
+ dynamic['typel'] = (dataType.substring(0,7) == "/shared" ? "/"+dataType.substring(7,dataType.length)+"s" : dataType) ;
+ dynamicContactsList.push(dynamic);
+ });
+ }
+
+ dynamicData = dynamicContactsList;
}
@@ -469,129 +472,171 @@
function showExParticipants(el,path){
- updateDynamicContact();
- updateDynamicPersonalContacts();
- REST.load("");
+ //updateDynamicPersonalContacts();
+ //REST.load("");
controlInputBinds();
Element('tbl_ext_participants').style.display='';
el.style.display='none';
- $.widget( "custom.catcomplete", $.ui.autocomplete, {
- _renderMenu: function( ul, items ) {
- var self = this,
- currentType = "";
- $.each( items, function( index, item ) {
- if ( item.typel != currentType) {
- if(item.typel == "/groups" && $(ul).find(".dynamic-recent").length)
- self._renderItem( ul, {name:"", value:"", type:"linha"} );
- if(item.typel == "/contacts" && ($(ul).find(".dynamic-group").length || $(ul).find(".dynamic-recent").length))
- self._renderItem( ul, {name:"", value:"", type:"linha"} );
- currentType = item.typel;
- }
- self._renderItem( ul, item );
- $(ul).find("li:last").find(".dynamic-stars").raty({
- readOnly : true,
- half : true,
- hints : ['','','','',''],
- score : ((item.number_of_messages*5)/topContact) > 0.5 ? ((item.number_of_messages*5)/topContact) : 0.5,
- starOn : '../prototype/plugins/jq-raty/img/star-on.png',
- starOff : '../prototype/plugins/jq-raty/img/star-off.png',
- starHalf : '../prototype/plugins/jq-raty/img/star-half.png'
- });
- });
-
- if($(ul).find("li:last").hasClass("dynamic-separator")){
- $(ul).find("li:last").remove();
- }
- $(ul).scroll(function(){
- canMakeBox = false;
- });
- }
- });
- $('#tbl_ext_participants').find('textarea').catcomplete({
- minLength: 1,
- source: function(request, response){
- request.term = extractLast( request.term );
- if ( request.term in cache ) {
- response( cache[ request.term ] );
- return;
- }
- dynamicContactsList = new Array();
- REST.get("/usercontacts", false, function(data){
- dynamicData = data.collection.itens;
- if(dynamicData){
- $.each(dynamicData, function(index, value){
- dynamic = {};
- $.each(value.data, function(index, value){
- dynamic[value.name] = value.value;
- });
- dynamic['value'] = (dynamic.name ? dynamic.name +' - ': '') + dynamic.mail;
- dynamic['type'] = value.dataType;
- dynamic['typel'] = (value.dataType.substring(0,7) == "/shared" ? "/"+value.dataType.substring(7,value.dataType.length)+"s" : value.dataType) ;
- dynamicContactsList.push(dynamic);
- });
- }
- var data = $.ui.autocomplete.filter(dynamicContactsList, request.term );
- cache[ request.term ] = data;
- response( data );
- });
- },
- focus: function() {
- return false;
- },
-
- //EVENTO AO SELECIONAR UM CONTATO DINÂMICO
- select: function( event, ui ) {
- event.preventDefault();
- update_mailField((ui.item.name ? ui.item.name : ""),ui.item.mail);
- },
- position : { my: "left top", at: "left bottom", collision: "fit" }
- }).bind('catcompleteopen', function(event, ui) {
- $(this).data('is_open',true);
- }).bind('catcompleteclose', function(event, ui) {
- $(this).data('is_open',false);
- })
-
- //MONTAGEM DA LISTA DE CONTATOS DINÂMICOS DO AUTO COMPLETE
- .data( "catcomplete" )._renderItem = function( ul, item ) {
- if($(ul).find("li").length < 50){
- var autocomplete = $(this)[0].element;
- //cálculo dinâmico da largura da lista
- var width = (item.label ? item.label.length : (item.value ? item.value.length : (item.email ? item.email.length : 20 )));
- width = width*5 + (is_ie ? 170 : 200) + 16;
- if (width < $(ul).width())
- width = $(ul).width();
- ul.css({"min-width":width,"max-width":$('#tbl_ext_participants').find('textarea').width(),"max-height" : "180px", "overflow-y" : "auto", "min-height": "30px"});
- var listContacts = DataLayer.render("calendar/templates/default/listContacts.ejs", item);
- return $(listContacts).data( "item.autocomplete", item ).appendTo( ul ).find("span:last").button({
- icons : {
- primary : "ui-icon-close"
- },
- text: false
- }).click(function(event){
- var removeLi = $(this).parents("li:first");
- if(!event.keyCode)
- autocomplete.catcomplete( "close" );
- canMakeBox = false;
- $.Zebra_Dialog('Deseja remover '+(item.name ? item.name+" - " : "")+ item.mail+'?', {
- 'type': 'question',
- 'custom_class': (is_ie ? 'configure-zebra-dialog' : ''),
- 'title': 'Atenção',
- 'buttons': ['Sim','Não'],
- 'overlay_opacity': '0.5',
- 'onClose': function(caption) {
- if(caption == 'Sim'){
- $(removeLi).remove();
- REST['delete']("/dynamiccontact/"+item.id);
- updateDynamicContact();
- cache = new Array();
- }else if(caption == 'Não'){
- $(focusIn).focus();
- }
- }
- });
- });
- }
- return;
- };
- }
+
+ //PREPARAÇÃO DA ARRAY DOS CONTATOS DINÂMICOS
+
+ var decodeType = {
+ '/dynamiccontacts': {
+ css: 'recent',
+ img: 'recent',
+ text: 'Contato Recente'
+ },
+ '/personalContact':{
+ css: 'personal',
+ img: 'personal',
+ text: 'Contato pessoal'
+ },
+ '/sharedcontact':{
+ css: 'personal',
+ img: 'sharedcontact',
+ text: 'Contato compartilhado'
+ },
+ '/groups':{
+ css: 'group',
+ img: 'group',
+ text: 'Grupo pessoal'
+ },
+ '/sharedgroup':{
+ css: 'group',
+ img: 'sharedgroup',
+ text: 'Grupo compartilhado'
+ }
+ }
+
+ $('#tbl_ext_participants').find('textarea').autocomplete({
+ source: function(request, response){
+ if ( request.term in cache ) {
+ response( cache[ request.term ] );
+ return;
+ }
+
+ if(dynamicData === false){
+ updateDynamicContact();
+ }
+
+ var data = $.ui.autocomplete.filter(dynamicData, extractLast( request.term ) ).slice(0, 50);
+ cache[ request.term ] = data;
+ response( data );
+ },
+ focus: function() {
+ return false;
+ },
+
+ //EVENTO AO SELECIONAR UM CONTATO DINÂMICO
+ select: function( event, ui ) {
+ event.preventDefault();
+ update_mailField((ui.item.name ? ui.item.name : ""),ui.item.mail);
+ },
+ autoFocus: true,
+ position : { my: "left top", at: "left bottom", collision: "fit" },
+ delay : 120,
+ minLength: 0
+ }).bind('autocompleteopen', function(event, ui) {
+
+ $(this).data('is_open',true);
+
+ }).bind('autocompleteclose', function(event, ui) {
+
+ canMakeBox = true;
+ $(this).data('is_open',false);
+
+ }).data( "autocomplete" )._renderItem = function( ul, item ) {
+
+ if(item.typel == "/groups")
+ return true;
+
+ var autocomplete = $(this)[0].element;
+
+ //cálculo dinâmico da largura da lista
+ var width = (item.label ? item.label.length : (item.value ? item.value.length : (item.mail ? item.mail.length : 20 )));
+ width = width*5 + (is_ie ? 170 : 200) + 16;
+
+ width = (width < $(ul).width()) ? $(ul).width() : width;
+
+ ul.css({"min-width":width,"max-width":$('#tbl_ext_participants').find('textarea').width(),"max-height" : "180px", "overflow-y" : "auto", "min-height": "30px"});
+
+ item.raty = ((item.number_of_messages*10)/topContact) > 1 ? ((item.number_of_messages*10)/topContact) : 1;
+
+ if ( item.typel != currentTypeContact) {
+ if((item.typel == "/groups" && $(ul).find(".dynamic-recent").length) || (item.typel == "/personalContact" && ($(ul).find(".dynamic-group").length || $(ul).find(".dynamic-recent").length))){
+ currentTypeContact = item.typel;
+ item.asDiv = true;
+ }else{
+ currentTypeContact = item.typel;
+ }
+ }
+
+ var li = '';
+ if(item.asDiv){
+ li = '
';
+ }
+ li += '';
+ li += '';
+ li += '';
+ li += ($.trim(item.name) != "" ? ((item.name.length > 20 ? item.name.substring(0,17)+"..." : item.name) + " - " ) : '') + item.mail;
+ li += item.type == '/dynamiccontacts' ? '' : ''
+ li += '';
+ li += 'Excluir contato recente';
+ li += '';
+
+
+ li = $( li )
+ .data( "item.autocomplete", item )
+ //.append( li )
+ .appendTo( ul );
+
+ li.find("span").button({
+ icons : {
+ primary : "ui-icon-close"
+ },
+ text: false
+ }).click(function(event){
+ if(!event.keyCode)
+ autocomplete.autocomplete( "close" );
+
+ canMakeBox = false;
+ $.Zebra_Dialog('Deseja remover '+(item.name ? (item.name.length <= 30 ? item.name: item.name.substr(0,27)+"...")+" - " : "")+ item.mail+'?', {
+ 'type': 'question',
+ 'custom_class': (is_ie ? 'configure-zebra-dialog' : ''),
+ 'buttons': ['Sim','Não'],
+ 'overlay_opacity': '0.5',
+ 'onClose': function(caption) {
+ if(caption == 'Sim'){
+
+ REST['delete']("/dynamiccontact/"+item.id);
+ updateDynamicContact();
+ cache = new Array();
+ }else if(caption == 'Não'){
+ $(focusIn).focus();
+ }
+ }
+ });
+ });
+
+ li.find(".dynamic-stars").jRating({
+ step:true,
+ length : 5, // nb of stars
+ decimalLength: 2, // number of decimal in the rate
+ rateMax: 10,
+ isDisabled:true,
+ bigStarsPath : 'prototype/plugins/jquery.jrating/icons/stars.png', // path of the icon stars.png
+ smallStarsPath : 'prototype/plugins/jquery.jrating/icons/small.png' // path of the icon small.png
+ });
+
+ if($(ul).find("li:last").hasClass("dynamic-separator")){
+ $(ul).find("li:last").remove();
+ }
+
+ $(ul).scroll(function(){
+ canMakeBox = false;
+ });
+
+ return li;
+ };
+}
function hideExParticipants(el,path){
Index: /branches/2.4/expressoMail1_2/index.php
===================================================================
--- /branches/2.4/expressoMail1_2/index.php (revision 7228)
+++ /branches/2.4/expressoMail1_2/index.php (revision 7444)
@@ -32,5 +32,6 @@
-
+
+
@@ -66,5 +67,6 @@
-
+
+
Index: /branches/2.4/expressoMail1_2/js/main.js
===================================================================
--- /branches/2.4/expressoMail1_2/js/main.js (revision 7396)
+++ /branches/2.4/expressoMail1_2/js/main.js (revision 7444)
@@ -31,6 +31,35 @@
}
-function updateDynamicContact(){
- dynamicContacts = new Array();
+function updateDynamicContact(userContacts){
+
+ if(!userContacts)
+ userContacts = REST.get("/usercontacts", false);
+
+ if(userContacts.collection && !userContacts.collection.error){
+ dynamicData = normalizeContacts(userContacts.collection.itens);
+ }else{
+ dynamicData = [];
+ }
+
+ if(dynamicData){
+ var dynamicContactsList = [];
+ $.each(dynamicData, function(index, dynamic){
+
+ var dataType = userContacts.collection.itens[index].dataType;
+
+ dynamic['value'] = (dynamic.name ? dynamic.name +' - ': '') + dynamic.mail;
+ dynamic['type'] = dataType
+ dynamic['typel'] = (dataType.substring(0,7) == "/shared" ? "/"+dataType.substring(7,dataType.length)+"s" : dataType);
+
+ topContact = dynamic.number_of_messages > topContact ? dynamic.number_of_messages : topContact;
+
+ dynamicContactsList.push(dynamic);
+ });
+ }
+
+ dynamicData = dynamicContactsList;
+
+
+ /*dynamicContacts = new Array();
var dynamicUsers = REST.get("/dynamiccontacts");
@@ -53,5 +82,5 @@
dynamicContacts.push(dynamic);
});
- }
+ }*/
}
@@ -2754,5 +2783,5 @@
if(!stop){
var exist = 0;
- $.each(dynamicContacts, function(x, valuex){
+ $.each(dynamicData, function(x, valuex){
if(valuex.mail == $(value).find("input").val().match(reComplexEmail)[1]){
exist = valuex.id;
Index: /branches/2.4/expressoMail1_2/js/draw_api.js
===================================================================
--- /branches/2.4/expressoMail1_2/js/draw_api.js (revision 7380)
+++ /branches/2.4/expressoMail1_2/js/draw_api.js (revision 7444)
@@ -3886,5 +3886,5 @@
if(parseInt(preferences.use_dynamic_contacts) && !input.hasClass("box-input")){
//SELECIONA O CONTATO E EVITA OUTROS COMANDOS
- if ( e.keyCode === $.ui.keyCode.TAB && $( this ).data( "catcomplete" ).menu.active ) {
+ if ( e.keyCode === $.ui.keyCode.TAB && $( this ).data( "autocomplete" ).menu.active ) {
e.preventDefault();
return false;
@@ -3892,5 +3892,5 @@
//FECHA OS CONTATOS DINÂMICOS
- if( (e.keyCode == 27) && $( this ).data( "catcomplete" ).menu.active ){
+ if( (e.keyCode == 27) && $( this ).data( "autocomplete" ).menu.active ){
e.stopPropagation();
e.preventDefault();
@@ -3898,12 +3898,12 @@
//SELECIONA O CONTATO E EVITA OUTROS COMANDOS
- if(e.keyCode == $.ui.keyCode.ENTER && $( this ).data( "catcomplete" ).menu.active){
+ if(e.keyCode == $.ui.keyCode.ENTER && $( this ).data( "autocomplete" ).menu.active){
e.preventDefault();
return false;
}
- if(e.keyCode == $.ui.keyCode.DELETE && $( this ).data( "catcomplete" ).menu.active){
- if($($( this ).data( "catcomplete" ).menu.element).find(".ui-state-hover").parents("li:first").hasClass("dynamic-recent"))
- $($( this ).data( "catcomplete" ).menu.element).find(".ui-state-hover").next().trigger("click");
+ if(e.keyCode == $.ui.keyCode.DELETE && $( this ).data( "autocomplete" ).menu.active){
+ if($($( this ).data( "autocomplete" ).menu.element).find(".ui-state-hover").parents("li:first").hasClass("dynamic-recent"))
+ $($( this ).data( "autocomplete" ).menu.element).find(".ui-state-hover").next().trigger("click");
return false;
}
@@ -4279,4 +4279,6 @@
}
+dynamicData = false;
+currentTypeContact = '';
//FUNÇÃO QUE "SETA" OS BINDS DOS CAMPOS PARA - CC - CCO
@@ -4324,136 +4326,183 @@
//VERIFICA PREFERENCIA DE CONTATOS DINÂMICOS ESTA ATIVA
if(parseInt(preferences.use_dynamic_contacts)){
+
+ REST.get("/usercontacts", false, updateDynamicContact);
+
//PREPARAÇÃO DA ARRAY DOS CONTATOS DINÂMICOS
- $.widget( "custom.catcomplete", $.ui.autocomplete, {
- _renderMenu: function( ul, items ) {
- var self = this,
- currentType = "";
- $.each( items, function( index, item ) {
- if ( item.typel != currentType) {
- if(item.typel == "/groups" && $(ul).find(".dynamic-recent").length)
- self._renderItem( ul, {name:"", value:"", type:"linha"} );
- if(item.typel == "/personalContact" && ($(ul).find(".dynamic-group").length || $(ul).find(".dynamic-recent").length))
- self._renderItem( ul, {name:"", value:"", type:"linha"} );
- currentType = item.typel;
- }
- self._renderItem( ul, item );
- $(ul).find("li:last").find(".dynamic-stars").raty({
- readOnly : true,
- half : true,
- hints : ['','','','',''],
- score : ((item.number_of_messages*5)/topContact) > 0.5 ? ((item.number_of_messages*5)/topContact) : 0.5,
- starOn : '../../prototype/plugins/jq-raty/img/star-on.png',
- starOff : '../../prototype/plugins/jq-raty/img/star-off.png',
- starHalf : '../../prototype/plugins/jq-raty/img/star-half.png'
- });
- });
- if($(ul).find("li:last").hasClass("dynamic-separator")){
- $(ul).find("li:last").remove();
- }
- $(ul).scroll(function(){
- canMakeBox = false;
- });
- }
- });
- //INSERÇÃO DO AUTO COMPLETE AO INPUT
- div.find("textarea").catcomplete({
- minLength: 1,
- source: function(request, response){
- if ( request.term in cache ) {
- response( cache[ request.term ] );
- return;
- }
- dynamicContactsList = new Array();
- REST.get("/usercontacts", false, function(data){
- dynamicData = data.collection.itens;
- if(dynamicData){
- $.each(dynamicData, function(index, value){
- dynamic = {};
- $.each(value.data, function(index, value){
- dynamic[value.name] = value.value;
- });
- dynamic['value'] = (dynamic.name ? dynamic.name +' - ': '') + dynamic.mail;
- dynamic['type'] = value.dataType;
- dynamic['typel'] = (value.dataType.substring(0,7) == "/shared" ? "/"+value.dataType.substring(7,value.dataType.length)+"s" : value.dataType) ;
- dynamicContactsList.push(dynamic);
- });
- }
- var data = $.ui.autocomplete.filter(dynamicContactsList, request.term );
- cache[ request.term ] = data;
- response( data );
- });
- },
- focus: function() {
- return false;
- },
-
- //EVENTO AO SELECIONAR UM CONTATO DINÂMICO
- select: function( event, ui ) {
- canMakeBox = false;
- event.preventDefault();
- $(this).val("");
- if(ui.item.typel == "/personalContact")
- draw_email_box(""+ui.item.id, $(this), true, (ui.item.type.substring(0,7) == "/shared" ? true : false));
- else if(ui.item.typel == "/groups")
- draw_email_box(""+ui.item.id, $(this), "G", (ui.item.type.substring(0,7) == "/shared" ? true : false));
- else
- draw_email_box(ui.item.name ? "\""+ui.item.name+"\" <"+ui.item.mail+">" : ui.item.mail, $(this));
- return false;
- },
- autoFocus: true,
- position : { my: "left top", at: "left bottom", collision: "fit" },
- delay : 400
- }).bind('catcompleteopen', function(event, ui) {
- $(this).data('is_open',true);
- }).bind('catcompleteclose', function(event, ui) {
- canMakeBox = true;
- $(this).data('is_open',false);
- })
-
- //MONTAGEM DA LISTA DE CONTATOS DINÂMICOS DO AUTO COMPLETE
- .data( "catcomplete" )._renderItem = function( ul, item ) {
- if($(ul).find("li").length < 50){
- var autocomplete = $(this)[0].element;
- //cálculo dinâmico da largura da lista
- var minwidth = 450;
- var width = (item.label ? item.label.length : (item.value ? item.value.length : (item.mail ? item.mail.length : 30 )));
- width = (is_ie ? width*2 : (is_webkit && !is_mozilla ? width*4 : width*5)) + 30;
- if (width < minwidth)
- width = minwidth;
- ul.css({"min-width":width,"max-height" : "180px", "overflow-y" : "auto", "min-height": "30px"});
- var listContacts = DataLayer.render("../prototype/modules/mail/templates/listContacts.ejs", item);
- return $(listContacts).data( "item.autocomplete", item ).appendTo( ul ).find("span:last").button({
- icons : {
- primary : "ui-icon-close"
- },
- text: false
- }).click(function(event){
- var removeLi = $(this).parents("li:first");
- if(!event.keyCode)
- autocomplete.catcomplete( "close" );
- canMakeBox = false;
- $.Zebra_Dialog('Deseja remover '+(item.name ? (item.name.length <=30 ? item.name: item.name.substr(0,27)+"...")+" - " : "")+ item.mail+'?', {
- 'type': 'question',
- 'custom_class': (is_ie ? 'configure-zebra-dialog' : ''),
- 'title': 'Atenção',
- 'buttons': ['Sim','Não'],
- 'overlay_opacity': '0.5',
- 'onClose': function(caption) {
- if(caption == 'Sim'){
- $(removeLi).remove();
- REST['delete']("/dynamiccontact/"+item.id);
- updateDynamicContact();
- cache = new Array();
- }else if(caption == 'Não'){
- $(focusIn).focus();
- }
- }
- });
- });
- }
- return;
- };
- }
+ var decodeType = {
+ '/dynamiccontacts': {
+ css: 'recent',
+ img: 'recent',
+ text: 'Contato Recente'
+ },
+ '/personalContact':{
+ css: 'personal',
+ img: 'personal',
+ text: 'Contato pessoal'
+ },
+ '/sharedcontact':{
+ css: 'personal',
+ img: 'sharedcontact',
+ text: 'Contato compartilhado'
+ },
+ '/groups':{
+ css: 'group',
+ img: 'group',
+ text: 'Grupo pessoal'
+ },
+ '/sharedgroup':{
+ css: 'group',
+ img: 'sharedgroup',
+ text: 'Grupo compartilhado'
+ }
+ }
+
+ div.find("textarea").autocomplete({
+ source: function(request, response){
+ if ( request.term in cache ) {
+ response( cache[ request.term ] );
+ return;
+ }
+
+ if(dynamicData === false){
+ updateDynamicContact();
+ }
+
+ var data = $.ui.autocomplete.filter(dynamicData, request.term ).slice(0, 50);
+ cache[ request.term ] = data;
+ response( data );
+
+ },
+ focus: function() {
+ return false;
+ },
+
+ //EVENTO AO SELECIONAR UM CONTATO DINÂMICO
+ select: function( event, ui ) {
+ canMakeBox = false;
+
+ event.preventDefault();
+ $(this).val("");
+
+ var isShared = (ui.item.type.substring(0,7) == "/shared");
+
+ switch (ui.item.typel){
+ case '/personalContact':
+ draw_email_box(""+ui.item.id, $(this), true, isShared);
+ break;
+ case '/groups':
+ draw_email_box(""+ui.item.id, $(this), "G", isShared);
+ break;
+ default:
+ draw_email_box(ui.item.name ? ("\""+ui.item.name+"\" <"+ui.item.mail+">") : ui.item.mail, $(this));
+ }
+
+ return false;
+ },
+ autoFocus: true,
+ position : { my: "left top", at: "left bottom", collision: "fit" },
+ delay : 120,
+ minLength: 0
+ }).bind('catcompleteopen', function(event, ui) {
+
+ $(this).data('is_open',true);
+
+ }).bind('catcompleteclose', function(event, ui) {
+
+ canMakeBox = true;
+ $(this).data('is_open',false);
+
+ }).data( "autocomplete" )._renderItem = function( ul, item ) {
+ var autocomplete = $(this)[0].element;
+
+ //cálculo dinâmico da largura da lista
+ var minwidth = 450;
+ var width = (item.label ? item.label.length : (item.value ? item.value.length : (item.mail ? item.mail.length : 30 )));
+ width = (is_ie ? width*2 : (is_webkit && !is_mozilla ? width*4 : width*5)) + 30;
+ if (width < minwidth)
+ width = minwidth;
+
+ ul.css({"min-width":width, "max-height" : "180px", "overflow-y" : "auto", "min-height": "30px"});
+
+ item.raty = ((item.number_of_messages*10)/topContact) > 1 ? ((item.number_of_messages*10)/topContact) : 1;
+
+ if ( item.typel != currentTypeContact) {
+ if((item.typel == "/groups" && $(ul).find(".dynamic-recent").length) || (item.typel == "/personalContact" && ($(ul).find(".dynamic-group").length || $(ul).find(".dynamic-recent").length))){
+ currentTypeContact = item.typel;
+ item.asDiv = true;
+ }else{
+ currentTypeContact = item.typel;
+ }
+ }
+
+ var li = '';
+ if(item.asDiv){
+ li = '
';
+ }
+ li += '';
+ li += '';
+ li += '';
+ li += ($.trim(item.name) != "" ? ((item.name.length > 20 ? item.name.substring(0,17)+"..." : item.name) + " - " ) : '') + item.mail;
+ li += item.type == '/dynamiccontacts' ? '' : ''
+ li += '';
+ li += 'Excluir contato recente';
+ li += '';
+
+
+ li = $( li )
+ .data( "item.autocomplete", item )
+ //.append( li )
+ .appendTo( ul );
+
+ li.find("span").button({
+ icons : {
+ primary : "ui-icon-close"
+ },
+ text: false
+ }).click(function(event){
+ if(!event.keyCode)
+ autocomplete.autocomplete( "close" );
+
+ canMakeBox = false;
+ $.Zebra_Dialog('Deseja remover '+(item.name ? (item.name.length <= 30 ? item.name: item.name.substr(0,27)+"...")+" - " : "")+ item.mail+'?', {
+ 'type': 'question',
+ 'custom_class': (is_ie ? 'configure-zebra-dialog' : ''),
+ 'buttons': ['Sim','Não'],
+ 'overlay_opacity': '0.5',
+ 'onClose': function(caption) {
+ if(caption == 'Sim'){
+
+ REST['delete']("/dynamiccontact/"+item.id);
+ updateDynamicContact();
+ cache = new Array();
+ }else if(caption == 'Não'){
+ $(focusIn).focus();
+ }
+ }
+ });
+ });
+
+ li.find(".dynamic-stars").jRating({
+ step:true,
+ length : 5, // nb of stars
+ decimalLength: 2, // number of decimal in the rate
+ rateMax: 10,
+ isDisabled:true,
+ bigStarsPath : '../prototype/plugins/jquery.jrating/icons/stars.png', // path of the icon stars.png
+ smallStarsPath : '../prototype/plugins/jquery.jrating/icons/small.png' // path of the icon small.png
+ });
+
+ if($(ul).find("li:last").hasClass("dynamic-separator")){
+ $(ul).find("li:last").remove();
+ }
+
+ $(ul).scroll(function(){
+ canMakeBox = false;
+ });
+
+ return li;
+ };
+ }
//FUNÇÃO DOS BOTÕES PARA - CC - CCO