| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 var localStrings = new LocalStrings(); | 5 var localStrings = new LocalStrings(); |
| 6 | 6 |
| 7 // The total page count of the previewed document regardless of which pages the | 7 // The total page count of the previewed document regardless of which pages the |
| 8 // user has selected. | 8 // user has selected. |
| 9 var totalPageCount = -1; | 9 var totalPageCount = -1; |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Window onload handler, sets up the page and starts print preview by getting | 42 * Window onload handler, sets up the page and starts print preview by getting |
| 43 * the printer list. | 43 * the printer list. |
| 44 */ | 44 */ |
| 45 function onLoad() { | 45 function onLoad() { |
| 46 $('system-dialog-link').addEventListener('click', showSystemDialog); | 46 $('system-dialog-link').addEventListener('click', showSystemDialog); |
| 47 $('cancel-button').addEventListener('click', handleCancelButtonClick); | 47 $('cancel-button').addEventListener('click', handleCancelButtonClick); |
| 48 | 48 |
| 49 if (!checkCompatiblePluginExists()) { | 49 if (!checkCompatiblePluginExists()) { |
| 50 displayErrorMessage(localStrings.getString('noPlugin')); | 50 displayErrorMessage(localStrings.getString('noPlugin'), false); |
| 51 $('mainview').parentElement.removeChild($('dummy-viewer')); | 51 $('mainview').parentElement.removeChild($('dummy-viewer')); |
| 52 return; | 52 return; |
| 53 } | 53 } |
| 54 $('mainview').parentElement.removeChild($('dummy-viewer')); | 54 $('mainview').parentElement.removeChild($('dummy-viewer')); |
| 55 | 55 |
| 56 $('printer-list').disabled = true; | 56 $('printer-list').disabled = true; |
| 57 $('print-button').disabled = true; | 57 $('print-button').disabled = true; |
| 58 $('print-button').addEventListener('click', printFile); | 58 $('print-button').addEventListener('click', printFile); |
| 59 $('all-pages').addEventListener('click', onPageSelectionMayHaveChanged); | 59 $('all-pages').addEventListener('click', onPageSelectionMayHaveChanged); |
| 60 $('copies').addEventListener('input', copiesFieldChanged); | 60 $('copies').addEventListener('input', copiesFieldChanged); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 function showSystemDialog() { | 94 function showSystemDialog() { |
| 95 chrome.send('showSystemDialog'); | 95 chrome.send('showSystemDialog'); |
| 96 } | 96 } |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * Disables the controls which need the initiator tab to generate preview | 99 * Disables the controls which need the initiator tab to generate preview |
| 100 * data. This function is called when the initiator tab is closed. | 100 * data. This function is called when the initiator tab is closed. |
| 101 * @param {string} initiatorTabURL The URL of the initiator tab. | 101 * @param {string} initiatorTabURL The URL of the initiator tab. |
| 102 */ | 102 */ |
| 103 function onInitiatorTabClosed(initiatorTabURL) { | 103 function onInitiatorTabClosed(initiatorTabURL) { |
| 104 displayErrorMessage(localStrings.getStringF('initiatorTabClosed', | 104 $('reopen-page').addEventListener('click', function() { |
| 105 initiatorTabURL)); | 105 window.location = initiatorTabURL; |
| 106 }); |
| 107 displayErrorMessage(localStrings.getString('initiatorTabClosed'), true); |
| 106 } | 108 } |
| 107 | 109 |
| 108 /** | 110 /** |
| 109 * Gets the selected printer capabilities and updates the controls accordingly. | 111 * Gets the selected printer capabilities and updates the controls accordingly. |
| 110 */ | 112 */ |
| 111 function updateControlsWithSelectedPrinterCapabilities() { | 113 function updateControlsWithSelectedPrinterCapabilities() { |
| 112 var printerList = $('printer-list'); | 114 var printerList = $('printer-list'); |
| 113 var selectedIndex = printerList.selectedIndex; | 115 var selectedIndex = printerList.selectedIndex; |
| 114 if (selectedIndex < 0) | 116 if (selectedIndex < 0) |
| 115 return; | 117 return; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 function setColor(color) { | 378 function setColor(color) { |
| 377 var pdfViewer = $('pdf-viewer'); | 379 var pdfViewer = $('pdf-viewer'); |
| 378 if (!pdfViewer) { | 380 if (!pdfViewer) { |
| 379 return; | 381 return; |
| 380 } | 382 } |
| 381 pdfViewer.grayscale(!color); | 383 pdfViewer.grayscale(!color); |
| 382 } | 384 } |
| 383 | 385 |
| 384 /** | 386 /** |
| 385 * Display an error message in the center of the preview area. | 387 * Display an error message in the center of the preview area. |
| 386 * @param (string) errorMessage The error message to be displayed. | 388 * @param {string} errorMessage The error message to be displayed. |
| 389 * @param {boolean} showButton Indivates whether the "Reopen the page" button |
| 390 * should be displayed. |
| 387 */ | 391 */ |
| 388 function displayErrorMessage(errorMessage) { | 392 function displayErrorMessage(errorMessage, showButton) { |
| 389 isPreviewStillLoading = false; | 393 isPreviewStillLoading = false; |
| 390 $('dancing-dots').classList.remove('invisible'); | 394 $('dancing-dots').classList.remove('invisible'); |
| 391 $('dancing-dots-text').classList.add('hidden'); | 395 $('dancing-dots-text').classList.add('hidden'); |
| 392 $('error-text').innerHTML = errorMessage; | 396 $('error-text').innerHTML = errorMessage; |
| 393 $('error-text').classList.remove('hidden'); | 397 $('error-text').classList.remove('hidden'); |
| 398 if (showButton) |
| 399 $('reopen-page').classList.remove('hidden'); |
| 400 else |
| 401 $('reopen-page').classList.add('hidden'); |
| 402 |
| 394 setControlsDisabled(true); | 403 setControlsDisabled(true); |
| 395 | 404 |
| 396 var pdfViewer = $('pdf-viewer'); | 405 var pdfViewer = $('pdf-viewer'); |
| 397 if (pdfViewer) | 406 if (pdfViewer) |
| 398 $('mainview').removeChild(pdfViewer); | 407 $('mainview').removeChild(pdfViewer); |
| 399 } | 408 } |
| 400 | 409 |
| 401 /** | 410 /** |
| 402 * Display an error message when print preview fails. | 411 * Display an error message when print preview fails. |
| 403 * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed(). | 412 * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed(). |
| 404 */ | 413 */ |
| 405 function printPreviewFailed() { | 414 function printPreviewFailed() { |
| 406 displayErrorMessage(localStrings.getString('previewFailed')); | 415 displayErrorMessage(localStrings.getString('previewFailed'), false); |
| 407 } | 416 } |
| 408 | 417 |
| 409 /** | 418 /** |
| 410 * Called when the PDF plugin loads its document. | 419 * Called when the PDF plugin loads its document. |
| 411 */ | 420 */ |
| 412 function onPDFLoad() { | 421 function onPDFLoad() { |
| 413 if (isLandscape()) | 422 if (isLandscape()) |
| 414 $('pdf-viewer').fitToWidth(); | 423 $('pdf-viewer').fitToWidth(); |
| 415 else | 424 else |
| 416 $('pdf-viewer').fitToHeight(); | 425 $('pdf-viewer').fitToHeight(); |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 copiesField.value = 1; | 901 copiesField.value = 1; |
| 893 else { | 902 else { |
| 894 var newValue = getCopies() + sign * 1; | 903 var newValue = getCopies() + sign * 1; |
| 895 if (newValue < copiesField.min || newValue > copiesField.max) | 904 if (newValue < copiesField.min || newValue > copiesField.max) |
| 896 return; | 905 return; |
| 897 copiesField.value = newValue; | 906 copiesField.value = newValue; |
| 898 } | 907 } |
| 899 copiesFieldChanged(); | 908 copiesFieldChanged(); |
| 900 } | 909 } |
| 901 | 910 |
| OLD | NEW |