Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/notificationHelper.js

Issue 29326181: Issue 3022 - Implemented new notification type for normal messages (Closed)
Patch Set: Created Sept. 9, 2015, 1:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | notification.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 24 matching lines...) Expand all
35 if (navigator.platform.indexOf("Linux") == -1) 35 if (navigator.platform.indexOf("Linux") == -1)
36 return true; 36 return true;
37 if (Services.vc.compare(info.applicationVersion, "35") >= 0) 37 if (Services.vc.compare(info.applicationVersion, "35") >= 0)
38 return true; 38 return true;
39 } 39 }
40 return false; 40 return false;
41 })(); 41 })();
42 42
43 function prepareNotificationIconAndPopup() 43 function prepareNotificationIconAndPopup()
44 { 44 {
45 let animateIcon = (activeNotification.type != "question"); 45 let animateIcon = (activeNotification.type == "critical"
Sebastian Noack 2015/09/09 13:35:36 I wonder whether we should use global objects used
Thomas Greiner 2015/09/09 15:32:36 Done. However, I decided to implement a function t
46 || activeNotification.type == "information");
46 activeNotification.onClicked = function() 47 activeNotification.onClicked = function()
47 { 48 {
48 if (animateIcon) 49 if (animateIcon)
49 stopIconAnimation(); 50 stopIconAnimation();
50 notificationClosed(); 51 notificationClosed();
51 }; 52 };
52 if (animateIcon) 53 if (animateIcon)
53 startIconAnimation(activeNotification.type); 54 startIconAnimation(activeNotification.type);
54 } 55 }
55 56
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 chrome.notifications.onClicked.addListener(clearActiveNotification); 129 chrome.notifications.onClicked.addListener(clearActiveNotification);
129 chrome.notifications.onClosed.addListener(notificationClosed); 130 chrome.notifications.onClosed.addListener(notificationClosed);
130 } 131 }
131 132
132 function showNotification(notification) 133 function showNotification(notification)
133 { 134 {
134 if (activeNotification && activeNotification.id == notification.id) 135 if (activeNotification && activeNotification.id == notification.id)
135 return; 136 return;
136 137
137 activeNotification = notification; 138 activeNotification = notification;
138 if (activeNotification.type == "critical" || activeNotification.type == "quest ion") 139 if (activeNotification.type == "critical"
140 || activeNotification.type == "question"
141 || activeNotification.type == "normal")
139 { 142 {
140 let texts = NotificationStorage.getLocalizedTexts(notification); 143 let texts = NotificationStorage.getLocalizedTexts(notification);
141 let title = texts.title || ""; 144 let title = texts.title || "";
142 let message = texts.message ? texts.message.replace(/<\/?(a|strong)>/g, "") : ""; 145 let message = texts.message ? texts.message.replace(/<\/?(a|strong)>/g, "") : "";
143 let iconUrl = ext.getURL("icons/detailed/abp-128.png"); 146 let iconUrl = ext.getURL("icons/detailed/abp-128.png");
144 let hasLinks = activeNotification.links && activeNotification.links.length > 0; 147 let hasLinks = activeNotification.links && activeNotification.links.length > 0;
145 148
146 if (canUseChromeNotifications) 149 if (canUseChromeNotifications)
147 { 150 {
148 let opts = { 151 let opts = {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 * Gets the active notification to be shown if any. 236 * Gets the active notification to be shown if any.
234 * 237 *
235 * @return {?object} 238 * @return {?object}
236 */ 239 */
237 exports.getActiveNotification = function() 240 exports.getActiveNotification = function()
238 { 241 {
239 return activeNotification; 242 return activeNotification;
240 }; 243 };
241 244
242 NotificationStorage.addShowListener(showNotification); 245 NotificationStorage.addShowListener(showNotification);
OLDNEW
« no previous file with comments | « no previous file | notification.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld