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

Side by Side Diff: notification.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
« lib/notificationHelper.js ('K') | « 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
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 newElement.href = links.shift(); 56 newElement.href = links.shift();
57 insertMessage(newElement, value, links); 57 insertMessage(newElement, value, links);
58 element.appendChild(newElement); 58 element.appendChild(newElement);
59 59
60 insertMessage(element, after, links); 60 insertMessage(element, after, links);
61 } 61 }
62 62
63 window.addEventListener("load", function() 63 window.addEventListener("load", function()
64 { 64 {
65 var notification = getActiveNotification(); 65 var notification = getActiveNotification();
66 if (!notification) 66 if (!notification
67 || notification.type == "question"
68 || notification.type == "normal")
67 return; 69 return;
68 70
69 var texts = Notification.getLocalizedTexts(notification); 71 var texts = Notification.getLocalizedTexts(notification);
70 var titleElement = document.getElementById("notification-title"); 72 var titleElement = document.getElementById("notification-title");
71 titleElement.textContent = texts.title; 73 titleElement.textContent = texts.title;
72 74
73 var docLinks = getDocLinks(notification); 75 var docLinks = getDocLinks(notification);
74 var messageElement = document.getElementById("notification-message"); 76 var messageElement = document.getElementById("notification-message");
75 insertMessage(messageElement, texts.message, docLinks); 77 insertMessage(messageElement, texts.message, docLinks);
76 78
77 messageElement.addEventListener("click", function(event) 79 messageElement.addEventListener("click", function(event)
78 { 80 {
79 var link = event.target; 81 var link = event.target;
80 while (link && link !== messageElement && link.localName !== "a") 82 while (link && link !== messageElement && link.localName !== "a")
81 link = link.parentNode; 83 link = link.parentNode;
82 if (!link) 84 if (!link)
83 return; 85 return;
84 event.preventDefault(); 86 event.preventDefault();
85 event.stopPropagation(); 87 event.stopPropagation();
86 ext.pages.open(link.href); 88 ext.pages.open(link.href);
87 }); 89 });
88 90
89 if (notification.type == "question")
90 {
91 document.getElementById("notification-question").addEventListener("click", f unction(event)
92 {
93 event.preventDefault();
94 event.stopPropagation();
95
96 var approved = false;
97 switch (event.target.id)
98 {
99 case "notification-yes":
100 approved = true;
101 case "notification-no":
102 Notification.triggerQuestionListeners(notification.id, approved);
103 Notification.markAsShown(notification.id);
104 notification.onClicked();
105 break;
106 }
107 window.close();
108 }, true);
109 }
110
111 var notificationElement = document.getElementById("notification"); 91 var notificationElement = document.getElementById("notification");
112 notificationElement.className = notification.type; 92 notificationElement.className = notification.type;
113 notificationElement.hidden = false; 93 notificationElement.hidden = false;
114 notificationElement.addEventListener("click", function(event) 94 notificationElement.addEventListener("click", function(event)
115 { 95 {
116 switch (event.target.id) 96 switch (event.target.id)
117 { 97 {
118 case "notification-close": 98 case "notification-close":
119 notificationElement.classList.add("closing"); 99 notificationElement.classList.add("closing");
120 break; 100 break;
121 case "notification-optout": 101 case "notification-optout":
122 Notification.toggleIgnoreCategory("*", true); 102 Notification.toggleIgnoreCategory("*", true);
123 case "notification-hide": 103 case "notification-hide":
124 notificationElement.hidden = true; 104 notificationElement.hidden = true;
125 notification.onClicked(); 105 notification.onClicked();
126 break; 106 break;
127 } 107 }
128 }, true); 108 }, true);
129 }, false); 109 }, false);
OLDNEW
« lib/notificationHelper.js ('K') | « lib/notificationHelper.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld