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

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

Issue 7057047: Print Preview: Preventing "Preview loading..." animation from rendering when not displayed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing 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 29 matching lines...) Expand all
40 40
41 if (!checkCompatiblePluginExists()) { 41 if (!checkCompatiblePluginExists()) {
42 displayErrorMessage(localStrings.getString('noPlugin'), false); 42 displayErrorMessage(localStrings.getString('noPlugin'), false);
43 $('mainview').parentElement.removeChild($('dummy-viewer')); 43 $('mainview').parentElement.removeChild($('dummy-viewer'));
44 return; 44 return;
45 } 45 }
46 $('mainview').parentElement.removeChild($('dummy-viewer')); 46 $('mainview').parentElement.removeChild($('dummy-viewer'));
47 47
48 $('printer-list').disabled = true; 48 $('printer-list').disabled = true;
49 $('print-button').disabled = true; 49 $('print-button').disabled = true;
50 $('dancing-dots').classList.remove('invisible'); 50 showLoadingAnimation();
51 chrome.send('getDefaultPrinter'); 51 chrome.send('getDefaultPrinter');
52 } 52 }
53 53
54 /** 54 /**
55 * Adds event listeners to the settings controls. 55 * Adds event listeners to the settings controls.
56 */ 56 */
57 function addEventListeners() { 57 function addEventListeners() {
58 $('print-button').onclick = printFile; 58 $('print-button').onclick = printFile;
59 59
60 // Controls that require preview rendering. 60 // Controls that require preview rendering.
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } else 336 } else
337 chrome.send('print', [getSettingsJSON()]); 337 chrome.send('print', [getSettingsJSON()]);
338 } 338 }
339 339
340 /** 340 /**
341 * Asks the browser to generate a preview PDF based on current print settings. 341 * Asks the browser to generate a preview PDF based on current print settings.
342 */ 342 */
343 function requestPrintPreview() { 343 function requestPrintPreview() {
344 removeEventListeners(); 344 removeEventListeners();
345 printSettings.save(); 345 printSettings.save();
346 $('dancing-dots').classList.remove('invisible'); 346 showLoadingAnimation();
347 chrome.send('getPreview', [getSettingsJSON()]); 347 chrome.send('getPreview', [getSettingsJSON()]);
348 } 348 }
349 349
350 /** 350 /**
351 * Set the default printer. If there is one, generate a print preview. 351 * Set the default printer. If there is one, generate a print preview.
352 * @param {string} printer Name of the default printer. Empty if none. 352 * @param {string} printer Name of the default printer. Empty if none.
353 */ 353 */
354 function setDefaultPrinter(printer) { 354 function setDefaultPrinter(printer) {
355 // Add a placeholder value so the printer list looks valid. 355 // Add a placeholder value so the printer list looks valid.
356 addDestinationListOption('', '', true, true); 356 addDestinationListOption('', '', true, true);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 pdfViewer.grayscale(!color); 435 pdfViewer.grayscale(!color);
436 } 436 }
437 437
438 /** 438 /**
439 * Display an error message in the center of the preview area. 439 * Display an error message in the center of the preview area.
440 * @param {string} errorMessage The error message to be displayed. 440 * @param {string} errorMessage The error message to be displayed.
441 * @param {boolean} showButton Indivates whether the "Reopen the page" button 441 * @param {boolean} showButton Indivates whether the "Reopen the page" button
442 * should be displayed. 442 * should be displayed.
443 */ 443 */
444 function displayErrorMessage(errorMessage, showButton) { 444 function displayErrorMessage(errorMessage, showButton) {
445 $('dancing-dots').classList.remove('invisible'); 445 $('overlay-layer').classList.remove('invisible');
446 $('dancing-dots-text').classList.add('hidden'); 446 $('dancing-dots-text').classList.add('hidden');
447 $('error-text').innerHTML = errorMessage; 447 $('error-text').innerHTML = errorMessage;
448 $('error-text').classList.remove('hidden'); 448 $('error-text').classList.remove('hidden');
449 if (showButton) 449 if (showButton)
450 $('reopen-page').classList.remove('hidden'); 450 $('reopen-page').classList.remove('hidden');
451 else 451 else
452 $('reopen-page').classList.add('hidden'); 452 $('reopen-page').classList.add('hidden');
453 453
454 removeEventListeners(); 454 removeEventListeners();
455 var pdfViewer = $('pdf-viewer'); 455 var pdfViewer = $('pdf-viewer');
(...skipping 11 matching lines...) Expand all
467 467
468 /** 468 /**
469 * Called when the PDF plugin loads its document. 469 * Called when the PDF plugin loads its document.
470 */ 470 */
471 function onPDFLoad() { 471 function onPDFLoad() {
472 if (isLandscape()) 472 if (isLandscape())
473 $('pdf-viewer').fitToWidth(); 473 $('pdf-viewer').fitToWidth();
474 else 474 else
475 $('pdf-viewer').fitToHeight(); 475 $('pdf-viewer').fitToHeight();
476 476
477 $('dancing-dots').classList.add('invisible'); 477 hideLoadingAnimation();
478 478
479 if (!previewModifiable) 479 if (!previewModifiable)
480 fadeOutElement($('landscape-option')); 480 fadeOutElement($('landscape-option'));
481 481
482 updateCopiesButtonsState(); 482 updateCopiesButtonsState();
483 } 483 }
484 484
485 /** 485 /**
486 * Update the print preview when new preview data is available. 486 * Update the print preview when new preview data is available.
487 * Create the PDF plugin as needed. 487 * Create the PDF plugin as needed.
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 this.isLandscape = ''; 964 this.isLandscape = '';
965 } 965 }
966 966
967 /** 967 /**
968 * Takes a snapshot of the print settings. 968 * Takes a snapshot of the print settings.
969 */ 969 */
970 PrintSettings.prototype.save = function() { 970 PrintSettings.prototype.save = function() {
971 this.deviceName = getSelectedPrinterName(); 971 this.deviceName = getSelectedPrinterName();
972 this.isLandscape = isLandscape(); 972 this.isLandscape = isLandscape();
973 } 973 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview.html ('k') | chrome/browser/resources/print_preview_animations.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698