Ignore:
Timestamp:
07/12/12 17:53:57 (12 years ago)
Author:
thiago
Message:

Ticket #2951 - Nossa montagem das notificacao foram implementadas.

Location:
sandbox/2.4.2-expresso1
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.4.2-expresso1/expressoMail1_2/js/main.js

    r6765 r6774  
    1313var auxNotification; 
    1414 
    15 var notifyNewMessage = []; 
     15var countNewMessage = 0; 
    1616var notifyNewMessageFilter = []; 
    1717 
     
    560560} 
    561561 
    562  
    563 //here 
    564 var window_focus; 
    565 function Notifier() {} 
    566  
    567 function refreshCriteria(){ 
    568         if(auxNotificationCriteriaVetor.length > 0){ 
    569                 for(var i=0; i<auxNotificationCriteriaVetor.length; i++){ 
    570                         auxNotificationCriteriaVetor[i].cancel(); 
    571                 } 
    572         } 
    573 } 
    574 function refreshNewMsg(){ 
    575         if(auxNotification){ 
    576                 auxNotification.cancel(); 
    577                 notifyNewMessage = []; 
    578         } 
    579 } 
    580  
    581 $(document).ready( function(){ 
    582  
    583         $(window).focus(function() { 
    584                 window_focus = true; 
    585         }).blur(function() { 
    586                 window_focus = false; 
    587         }); 
    588          
    589     Notifier.prototype.HasSupport = function() { 
    590       if (window.webkitNotifications)  
    591                         return true; 
    592        else  
    593                         return false; 
    594        
    595     } 
    596  
    597     Notifier.prototype.RequestPermission = function(cb) { 
    598       window.webkitNotifications.requestPermission(); 
    599     } 
    600  
    601     Notifier.prototype.Notify = function(icon, title, body) { 
    602       if (window.webkitNotifications.checkPermission() == 0) { 
    603         var popup = window.webkitNotifications.createNotification( 
    604         icon, title, body); 
    605         popup.show(); 
    606  
    607         return true; 
    608       } 
    609  
    610       return false; 
    611     } 
    612  
    613     $(function() { 
    614                 var notifier = new Notifier(); 
    615                  
    616                 if (window.webkitNotifications.checkPermission() != 0){ 
    617                         notifier.RequestPermission(); 
    618                 } 
    619         }); 
    620 }); 
    621  
    622  
    623562function auto_archiving() { 
    624563        expresso_mail_sync.start_sync(); 
     
    628567function notificationFilter(data, notifyCriteria){ 
    629568         
    630         if(parseInt(notifyCriteria)  && data.length > 0 && !window_focus ){ 
     569        if(parseInt(notifyCriteria)  && data.length > 0 && !activePage ){ 
    631570         
    632571                var howManyCriteria = $('div.gray.filtersDeadline .message-list li').length; 
     
    635574                if(differenceOfNewCriteria > 0){ 
    636575                        for(var i=data.length - differenceOfNewCriteria; i < data.length; i++){ 
    637                  
    638                         notificationCriteriaVetor = webkitNotifications.createNotification("","Critério de filtro",data[i].from+" - "+data[i].subject); 
    639                         notificationCriteriaVetor.onclick = function(){ 
    640                                 window.focus(); 
    641                                 this.cancel(); 
    642                         }; 
    643                          
    644                         notificationCriteriaVetor.show(); 
    645                         auxNotificationCriteriaVetor.push(notificationCriteriaVetor); 
    646                         } 
    647                 } 
    648576         
    649         } 
    650  
     577                                desktopNotification.sentNotification("","Critério de filtro",data[i].from+" - "+data[i].subject); 
     578                                 
     579                                desktopNotification.showNotification(false, function(){ 
     580                                        window.focus(); 
     581                                        this.cancel(); 
     582                                }); 
     583                        } 
     584                } 
     585        } 
    651586} 
    652587 
    653588function refresh(alert_new_msg, notifyPermission){ 
    654  
    655         if(window_focus){ 
    656                 setTimeout('refreshCriteria()', 5000); 
    657                 setTimeout('refreshNewMsg()', 5000); 
    658         } 
    659589 
    660590        getFromAlertRules(); 
    661591        var handler_refresh = function(data){ 
    662                 handlerMessageFilter = function (data) { 
     592                handlerMessageFilter = function (data) {                         
    663593                        notificationFilter(data, notifyPermission); 
    664594                        if(checkAlarmsFilter){ 
     
    682612                        showEmptyBoxMsg(box); 
    683613 
    684                 if (data.length > 0 || notifyNewMessage.length > 0){ 
     614                if (data.length > 0 || countNewMessage > 0){ 
    685615                        for(var i=0;i< data.length;i++){ 
    686616                                if (!onceOpenedHeadersMessages[current_folder]) 
     
    812742                                select_msg("null","reload_msg","null"); 
    813743                 
    814                         if(parseInt(alert_new_msg) && data.new_msgs > 0 && window_focus) 
     744                        if(parseInt(alert_new_msg) && data.new_msgs > 0 && activePage) 
    815745                                alert(data['new_msgs'] > 1 ? get_lang("You have %1 new messages", data['new_msgs']) + "!" : get_lang("You have 1 new message") +"!"); 
    816746                         
    817747                         
    818                         if(parseInt(notifyPermission)  && (data.new_msgs > 0 || notifyNewMessage.length > 0) && !window_focus ){ 
     748                        if(parseInt(notifyPermission)  && (data.new_msgs > 0 || !!countNewMessage) && !activePage ){ 
    819749                         
    820                                 for(var i=0; i<data.length; i++){ 
    821                                         notifyNewMessage.push(true); 
    822                                 } 
    823                                          
    824                                 notification = webkitNotifications.createNotification("","Notificação",notifyNewMessage.length > 1 ? get_lang("You have %1 new messages", notifyNewMessage.length) + "!" : get_lang("You have 1 new message") +"!"); 
    825                                         notification.onclick = function(){ 
    826                                                 window.focus(); 
    827                                                 this.cancel(); 
    828                                                 notifyNewMessage = []; 
    829                                         }; 
    830                                          
    831                                         notification.onclose = function(){ 
    832                                                 notifyNewMessage = []; 
    833                                         } 
    834                                          
    835                                         if(auxNotification) 
    836                                                 auxNotification.cancel(); 
    837                                          
    838                                         notification.ondisplay = function(){ 
    839                                                 auxNotification = notification; 
    840                                         }; 
    841                                         notification.show(); 
    842  
     750                                countNewMessage += data.length; 
     751                                 
     752                                desktopNotificationAux = desktopNotification.sentNotification("","Notificação", countNewMessage > 1 ? get_lang("You have %1 new messages", countNewMessage) + "!" : get_lang("You have 1 new message") + "!"); 
     753                                 
     754                                if(auxNotification !== 'undefined') 
     755                                        desktopNotification.cancelByReference(auxNotification); 
     756                                 
     757                                desktopNotification.showNotification(function(){ 
     758                                        countNewMessage = 0; 
     759                                }, function(){ 
     760                                        window.focus(); 
     761                                        this.cancel(); 
     762                                        countNewMessage = 0; 
     763                                }); 
     764                                 
     765                                auxNotification = desktopNotificationAux; 
    843766                        } 
    844767                        build_quota(data['quota']); 
  • sandbox/2.4.2-expresso1/prototype/modules/calendar/js/calendar.alarms.js

    r6768 r6774  
    2626                    }; 
    2727                */ 
    28                     desktopNotification.showNotification(); 
     28                    desktopNotification.showNotification(false, function(){ 
     29                                window.focus(); 
     30                                this.cancel(); 
     31                        }); 
    2932 
    3033                }else{ 
  • sandbox/2.4.2-expresso1/prototype/modules/calendar/js/desktop.notification.js

    r6768 r6774  
    44 
    55    initDesktopNotificationAddon: function(){ 
    6         if(useDesktopNotification()){ 
     6                if(useDesktopNotification()){ 
    77 
    8             if (!window.webkitNotifications && $.browser.mozilla) 
    9                 this.installDektopNotificationAddon(); 
     8                        if (!window.webkitNotifications && $.browser.mozilla) 
     9                        this.installDektopNotificationAddon(); 
    1010 
    11             if(window.webkitNotifications && window.webkitNotifications.checkPermission()) 
    12                 window.webkitNotifications.requestPermission(); 
     11                        if(window.webkitNotifications && window.webkitNotifications.checkPermission()) 
     12                        window.webkitNotifications.requestPermission(); 
    1313 
    14         } 
     14                } 
    1515    }, 
    1616 
     
    1919        var params = { 
    2020            "Foo": {  
    21                 URL: '../prototype/plugins/desktop.notification/html_desktop_notifications-1.0.7-fx.xpi' , 
    22                 IconURL:'../prototype/plugins/desktop.notification/desktop-notification.png', 
    23                 //Hash:'sha1:28857e60d043447c5f4550853f2d40770b326a13', 
    24                 toString: function () { 
    25                     return this.URL; 
    26                 } 
     21                        URL: '../prototype/plugins/desktop.notification/html_desktop_notifications-1.0.7-fx.xpi' , 
     22                        IconURL:'../prototype/plugins/desktop.notification/desktop-notification.png', 
     23                        //Hash:'sha1:28857e60d043447c5f4550853f2d40770b326a13', 
     24                        toString: function () { 
     25                                return this.URL; 
     26                        } 
    2727            } 
    2828        }; 
     
    3535    verifyComplement: function(){ 
    3636 
    37         if(!window.webkitNotifications) 
    38             return false; 
     37                if(!window.webkitNotifications) 
     38                        return false; 
    3939 
    40         if(window.webkitNotifications.checkPermission()) 
    41             return false; 
     40                if(window.webkitNotifications.checkPermission()) 
     41                        return false; 
    4242 
    43         return true; 
    44  
     43                return true; 
    4544    }, 
    4645 
    4746    sentNotification: function(icon, title, body){ 
    48         this.notification[this.notification.length] = window.webkitNotifications.createNotification( icon, title, body); 
    49     }, 
     47                var reference = this.notification.length; 
     48                this.notification[reference] = window.webkitNotifications.createNotification( icon, title, body); 
     49                return reference; 
     50        }, 
    5051 
     52        cancelByReference: function(index){ 
     53                if(this.notification[index]) 
     54                        this.notification[index].cancel(); 
     55        }, 
     56         
     57         
    5158    showNotification: function(onClose, onClick, onDisplay, onError){ 
    52         var length = this.notification.length -1;  
     59                var length = this.notification.length -1;  
    5360 
    54         this.notification[length].ondisplay = onDisplay; 
    55         this.notification[length].onclose = onClose; 
    56         this.notification[length].onclick = onClick; 
    57         this.notification[length].onerror = onError; 
     61                this.notification[length].ondisplay = onDisplay; 
     62                this.notification[length].onclose = onClose; 
     63                this.notification[length].onclick = onClick; 
     64                this.notification[length].onerror = onError; 
    5865 
    59         this.notification[length].show(); 
     66                this.notification[length].show(); 
    6067    } 
    6168} 
     
    6774            activePage = true;   
    6875            if(!desktopNotification.verifyComplement()){ 
    69                 setTimeout(function(){               
    70                     console.log(desktopNotification.notification); 
    71                      
    72                     for(var i = 0; i < desktopNotification.notification.length; i++){ 
    73                         desktopNotification.notification[i].cancel(); 
    74                     }                
    75                     desktopNotification.notification = []; 
    76  
    77                     console.log(desktopNotification.notification); 
    78                 }, 60000); 
     76                        setTimeout(function(){               
     77                                 
     78                                for(var i = 0; i < desktopNotification.notification.length; i++){ 
     79                                desktopNotification.notification[i].cancel(); 
     80                                }                    
     81                                desktopNotification.notification = []; 
     82                                 
     83                        }, 60000); 
    7984            } 
    8085        }) 
Note: See TracChangeset for help on using the changeset viewer.