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

Side by Side Diff: issue-reporter.js

Issue 29595588: Issue 5952 - Clicking Cancel in the issue reporter doesn't close the tab (Closed) Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Created Nov. 2, 2017, 11:39 a.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 | messageResponder.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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 14 matching lines...) Expand all
25 let pages = { 25 let pages = {
26 typeSelectorPage: [initTypeSelector, leaveTypeSelector], 26 typeSelectorPage: [initTypeSelector, leaveTypeSelector],
27 commentPage: [initCommentPage, leaveCommentPage], 27 commentPage: [initCommentPage, leaveCommentPage],
28 sendPage: [initSendPage, leaveSendPage] 28 sendPage: [initSendPage, leaveSendPage]
29 }; 29 };
30 30
31 document.addEventListener("DOMContentLoaded", () => 31 document.addEventListener("DOMContentLoaded", () =>
32 { 32 {
33 document.getElementById("cancel").addEventListener("click", () => 33 document.getElementById("cancel").addEventListener("click", () =>
34 { 34 {
35 window.close(); 35 closeMe();
36 }); 36 });
37 37
38 document.getElementById("continue").addEventListener("click", () => 38 document.getElementById("continue").addEventListener("click", () =>
39 { 39 {
40 if (!document.getElementById("continue").disabled) 40 if (!document.getElementById("continue").disabled)
41 pages[getCurrentPage()][1](); 41 pages[getCurrentPage()][1]();
42 }); 42 });
43 43
44 document.addEventListener("keydown", event => 44 document.addEventListener("keydown", event =>
45 { 45 {
(...skipping 10 matching lines...) Expand all
56 what: "doclink", 56 what: "doclink",
57 link: "reporter_privacy" 57 link: "reporter_privacy"
58 }).then(url => 58 }).then(url =>
59 { 59 {
60 document.getElementById("privacyPolicy").href = url; 60 document.getElementById("privacyPolicy").href = url;
61 }); 61 });
62 62
63 initDataCollector(); 63 initDataCollector();
64 }); 64 });
65 65
66 function closeMe()
67 {
68 browser.runtime.sendMessage({
69 type: "app.get",
70 what: "senderId"
71 }).then(tabId => browser.tabs.remove(tabId));
Thomas Greiner 2017/11/02 12:39:51 Wouldn't it make more sense to leave it up to the
Wladimir Palant 2017/11/02 13:16:51 That's the approach I chose initially but so far w
Thomas Greiner 2017/11/02 14:13:02 Not sure either whether this choice was made inten
72 }
73
66 function getCurrentPage() 74 function getCurrentPage()
67 { 75 {
68 return document.querySelector(".page:not([hidden])").id; 76 return document.querySelector(".page:not([hidden])").id;
69 } 77 }
70 78
71 function setCurrentPage(pageId) 79 function setCurrentPage(pageId)
72 { 80 {
73 if (!pages.hasOwnProperty(pageId)) 81 if (!pages.hasOwnProperty(pageId))
74 return; 82 return;
75 83
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 retrieveSubscriptions() 250 retrieveSubscriptions()
243 ]; 251 ];
244 return Promise.all(handlers); 252 return Promise.all(handlers);
245 }).then(() => 253 }).then(() =>
246 { 254 {
247 setCurrentPage("typeSelectorPage"); 255 setCurrentPage("typeSelectorPage");
248 }).catch(e => 256 }).catch(e =>
249 { 257 {
250 console.error(e); 258 console.error(e);
251 alert(e); 259 alert(e);
252 window.close(); 260 closeMe();
253 }); 261 });
254 } 262 }
255 263
256 function initTypeSelector() 264 function initTypeSelector()
257 { 265 {
258 document.getElementById("typeFalsePositive").focus(); 266 document.getElementById("typeFalsePositive").focus();
259 267
260 268
261 for (let checkbox of document.querySelectorAll("input[name='type']")) 269 for (let checkbox of document.querySelectorAll("input[name='type']"))
262 { 270 {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 let progress = document.getElementById("sendingProgress"); 500 let progress = document.getElementById("sendingProgress");
493 progress.max = event.total; 501 progress.max = event.total;
494 progress.value = event.loaded; 502 progress.value = event.loaded;
495 } 503 }
496 }); 504 });
497 request.send(serializeReportData()); 505 request.send(serializeReportData());
498 } 506 }
499 507
500 function leaveSendPage() 508 function leaveSendPage()
501 { 509 {
502 window.close(); 510 closeMe();
503 } 511 }
OLDNEW
« no previous file with comments | « no previous file | messageResponder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld