source: trunk/calendar/templates/default/js/edit_exmail.js @ 7147

Revision 7147, 23.1 KB checked in by angelo, 12 years ago (diff)

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

Line 
1/******************************************************************************\
2|**************************   CALENDAR MODULE   *******************************|
3|********** INCLUDE PARTICIPANTS - PLUGIN USING AJAX EXPRESSOMAIL COMPONENT  **|
4\******************************************************************************/
5var contacts = '';
6var expresso_offline = '';
7var array_lang = new Array();
8var finderTimeout = '';
9// onUnload edit message
10if(!document.all)
11{
12        var beforeunload = window.onbeforeunload;
13        window.onbeforeunload = function()
14        {
15                if ( typeof beforeunload == 'function' )
16                        beforeunload();
17        };
18}
19       
20// Verifica versão do Firefox
21var agt = navigator.userAgent.toLowerCase();
22var is_firefox_0 = agt.indexOf('firefox/1.0') != -1 && agt.indexOf('firefox/0.') ? true : false;
23
24var handler_get_available_users = function(fill)
25{       
26        var groupHandler = function( toGroup )
27        {
28            switch( toGroup[ 'phpgwaccounttype' ] )
29            {
30                case 'u':return 'users';
31                break;
32                case 'g':return 'groups';
33                break;
34                case 's':return 'shared_accounts';
35                break
36            }
37
38            return( false );
39        }
40
41        return fillGroupableSelect( fill, 'user_list_in', groupHandler, default_field );
42}       
43
44function get_available_users(module,context,type, autoSearch){
45//      Element('cal_input_searchUser').value = '';
46//      if(autoSearch != 'True'){
47//              return true;
48//      }
49//      var context = document.getElementById('combo_org').value;       
50//      cExecute (module+'.ldap_functions.get_available_users&context='+context+'&type='+type, handler_get_available_users);
51}
52
53function optionFinderTimeout(obj, numMin, type, autoSearch, event){
54
55        if( event.keyCode === 13 )
56        {
57            //limit = 0;
58
59            optionFinderLdap( obj.id, numMin, type );
60
61            return( false );
62        }
63
64        return( true );
65}
66// Pesquisa Javascript
67function optionFinderLocal(id){
68
69        var sentence = Element( id ).value;
70
71        finder( sentence, 'user_list_in' );
72}
73
74// Pesquisa LDAP
75function optionFinderLdap(id,numMin, type){
76
77        var sentence = Element( id ).value;
78
79        var url = 'expressoMail1_2.ldap_functions.search_users&context=' + document.getElementById('combo_org').value + '&type='+(type == '' ? 'list' : 'search')+'&filter=' + sentence;
80       
81        var parser = function( data ){
82
83            var result = {};
84
85            for( accountType in data )
86            {
87                var target = data[ accountType ];
88
89                accountType = accountType.charAt(0);
90
91                for( value in target )
92                {
93                    result[value] = {};
94                    result[value][default_field] = target[value];
95                    result[value]['phpgwaccounttype'] = accountType;
96                }
97
98            }
99
100            return( result );
101        };
102
103        return userFinder( sentence, handler_get_available_users, url, parser, 'cal_span_searching' );
104}
105
106function add_user()
107{
108        var select_available_users = document.getElementById('user_list_in');
109        var select_users = document.getElementById('user_list');
110        var count_available_users = select_available_users.length;
111        var count_users = select_users.options.length;
112        var new_options = '';
113       
114        for (i = 0 ; i < count_available_users ; i++) {
115                if (select_available_users.options[i].selected) {
116                        if(document.all) {
117                                if ( (select_users.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) {
118                                        new_options +=  '<option value='
119                                                                + select_available_users.options[i].value
120                                                                + '>'
121                                                                + select_available_users.options[i].text
122                                                                + '</option>';
123                                }
124                        }
125                        else if ( (select_users.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) {
126                                        new_options +=  '<option value='
127                                                                + select_available_users.options[i].value
128                                                                + '>'
129                                                                + select_available_users.options[i].text
130                                                                + '</option>';
131                        }
132                }
133        }
134
135        if (new_options != '') {
136
137                if(is_firefox_0)
138                        fixBugInnerSelect(select_users,'###' + new_options + select_users.innerHTML);
139                else
140                        select_users.innerHTML = '###' + new_options + select_users.innerHTML;
141
142                select_users.outerHTML = select_users.outerHTML;
143        }
144}
145
146function remove_user(){
147        select_users = document.getElementById('user_list');
148       
149        for(var i = 0;i < select_users.options.length; i++)
150                if(select_users.options[i].selected)
151                        select_users.options[i--] = null;
152}
153
154function submitValues(button){
155    loadScript("expressoMail1_2/js/common_functions.js");
156        button.disabled = true; //Desabilita Botão para evitar varios clicks
157
158        var typeField = document.getElementById('cal[type]');
159        if (typeField && typeField.value == 'hourAppointment') {
160                if(document.getElementsByName('categories[]')[0].value == ""){
161                        alert(alert_msg);
162                        button.disabled = false;
163                        return false;
164                }
165        }
166
167        var select_in = document.getElementById('user_list');
168        for(i = 0; i < select_in.length; i++)
169                select_in.options[i].selected = true;
170
171        var rptDay = document.getElementsByName( 'cal[rpt_day][]' );
172        var isChecked = false;
173
174        for(var i = 0 ; i < rptDay.length; i++)
175            if(rptDay[i].checked == true)
176                isChecked = true; 
177       
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");
180            button.disabled = false;
181            return false;
182        }
183   
184        if( !isChecked && document.getElementsByName( "cal[recur_type]" )[0].value === "2" ){
185            //TODO: por essa mensagem no lang
186            alert("Voce nao especificou um dia na sua repeticao semanal");
187            button.disabled = false;
188            return false;
189        }
190        if(document.getElementsByName( "cal[rpt_use_end]" )[0].checked){
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.");
193                        button.disabled = false;
194                        return false;
195                }
196        }
197        //Valida data inicio nao nula
198        if(document.getElementById('start[str]').value == ''){
199                alert("Necessario preencher a data de início.");
200                document.getElementById('start[str]').focus();
201                button.disabled = false;
202                return false;
203        }
204        //Valida data inicio
205        if(document.getElementById('start[str]').value != ''){
206                if(!validate_date(document.getElementById('start[str]').value)){
207                        document.getElementById('start[str]').value = '';
208                        document.getElementById('start[str]').focus();
209                        alert("A data de início não é válida.");
210                        button.disabled = false;
211                        return false;
212                }
213        }
214        //Valida data termino
215        if(document.getElementById('end[str]').value != ''){
216                if(!validate_date(document.getElementById('end[str]').value)){
217                        document.getElementById('end[str]').value = '';
218                        document.getElementById('end[str]').focus();
219                        alert("A data de término não é válida.");
220                        button.disabled = false;
221                        return false;
222                }
223        }
224
225        //Valida hora inicio somente numeros   
226        if(isNaN(parseInt(document.getElementById('start_hour').value))){
227                document.getElementById('start_hour').value = '';
228                document.getElementById('start_hour').focus();
229                alert("A hora de início deve ser números.");
230                button.disabled = false;
231                return false;
232        }
233        //Valida hora inicio somente numeros   
234        if(isNaN(parseInt(document.getElementById('start_minute').value))){
235                document.getElementById('start_minute').value = '';
236                document.getElementById('start_minute').focus();
237                alert("A hora de início deve ser números.");
238                button.disabled = false;
239                return false;
240        }
241        //Valida hora termino somente numeros   
242        if(isNaN(parseInt(document.getElementById('end_hour').value))){
243                document.getElementById('end_hour').value = '';
244                document.getElementById('end_hour').focus();
245                alert("A hora do término deve ser números.");
246                button.disabled = false;
247                return false;
248        }
249        //Valida hora termino somente numeros   
250        if(isNaN(parseInt(document.getElementById('end_minute').value))){
251                document.getElementById('end_minute').value = '';
252                document.getElementById('end_minute').focus();
253                alert("A hora do término deve ser números.");
254                button.disabled = false;
255                return false;
256        }
257         
258        //Valida hora inicial maior que final
259        if( (document.getElementById('start_hour').value != '') && (document.getElementById('end_hour').value != '') ){
260                if( (document.getElementById('start_hour').value) > (document.getElementById('end_hour').value) ){
261                        //JA ESTA ERRADO
262                        document.getElementById('start_hour').value = '';
263                        document.getElementById('end_hour').value = '';
264                        document.getElementById('start_minute').value = '';
265                        document.getElementById('end_minute').value = '';
266                        document.getElementById('start_hour').focus();
267                        alert("A hora final não pode ser menor que a hora inicial.");
268                        button.disabled = false;
269                        return false;
270                }else if ( (document.getElementById('start_hour').value) == (document.getElementById('end_hour').value) ){
271                        if ( (document.getElementById('start_minute').value) > (document.getElementById('end_minute').value) ){
272                                //DEU ERRO
273                                document.getElementById('start_hour').value = '';
274                                document.getElementById('end_hour').value = '';
275                                document.getElementById('start_minute').value = '';
276                                document.getElementById('end_minute').value = '';
277                                document.getElementById('start_hour').focus();
278                                alert("A hora final não pode ser menor que a hora inicial.");
279                                button.disabled = false;
280                                return false;
281                        }
282                }
283        }
284
285       
286        document.getElementById('formEvent').submit();
287}       
288
289function Element(id){
290        return document.getElementById(id);
291}
292
293function loadScript(scriptPath){
294
295        if(!connector)
296                throw new Error("Error : Connector is not loaded.");
297               
298        if (document.getElementById('uploadscript_'+scriptPath)) {
299                return;
300        }
301
302        if( connector.oxmlhttp === null )
303            connector.createXMLHTTP();
304
305        connector.oxmlhttp.open("GET", scriptPath, false);
306        connector.oxmlhttp.setRequestHeader('Content-Type','text/plain');
307        connector.oxmlhttp.send(null);
308        if(connector.oxmlhttp.status != 0 && connector.oxmlhttp.status != 200 ||        connector.oxmlhttp.status == 0 && connector.oxmlhttp.responseText.length == 0)
309                throw new Error("Error " + connector.oxmlhttp.status + "("+connector.oxmlhttp.statusText+") when loading script file '"+scriptPath+"'");
310       
311        var head = document.getElementsByTagName("head")[0];
312        var script = document.createElement("SCRIPT");
313        script.id = 'uploadscript_'+scriptPath;
314        script.type = 'text/javascript';               
315        script.text = connector.oxmlhttp.responseText;
316        head.appendChild(script);
317        return;
318}
319
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
422function showExParticipants(el,path){
423        updateDynamicContact();
424        updateDynamicPersonalContacts();
425        REST.load("");
426        controlInputBinds();
427        Element('tbl_ext_participants').style.display='';
428        el.style.display='none';
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        }
548
549function hideExParticipants(el,path){
550        Element('a_ext_participants').style.display = '';
551        Element('tbl_ext_participants').style.display ='none';
552}
553
554function save_contacts(data){
555        contacts = data;       
556        var input_to = Element("ex_participants");
557        input_to.style.width = "100%";
558        input_to.setAttribute("wrap","soft");   
559        input_to.onfocus = function(){clearTimeout(parseInt(setTimeOutLayer));search_contacts('onfocus', this.id);};
560        input_to.onblur = function(){setTimeOutLayer=setTimeout('search_contacts("lostfocus","'+this.id+'")',100);};
561        if (!is_ie)
562        {
563                input_to.rows = 2;
564                input_to.onkeypress = function (e)
565                {
566                        if ((e.keyCode) == 120) //F9
567                        {
568                                emQuickSearch(input_to);
569                        }
570                        else
571                        {
572                                if (((e.keyCode == 13) || ((e.keyCode == 38)||(e.keyCode == 40))) && (document.getElementById('tipDiv').style.visibility!='hidden'))
573                                {
574                                        e.preventDefault();
575                                        search_contacts(e.keyCode,this.id);
576                                }
577                        }
578                }
579                input_to.onkeyup = function (e)
580                {
581                        if ((e.keyCode != 13) && (e.keyCode != 38) && (e.keyCode != 40))
582                        {
583                                search_contacts(e.keyCode,this.id);
584                        }
585                }
586        }
587        else
588        {
589                input_to.rows = 3;
590                input_to.onkeyup = function (e)
591                {
592                        if ((window.event.keyCode) == 120) //F9
593                        {
594                                emQuickSearch(input_to);
595                        }
596                        else
597                        {
598                                search_contacts(window.event.keyCode,this.id);
599                        }       
600                }
601        }
602}
603
604function fixBugInnerSelect(objeto,innerHTML){
605/******
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
608* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
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
612* Parametros:
613* objeto(tipo object): o select a ser alterado
614* innerHTML(tipo string): o novo valor do innerHTML
615*******/
616    objeto.innerHTML = ""
617    var selTemp = document.createElement("micoxselect")
618    var opt;
619    selTemp.id="micoxselect1"
620    document.body.appendChild(selTemp)
621    selTemp = document.getElementById("micoxselect1")
622    selTemp.style.display="none"
623    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto
624        innerHTML = "<option>" + innerHTML + "</option>"
625    }
626    innerHTML = innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span")
627    selTemp.innerHTML = innerHTML
628    for(var i=0;i<selTemp.childNodes.length;i++){
629        if(selTemp.childNodes[i].tagName){
630            opt = document.createElement("OPTION")
631            for(var j=0;j<selTemp.childNodes[i].attributes.length;j++){
632                opt.setAttributeNode(selTemp.childNodes[i].attributes[j].cloneNode(true))
633            }
634            opt.value = selTemp.childNodes[i].getAttribute("value")
635            opt.text = selTemp.childNodes[i].innerHTML
636            if(document.all){ //IEca
637                objeto.add(opt)
638            }else{
639                objeto.appendChild(opt)
640            }                   
641        }   
642    }
643    document.body.removeChild(selTemp)
644    selTemp = null
645}
646
647function changeViewMode(eltype){
648        var chValue = eltype;
649        switch (chValue){
650                case 'hourAppointment':
651                        var names=new Array('title','priority','location','alarmhours','alarmminutes','recur_type','rpt_use_end','recur_interval','rpt_label');
652                        for (var i=0; i < names.length; i++)
653                        {
654                                var Field = document.getElementsByName('cal['+names[i]+']');
655                                if (Field[0])
656                                        Field[0].parentNode.parentNode.style.display = "none";
657                        }
658
659                        Field = document.getElementsByName('participants[]');
660                        Field[0].parentNode.parentNode.style.display = "none";
661                        Field[1].parentNode.parentNode.style.display = "none";
662                        Field = document.getElementById('txt_loading');
663                        Field.parentNode.parentNode.style.display = "none";
664                        Field = document.getElementsByName('cal[rpt_day][]');
665                        Field[0].parentNode.parentNode.style.display = "none";
666                        break;
667                case 'privateHiddenFields':
668                        var names=new Array('title','priority','location','alarmhours','alarmminutes','recur_type','rpt_use_end','recur_interval','rpt_label');
669                        for (var i=0; i < names.length; i++)
670                        {
671                                var Field = document.getElementsByName('cal['+names[i]+']');
672                                if (Field[0])
673                                        Field[0].parentNode.parentNode.style.display = "";
674                        }
675                        Field = document.getElementsByName('participants[]');
676                        Field[0].parentNode.parentNode.style.display = "none";
677                        Field[1].parentNode.parentNode.style.display = "none";
678                        Field = document.getElementById('txt_loading');
679                        Field.parentNode.parentNode.style.display = "none";
680                        Field = document.getElementsByName('cal[rpt_day][]');
681                        Field[0].parentNode.parentNode.style.display = "";
682                        break;
683                default:
684                        var names=new Array('title','priority','location','alarmhours','alarmminutes','recur_type','rpt_use_end','recur_interval','rpt_label');
685                        for (var i=0; i < names.length; i++)
686                        {
687                                var Field = document.getElementsByName('cal['+names[i]+']');
688                                if (Field[0])
689                                        Field[0].parentNode.parentNode.style.display = "";
690                        }
691                        Field = document.getElementsByName('participants[]');
692                        Field[0].parentNode.parentNode.style.display = "";
693                        Field[1].parentNode.parentNode.style.display = "";
694                        Field = document.getElementById('txt_loading');
695                        Field.parentNode.parentNode.style.display = "";
696                        Field = document.getElementsByName('cal[rpt_day][]');
697                        Field[0].parentNode.parentNode.style.display = "";
698                        break;
699        }
700
701}
702function updateTitleField(select){
703        var typeField = document.getElementsByName('cal[type]');
704        if (typeField[0].value != 'hourAppointment')
705                return;
706        var titleField = document.getElementsByName('cal[title]');
707        var optionsArray = select.childNodes;
708        titleField[0].value = '';
709        for(option in optionsArray)
710                if (optionsArray[option].selected)
711                        titleField[0].value += optionsArray[option].text + ' ';
712}
713
714var __onLoad = window.onload;
715window.onload = function(){
716        __onLoad();
717        var cal_type = document.getElementById('cal[type]').value;
718        changeViewMode(cal_type);
719        if(cal_type == 'hourAppointment'){
720                clearTimeout(timeout_get_available_users);
721        }
722};
Note: See TracBrowser for help on using the repository browser.