Changeset 6774 for sandbox/2.4.2-expresso1/expressoMail1_2/js/main.js
- Timestamp:
- 07/12/12 17:53:57 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.4.2-expresso1/expressoMail1_2/js/main.js
r6765 r6774 13 13 var auxNotification; 14 14 15 var notifyNewMessage = [];15 var countNewMessage = 0; 16 16 var notifyNewMessageFilter = []; 17 17 … … 560 560 } 561 561 562 563 //here564 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 else593 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 623 562 function auto_archiving() { 624 563 expresso_mail_sync.start_sync(); … … 628 567 function notificationFilter(data, notifyCriteria){ 629 568 630 if(parseInt(notifyCriteria) && data.length > 0 && ! window_focus){569 if(parseInt(notifyCriteria) && data.length > 0 && !activePage ){ 631 570 632 571 var howManyCriteria = $('div.gray.filtersDeadline .message-list li').length; … … 635 574 if(differenceOfNewCriteria > 0){ 636 575 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 576 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 } 651 586 } 652 587 653 588 function refresh(alert_new_msg, notifyPermission){ 654 655 if(window_focus){656 setTimeout('refreshCriteria()', 5000);657 setTimeout('refreshNewMsg()', 5000);658 }659 589 660 590 getFromAlertRules(); 661 591 var handler_refresh = function(data){ 662 handlerMessageFilter = function (data) { 592 handlerMessageFilter = function (data) { 663 593 notificationFilter(data, notifyPermission); 664 594 if(checkAlarmsFilter){ … … 682 612 showEmptyBoxMsg(box); 683 613 684 if (data.length > 0 || notifyNewMessage.length> 0){614 if (data.length > 0 || countNewMessage > 0){ 685 615 for(var i=0;i< data.length;i++){ 686 616 if (!onceOpenedHeadersMessages[current_folder]) … … 812 742 select_msg("null","reload_msg","null"); 813 743 814 if(parseInt(alert_new_msg) && data.new_msgs > 0 && window_focus)744 if(parseInt(alert_new_msg) && data.new_msgs > 0 && activePage) 815 745 alert(data['new_msgs'] > 1 ? get_lang("You have %1 new messages", data['new_msgs']) + "!" : get_lang("You have 1 new message") +"!"); 816 746 817 747 818 if(parseInt(notifyPermission) && (data.new_msgs > 0 || notifyNewMessage.length > 0) && !window_focus){748 if(parseInt(notifyPermission) && (data.new_msgs > 0 || !!countNewMessage) && !activePage ){ 819 749 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; 843 766 } 844 767 build_quota(data['quota']);
Note: See TracChangeset
for help on using the changeset viewer.