Changeset 6774 for sandbox/2.4.2-expresso1
- Timestamp:
- 07/12/12 17:53:57 (12 years ago)
- 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 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']); -
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/calendar.alarms.js
r6768 r6774 26 26 }; 27 27 */ 28 desktopNotification.showNotification(); 28 desktopNotification.showNotification(false, function(){ 29 window.focus(); 30 this.cancel(); 31 }); 29 32 30 33 }else{ -
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/desktop.notification.js
r6768 r6774 4 4 5 5 initDesktopNotificationAddon: function(){ 6 if(useDesktopNotification()){6 if(useDesktopNotification()){ 7 7 8 9 this.installDektopNotificationAddon();8 if (!window.webkitNotifications && $.browser.mozilla) 9 this.installDektopNotificationAddon(); 10 10 11 12 window.webkitNotifications.requestPermission();11 if(window.webkitNotifications && window.webkitNotifications.checkPermission()) 12 window.webkitNotifications.requestPermission(); 13 13 14 }14 } 15 15 }, 16 16 … … 19 19 var params = { 20 20 "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 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 } 27 27 } 28 28 }; … … 35 35 verifyComplement: function(){ 36 36 37 if(!window.webkitNotifications)38 37 if(!window.webkitNotifications) 38 return false; 39 39 40 if(window.webkitNotifications.checkPermission())41 40 if(window.webkitNotifications.checkPermission()) 41 return false; 42 42 43 return true; 44 43 return true; 45 44 }, 46 45 47 46 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 }, 50 51 52 cancelByReference: function(index){ 53 if(this.notification[index]) 54 this.notification[index].cancel(); 55 }, 56 57 51 58 showNotification: function(onClose, onClick, onDisplay, onError){ 52 var length = this.notification.length -1;59 var length = this.notification.length -1; 53 60 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; 58 65 59 this.notification[length].show();66 this.notification[length].show(); 60 67 } 61 68 } … … 67 74 activePage = true; 68 75 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); 79 84 } 80 85 })
Note: See TracChangeset
for help on using the changeset viewer.