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

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

Issue 7003089: Print Preview: Changing displayed error message when PDF Viewer is missing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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 24 matching lines...) Expand all
35 35
36 /** 36 /**
37 * Window onload handler, sets up the page and starts print preview by getting 37 * Window onload handler, sets up the page and starts print preview by getting
38 * the printer list. 38 * the printer list.
39 */ 39 */
40 function onLoad() { 40 function onLoad() {
41 $('system-dialog-link').addEventListener('click', showSystemDialog); 41 $('system-dialog-link').addEventListener('click', showSystemDialog);
42 $('cancel-button').addEventListener('click', handleCancelButtonClick); 42 $('cancel-button').addEventListener('click', handleCancelButtonClick);
43 43
44 if (!checkCompatiblePluginExists()) { 44 if (!checkCompatiblePluginExists()) {
45 displayErrorMessage(localStrings.getString('noPlugin'), false); 45 var errorButton = $('error-button');
46 errorButton.onclick = showSystemDialog;
47 errorButton.innerHTML = localStrings.getString('launchNativeDialog');
James Hawkins 2011/06/09 16:59:52 s/innerHTML/value/ It's just text.
dpapad 2011/06/09 17:21:25 I tried value, but strangely it does not set the t
48 displayErrorMessage(localStrings.getString('noPlugin'), true);
46 $('mainview').parentElement.removeChild($('dummy-viewer')); 49 $('mainview').parentElement.removeChild($('dummy-viewer'));
47 return; 50 return;
48 } 51 }
49 $('mainview').parentElement.removeChild($('dummy-viewer')); 52 $('mainview').parentElement.removeChild($('dummy-viewer'));
50 53
51 $('printer-list').disabled = true; 54 $('printer-list').disabled = true;
52 $('print-button').disabled = true; 55 $('print-button').disabled = true;
53 showLoadingAnimation(); 56 showLoadingAnimation();
54 chrome.send('getDefaultPrinter'); 57 chrome.send('getDefaultPrinter');
55 } 58 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 function showSystemDialog() { 137 function showSystemDialog() {
135 chrome.send('showSystemDialog'); 138 chrome.send('showSystemDialog');
136 } 139 }
137 140
138 /** 141 /**
139 * Disables the controls which need the initiator tab to generate preview 142 * Disables the controls which need the initiator tab to generate preview
140 * data. This function is called when the initiator tab is closed. 143 * data. This function is called when the initiator tab is closed.
141 * @param {string} initiatorTabURL The URL of the initiator tab. 144 * @param {string} initiatorTabURL The URL of the initiator tab.
142 */ 145 */
143 function onInitiatorTabClosed(initiatorTabURL) { 146 function onInitiatorTabClosed(initiatorTabURL) {
144 $('reopen-page').addEventListener('click', function() { 147 var errorButton = $('error-button');
145 window.location = initiatorTabURL; 148 errorButton.innerHTML = localStrings.getString('reopenPage');
146 }); 149 errorButton.onclick = function() { window.location = initiatorTabURL; };
147 displayErrorMessage(localStrings.getString('initiatorTabClosed'), true); 150 displayErrorMessage(localStrings.getString('initiatorTabClosed'), true);
148 } 151 }
149 152
150 /** 153 /**
151 * Gets the selected printer capabilities and updates the controls accordingly. 154 * Gets the selected printer capabilities and updates the controls accordingly.
152 */ 155 */
153 function updateControlsWithSelectedPrinterCapabilities() { 156 function updateControlsWithSelectedPrinterCapabilities() {
154 var printerList = $('printer-list'); 157 var printerList = $('printer-list');
155 var selectedIndex = printerList.selectedIndex; 158 var selectedIndex = printerList.selectedIndex;
156 if (selectedIndex < 0) 159 if (selectedIndex < 0)
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 var pdfViewer = $('pdf-viewer'); 433 var pdfViewer = $('pdf-viewer');
431 if (!pdfViewer) { 434 if (!pdfViewer) {
432 return; 435 return;
433 } 436 }
434 pdfViewer.grayscale(!color); 437 pdfViewer.grayscale(!color);
435 } 438 }
436 439
437 /** 440 /**
438 * Display an error message in the center of the preview area. 441 * Display an error message in the center of the preview area.
439 * @param {string} errorMessage The error message to be displayed. 442 * @param {string} errorMessage The error message to be displayed.
440 * @param {boolean} showButton Indivates whether the "Reopen the page" button 443 * @param {boolean} showButton Indicates whether the error-button should be
James Hawkins 2011/06/09 16:59:52 This is fragile; just have the call site show the
dpapad 2011/06/09 17:21:25 Done. Made it a little more flexible.
441 * should be displayed. 444 * displayed. Callers of this function have the responsibility to attach a
445 * listener to the button and also set the displayed text before calling this
446 * function.
442 */ 447 */
443 function displayErrorMessage(errorMessage, showButton) { 448 function displayErrorMessage(errorMessage, showButton) {
444 $('overlay-layer').classList.remove('invisible'); 449 $('overlay-layer').classList.remove('invisible');
445 $('dancing-dots-text').classList.add('hidden'); 450 $('dancing-dots-text').classList.add('hidden');
446 $('error-text').innerHTML = errorMessage; 451 $('error-text').innerHTML = errorMessage;
447 $('error-text').classList.remove('hidden'); 452 $('error-text').classList.remove('hidden');
448 if (showButton) 453 if (showButton)
449 $('reopen-page').classList.remove('hidden'); 454 $('error-button').classList.remove('hidden');
450 else 455 else
451 $('reopen-page').classList.add('hidden'); 456 $('error-button').classList.add('hidden');
452 457
453 removeEventListeners(); 458 removeEventListeners();
454 var pdfViewer = $('pdf-viewer'); 459 var pdfViewer = $('pdf-viewer');
455 if (pdfViewer) 460 if (pdfViewer)
456 $('mainview').removeChild(pdfViewer); 461 $('mainview').removeChild(pdfViewer);
457 } 462 }
458 463
459 /** 464 /**
460 * Display an error message when print preview fails. 465 * Display an error message when print preview fails.
461 * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed(). 466 * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed().
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 this.isLandscape = ''; 960 this.isLandscape = '';
956 } 961 }
957 962
958 /** 963 /**
959 * Takes a snapshot of the print settings. 964 * Takes a snapshot of the print settings.
960 */ 965 */
961 PrintSettings.prototype.save = function() { 966 PrintSettings.prototype.save = function() {
962 this.deviceName = getSelectedPrinterName(); 967 this.deviceName = getSelectedPrinterName();
963 this.isLandscape = isLandscape(); 968 this.isLandscape = isLandscape();
964 } 969 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview.html ('k') | chrome/browser/ui/webui/print_preview_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698