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

Revision 7173, 23.9 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                        quickSearchCatalogUser();
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
402function quickSearchCatalogUser(){
403        var begin,end;
404        var mailList = document.getElementById('ex_participants').value;
405        var search =  "";
406        if (mailList.lastIndexOf(',') != -1){
407                begin = mailList.lastIndexOf(',');
408                end = mailList.length;
409                search = mailList.substring(begin+1,255);
410        }
411        else{
412                begin = 0;
413                end = mailList.length;
414                search = mailList;
415        }
416        var handler_Search = function(data){
417                if ((!data.status) && (data.error == "many results")){
418                        return false;
419                }
420                if (data.length > 0){
421                        quickSearchUser.showList(data,begin,end);
422                }
423        }
424        if (search.length > 0)
425        cExecute ("$this.ldap_functions.quicksearchcontact&search_for="+search+"&field="+null+"&ID="+null, handler_Search);
426}
427
428/*Adiciona um novo contato selecionado*/
429function update_mailField(name,email){
430        var mailList = $('#tbl_ext_participants').find('textarea');
431        var newList = "";
432        if (mailList.val().indexOf(email) != -1){
433                $.Zebra_Dialog('O email <b>'+ email +'</b> já consta na lista!');
434        }
435        if (mailList.val().indexOf(',') > 0){
436                var ctcList = mailList.val().split(',');
437                for(var ii=0; ii<ctcList.length - 1;ii++){
438                        newList += ctcList[ii] + ",";
439                }
440                newList += '"'+ name + '"'+ " <" + email + ">" + ",";
441        }
442        else{
443                newList +=  '"'+ name + '"'+ " <" + email + ">" +",";
444        }
445        mailList.val(newList);
446}
447
448function showExParticipants(el,path){
449        updateDynamicContact();
450        updateDynamicPersonalContacts();
451        REST.load("");
452        controlInputBinds();
453        Element('tbl_ext_participants').style.display='';
454        el.style.display='none';
455                        $.widget( "custom.catcomplete", $.ui.autocomplete, {
456                        _renderMenu: function( ul, items ) {
457                                var self = this,
458                                currentType = "";
459                                $.each( items, function( index, item ) {
460                                        if ( item.typel != currentType) {
461                                                if(item.typel == "/groups" && $(ul).find(".dynamic-recent").length)
462                                                        self._renderItem( ul, {name:"", value:"", type:"linha"} );
463                                                if(item.typel == "/contacts" && ($(ul).find(".dynamic-group").length || $(ul).find(".dynamic-recent").length))
464                                                        self._renderItem( ul, {name:"", value:"", type:"linha"} );     
465                                                currentType = item.typel;
466                                        }
467                                        self._renderItem( ul, item );
468                                        $(ul).find("li:last").find(".dynamic-stars").raty({
469                                                readOnly : true,
470                                                half : true,
471                                                hints : ['','','','',''],
472                                                score    : ((item.number_of_messages*5)/topContact) > 0.5 ? ((item.number_of_messages*5)/topContact) : 0.5,
473                                                starOn  : '../prototype/plugins/jq-raty/img/star-on.png',
474                                                starOff : '../prototype/plugins/jq-raty/img/star-off.png',
475                                                starHalf : '../prototype/plugins/jq-raty/img/star-half.png'
476                                        });
477                                });
478                               
479                                if($(ul).find("li:last").hasClass("dynamic-separator")){
480                                        $(ul).find("li:last").remove();
481                                }
482                                $(ul).scroll(function(){
483                                        canMakeBox = false;
484                                });
485                        }
486                });
487        $('#tbl_ext_participants').find('textarea').catcomplete({
488                        minLength: 1,                   
489                        source: function(request, response){
490                                request.term = extractLast( request.term );
491                                if ( request.term in cache ) {
492                                        response( cache[ request.term ] );
493                                        return;
494                                }
495                                dynamicContactsList = new Array();
496                                REST.get("/usercontacts", false, function(data){
497                                        dynamicData = data.collection.itens;
498                                        if(dynamicData){
499                                                $.each(dynamicData, function(index, value){
500                                                        dynamic = {};
501                                                        $.each(value.data, function(index, value){
502                                                                dynamic[value.name] = value.value;
503                                                        });
504                                                        dynamic['value'] = (dynamic.name ? dynamic.name +' - ': '') + dynamic.mail;
505                                                        dynamic['type'] = value.dataType;
506                                                        dynamic['typel'] = (value.dataType.substring(0,7) == "/shared" ? "/"+value.dataType.substring(7,value.dataType.length)+"s" : value.dataType) ;
507                                                        dynamicContactsList.push(dynamic);
508                                                });
509                                        }
510                                        var data = $.ui.autocomplete.filter(dynamicContactsList, request.term );
511                                        cache[ request.term ] = data;
512                                        response( data );
513                                });
514                        },
515                        focus: function() {
516                                return false;
517                        },
518                       
519                        //EVENTO AO SELECIONAR UM CONTATO DINÂMICO
520                        select: function( event, ui ) {                 
521                                event.preventDefault();
522                                update_mailField((ui.item.name ? ui.item.name : ""),ui.item.mail);
523                        },
524                        position : { my: "left top", at: "left bottom", collision: "fit" }
525                }).bind('catcompleteopen', function(event, ui) {
526                        $(this).data('is_open',true);
527                }).bind('catcompleteclose', function(event, ui) {
528                        $(this).data('is_open',false);
529                })
530               
531                //MONTAGEM DA LISTA DE CONTATOS DINÂMICOS DO AUTO COMPLETE
532                .data( "catcomplete" )._renderItem = function( ul, item ) {
533                        if($(ul).find("li").length < 50){
534                                var autocomplete = $(this)[0].element;
535                                //cálculo dinâmico da largura da lista
536                                var width = (item.label ? item.label.length : (item.value ? item.value.length : (item.email ? item.email.length : 20 )));
537                                width = width*5 + (is_ie ? 170 : 200) + 16;
538                                if (width < $(ul).width())
539                                        width = $(ul).width();
540                                ul.css({"min-width":width,"max-width":$('#tbl_ext_participants').find('textarea').width(),"max-height" : "180px", "overflow-y" : "auto", "min-height": "30px"});
541                                var listContacts = DataLayer.render("calendar/templates/default/listContacts.ejs", item);
542                                return $(listContacts).data( "item.autocomplete", item ).appendTo( ul ).find("span:last").button({
543                                                icons : {
544                                                primary : "ui-icon-close"
545                                        },
546                                        text: false
547                                }).click(function(event){
548                                        var removeLi = $(this).parents("li:first");
549                                        if(!event.keyCode)
550                                                autocomplete.catcomplete( "close" );
551                                        canMakeBox = false;
552                                        $.Zebra_Dialog('Deseja remover <b>'+(item.name ? item.name+" - " : "")+ item.mail+'</b>?', {
553                                                        'type':     'question',
554                                                        'custom_class': (is_ie ? 'configure-zebra-dialog' : ''),
555                                                        'title':    'Atenção',
556                                                        'buttons': ['Sim','Não'],               
557                                                        'overlay_opacity': '0.5',
558                                                        'onClose':  function(caption) {
559                                                                if(caption == 'Sim'){
560                                                                        $(removeLi).remove();
561                                                                        REST['delete']("/dynamiccontact/"+item.id);
562                                                                        updateDynamicContact();
563                                                                        cache = new Array();
564                                                                }else if(caption == 'Não'){
565                                                                        $(focusIn).focus();
566                                                                }
567                                                        }
568                                        });
569                                });
570                        }
571                        return;
572                };
573        }
574
575function hideExParticipants(el,path){
576        Element('a_ext_participants').style.display = '';
577        Element('tbl_ext_participants').style.display ='none';
578}
579
580function save_contacts(data){
581        contacts = data;       
582        var input_to = Element("ex_participants");
583        input_to.style.width = "100%";
584        input_to.setAttribute("wrap","soft");   
585        input_to.onfocus = function(){clearTimeout(parseInt(setTimeOutLayer));search_contacts('onfocus', this.id);};
586        input_to.onblur = function(){setTimeOutLayer=setTimeout('search_contacts("lostfocus","'+this.id+'")',100);};
587        if (!is_ie)
588        {
589                input_to.rows = 2;
590                input_to.onkeypress = function (e)
591                {
592                        if ((e.keyCode) == 120) //F9
593                        {
594                                emQuickSearch(input_to);
595                        }
596                        else
597                        {
598                                if (((e.keyCode == 13) || ((e.keyCode == 38)||(e.keyCode == 40))) && (document.getElementById('tipDiv').style.visibility!='hidden'))
599                                {
600                                        e.preventDefault();
601                                        search_contacts(e.keyCode,this.id);
602                                }
603                        }
604                }
605                input_to.onkeyup = function (e)
606                {
607                        if ((e.keyCode != 13) && (e.keyCode != 38) && (e.keyCode != 40))
608                        {
609                                search_contacts(e.keyCode,this.id);
610                        }
611                }
612        }
613        else
614        {
615                input_to.rows = 3;
616                input_to.onkeyup = function (e)
617                {
618                        if ((window.event.keyCode) == 120) //F9
619                        {
620                                emQuickSearch(input_to);
621                        }
622                        else
623                        {
624                                search_contacts(window.event.keyCode,this.id);
625                        }       
626                }
627        }
628}
629
630function fixBugInnerSelect(objeto,innerHTML){
631/******
632* select_innerHTML - altera o innerHTML de um select independente se é FF ou IE
633* Corrige o problema de não ser possível usar o innerHTML no IE corretamente
634* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
635* Use a vontade mas coloque meu nome nos créditos. Dúvidas, me mande um email.
636* Versão: 1.0 - 06/04/2006
637* Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br
638* Parametros:
639* objeto(tipo object): o select a ser alterado
640* innerHTML(tipo string): o novo valor do innerHTML
641*******/
642    objeto.innerHTML = ""
643    var selTemp = document.createElement("micoxselect")
644    var opt;
645    selTemp.id="micoxselect1"
646    document.body.appendChild(selTemp)
647    selTemp = document.getElementById("micoxselect1")
648    selTemp.style.display="none"
649    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto
650        innerHTML = "<option>" + innerHTML + "</option>"
651    }
652    innerHTML = innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span")
653    selTemp.innerHTML = innerHTML
654    for(var i=0;i<selTemp.childNodes.length;i++){
655        if(selTemp.childNodes[i].tagName){
656            opt = document.createElement("OPTION")
657            for(var j=0;j<selTemp.childNodes[i].attributes.length;j++){
658                opt.setAttributeNode(selTemp.childNodes[i].attributes[j].cloneNode(true))
659            }
660            opt.value = selTemp.childNodes[i].getAttribute("value")
661            opt.text = selTemp.childNodes[i].innerHTML
662            if(document.all){ //IEca
663                objeto.add(opt)
664            }else{
665                objeto.appendChild(opt)
666            }                   
667        }   
668    }
669    document.body.removeChild(selTemp)
670    selTemp = null
671}
672
673function changeViewMode(eltype){
674        var chValue = eltype;
675        switch (chValue){
676                case 'hourAppointment':
677                        var names=new Array('title','priority','location','alarmhours','alarmminutes','recur_type','rpt_use_end','recur_interval','rpt_label');
678                        for (var i=0; i < names.length; i++)
679                        {
680                                var Field = document.getElementsByName('cal['+names[i]+']');
681                                if (Field[0])
682                                        Field[0].parentNode.parentNode.style.display = "none";
683                        }
684
685                        Field = document.getElementsByName('participants[]');
686                        Field[0].parentNode.parentNode.style.display = "none";
687                        Field[1].parentNode.parentNode.style.display = "none";
688                        Field = document.getElementById('txt_loading');
689                        Field.parentNode.parentNode.style.display = "none";
690                        Field = document.getElementsByName('cal[rpt_day][]');
691                        Field[0].parentNode.parentNode.style.display = "none";
692                        break;
693                case 'privateHiddenFields':
694                        var names=new Array('title','priority','location','alarmhours','alarmminutes','recur_type','rpt_use_end','recur_interval','rpt_label');
695                        for (var i=0; i < names.length; i++)
696                        {
697                                var Field = document.getElementsByName('cal['+names[i]+']');
698                                if (Field[0])
699                                        Field[0].parentNode.parentNode.style.display = "";
700                        }
701                        Field = document.getElementsByName('participants[]');
702                        Field[0].parentNode.parentNode.style.display = "none";
703                        Field[1].parentNode.parentNode.style.display = "none";
704                        Field = document.getElementById('txt_loading');
705                        Field.parentNode.parentNode.style.display = "none";
706                        Field = document.getElementsByName('cal[rpt_day][]');
707                        Field[0].parentNode.parentNode.style.display = "";
708                        break;
709                default:
710                        var names=new Array('title','priority','location','alarmhours','alarmminutes','recur_type','rpt_use_end','recur_interval','rpt_label');
711                        for (var i=0; i < names.length; i++)
712                        {
713                                var Field = document.getElementsByName('cal['+names[i]+']');
714                                if (Field[0])
715                                        Field[0].parentNode.parentNode.style.display = "";
716                        }
717                        Field = document.getElementsByName('participants[]');
718                        Field[0].parentNode.parentNode.style.display = "";
719                        Field[1].parentNode.parentNode.style.display = "";
720                        Field = document.getElementById('txt_loading');
721                        Field.parentNode.parentNode.style.display = "";
722                        Field = document.getElementsByName('cal[rpt_day][]');
723                        Field[0].parentNode.parentNode.style.display = "";
724                        break;
725        }
726
727}
728function updateTitleField(select){
729        var typeField = document.getElementsByName('cal[type]');
730        if (typeField[0].value != 'hourAppointment')
731                return;
732        var titleField = document.getElementsByName('cal[title]');
733        var optionsArray = select.childNodes;
734        titleField[0].value = '';
735        for(option in optionsArray)
736                if (optionsArray[option].selected)
737                        titleField[0].value += optionsArray[option].text + ' ';
738}
739
740var __onLoad = window.onload;
741window.onload = function(){
742        __onLoad();
743        var cal_type = document.getElementById('cal[type]').value;
744        changeViewMode(cal_type);
745        if(cal_type == 'hourAppointment'){
746                clearTimeout(timeout_get_available_users);
747        }
748};
Note: See TracBrowser for help on using the repository browser.