Ignore:
Timestamp:
01/15/12 15:23:09 (12 years ago)
Author:
acoutinho
Message:

Ticket #2434 - Melhorias e correcoes de bugs e limpeza de codigo

Location:
trunk/prototype/modules/calendar/js
Files:
2 edited

Legend:

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

    r5376 r5381  
    177177//DataLayer.poll( "schedulable" ); 
    178178 
    179 DataLayer.listen( "schedulable", function( status ){ 
     179DataLayer.listen( "schedulable", function( status, updateData){ 
    180180   
    181181    if( status === 'serverclient' ){ 
     
    193193                                pageselectCallback("", 0); 
    194194                }); 
    195     } 
     195    }    
    196196}); 
    197197 
  • trunk/prototype/modules/calendar/js/helpers.js

    r5376 r5381  
    214214                                                                                canDiscardEventDialog = true; 
    215215                                                                                UI.dialogs.addEvent.dialog('close'); 
     216                                                                        }else{ 
     217                                                                                zebraDiscardEventDialog = false; 
    216218                                                                        } 
    217219                                                                         
     
    243245            var tabs = UI.dialogs.addEvent.children('.content').tabs(); 
    244246                var calendar = DataLayer.get('calendar', objEvent.calendar); 
    245                  
    246  
    247                 UI.dialogs.addEvent.find(':input').change(function(event){ 
    248                         if (event.keyCode != '27' && event.keyCode != '13') 
    249                                 canDiscardEventDialog = false; 
    250                 }).keydown(function(event){ 
    251                         if (event.keyCode != '27' && event.keyCode != '13') 
    252                                 canDiscardEventDialog = false; 
    253                 }); 
    254                  
     247                                 
    255248                if (calendar.timezone != objEvent.timezone){ 
    256249                        UI.dialogs.addEvent.find('.calendar-addevent-details-txt-timezone').find('option[value="'+objEvent.timezone+'"]').attr('selected','selected').trigger('change'); 
     
    275268                        } 
    276269                }); 
     270                 
     271                /*Seleciona a agenda padrão para criação de um evento*/ 
     272                UI.dialogs.addEvent.find('option[value="'+User.preferences.defaultCalendar+'"]').attr('selected','selected').trigger('change'); 
    277273                 
    278274                /*Adicionar alarms padrões, quando alterado a agenda do usuário*/                
     
    497493                                                var isValidMail = newAttendeeEmail.match(/^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/); 
    498494                                                if (!isValidMail) { 
    499                                                         currentTip.find('.messages').removeClass('hidden').find('.message label').append('Email inválido.'); 
     495                                                        currentTip.find('.messages').removeClass('hidden').find('.message label').html('Email inválido.'); 
    500496                                                        return false; 
    501497                                                } 
     
    770766                        }); 
    771767                }); 
     768                UI.dialogs.addEvent.find(':input').change(function(event){ 
     769                        if (event.keyCode != '27' && event.keyCode != '13') 
     770                                canDiscardEventDialog = false; 
     771                }).keydown(function(event){ 
     772                        if (event.keyCode != '27' && event.keyCode != '13') 
     773                                canDiscardEventDialog = false; 
     774                }); 
     775                 
    772776                UI.dialogs.addEvent.dialog('open'); 
    773777        }); 
     
    10581062function remove_calendar(){ 
    10591063        /* Pode ser assim $('.cal-list-options-btn.ui-state-active').attr('class').replace(/[a-zA-Z-]+/g, ''); */ 
    1060         $.Zebra_Dialog('Todos os eventos desta agenda serão apagados. Deseja prosseguir com a operação ?', { 
     1064        $.Zebra_Dialog('Todos os eventos desta agenda serão removidos. Deseja prosseguir com a operação?', { 
    10611065                'type':     'question', 
    10621066                'overlay_opacity': '0.5', 
     
    12171221                                $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-e"); 
    12181222            }); 
    1219  
     1223                 
    12201224            $(".signed-calendars a.title-signed-calendars").click(function() { 
    12211225                        $(".signed-calendars ul.signed-list-calendars").toggleClass( "hidden"); 
     
    12731277 
    12741278function paginatorSearch(currentView){ 
    1275         if(parseInt($(currentView+' [name = results]').val()) > 25){ 
    1276                 $(currentView+' .header-paginator .fc-header-left .fc-button.fc-button-next .fc-button-inner').hover( 
    1277                                 function(){ 
    1278                                         $(this).addClass('fc-state-hover'); 
    1279                                 }, 
    1280                                 function(){ 
    1281                                         $(this).removeClass('fc-state-hover'); 
    1282                         }).mousedown(function(){ 
    1283                                 $(this).addClass('fc-state-down'); 
    1284                         }).mouseup(function(){ 
    1285                                 $(this).removeClass('fc-state-down'); 
    1286                                 $('.events-list.events-list-win.active').removeClass('active'); 
    1287                                 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($('[name = page_index]').val())) +1)); 
    1288                         }); 
    1289                 } 
    1290                 if(parseInt($(currentView+' [name = page_index]').val()) > 0){ 
    1291                         $(currentView+' .header-paginator .fc-header-left .fc-button.fc-button-prev .fc-button-inner').hover( 
    1292                                 function(){ 
    1293                                         $(this).addClass('fc-state-hover'); 
    1294                                 }, 
    1295                                 function(){ 
    1296                                         $(this).removeClass('fc-state-hover'); 
    1297                         }).mousedown(function(){ 
    1298                                 $(this).addClass('fc-state-down'); 
    1299                         }).mouseup(function(){ 
    1300                                 $(this).removeClass('fc-state-down'); 
    1301                                 $('.events-list.events-list-win.active').removeClass('active'); 
    1302                                 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($('[name = page_index]').val())) -1)); 
    1303                         }); 
    1304                 }                        
     1279        $(currentView+' .header-paginator .fc-header-left .fc-button').hover( 
     1280                        function(){ 
     1281                                $(this).addClass('fc-state-hover'); 
     1282                        }, 
     1283                        function(){ 
     1284                                $(this).removeClass('fc-state-hover'); 
     1285                }).mousedown(function(){ 
     1286                        $(this).addClass('fc-state-down'); 
     1287                }).mouseup(function(){ 
     1288                        $(this).removeClass('fc-state-down'); 
     1289                        $('.events-list.events-list-win.active').removeClass('active'); 
     1290                        var paginator = $(this).attr('class'); 
     1291                        if(paginator.indexOf('next') > 0){ 
     1292                                if(parseInt($(currentView+' [name = results]').val()) > 25) 
     1293                                        pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) +1)); 
     1294                        }else{ 
     1295                                if(parseInt($(currentView+' [name = page_index]').val()) > 0) 
     1296                                        pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) -1)); 
     1297                        } 
     1298                }); 
    13051299} 
    13061300 
     
    13371331                        $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button-'+((view == 'day' || view == 'week') ? 'agenda'+view : view )).addClass('fc-state-active'); 
    13381332                $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right').addClass('list-right'); 
    1339                 $(currentView+' .header-paginator .fc-header-right .fc-button-agendaday').hover( 
     1333                 
     1334                $(currentView+' .header-paginator .fc-header-right .fc-button').hover( 
    13401335                                function(){ 
    13411336                                        $(this).addClass('fc-state-hover'); 
     
    13471342                                $(this).addClass('fc-state-active'); 
    13481343                        }).mouseup(function(){ 
    1349                                 pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'day'); 
    1350                         }); 
    1351                          
    1352                 $(currentView+' .header-paginator .fc-header-right .fc-button-agendaweek').hover( 
    1353                                 function(){ 
    1354                                         $(this).addClass('fc-state-hover'); 
    1355                                 }, 
    1356                                 function(){ 
    1357                                         $(this).removeClass('fc-state-hover'); 
    1358                         }).mousedown(function(){ 
    1359                                 $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button').removeClass('fc-state-active') 
    1360                                 $(this).addClass('fc-state-active'); 
    1361                         }).mouseup(function(){ 
    1362                                 pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'week'); 
    1363                         });      
    1364                          
    1365                 $(currentView+' .header-paginator .fc-header-right .fc-button-month').hover( 
    1366                                 function(){ 
    1367                                         $(this).addClass('fc-state-hover'); 
    1368                                 }, 
    1369                                 function(){ 
    1370                                         $(this).removeClass('fc-state-hover'); 
    1371                         }).mousedown(function(){ 
    1372                                 $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button').removeClass('fc-state-active') 
    1373                                 $(this).addClass('fc-state-active'); 
    1374                         }).mouseup(function(){ 
    1375                                 pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'month'); 
    1376                         }); 
    1377                          
    1378                 $(currentView+' .header-paginator .fc-header-right .fc-button-year').hover( 
    1379                                 function(){ 
    1380                                         $(this).addClass('fc-state-hover'); 
    1381                                 }, 
    1382                                 function(){ 
    1383                                         $(this).removeClass('fc-state-hover'); 
    1384                         }).mousedown(function(){ 
    1385                                 $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button').removeClass('fc-state-active') 
    1386                                 $(this).addClass('fc-state-active'); 
    1387                         }).mouseup(function(){ 
    1388                                 pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'year'); 
    1389                         }); 
    1390                  
    1391                  
    1392                 $(currentView+' .header-paginator .fc-header-left .fc-button.fc-button-next .fc-button-inner').hover( 
     1344                                var goView = $(this).attr('class'); 
     1345                                if(goView.indexOf('agendaDay') > 0) 
     1346                                        pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'day'); 
     1347                                else if(goView.indexOf('month') > 0) 
     1348                                        pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'month'); 
     1349                                else if(goView.indexOf('year') > 0) 
     1350                                        pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'year'); 
     1351                                else if(goView.indexOf('agendaWeek') > 0) 
     1352                                        pageselectCallback($(currentView+' [name = keyword]').val(), 0, '', 'week'); 
     1353 
     1354                        }); 
     1355 
     1356                $(currentView+' .header-paginator .fc-header-left .fc-button').hover( 
    13931357                                function(){ 
    13941358                                        $(this).addClass('fc-state-hover'); 
     
    14001364                        }).mouseup(function(){ 
    14011365                                $(this).removeClass('fc-state-down'); 
    1402                                 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($('[name = page_index]').val())) +1), '', view); 
    1403                         }); 
    1404                  
    1405                         $(currentView+' .header-paginator .fc-header-left .fc-button.fc-button-prev .fc-button-inner').hover( 
    1406                                 function(){ 
    1407                                         $(this).addClass('fc-state-hover'); 
    1408                                 }, 
    1409                                 function(){ 
    1410                                         $(this).removeClass('fc-state-hover'); 
    1411                         }).mousedown(function(){ 
    1412                                 $(this).addClass('fc-state-down'); 
    1413                         }).mouseup(function(){ 
    1414                                 $(this).removeClass('fc-state-down'); 
    1415                                 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($('[name = page_index]').val())) -1), '', view); 
    1416                         });      
     1366                                var paginator = $(this).attr('class'); 
     1367                                if(paginator.indexOf('next') > 0) 
     1368                                        pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($('[name = page_index]').val())) +1), '', view); 
     1369                                else 
     1370                                        pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($('[name = page_index]').val())) -1), '', view); 
     1371                                });      
    14171372} 
    14181373 
     
    15081463                                        $(this).siblings("div.details-event-list").toggleClass("hidden") 
    15091464                                        .find('.button.delete').click(function(){ 
    1510                                                 DataLayer.remove('schedulable', $(this).siblings('[name="eventid"]').val()); 
     1465                                                var eventId = $(this).siblings('[name="eventid"]').val(); 
     1466                                                $.Zebra_Dialog('Tem certeza que deseja excluir o evento?', { 
     1467                                                        'type':     'question', 
     1468                                                        'overlay_opacity': '0.5', 
     1469                                                        'buttons':  ['Sim', 'Não'], 
     1470                                                        'onClose':  function(clicked) { 
     1471                                                                if(clicked == 'Sim'){ 
     1472                                                                        DataLayer.remove('schedulable', eventId); 
     1473                                                                } 
     1474                                                        } 
     1475                                                }); 
    15111476                                        }) 
    15121477                                        .end().find('.button.edit').click(function(){                            
     
    15331498} 
    15341499 
    1535 function show_modal_import_export(tab) { 
     1500function show_modal_import_export(tab, calendarId) { 
    15361501    DataLayer.render( 'templates/import_export.ejs', {calendars: Calendar.calendars, owner: User.me.id}, function( html ){ 
    15371502 
     
    15541519        UI.dialogs.importCalendar.find('.button').button(); 
    15551520 
     1521                tabsImportExport.find('option[value="'+calendarId+'"]').attr('selected','selected').trigger('change'); 
     1522                 
     1523                 
    15561524        UI.dialogs.importCalendar.find(".menu-import-event")         
    1557             .children(".import").click(function(){ 
    1558                
    1559                         $('.import-event-form', UI.dialogs.importCalendar).submit(); 
     1525            .children(".import").click(function(data){ 
     1526                        $('.import-event-form', UI.dialogs.importCalendar).submit();                     
    15601527                        UI.dialogs.importCalendar.dialog("close"); 
    15611528                        /** 
Note: See TracChangeset for help on using the changeset viewer.