Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 }); | 281 }); |
282 } | 282 } |
283 | 283 |
284 function prepareNotificationIconAndPopup() | 284 function prepareNotificationIconAndPopup() |
285 { | 285 { |
286 activeNotification.onClicked = function() | 286 activeNotification.onClicked = function() |
287 { | 287 { |
288 iconAnimation.stop(); | 288 iconAnimation.stop(); |
289 activeNotification = null; | 289 activeNotification = null; |
290 }; | 290 }; |
291 | 291 |
292 iconAnimation.update(activeNotification.severity); | 292 iconAnimation.update(activeNotification.severity); |
Felix Dahlke
2014/02/27 14:10:39
Nit: Probably whitespace differences, this shouldn
| |
293 } | 293 } |
294 | 294 |
295 function openNotificationLinks() | 295 function openNotificationLinks() |
296 { | 296 { |
297 if (activeNotification.links) | 297 if (activeNotification.links) |
298 { | 298 { |
299 activeNotification.links.forEach(function(link) | 299 activeNotification.links.forEach(function(link) |
300 { | 300 { |
301 ext.windows.getLastFocused(function(win) | 301 ext.windows.getLastFocused(function(win) |
302 { | 302 { |
303 win.openTab(Utils.getDocLink(link)); | 303 win.openTab(Utils.getDocLink(link)); |
304 }); | 304 }); |
305 }); | 305 }); |
306 } | 306 } |
307 prepareNotificationIconAndPopup(); | |
308 } | 307 } |
309 | 308 |
310 function notificationButtonClick(id, index) | 309 function notificationButtonClick(id, index) |
311 { | 310 { |
312 if (activeNotification.links && activeNotification.links[index]) | 311 if (activeNotification.links && activeNotification.links[index]) |
313 { | 312 { |
314 ext.windows.getLastFocused(function(win) | 313 ext.windows.getLastFocused(function(win) |
315 { | 314 { |
316 win.openTab(Utils.getDocLink(activeNotification.links[index])); | 315 win.openTab(Utils.getDocLink(activeNotification.links[index])); |
317 }); | 316 }); |
318 } | 317 } |
319 prepareNotificationIconAndPopup(); | |
320 } | 318 } |
321 | 319 |
322 function showNotification(notification) | 320 function showNotification(notification) |
323 { | 321 { |
324 activeNotification = notification; | 322 activeNotification = notification; |
325 if (activeNotification.severity === "critical") | 323 if (activeNotification.severity === "critical") |
326 { | 324 { |
327 var hasWebkitNotifications = typeof webkitNotifications !== "undefined"; | 325 var hasWebkitNotifications = typeof webkitNotifications !== "undefined"; |
328 if (hasWebkitNotifications && "createHTMLNotification" in webkitNotification s) | 326 if (hasWebkitNotifications && "createHTMLNotification" in webkitNotification s) |
329 { | 327 { |
(...skipping 24 matching lines...) Expand all Loading... | |
354 opts.buttons.push({title: match[1]}); | 352 opts.buttons.push({title: match[1]}); |
355 | 353 |
356 var notification = ext.browserNotifications; | 354 var notification = ext.browserNotifications; |
357 notification.create("", opts, function() {}); | 355 notification.create("", opts, function() {}); |
358 notification.onClosed.addListener(prepareNotificationIconAndPopup); | 356 notification.onClosed.addListener(prepareNotificationIconAndPopup); |
359 notification.onButtonClicked.addListener(notificationButtonClick); | 357 notification.onButtonClicked.addListener(notificationButtonClick); |
360 } | 358 } |
361 else if (hasWebkitNotifications && "createNotification" in webkitNotificatio ns) | 359 else if (hasWebkitNotifications && "createNotification" in webkitNotificatio ns) |
362 { | 360 { |
363 if (hasLinks) | 361 if (hasLinks) |
364 message += " " + ext.i18n.getMessage("notification_without_buttons"); | 362 message += " " + ext.i18n.getMessage("notification_without_buttons"); |
Felix Dahlke
2014/02/21 19:17:37
Should be in a new paragraph IMO, likewise below f
saroyanm
2014/02/22 10:22:15
webkitNotifications.createNotification removes any
| |
365 | 363 |
366 var notification = webkitNotifications.createNotification(iconUrl, title, message); | 364 var notification = webkitNotifications.createNotification(iconUrl, title, message); |
367 notification.show(); | 365 notification.show(); |
368 notification.addEventListener("close", prepareNotificationIconAndPopup, fa lse); | 366 notification.addEventListener("close", prepareNotificationIconAndPopup, fa lse); |
369 notification.addEventListener("click", openNotificationLinks, false); | 367 notification.addEventListener("click", openNotificationLinks, false); |
370 } | 368 } |
371 else | 369 else |
372 { | 370 { |
373 var message = title + "\n" + message; | 371 var message = title + "\n" + message; |
374 if (hasLinks) | 372 if (hasLinks) |
375 message += "\n\n" + ext.i18n.getMessage("notification_with_buttons"); | 373 message += "\n\n" + ext.i18n.getMessage("notification_with_buttons"); |
376 | 374 |
377 var notification = confirm(message); | 375 if (confirm(message)) |
Thomas Greiner
2014/02/27 10:07:32
Nit: Change to…
if (confirm(message))
openNotif
| |
378 if (notification == true) | 376 { |
379 openNotificationLinks(); | 377 openNotificationLinks(); |
378 prepareNotificationIconAndPopup(); | |
379 } | |
380 else | |
381 prepareNotificationIconAndPopup(); | |
380 } | 382 } |
381 } | 383 } |
382 else | 384 else |
383 prepareNotificationIconAndPopup(); | 385 prepareNotificationIconAndPopup(); |
384 } | 386 } |
385 | 387 |
386 ext.onMessage.addListener(function (msg, sender, sendResponse) | 388 ext.onMessage.addListener(function (msg, sender, sendResponse) |
387 { | 389 { |
388 switch (msg.type) | 390 switch (msg.type) |
389 { | 391 { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 tab.sendMessage({type: "clickhide-deactivate"}); | 497 tab.sendMessage({type: "clickhide-deactivate"}); |
496 refreshIconAndContextMenu(tab); | 498 refreshIconAndContextMenu(tab); |
497 }); | 499 }); |
498 | 500 |
499 setTimeout(function() | 501 setTimeout(function() |
500 { | 502 { |
501 var notificationToShow = Notification.getNextToShow(); | 503 var notificationToShow = Notification.getNextToShow(); |
502 if (notificationToShow) | 504 if (notificationToShow) |
503 showNotification(notificationToShow); | 505 showNotification(notificationToShow); |
504 }, 3 * 60 * 1000); | 506 }, 3 * 60 * 1000); |
LEFT | RIGHT |