Ignore:
Timestamp:
08/10/12 19:11:37 (12 years ago)
Author:
acoutinho
Message:

Ticket #2966 - Merge de novas funcionalidades com trunk #2951, #2952

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/modules/calendar/js/init.js

    r6444 r6996  
    147147                        }, true ); 
    148148                }); 
     149                 
     150                var currentToolTip = null; 
     151                $('#divAppbox').on('scroll',function(){ 
     152                        if ($(".new-task").length)                       
     153                                currentToolTip.qtip('destroy'); 
     154                }); 
     155                 
     156                /* Quick add task 
     157        -----------------------------------------------------------------*/ 
     158                $(".button.add.add-task").click(function(event){ 
     159                        currentToolTip = $(this); 
     160                        var componente = $(this); 
     161                         
     162            if(!$('div.qtip.qtip-blue.new-task').length){ 
     163 
     164                $('div.qtip.qtip-blue').remove(); 
     165 
     166                        $(componente).qtip({ 
     167                            show: { 
     168                                ready: true,  
     169                                solo: true,  
     170                                when: { 
     171                                        event: 'click' 
     172                                } 
     173                                }, 
     174                                hide: false, 
     175                                content: { 
     176                                        text: $('<div></div>').html( DataLayer.render( 'templates/task_quick_add.ejs', {"componente" : componente} ) ), 
     177                                        title: { 
     178                                                text:'Nova tarefa',  
     179                                                button: '<a class="button close" href="#">close</a>' 
     180                                        } 
     181                                }, 
     182                                style: { 
     183                                        name: 'blue',  
     184                                tip: { 
     185                                                corner: 'leftMiddle' 
     186                                        },  
     187                                border: { 
     188                                            width: 4,  
     189                                            radius: 8 
     190                                        },  
     191                                width: { 
     192                                                min: 225,  
     193                                            max:225 
     194                                        } 
     195                                }, 
     196                        position: { 
     197                                corner: { 
     198                                            target: 'rightMiddle', 
     199                                            tooltip: 'leftMiddle' 
     200                                }, 
     201                                adjust: { 
     202                                            x:0,  
     203                                            y:0 
     204                                } 
     205                        } 
     206                    }) 
     207                .qtip("api").onShow = function(arg0) { 
     208 
     209                        /*------------------------------------------------------------------------*/ 
     210                        /*               Seta os valores padrões nos inputs do qtip               */ 
     211                         $('div.qtip div.add-simple-task input.task').Watermark("Tarefa sem título"); 
     212                             $('div.qtip div.add-simple-task textarea').Watermark("Descrição"); 
     213                        /*------------------------------------------------------------------------*/ 
     214 
     215                            $('.qtip-active .button.close').button({ 
     216                                icons: { 
     217                                    primary: "ui-icon-close" 
     218                                }, 
     219                                text: false 
     220                            }) 
     221                            .click(function(){ 
     222                                        $(componente).qtip('destroy'); 
     223                            }); 
     224                                                         
     225                            $('.qtip-active .button.save').button().click(function(){ 
     226                                 
     227                                var title = $('div.qtip div.add-simple-task input.task').val(); 
     228                                        var description = $('div.qtip div.add-simple-task textarea').val(); 
     229 
     230                                        var calendar, timezone = ''; 
     231 
     232                                        for (var i = 0; i < Calendar.signatures.length; i++){ 
     233                                                if(Calendar.signatures[i].type == 1 && Calendar.signatures[i].calendar.type == 1){ 
     234                                                        calendar = Calendar.signatures[i].calendar.id; 
     235                                                        timezone = Calendar.signatures[i].calendar.timezone; 
     236                                                        break; 
     237                                                } 
     238                                        } 
     239 
     240                                DataLayer.put('schedulable',  
     241                                { 
     242                                        summary: title,  
     243                                        description: description,  
     244                                        type: '2',  
     245                                        calendar: calendar,  
     246                                        timezone: timezone, 
     247                                                        status: '1', 
     248                                        startTime: new Date().toString('yyyy-MM-dd 00:00:00'), 
     249                                        endTime: new Date().toString('yyyy-MM-dd 00:00:00'), 
     250                                        allDay: '1', 
     251                                        participants:  
     252                                        [{   
     253                                            user: User.me.id,  
     254                                            isOrganizer: 1, 
     255                                            acl: 'row' 
     256                                        }] 
     257                                }); 
     258                                 
     259                        $(componente).qtip('destroy'); 
     260 
     261                    }); 
     262 
     263                            $('.qtip-active .button.advanced').button().click(function(){ 
     264 
     265                                var startEvent = new Date(); 
     266                                        var configData = (startEvent.toString('mm') < 30)  ? {minutes: (30 - parseInt(startEvent.toString('mm')))} : {hours: 1, minutes: '-'+startEvent.toString('mm')}; 
     267                                        startEvent.add(configData); 
     268                         
     269                                                var componente = $(this); 
     270                        var description = $('div.qtip div.add-simple-task textarea[name="description"]').val(); 
     271 
     272                                        taskDetails({ 
     273                            summary: $('div.qtip div.add-simple-task input[name="summary"]').val(), 
     274                            description: description == 'Descrição' ? '' : description, 
     275                                                startTime: startEvent.getTime(), 
     276                                                endTime: dateCalendar.decodeRange(startEvent, (!!User.preferences.defaultCalendar ? (   !!Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration ?   
     277                                                        (Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration) : (User.preferences.defaultDuration)) : (User.preferences.defaultDuration))) 
     278                                        }, true ); 
     279 
     280                        $(componente).qtip('destroy'); 
     281                            }); 
     282                                                                 
     283                                $('.qtip-active .button.cancel').button().click(function(){ 
     284                                        $(componente).qtip('destroy'); 
     285                            }); 
     286                                                         
     287                            $('.qtip-active .button').button(); 
     288                         
     289                        $('div.qtip.qtip-blue.qtip-active').addClass('new-task'); 
     290            } 
     291        } 
     292                }); 
     293 
     294        $(".button.add.add-activity").click(function(event){ 
     295                        var startEvent = new Date(); 
     296                        var configData = (startEvent.toString('mm') < 30)  ? {minutes: (30 - parseInt(startEvent.toString('mm')))} : {hours: 1, minutes: '-'+startEvent.toString('mm')}; 
     297                        startEvent.add(configData);  
     298                         
     299                        activityDetails({  
     300                                startTime: startEvent.getTime(), 
     301                                endTime: dateCalendar.decodeRange(startEvent, (!!User.preferences.defaultCalendar ? (   !!Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration ?   
     302                                                (Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration) : (User.preferences.defaultDuration)) : (User.preferences.defaultDuration))) 
     303                        }, true ); 
     304 
     305        }); 
    149306 
    150307        var calendar = $('#calendar').fullCalendar(DataLayer.merge({  
     
    189346                        year: 'ano' 
    190347                }, 
     348                 
     349                eventRender: function( event, element, view ){ 
    191350                /* 
    192                 eventRender: function( event, element, view ){ 
    193                         $(element).attr( 'event-id', event.id ); 
    194                 }, 
    195                 */ 
     351                         * TODO - Encontrar icones mais filé 
     352                         */ 
     353                        var img_icon = ""; 
     354                        if(event.type == 1) 
     355                                img_icon = "mini-event.png"; 
     356                        if(event.type == 2) 
     357                                img_icon = "mini-task.png"; 
     358                        if(event.type == 3) 
     359                                img_icon = "activity_icon.jpg"; 
     360 
     361                         
     362            element.find(".fc-event-inner.fc-event-skin").prepend($('<img style="width: 11px; height: 13px;" class="" src="../prototype/modules/calendar/img/' + img_icon + '"></img>')); 
     363                }, 
     364                 
    196365                select: function( start, end, allDay, event, view ){ 
    197366                        if (view.name == "month") { 
     
    285454                eventClick: function( evt, event, view ){ 
    286455                        evt.id = evt.id.split('-')[0]; 
    287                         if(evt.selectable){ 
    288                             if(evt.isRepeat){ 
    289                                 $.Zebra_Dialog(evt.title + ' é um evento com repetição.', { 
    290                                         'type':     'question', 
    291                                         'overlay_opacity': '0.5', 
    292                                         'buttons':  ['Editar todas ocorrências', 'Editar essa ocorrência'], 
    293                                         'onClose':  function(clicked) { 
    294                                                 if(clicked == 'Editar todas ocorrências') { 
    295                                                     eventDetails( DataLayer.get( "schedulable", evt.id), true); 
    296                                                 }else{ 
    297                                                     /* 
    298                                                     * TODO - repeat foi adicionado pois melhorias devem ser feitas no rollback do 
    299                                                     *DataLayer, repeat somente é usado quando se trata da criação de um evento 
    300                                                     *pela edição de uma ocorrência. 
    301                                                     */       
    302                                                     var repeat = mount_exception(evt.id, evt.occurrence); 
    303                                                                                                    
    304                                                     $('.calendar-copy-move input[name="typeEvent"]').val("3"); 
    305                                                      
    306                                                     eventDetails(copyAndMoveTo(false , evt.id , false, "3", evt), true, '', false, repeat); 
    307                                                 }        
    308                                         } 
    309                                 }); 
    310                                  
    311                             }else{ 
    312                                 var schedulable = DataLayer.get( "schedulable", evt.id); 
    313                                 schedulable.calendar = evt.calendar; 
    314                                 eventDetails( schedulable, true); 
    315                                  
    316                             } 
    317                                  
     456             
     457            switch (parseInt(evt.type)){ 
     458                case 1: 
     459                    if(evt.selectable){ 
     460                        if(evt.isRepeat){ 
     461                            $.Zebra_Dialog(evt.title + ' é um evento com repetição.', { 
     462                                'type':     'question', 
     463                                'overlay_opacity': '0.5', 
     464                                'buttons':  ['Editar todas ocorrências', 'Editar essa ocorrência'], 
     465                                'onClose':  function(clicked) { 
     466                                    if(clicked == 'Editar todas ocorrências') { 
     467                                        eventDetails( DataLayer.get( "schedulable", evt.id), true); 
     468                                    }else{ 
     469                                        /* 
     470                                        * TODO - repeat foi adicionado pois melhorias devem ser feitas no rollback do 
     471                                        *DataLayer, repeat somente é usado quando se trata da criação de um evento 
     472                                        *pela edição de uma ocorrência. 
     473                                        */       
     474                                        var repeat = mount_exception(evt.id, evt.occurrence); 
     475                                                                                           
     476                                        $('.calendar-copy-move input[name="typeEvent"]').val("3"); 
     477                                         
     478                                        eventDetails(copyAndMoveTo(false , evt.id , false, "3", evt), true, '', false, repeat); 
     479                                    }        
     480                                } 
     481                            }); 
     482                        }else{ 
     483                            var schedulable = DataLayer.get( "schedulable", evt.id); 
     484                            schedulable.group = evt.calendar; 
     485                            eventDetails( schedulable, true); 
     486                            } 
    318487                        } 
     488                        break; 
     489                    case 2: 
     490                        var task = DataLayer.get( "schedulable", evt.id); 
     491                        task.group = evt.calendar; 
     492                        taskDetails( task, true); 
     493                        break; 
     494                    case 3: 
     495                        var activity = DataLayer.get( "schedulable", evt.id); 
     496                        activity.group = evt.calendar; 
     497                        activityDetails( activity, true); 
     498                        break; 
     499            } 
    319500                }, 
    320501                 
     
    322503                        contentMenu(); 
    323504                } 
    324         }, dateCalendar)); 
    325   
     505        }, dateCalendar));       
     506                 
     507                 
    326508        contentMenu(); 
    327509          
     
    346528        });        
    347529        //Todo chamada do metodo que adiciona ao full calendar o botao de listagem de eventos   
    348         //listEvents(); 
     530        printEvents(); 
    349531}); 
     532 
     533 
     534function useDesktopNotification(){ 
     535        return !!parseInt(User.preferences.useDesktopNotification); 
     536} 
Note: See TracChangeset for help on using the changeset viewer.