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

Side by Side Diff: notification.js

Issue 5749582424178688: Ported over anti-adblock message notification (Closed)
Patch Set: Created March 21, 2014, 1:29 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 | « notification.html ('k') | webrequest.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 <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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 insertMessage(element, after, links); 59 insertMessage(element, after, links);
60 } 60 }
61 61
62 window.addEventListener("load", function() 62 window.addEventListener("load", function()
63 { 63 {
64 var notification = backgroundPage.activeNotification; 64 var notification = backgroundPage.activeNotification;
65 if (!notification) 65 if (!notification)
66 return; 66 return;
67 67
68 if (notification.onClicked)
69 notification.onClicked();
70
71 var texts = Notification.getLocalizedTexts(notification); 68 var texts = Notification.getLocalizedTexts(notification);
72 var titleElement = document.getElementById("notification-title"); 69 var titleElement = document.getElementById("notification-title");
73 titleElement.textContent = texts.title; 70 titleElement.textContent = texts.title;
74 71
75 var docLinks = getDocLinks(notification); 72 var docLinks = getDocLinks(notification);
76 var messageElement = document.getElementById("notification-message"); 73 var messageElement = document.getElementById("notification-message");
77 insertMessage(messageElement, texts.message, docLinks); 74 insertMessage(messageElement, texts.message, docLinks);
78 75
79 messageElement.addEventListener("click", function(event) 76 messageElement.addEventListener("click", function(event)
80 { 77 {
81 var link = event.target; 78 var link = event.target;
82 while (link && link !== messageElement && link.localName !== "a") 79 while (link && link !== messageElement && link.localName !== "a")
83 link = link.parentNode; 80 link = link.parentNode;
84 if (!link) 81 if (!link)
85 return; 82 return;
86 event.preventDefault(); 83 event.preventDefault();
87 event.stopPropagation(); 84 event.stopPropagation();
88 ext.windows.getLastFocused(function(win) { win.openTab(link.href); }); 85 ext.windows.getLastFocused(function(win) { win.openTab(link.href); });
89 }); 86 });
90 87
88 if (notification.type == "question")
89 {
90 document.getElementById("notification-question").addEventListener("click", f unction(event)
91 {
92 event.preventDefault();
93 event.stopPropagation();
94
95 var approved = false;
96 switch (event.target.id)
97 {
98 case "notification-yes":
99 approved = true;
100 case "notification-no":
101 Notification.triggerQuestionListeners(notification.id, approved);
102 Notification.markAsShown(notification.id);
103 notification.onClicked();
104 break;
105 }
106 window.close();
107 }, true);
108 }
109
91 var notificationElement = document.getElementById("notification"); 110 var notificationElement = document.getElementById("notification");
92 notificationElement.className = notification.severity; 111 notificationElement.className = notification.type;
93 notificationElement.style.display = "block"; 112 notificationElement.style.display = "block";
94 113
95 document.getElementById("close-notification").addEventListener("click", functi on() 114 document.getElementById("close-notification").addEventListener("click", functi on()
96 { 115 {
97 notificationElement.style.display = "none"; 116 notificationElement.style.display = "none";
117 notification.onClicked();
98 }, false); 118 }, false);
99 }, false); 119 }, false);
OLDNEW
« no previous file with comments | « notification.html ('k') | webrequest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld