Changeset 7158 for branches


Ignore:
Timestamp:
09/04/12 12:02:12 (12 years ago)
Author:
eduardow
Message:

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

Location:
branches/2.4
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4/calendar/templates/default/js/edit_exmail.js

    r5143 r7158  
    318318} 
    319319 
     320function controlInputBinds(){ 
     321        var div = $('#tbl_ext_participants').find('textarea'); 
     322        div.bind('keydown',function(e){ 
     323                        //SELECIONA O CONTATO E EVITA OUTROS COMANDOS 
     324                        if ( e.keyCode === $.ui.keyCode.TAB && $( this ).data( "catcomplete" ).menu.active ) { 
     325                                e.preventDefault(); 
     326                                return false; 
     327                        }                
     328                         
     329                        //FECHA OS CONTATOS DINÂMICOS 
     330                        if( (e.keyCode == 27) && $( this ).data( "catcomplete" ).menu.active ){ 
     331                                   e.stopPropagation(); 
     332                                   e.preventDefault(); 
     333                        } 
     334                         
     335                        //SELECIONA O CONTATO E EVITA OUTROS COMANDOS 
     336                        if(e.keyCode == $.ui.keyCode.ENTER && $( this ).data( "catcomplete" ).menu.active){ 
     337                                e.preventDefault(); 
     338                                return false; 
     339                        } 
     340                //BUSCA COM A TECLA F9 
     341                if((e.keyCode) == 120){ 
     342                         
     343                        e.preventDefault(); 
     344                        return false; 
     345                } 
     346        }); 
     347} 
     348 
     349var cache = new Array(); 
     350var dynamicPersonalContacts = new Array(); 
     351var dynamicContacts = new Array(); 
     352var topContact = 0; 
     353 
     354function split( val ) { 
     355        return val.split( /,\s*/ ); 
     356} 
     357 
     358function extractLast( term ) { 
     359        return split( term ).pop(); 
     360}                
     361 
     362function updateDynamicContact(){ 
     363        dynamicContacts = new Array(); 
     364        var dynamicData = REST.get("/dynamiccontacts").collection.itens; 
     365        if(dynamicData){ 
     366                $.each(dynamicData, function(index, value){ 
     367                        if(index ==0){ 
     368                                topContact = parseInt(value.data[2].value); 
     369                        } 
     370                        var dynamic = { 
     371                                name : value.data[0].value, 
     372                                mail : value.data[1].value, 
     373                                value: value.data[0].value + " - " + value.data[1].value, 
     374                                type: "", 
     375                                id: parseInt(value.data[3].value), 
     376                                qtd : parseInt(value.data[2].value) 
     377                        }; 
     378                        dynamicContacts.push(dynamic); 
     379                }); 
     380        } 
     381} 
     382 
     383 
     384function updateDynamicPersonalContacts(){ 
     385        dynamicPersonalContacts = new Array(); 
     386        var contactsData = REST.get("/contacts").collection.itens; 
     387        if(contactsData){ 
     388                $.each(contactsData, function(index, value){ 
     389                        var contact = { 
     390                                id : parseInt(value.data[0].value), 
     391                                name : value.data[1].value, 
     392                                email : value.data[2].value, 
     393                                value: value.data[1].value + " - " + value.data[2].value, 
     394                                type: "P" 
     395                        }; 
     396                        dynamicPersonalContacts.push(contact); 
     397                }); 
     398        } 
     399} 
     400 
     401/*Adiciona um novo contato selecionado*/ 
     402function update_mailField(email){ 
     403        var mailList = $('#tbl_ext_participants').find('textarea'); 
     404        var newList = ""; 
     405        if (mailList.val().indexOf(email) != -1){ 
     406                $.Zebra_Dialog('O email <b>'+ email +'</b> já consta na lista!'); 
     407        } 
     408        if (mailList.val().indexOf(',') > 0){ 
     409                var ctcList = mailList.val().split(','); 
     410                for(var ii=0; ii<ctcList.length - 1;ii++){ 
     411                        newList += ctcList[ii] + ","; 
     412                } 
     413                newList += email + ","; 
     414        } 
     415        else{ 
     416                newList += email+","; 
     417        } 
     418        mailList.val(newList); 
     419} 
     420 
    320421function showExParticipants(el,path){ 
     422        updateDynamicContact();  
     423        updateDynamicPersonalContacts();  
     424    REST.load("");  
     425    controlInputBinds();  
    321426        Element('tbl_ext_participants').style.display=''; 
    322427        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 } 
     428        $.widget( "custom.catcomplete", $.ui.autocomplete, { 
     429                        _renderMenu: function( ul, items ) { 
     430                                var self = this, 
     431                                currentType = ""; 
     432                                $.each( items, function( index, item ) { 
     433                                        if ( item.typel != currentType) { 
     434                                                if(item.typel == "/groups" && $(ul).find(".dynamic-recent").length) 
     435                                                        self._renderItem( ul, {name:"", value:"", type:"linha"} ); 
     436                                                if(item.typel == "/contacts" && ($(ul).find(".dynamic-group").length || $(ul).find(".dynamic-recent").length)) 
     437                                                        self._renderItem( ul, {name:"", value:"", type:"linha"} );       
     438                                                currentType = item.typel; 
     439                                        } 
     440                                        self._renderItem( ul, item ); 
     441                                        $(ul).find("li:last").find(".dynamic-stars").raty({ 
     442                                                readOnly : true, 
     443                                                half : true, 
     444                                                hints : ['','','','',''], 
     445                                                score    : ((item.number_of_messages*5)/topContact) > 0.5 ? ((item.number_of_messages*5)/topContact) : 0.5, 
     446                                                starOn  : '../prototype/plugins/jq-raty/img/star-on.png', 
     447                                                starOff : '../prototype/plugins/jq-raty/img/star-off.png', 
     448                                                starHalf : '../prototype/plugins/jq-raty/img/star-half.png' 
     449                                        }); 
     450                                }); 
     451                                 
     452                                if($(ul).find("li:last").hasClass("dynamic-separator")){ 
     453                                        $(ul).find("li:last").remove(); 
     454                                } 
     455                                $(ul).scroll(function(){ 
     456                                        canMakeBox = false; 
     457                                }); 
     458                        } 
     459                }); 
     460        $('#tbl_ext_participants').find('textarea').catcomplete({ 
     461                        minLength: 1,                    
     462                        source: function(request, response){ 
     463                                request.term = extractLast( request.term ); 
     464                                if ( request.term in cache ) { 
     465                                        response( cache[ request.term ] ); 
     466                                        return; 
     467                                } 
     468                                dynamicContactsList = new Array(); 
     469                                REST.get("/usercontacts", false, function(data){ 
     470                                        dynamicData = data.collection.itens; 
     471                                        if(dynamicData){ 
     472                                                $.each(dynamicData, function(index, value){ 
     473                                                        dynamic = {}; 
     474                                                        $.each(value.data, function(index, value){ 
     475                                                                dynamic[value.name] = value.value; 
     476                                                        }); 
     477                                                        dynamic['value'] = (dynamic.name ? dynamic.name +' - ': '') + dynamic.mail; 
     478                                                        dynamic['type'] = value.dataType; 
     479                                                        dynamic['typel'] = (value.dataType.substring(0,7) == "/shared" ? "/"+value.dataType.substring(7,value.dataType.length)+"s" : value.dataType) ; 
     480                                                        dynamicContactsList.push(dynamic); 
     481                                                }); 
     482                                        } 
     483                                        var data = $.ui.autocomplete.filter(dynamicContactsList, request.term ); 
     484                                        cache[ request.term ] = data; 
     485                                        response( data ); 
     486                                }); 
     487                        }, 
     488                        focus: function() { 
     489                                return false; 
     490                        }, 
     491                         
     492                        //EVENTO AO SELECIONAR UM CONTATO DINÂMICO 
     493                        select: function( event, ui ) {                  
     494                                event.preventDefault(); 
     495                                update_mailField(ui.item.mail); 
     496                        }, 
     497                        position : { my: "left top", at: "left bottom", collision: "fit" } 
     498                }).bind('catcompleteopen', function(event, ui) { 
     499                        $(this).data('is_open',true); 
     500                }).bind('catcompleteclose', function(event, ui) { 
     501                        $(this).data('is_open',false); 
     502                }) 
     503                 
     504                //MONTAGEM DA LISTA DE CONTATOS DINÂMICOS DO AUTO COMPLETE 
     505                .data( "catcomplete" )._renderItem = function( ul, item ) { 
     506                        if($(ul).find("li").length < 50){ 
     507                                var autocomplete = $(this)[0].element; 
     508                                //cálculo dinâmico da largura da lista 
     509                                var width = (item.label ? item.label.length : (item.value ? item.value.length : (item.email ? item.email.length : 20 ))); 
     510                                width = width*5 + (is_ie ? 170 : 200) + 16; 
     511                                if (width < $(ul).width()) 
     512                                        width = $(ul).width(); 
     513                                ul.css({"min-width":width,"max-width":$('#tbl_ext_participants').find('textarea').width(),"max-height" : "180px", "overflow-y" : "auto", "min-height": "30px"}); 
     514                                var listContacts = DataLayer.render("calendar/templates/default/listContacts.ejs", item); 
     515                                return $(listContacts).data( "item.autocomplete", item ).appendTo( ul ).find("span:last").button({ 
     516                                                icons : { 
     517                                                primary : "ui-icon-close" 
     518                                        }, 
     519                                        text: false 
     520                                }).click(function(event){ 
     521                                        var removeLi = $(this).parents("li:first"); 
     522                                        if(!event.keyCode) 
     523                                                autocomplete.catcomplete( "close" ); 
     524                                        canMakeBox = false; 
     525                                        $.Zebra_Dialog('Deseja remover <b>'+(item.name ? item.name+" - " : "")+ item.mail+'</b>?', { 
     526                                                        'type':     'question', 
     527                                                        'custom_class': (is_ie ? 'configure-zebra-dialog' : ''), 
     528                                                        'title':    'Atenção', 
     529                                                        'buttons': ['Sim','Não'],                
     530                                                        'overlay_opacity': '0.5', 
     531                                                        'onClose':  function(caption) { 
     532                                                                if(caption == 'Sim'){ 
     533                                                                        $(removeLi).remove(); 
     534                                                                        REST['delete']("/dynamiccontact/"+item.id); 
     535                                                                        updateDynamicContact(); 
     536                                                                        cache = new Array(); 
     537                                                                }else if(caption == 'Não'){ 
     538                                                                        $(focusIn).focus(); 
     539                                                                } 
     540                                                        } 
     541                                        }); 
     542                                }); 
     543                        } 
     544                        return; 
     545                }; 
     546        } 
    341547 
    342548function hideExParticipants(el,path){ 
  • branches/2.4/index.php

    r6116 r7158  
    145145                        $modulo = explode('.', $_GET['menuaction']); 
    146146                         
    147                         if($modulo[0] == 'expressoAdmin1_2') 
    148                                 echo '<script type="text/javascript" src="prototype/plugins/jquery/jquery.min.js"></script>'; 
     147                        if($modulo[0] == 'expressoAdmin1_2' || $modulo[0] == 'calendar'){  
     148                    echo '<script type="text/javascript" src="prototype/plugins/jquery/jquery.min.js"></script>  
     149                              <script type="text/javascript" src="prototype/plugins/jquery/jquery-ui.min.js"></script>  
     150                              <link rel="stylesheet" href="prototype/plugins/jqgrid/themes/prognusone/jquery-ui-1.8.2.custom.css" type="text/css" />  
     151                              <script src="prototype/plugins/json2/json2.js" language="javascript"></script>  
     152                              <script src="prototype/plugins/ejs/ejs.js" language="javascript"></script>  
     153                              <script src="prototype/plugins/store/jquery.store.js" language="javascript"></script>  
     154                              <script type="text/javascript" src="prototype/api/rest.js"></script>  
     155                          <script src="prototype/api/datalayer.js" language="javascript"></script>  
     156                              <script type="text/javascript" src="prototype/plugins/jq-raty/js/jquery.raty.min.js"></script>  
     157                              <script type="text/javascript">DataLayer.dispatchPath = "/"; REST.dispatchPath = "prototype/";REST.load("")</script>  
     158                          <script src="expressoMail1_2/js/QuickCatalogSearch.js" type="text/javascript"></script>  
     159                              <link rel="stylesheet" type="text/css" href="prototype/plugins/zebradialog/css/zebra_dialog.css"></link>  
     160                              <script type="text/javascript" src="prototype/plugins/zebradialog/javascript/zebra_dialog.js"></script>'; 
     161                        } 
    149162                } 
    150163?> 
Note: See TracChangeset for help on using the changeset viewer.