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

Side by Side Diff: notification.js

Issue 5000038044401664: Issue 2656 - Fixed notification shown in popup (Closed)
Patch Set: Created June 5, 2015, 4:38 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 | « lib/notificationHelper.js ('k') | no next file » | 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 var backgroundPage = ext.backgroundPage.getWindow(); 18 var backgroundPage = ext.backgroundPage.getWindow();
19 var require = backgroundPage.require; 19 var require = backgroundPage.require;
20 20
21 var Utils = require("utils").Utils; 21 var Utils = require("utils").Utils;
22 var Notification = require("notification").Notification; 22 var Notification = require("notification").Notification;
23 var getActiveNotification = require("notificationHelper").getActiveNotification;
23 24
24 function getDocLinks(notification) 25 function getDocLinks(notification)
25 { 26 {
26 if (!notification.links) 27 if (!notification.links)
27 return []; 28 return [];
28 29
29 var docLinks = []; 30 var docLinks = [];
30 notification.links.forEach(function(link) 31 notification.links.forEach(function(link)
31 { 32 {
32 docLinks.push(Utils.getDocLink(link)); 33 docLinks.push(Utils.getDocLink(link));
(...skipping 21 matching lines...) Expand all
54 if (tagName === "a" && links && links.length) 55 if (tagName === "a" && links && links.length)
55 newElement.href = links.shift(); 56 newElement.href = links.shift();
56 insertMessage(newElement, value, links); 57 insertMessage(newElement, value, links);
57 element.appendChild(newElement); 58 element.appendChild(newElement);
58 59
59 insertMessage(element, after, links); 60 insertMessage(element, after, links);
60 } 61 }
61 62
62 window.addEventListener("load", function() 63 window.addEventListener("load", function()
63 { 64 {
64 var notification = backgroundPage.activeNotification; 65 var notification = getActiveNotification();
65 if (!notification) 66 if (!notification)
66 return; 67 return;
67 68
68 var texts = Notification.getLocalizedTexts(notification); 69 var texts = Notification.getLocalizedTexts(notification);
69 var titleElement = document.getElementById("notification-title"); 70 var titleElement = document.getElementById("notification-title");
70 titleElement.textContent = texts.title; 71 titleElement.textContent = texts.title;
71 72
72 var docLinks = getDocLinks(notification); 73 var docLinks = getDocLinks(notification);
73 var messageElement = document.getElementById("notification-message"); 74 var messageElement = document.getElementById("notification-message");
74 insertMessage(messageElement, texts.message, docLinks); 75 insertMessage(messageElement, texts.message, docLinks);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 var notificationElement = document.getElementById("notification"); 111 var notificationElement = document.getElementById("notification");
111 notificationElement.className = notification.type; 112 notificationElement.className = notification.type;
112 notificationElement.style.display = "block"; 113 notificationElement.style.display = "block";
113 114
114 document.getElementById("close-notification").addEventListener("click", functi on() 115 document.getElementById("close-notification").addEventListener("click", functi on()
115 { 116 {
116 notificationElement.style.display = "none"; 117 notificationElement.style.display = "none";
117 notification.onClicked(); 118 notification.onClicked();
118 }, false); 119 }, false);
119 }, false); 120 }, false);
OLDNEW
« no previous file with comments | « lib/notificationHelper.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld