Chromium Code Reviews| 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 'http://www.google.com/support/chrome/go/feedback_confirmation'; | 7 'http://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 | 18 |
| 19 var localStrings = new LocalStrings(); | 19 var localStrings = new LocalStrings(); |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Selects an image thumbnail in the specified div. | 22 * Selects an image thumbnail in the specified div. |
| 23 * @param {string} divId The id of the div to search in. | |
| 24 * @param {string} thumbnailId The id of the thumbnail to search for. | |
| 23 */ | 25 */ |
| 24 function selectImage(divId, thumbnailId) { | 26 function selectImage(divId, thumbnailId) { |
| 25 var thumbnailDivs = $(divId).children; | 27 var thumbnailDivs = $(divId).children; |
| 26 selectedThumbnailDivId = divId; | 28 selectedThumbnailDivId = divId; |
| 27 if (thumbnailDivs.length == 0) { | 29 if (thumbnailDivs.length == 0) { |
| 28 $(divId).hidden = true; | 30 $(divId).hidden = true; |
| 29 return; | 31 return; |
| 30 } | 32 } |
| 31 for (var i = 0; i < thumbnailDivs.length; i++) { | 33 for (var i = 0; i < thumbnailDivs.length; i++) { |
| 32 // If the the current div matches the thumbnail id provided, | 34 // If the the current div matches the thumbnail id provided, |
| 33 // or there is no thumbnail id given, and we're at the first thumbnail. | 35 // or there is no thumbnail id given, and we're at the first thumbnail. |
| 34 if ((thumbnailDivs[i].id == thumbnailId) || (!thumbnailId && !i)) { | 36 if ((thumbnailDivs[i].id == thumbnailId) || (!thumbnailId && !i)) { |
| 35 thumbnailDivs[i].className = 'image-thumbnail-container-selected'; | 37 thumbnailDivs[i].className = 'image-thumbnail-container-selected'; |
| 36 selectedThumbnailId = thumbnailId; | 38 selectedThumbnailId = thumbnailId; |
| 37 savedThumbnailIds[divId] = thumbnailId; | 39 savedThumbnailIds[divId] = thumbnailId; |
| 38 } else { | 40 } else { |
| 39 thumbnailDivs[i].className = 'image-thumbnail-container'; | 41 thumbnailDivs[i].className = 'image-thumbnail-container'; |
| 40 } | 42 } |
| 41 } | 43 } |
| 42 } | 44 } |
| 43 | 45 |
| 44 /** | 46 /** |
| 45 * Adds an image thumbnail to the specified div. | 47 * Adds an image thumbnail to the specified div. |
| 48 * @param {string} divId The id of the div to add a screenshot to. | |
| 49 * @param {string} screenshot The URL of the screenshot being added. | |
| 46 */ | 50 */ |
| 47 function addScreenshot(divId, screenshot) { | 51 function addScreenshot(divId, screenshot) { |
| 48 var thumbnailDiv = document.createElement('div'); | 52 var thumbnailDiv = document.createElement('div'); |
| 49 thumbnailDiv.className = 'image-thumbnail-container'; | 53 thumbnailDiv.className = 'image-thumbnail-container'; |
| 50 | 54 |
| 51 thumbnailDiv.id = divId + '-thumbnailDiv-' + $(divId).children.length; | 55 thumbnailDiv.id = divId + '-thumbnailDiv-' + $(divId).children.length; |
| 52 thumbnailDiv.onclick = function() { | 56 thumbnailDiv.onclick = function() { |
| 53 selectImage(divId, thumbnailDiv.id); | 57 selectImage(divId, thumbnailDiv.id); |
| 54 }; | 58 }; |
| 55 | 59 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 79 function disableScreenshots() { | 83 function disableScreenshots() { |
| 80 $('screenshot-row').hidden = true; | 84 $('screenshot-row').hidden = true; |
| 81 $('screenshot-checkbox').checked = false; | 85 $('screenshot-checkbox').checked = false; |
| 82 | 86 |
| 83 $('current-screenshots').hidden = true; | 87 $('current-screenshots').hidden = true; |
| 84 if ($('saved-screenshots')) | 88 if ($('saved-screenshots')) |
| 85 $('saved-screenshots').hidden = true; | 89 $('saved-screenshots').hidden = true; |
| 86 } | 90 } |
| 87 | 91 |
| 88 /** | 92 /** |
| 89 * Send's the report; after the report is sent, we need to be redirected to | 93 * 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 | 94 * 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. | 95 * we open the landing page in a new tab and sendReport closes this tab. |
| 96 * @return {boolean} True if the report was sent. | |
| 92 */ | 97 */ |
| 93 function sendReport() { | 98 function sendReport() { |
| 94 if ($('description-text').value.length == 0) { | 99 if ($('description-text').value.length == 0) { |
| 95 alert(localStrings.getString('no-description')); | 100 alert(localStrings.getString('no-description')); |
| 96 return false; | 101 return false; |
| 97 } | 102 } |
| 98 | 103 |
| 99 var imagePath = ''; | 104 var imagePath = ''; |
| 100 if ($('screenshot-checkbox').checked && selectedThumbnailId) | 105 if ($('screenshot-checkbox').checked && selectedThumbnailId) |
| 101 imagePath = $(selectedThumbnailId + '-image').src; | 106 imagePath = $(selectedThumbnailId + '-image').src; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 116 reportArray = reportArray.concat([userEmail, | 121 reportArray = reportArray.concat([userEmail, |
| 117 String($('sys-info-checkbox').checked)]); | 122 String($('sys-info-checkbox').checked)]); |
| 118 } | 123 } |
| 119 | 124 |
| 120 // open the landing page in a new tab, sendReport will close this one. | 125 // open the landing page in a new tab, sendReport will close this one. |
| 121 window.open(FEEDBACK_LANDING_PAGE, '_blank'); | 126 window.open(FEEDBACK_LANDING_PAGE, '_blank'); |
| 122 chrome.send('sendReport', reportArray); | 127 chrome.send('sendReport', reportArray); |
| 123 return true; | 128 return true; |
| 124 } | 129 } |
| 125 | 130 |
| 131 /** | |
| 132 * Click listener for the cancel button. | |
| 133 * @return {boolean} true | |
|
Dan Beam
2012/04/27 03:28:46
remove this and change to take |e| param and call
| |
| 134 */ | |
| 126 function cancel() { | 135 function cancel() { |
| 127 chrome.send('cancel'); | 136 chrome.send('cancel'); |
| 128 return true; | 137 return true; |
| 129 } | 138 } |
| 130 | 139 |
| 131 /** | 140 /** |
| 132 * Select the current screenshots div, restoring the image that was | 141 * Select the current screenshots div, restoring the image that was |
| 133 * selected when we had this div open previously. | 142 * selected when we had this div open previously. |
| 134 */ | 143 */ |
| 135 function currentSelected() { | 144 function currentSelected() { |
| 136 // TODO(rkc): Change this to use a class instead. | 145 // TODO(rkc): Change this to use a class instead. |
| 137 $('current-screenshots').hidden = false; | 146 $('current-screenshots').hidden = false; |
| 138 if ($('saved-screenshots')) | 147 if ($('saved-screenshots')) |
| 139 $('saved-screenshots').hidden = true; | 148 $('saved-screenshots').hidden = true; |
| 140 | 149 |
| 141 if (selectedThumbnailDivId != 'current-screenshots') | 150 if (selectedThumbnailDivId != 'current-screenshots') |
| 142 selectImage('current-screenshots', | 151 selectImage('current-screenshots', |
| 143 savedThumbnailIds['current-screenshots']); | 152 savedThumbnailIds['current-screenshots']); |
| 144 | |
| 145 return true; | |
| 146 } | 153 } |
| 147 | 154 |
| 148 /** | 155 /** |
| 149 * Select the saved screenshots div, restoring the image that was | 156 * Select the saved screenshots div, restoring the image that was |
| 150 * selected when we had this div open previously. | 157 * selected when we had this div open previously. |
| 151 */ | 158 */ |
| 152 function savedSelected() { | 159 function savedSelected() { |
| 153 $('current-screenshots').hidden = true; | 160 $('current-screenshots').hidden = true; |
| 154 | 161 |
| 155 if ($('saved-screenshots').childElementCount == 0) { | 162 if ($('saved-screenshots').childElementCount == 0) { |
| 156 // setupSavedScreenshots will take care of changing visibility | 163 // setupSavedScreenshots will take care of changing visibility |
| 157 chrome.send('refreshSavedScreenshots'); | 164 chrome.send('refreshSavedScreenshots'); |
| 158 } else { | 165 } else { |
| 159 $('saved-screenshots').hidden = false; | 166 $('saved-screenshots').hidden = false; |
| 160 if (selectedThumbnailDivId != 'saved-screenshots') | 167 if (selectedThumbnailDivId != 'saved-screenshots') |
| 161 selectImage('saved-screenshots', savedThumbnailIds['saved-screenshots']); | 168 selectImage('saved-screenshots', savedThumbnailIds['saved-screenshots']); |
| 162 } | 169 } |
| 163 | |
| 164 return true; | |
| 165 } | 170 } |
| 166 | 171 |
| 167 | 172 |
| 168 /** | 173 /** |
| 169 * Change the type of screenshot we're showing to the user from | 174 * Change the type of screenshot we're showing to the user from |
| 170 * the current screenshot to saved screenshots | 175 * the current screenshot to saved screenshots |
| 171 */ | 176 */ |
| 172 function changeToSaved() { | 177 function changeToSaved() { |
| 173 $('screenshot-label-current').hidden = true; | 178 $('screenshot-label-current').hidden = true; |
| 174 $('screenshot-label-saved').hidden = false; | 179 $('screenshot-label-saved').hidden = false; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 $('user-email-table').hidden = true; | 302 $('user-email-table').hidden = true; |
| 298 | 303 |
| 299 // this also means we are in privacy mode, so no saved screenshots. | 304 // this also means we are in privacy mode, so no saved screenshots. |
| 300 $('screenshot-link-tosaved').hidden = true; | 305 $('screenshot-link-tosaved').hidden = true; |
| 301 } | 306 } |
| 302 } | 307 } |
| 303 } | 308 } |
| 304 } | 309 } |
| 305 | 310 |
| 306 window.addEventListener('DOMContentLoaded', load); | 311 window.addEventListener('DOMContentLoaded', load); |
| OLD | NEW |