OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Constants. | 5 // Constants. |
6 /** @const */ var FEEDBACK_LANDING_PAGE = | 6 /** @const */ var FEEDBACK_LANDING_PAGE = |
7 'https://www.google.com/support/chrome/go/feedback_confirmation'; | 7 'https://www.google.com/support/chrome/go/feedback_confirmation'; |
8 | 8 |
9 var selectedThumbnailDivId = ''; | 9 var selectedThumbnailDivId = ''; |
10 var selectedThumbnailId = ''; | 10 var selectedThumbnailId = ''; |
11 var selectedImageUrl; | 11 var selectedImageUrl; |
12 | 12 |
13 var savedThumbnailIds = []; | 13 var savedThumbnailIds = []; |
14 savedThumbnailIds['current-screenshots'] = ''; | 14 savedThumbnailIds['current-screenshots'] = ''; |
15 savedThumbnailIds['saved-screenshots'] = ''; | 15 savedThumbnailIds['saved-screenshots'] = ''; |
16 | 16 |
17 var categoryTag = ''; | 17 var categoryTag = ''; |
18 var forceDisableScreenshots = false; | |
18 | 19 |
19 /** | 20 /** |
20 * Selects an image thumbnail in the specified div. | 21 * Selects an image thumbnail in the specified div. |
21 * @param {string} divId The id of the div to search in. | 22 * @param {string} divId The id of the div to search in. |
22 * @param {string} thumbnailId The id of the thumbnail to search for. | 23 * @param {string} thumbnailId The id of the thumbnail to search for. |
23 */ | 24 */ |
24 function selectImage(divId, thumbnailId) { | 25 function selectImage(divId, thumbnailId) { |
25 var thumbnailDivs = $(divId).children; | 26 var thumbnailDivs = $(divId).children; |
26 selectedThumbnailDivId = divId; | 27 selectedThumbnailDivId = divId; |
27 if (thumbnailDivs.length == 0) { | 28 if (thumbnailDivs.length == 0) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 thumbnailDiv.appendChild(innerDiv); | 70 thumbnailDiv.appendChild(innerDiv); |
70 $(divId).appendChild(thumbnailDiv); | 71 $(divId).appendChild(thumbnailDiv); |
71 | 72 |
72 if (!selectedThumbnailId) | 73 if (!selectedThumbnailId) |
73 selectImage(divId, thumbnailDiv.id); | 74 selectImage(divId, thumbnailDiv.id); |
74 } | 75 } |
75 | 76 |
76 /** | 77 /** |
77 * Disables screenshots completely. | 78 * Disables screenshots completely. |
78 */ | 79 */ |
79 function disableScreenshots() { | 80 function enableScreenshots() { |
80 $('screenshot-row').hidden = true; | 81 if (forceDisableScreenshots) |
81 $('screenshot-checkbox').checked = false; | 82 return; |
Mattias Nissler (ping if slow)
2012/07/13 15:23:42
Why have you removed the updates to screenshot-che
qfel
2012/07/16 09:11:12
saved-screenshots and current-screenshots are insi
| |
82 | 83 $('screenshot-row').hidden = false; |
83 $('current-screenshots').hidden = true; | |
84 if ($('saved-screenshots')) | |
85 $('saved-screenshots').hidden = true; | |
86 } | 84 } |
87 | 85 |
88 /** | 86 /** |
89 * Sends the report; after the report is sent, we need to be redirected to | 87 * Sends the report; after the report is sent, we need to be redirected to |
90 * the landing page, but we shouldn't be able to navigate back, hence | 88 * the landing page, but we shouldn't be able to navigate back, hence |
91 * we open the landing page in a new tab and sendReport closes this tab. | 89 * we open the landing page in a new tab and sendReport closes this tab. |
92 * @return {boolean} True if the report was sent. | 90 * @return {boolean} True if the report was sent. |
93 */ | 91 */ |
94 function sendReport() { | 92 function sendReport() { |
95 if ($('description-text').value.length == 0) { | 93 if ($('description-text').value.length == 0) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 // For a clean URL, trim the parameters from the hash. | 231 // For a clean URL, trim the parameters from the hash. |
234 window.location.hash = window.location.hash.substring(0, queryPos); | 232 window.location.hash = window.location.hash.substring(0, queryPos); |
235 } | 233 } |
236 | 234 |
237 // Set the initial description text. | 235 // Set the initial description text. |
238 $('description-text').textContent = parameters['description']; | 236 $('description-text').textContent = parameters['description']; |
239 // If a page url is spcified in the parameters, override the default page url. | 237 // If a page url is spcified in the parameters, override the default page url. |
240 if (parameters['customPageUrl'] != '') { | 238 if (parameters['customPageUrl'] != '') { |
241 $('page-url-text').value = parameters['customPageUrl']; | 239 $('page-url-text').value = parameters['customPageUrl']; |
242 // and disable the page image, since it doesn't make sense on a custum url. | 240 // and disable the page image, since it doesn't make sense on a custum url. |
243 disableScreenshots(); | 241 $('screenshot-checkbox').checked = false; |
242 forceDisableScreenshots = true; | |
244 } | 243 } |
245 | 244 |
246 // Pick up the category tag (for most cases this will be an empty string) | 245 // Pick up the category tag (for most cases this will be an empty string) |
247 categoryTag = parameters['categoryTag']; | 246 categoryTag = parameters['categoryTag']; |
248 | 247 |
249 chrome.send('getDialogDefaults'); | 248 chrome.send('getDialogDefaults'); |
250 chrome.send('refreshCurrentScreenshot'); | 249 chrome.send('refreshCurrentScreenshot'); |
251 } | 250 } |
252 | 251 |
253 function setupCurrentScreenshot(screenshot) { | 252 function setupCurrentScreenshot(screenshot) { |
(...skipping 17 matching lines...) Expand all Loading... | |
271 for (i = 0; i < screenshots.length; ++i) | 270 for (i = 0; i < screenshots.length; ++i) |
272 addScreenshot('saved-screenshots', screenshots[i]); | 271 addScreenshot('saved-screenshots', screenshots[i]); |
273 | 272 |
274 // Now that we have our screenshots, try selecting the saved screenshots | 273 // Now that we have our screenshots, try selecting the saved screenshots |
275 // again. | 274 // again. |
276 savedSelected(); | 275 savedSelected(); |
277 } | 276 } |
278 } | 277 } |
279 | 278 |
280 function setupDialogDefaults(defaults) { | 279 function setupDialogDefaults(defaults) { |
281 if (defaults.length > 0) { | 280 // 0: current url |
282 if ($('page-url-text').value == '') | 281 if (defaults.length <= 0) |
283 $('page-url-text').value = defaults[0]; | 282 return; |
284 if (defaults[0] == '') | 283 if ($('page-url-text').value == '') |
285 $('page-url-checkbox').checked = false; | 284 $('page-url-text').value = defaults[0]; |
285 if (defaults[0] == '') | |
286 $('page-url-checkbox').checked = false; | |
286 | 287 |
287 if (defaults.length > 2) { | 288 // 1: are screenshots disabled? |
288 // We're in Chromium OS. | 289 if (defaults.length <= 1) |
289 $('user-email-text').textContent = defaults[2]; | 290 return; |
290 if (defaults[2] == '') { | 291 if (!defaults[1]) |
291 // if we didn't get an e-mail address from cros, | 292 enableScreenshots(); |
292 // disable the user email display totally. | |
293 $('user-email-table').hidden = true; | |
294 | 293 |
295 // this also means we are in privacy mode, so no saved screenshots. | 294 // 2: user e-mail |
296 $('screenshot-link-tosaved').hidden = true; | 295 if (defaults.length <= 2) |
297 } | 296 return; |
298 } | 297 // We're in Chromium OS. |
298 $('user-email-text').textContent = defaults[2]; | |
299 if (defaults[2] == '') { | |
300 // if we didn't get an e-mail address from cros, | |
301 // disable the user email display totally. | |
302 $('user-email-table').hidden = true; | |
303 | |
304 // this also means we are in privacy mode, so no saved screenshots. | |
305 $('screenshot-link-tosaved').hidden = true; | |
299 } | 306 } |
300 } | 307 } |
301 | 308 |
302 window.addEventListener('DOMContentLoaded', load); | 309 window.addEventListener('DOMContentLoaded', load); |
OLD | NEW |