Changeset 6749


Ignore:
Timestamp:
07/10/12 12:07:35 (12 years ago)
Author:
thiago
Message:

Ticket #2951 - Notificacao parcial da nova mensagem. dfd 105

File:
1 edited

Legend:

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

    r6721 r6749  
    11// Tempo do auto refresh (em milisegundos) 
    2 var time_refresh = 300000; 
     2//var time_refresh = 300000; 
     3var time_refresh = 30000; 
    34// tempo do auto save (em milisegundos) 
    45// 20000 = 20 segundos 
     
    910var checkAlarmsFilter = false; 
    1011 
     12var notifyNewMessage = []; 
     13 
    1114var dynamicPersonalContacts = new Array(); 
    1215var dynamicContacts = new Array(); 
     
    2023        }  
    2124} 
    22          
    23  
    24          
     25 
    2526function mount_url_folder(folders){ 
    2627        return folders.join(cyrus_delimiter); 
     
    555556} 
    556557 
     558 
     559//here 
     560 
     561function Notifier() {} 
     562 
     563$(document).ready( function(){ 
     564         
     565    // Returns "true" if this browser supports notifications. 
     566    Notifier.prototype.HasSupport = function() { 
     567      if (window.webkitNotifications)  
     568                        return true; 
     569       else  
     570                        return false; 
     571       
     572    } 
     573 
     574    // Request permission for this page to send notifications. If allowed, 
     575    // calls function "cb" with true. 
     576    Notifier.prototype.RequestPermission = function(cb) { 
     577      window.webkitNotifications.requestPermission(); 
     578    } 
     579 
     580    // Popup a notification with icon, title, and body. Returns false if 
     581    // permission was not granted. 
     582    Notifier.prototype.Notify = function(icon, title, body) { 
     583      if (window.webkitNotifications.checkPermission() == 0) { 
     584        var popup = window.webkitNotifications.createNotification( 
     585        icon, title, body); 
     586        popup.show(); 
     587 
     588        return true; 
     589      } 
     590 
     591      return false; 
     592    } 
     593 
     594    $(function() { 
     595                var notifier = new Notifier(); 
     596                if (window.webkitNotifications.checkPermission() != 0){ 
     597                        notifier.RequestPermission(); 
     598                } 
     599        }); 
     600}); 
     601 
     602 
    557603function auto_archiving() { 
    558604        expresso_mail_sync.start_sync(); 
    559605        setTimeout('auto_archiving()',600000); 
    560606} 
     607 
     608var auxNotification; 
    561609 
    562610function refresh(alert_new_msg){ 
     
    582630                        showEmptyBoxMsg(box); 
    583631 
    584                 if (data.length > 0){ 
     632                if (data.length > 0 || notifyNewMessage.length > 0){ 
    585633                        for(var i=0;i< data.length;i++){ 
    586634                                if (!onceOpenedHeadersMessages[current_folder]) 
     
    712760                                select_msg("null","reload_msg","null"); 
    713761 
    714                         if(parseInt(alert_new_msg) && data.new_msgs > 0) 
    715                                 alert(data['new_msgs'] > 1 ? get_lang("You have %1 new messages", data['new_msgs']) + "!" : get_lang("You have 1 new message") +"!"); 
     762                        if(parseInt(alert_new_msg) && (data.new_msgs > 0 || notifyNewMessage.length > 0) ){ 
     763                         
     764                        for(var i=0; i<data.length; i++){ 
     765                                        notifyNewMessage.push(true); 
     766                                } 
     767                                         
     768                                notification = webkitNotifications.createNotification("","Notificação",notifyNewMessage.length > 1 ? get_lang("You have %1 new messages", notifyNewMessage.length) + "!" : get_lang("You have 1 new message") +"!"); 
     769                                        notification.onclick = function(){ 
     770                                                window.focus(); 
     771                                                this.cancel(); 
     772                                                notifyNewMessage = []; 
     773                                        }; 
     774                                         
     775                                        if(auxNotification) 
     776                                                auxNotification.cancel(); 
     777                                         
     778                                        notification.ondisplay = function(){ 
     779                                                auxNotification = notification; 
     780                                        }; 
     781                                        notification.show(); 
     782 
     783                        } 
    716784                        build_quota(data['quota']); 
    717785                } 
Note: See TracChangeset for help on using the changeset viewer.