Changeset 6765 for sandbox/2.4.2-expresso1/expressoMail1_2/js
- Timestamp:
- 07/12/12 11:34:27 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.4.2-expresso1/expressoMail1_2/js/main.js
r6753 r6765 10 10 var checkAlarmsFilter = false; 11 11 12 var auxNotificationCriteriaVetor = []; 13 var auxNotification; 14 12 15 var notifyNewMessage = []; 16 var notifyNewMessageFilter = []; 13 17 14 18 var dynamicPersonalContacts = new Array(); … … 558 562 559 563 //here 560 564 var window_focus; 561 565 function Notifier() {} 562 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 563 581 $(document).ready( function(){ 582 583 $(window).focus(function() { 584 window_focus = true; 585 }).blur(function() { 586 window_focus = false; 587 }); 564 588 565 // Returns "true" if this browser supports notifications.566 589 Notifier.prototype.HasSupport = function() { 567 590 if (window.webkitNotifications) … … 572 595 } 573 596 574 // Request permission for this page to send notifications. If allowed,575 // calls function "cb" with true.576 597 Notifier.prototype.RequestPermission = function(cb) { 577 598 window.webkitNotifications.requestPermission(); 578 599 } 579 600 580 // Popup a notification with icon, title, and body. Returns false if581 // permission was not granted.582 601 Notifier.prototype.Notify = function(icon, title, body) { 583 602 if (window.webkitNotifications.checkPermission() == 0) { … … 594 613 $(function() { 595 614 var notifier = new Notifier(); 596 /*if(notifier.HasSupport){597 alert("Seu navegador não dá suporte!");598 //firefox/downloads/latest/221523/addon-221523-latest.xpi?src=dp-btn-primary599 }*/600 615 601 616 if (window.webkitNotifications.checkPermission() != 0){ … … 611 626 } 612 627 613 var auxNotification; 614 615 function refresh(alert_new_msg, notification){ 628 function notificationFilter(data, notifyCriteria){ 629 630 if(parseInt(notifyCriteria) && data.length > 0 && !window_focus ){ 631 632 var howManyCriteria = $('div.gray.filtersDeadline .message-list li').length; 633 var differenceOfNewCriteria = data.length - howManyCriteria; 634 635 if(differenceOfNewCriteria > 0){ 636 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 } 648 649 } 650 651 } 652 653 function refresh(alert_new_msg, notifyPermission){ 654 655 if(window_focus){ 656 setTimeout('refreshCriteria()', 5000); 657 setTimeout('refreshNewMsg()', 5000); 658 } 616 659 617 660 getFromAlertRules(); 618 661 var handler_refresh = function(data){ 619 if(checkAlarmsFilter){ 620 handlerMessageFilter = function (data) { 662 handlerMessageFilter = function (data) { 663 notificationFilter(data, notifyPermission); 664 if(checkAlarmsFilter){ 621 665 alarmFollowupflagged('filtersAlarms', data); 622 666 } 623 /* Busca nas pastas indexadas para ver se há novas mensagens com a flag $FilteredMessage */ 624 cExecute ("$this.imap_functions.getFlaggedAlertMessages&folders="+fromRules, handlerMessageFilter); 625 } 626 checkAlarmsFilter = true; 667 checkAlarmsFilter = true; 668 669 } 670 /* Busca nas pastas indexadas para ver se há novas mensagens com a flag $FilteredMessage */ 671 cExecute ("$this.imap_functions.getFlaggedAlertMessages&folders="+fromRules, handlerMessageFilter); 672 627 673 if(data['msg_range_end']) 628 674 if(data['msg_range_end'] > 0) … … 766 812 select_msg("null","reload_msg","null"); 767 813 768 if(parseInt(alert_new_msg) && data.new_msgs > 0 )814 if(parseInt(alert_new_msg) && data.new_msgs > 0 && window_focus) 769 815 alert(data['new_msgs'] > 1 ? get_lang("You have %1 new messages", data['new_msgs']) + "!" : get_lang("You have 1 new message") +"!"); 770 816 771 817 772 if(parseInt(notif ication) && (data.new_msgs > 0 || notifyNewMessage.length > 0)){818 if(parseInt(notifyPermission) && (data.new_msgs > 0 || notifyNewMessage.length > 0) && !window_focus ){ 773 819 774 for(var i=0; i<data.length; i++){820 for(var i=0; i<data.length; i++){ 775 821 notifyNewMessage.push(true); 776 822 } … … 782 828 notifyNewMessage = []; 783 829 }; 830 831 notification.onclose = function(){ 832 notifyNewMessage = []; 833 } 784 834 785 835 if(auxNotification)
Note: See TracChangeset
for help on using the changeset viewer.