Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: chrome/browser/resources/print_preview.js

Issue 7051026: Print Preview: Changing error message when initiator tab closes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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() {
Lei Zhang 2011/05/23 07:07:04 Show this go in onload()?
dpapad 2011/05/23 16:05:31 It cant go in onload() because |initiatorTabURL| i
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
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.
Lei Zhang 2011/05/23 07:07:04 update comment.
dpapad 2011/05/23 16:05:31 Done.
387 */ 389 */
388 function displayErrorMessage(errorMessage) { 390 function displayErrorMessage(errorMessage, showButton) {
389 isPreviewStillLoading = false; 391 isPreviewStillLoading = false;
390 $('dancing-dots').classList.remove('invisible'); 392 $('dancing-dots').classList.remove('invisible');
391 $('dancing-dots-text').classList.add('hidden'); 393 $('dancing-dots-text').classList.add('hidden');
392 $('error-text').innerHTML = errorMessage; 394 $('error-text').innerHTML = errorMessage;
393 $('error-text').classList.remove('hidden'); 395 $('error-text').classList.remove('hidden');
396 if (showButton)
397 $('reopen-page').classList.remove('hidden');
Lei Zhang 2011/05/23 07:07:04 can we ever get into a situation where displayErro
dpapad 2011/05/23 16:05:31 I cant think of such a scenario, but I will add th
394 setControlsDisabled(true); 398 setControlsDisabled(true);
395 399
396 var pdfViewer = $('pdf-viewer'); 400 var pdfViewer = $('pdf-viewer');
397 if (pdfViewer) 401 if (pdfViewer)
398 $('mainview').removeChild(pdfViewer); 402 $('mainview').removeChild(pdfViewer);
399 } 403 }
400 404
401 /** 405 /**
402 * Display an error message when print preview fails. 406 * Display an error message when print preview fails.
403 * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed(). 407 * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed().
404 */ 408 */
405 function printPreviewFailed() { 409 function printPreviewFailed() {
406 displayErrorMessage(localStrings.getString('previewFailed')); 410 displayErrorMessage(localStrings.getString('previewFailed'), false);
407 } 411 }
408 412
409 /** 413 /**
410 * Called when the PDF plugin loads its document. 414 * Called when the PDF plugin loads its document.
411 */ 415 */
412 function onPDFLoad() { 416 function onPDFLoad() {
413 if (isLandscape()) 417 if (isLandscape())
414 $('pdf-viewer').fitToWidth(); 418 $('pdf-viewer').fitToWidth();
415 else 419 else
416 $('pdf-viewer').fitToHeight(); 420 $('pdf-viewer').fitToHeight();
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 copiesField.value = 1; 896 copiesField.value = 1;
893 else { 897 else {
894 var newValue = getCopies() + sign * 1; 898 var newValue = getCopies() + sign * 1;
895 if (newValue < copiesField.min || newValue > copiesField.max) 899 if (newValue < copiesField.min || newValue > copiesField.max)
896 return; 900 return;
897 copiesField.value = newValue; 901 copiesField.value = newValue;
898 } 902 }
899 copiesFieldChanged(); 903 copiesFieldChanged();
900 } 904 }
901 905
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698