Changeset 7147 for trunk/calendar


Ignore:
Timestamp:
09/03/12 16:20:49 (12 years ago)
Author:
angelo
Message:

Ticket #3089 - Problema com os participantes externos na criacao de compromisso

Location:
trunk/calendar/templates/default
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/calendar/templates/default/js/edit_exmail.js

    r5143 r7147  
    1818} 
    1919         
    20 // Verifica versão do Firefox 
     20// Verifica versão do Firefox 
    2121var agt = navigator.userAgent.toLowerCase(); 
    2222var is_firefox_0 = agt.indexOf('firefox/1.0') != -1 && agt.indexOf('firefox/0.') ? true : false; 
     
    154154function submitValues(button){ 
    155155    loadScript("expressoMail1_2/js/common_functions.js"); 
    156         button.disabled = true; //Desabilita Botão para evitar varios clicks 
     156        button.disabled = true; //Desabilita Botão para evitar varios clicks 
    157157 
    158158        var typeField = document.getElementById('cal[type]'); 
     
    177177         
    178178        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"); 
    180180            button.disabled = false; 
    181181            return false; 
     
    190190        if(document.getElementsByName( "cal[rpt_use_end]" )[0].checked){ 
    191191                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."); 
    193193                        button.disabled = false; 
    194194                        return false; 
     
    197197        //Valida data inicio nao nula 
    198198        if(document.getElementById('start[str]').value == ''){ 
    199                 alert("Necessario preencher a data de início."); 
     199                alert("Necessario preencher a data de início."); 
    200200                document.getElementById('start[str]').focus(); 
    201201                button.disabled = false; 
     
    207207                        document.getElementById('start[str]').value = ''; 
    208208                        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."); 
    210210                        button.disabled = false; 
    211211                        return false; 
     
    217217                        document.getElementById('end[str]').value = ''; 
    218218                        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."); 
    220220                        button.disabled = false; 
    221221                        return false; 
     
    227227                document.getElementById('start_hour').value = ''; 
    228228                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."); 
    230230                button.disabled = false; 
    231231                return false; 
     
    235235                document.getElementById('start_minute').value = ''; 
    236236                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."); 
    238238                button.disabled = false; 
    239239                return false; 
     
    243243                document.getElementById('end_hour').value = ''; 
    244244                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."); 
    246246                button.disabled = false; 
    247247                return false; 
     
    251251                document.getElementById('end_minute').value = ''; 
    252252                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."); 
    254254                button.disabled = false; 
    255255                return false; 
     
    265265                        document.getElementById('end_minute').value = ''; 
    266266                        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."); 
    268268                        button.disabled = false; 
    269269                        return false; 
     
    276276                                document.getElementById('end_minute').value = ''; 
    277277                                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."); 
    279279                                button.disabled = false; 
    280280                                return false; 
     
    318318} 
    319319 
     320 
     321function 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 
     350var cache = new Array(); 
     351var dynamicPersonalContacts = new Array(); 
     352var dynamicContacts = new Array(); 
     353var topContact = 0; 
     354 
     355function split( val ) { 
     356        return val.split( /,\s*/ ); 
     357} 
     358 
     359function extractLast( term ) { 
     360        return split( term ).pop(); 
     361}                
     362 
     363function 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 
     385function 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*/ 
     403function 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 
    320422function showExParticipants(el,path){ 
     423        updateDynamicContact(); 
     424        updateDynamicPersonalContacts(); 
     425        REST.load(""); 
     426        controlInputBinds(); 
    321427        Element('tbl_ext_participants').style.display=''; 
    322428        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        } 
    341548 
    342549function hideExParticipants(el,path){ 
     
    397604function fixBugInnerSelect(objeto,innerHTML){ 
    398605/****** 
    399 * select_innerHTML - altera o innerHTML de um select independente se é FF ou IE 
    400 * Corrige o problema de não ser possível usar o innerHTML no IE corretamente 
     606* 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 
    401608* 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/2006 
    404 * Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br 
     609* 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 
    405612* Parametros: 
    406613* objeto(tipo object): o select a ser alterado 
     
    414621    selTemp = document.getElementById("micoxselect1") 
    415622    selTemp.style.display="none" 
    416     if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto 
     623    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto 
    417624        innerHTML = "<option>" + innerHTML + "</option>" 
    418625    } 
Note: See TracChangeset for help on using the changeset viewer.