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

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

Issue 7055018: Print Preview: Delaying page range validation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updating comments 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
« no previous file with comments | « chrome/browser/resources/print_preview.css ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
61 $('print-pages').addEventListener('click', handleIndividualPagesCheckbox); 61 $('print-pages').addEventListener('click', handleIndividualPagesCheckbox);
62 $('individual-pages').addEventListener('blur', function() { 62 $('individual-pages').addEventListener('blur', function() {
63 clearTimeout(timerId); 63 clearTimeout(timerId);
64 onPageSelectionMayHaveChanged(); 64 onPageSelectionMayHaveChanged();
65 }); 65 });
66 $('individual-pages').addEventListener('focus', addTimerToPageRangeField); 66 $('individual-pages').addEventListener('focus', addTimerToPageRangeField);
67 $('individual-pages').addEventListener('input', pageRangesFieldChanged); 67 $('individual-pages').addEventListener('input', resetPageRangeFieldTimer);
68 $('two-sided').addEventListener('click', handleTwoSidedClick) 68 $('two-sided').addEventListener('click', handleTwoSidedClick)
69 $('landscape').addEventListener('click', onLayoutModeToggle); 69 $('landscape').addEventListener('click', onLayoutModeToggle);
70 $('portrait').addEventListener('click', onLayoutModeToggle); 70 $('portrait').addEventListener('click', onLayoutModeToggle);
71 $('color').addEventListener('click', function() { setColor(true); }); 71 $('color').addEventListener('click', function() { setColor(true); });
72 $('bw').addEventListener('click', function() { setColor(false); }); 72 $('bw').addEventListener('click', function() { setColor(false); });
73 $('printer-list').addEventListener( 73 $('printer-list').addEventListener(
74 'change', updateControlsWithSelectedPrinterCapabilities); 74 'change', updateControlsWithSelectedPrinterCapabilities);
75 $('increment').addEventListener('click', 75 $('increment').addEventListener('click',
76 function() { onCopiesButtonsClicked(1); }); 76 function() { onCopiesButtonsClicked(1); });
77 $('decrement').addEventListener('click', 77 $('decrement').addEventListener('click',
(...skipping 16 matching lines...) Expand all
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 if (isPreviewStillLoading) 104 displayErrorMessage(localStrings.getStringF('initiatorTabClosed',
105 displayErrorMessage(localStrings.getStringF('initiatorTabClosed', 105 initiatorTabURL));
106 initiatorTabURL));
107
108 var controlIDs = ['landscape', 'portrait', 'all-pages', 'print-pages',
109 'individual-pages', 'printer-list'];
110 var controlCount = controlIDs.length;
111 for (var i = 0; i < controlCount; i++)
112 $(controlIDs[i]).disabled = true;
113 } 106 }
114 107
115 /** 108 /**
116 * Gets the selected printer capabilities and updates the controls accordingly. 109 * Gets the selected printer capabilities and updates the controls accordingly.
117 */ 110 */
118 function updateControlsWithSelectedPrinterCapabilities() { 111 function updateControlsWithSelectedPrinterCapabilities() {
119 var printerList = $('printer-list'); 112 var printerList = $('printer-list');
120 var selectedIndex = printerList.selectedIndex; 113 var selectedIndex = printerList.selectedIndex;
121 if (selectedIndex < 0) 114 if (selectedIndex < 0)
122 return; 115 return;
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 * field. 523 * field.
531 */ 524 */
532 function copiesFieldChanged() { 525 function copiesFieldChanged() {
533 updateCopiesButtonsState(); 526 updateCopiesButtonsState();
534 updatePrintButtonState(); 527 updatePrintButtonState();
535 $('collate-option').hidden = getCopies() <= 1; 528 $('collate-option').hidden = getCopies() <= 1;
536 updatePrintSummary(); 529 updatePrintSummary();
537 } 530 }
538 531
539 /** 532 /**
540 * Executes whenever an input event occurs on the 'individual-pages' 533 * Executes whenever a blur event occurs on the 'individual-pages'
541 * field. It takes care of 534 * field or when the timer expires. It takes care of
542 * 1) showing/hiding warnings/suggestions 535 * 1) showing/hiding warnings/suggestions
543 * 2) updating print button/summary 536 * 2) updating print button/summary
544 */ 537 */
545 function pageRangesFieldChanged() { 538 function pageRangesFieldChanged() {
546 var currentlySelectedPages = getSelectedPagesSet(); 539 var currentlySelectedPages = getSelectedPagesSet();
547 var individualPagesField = $('individual-pages'); 540 var individualPagesField = $('individual-pages');
548 var individualPagesHint = $('individual-pages-hint'); 541 var individualPagesHint = $('individual-pages-hint');
549 var validityLevel = getSelectedPagesValidityLevel(); 542 var validityLevel = getSelectedPagesValidityLevel();
550 543
551 if (validityLevel == 1) 544 if (validityLevel == 1)
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 */ 647 */
655 function handleTwoSidedClick() { 648 function handleTwoSidedClick() {
656 updatePrintSummary(); 649 updatePrintSummary();
657 } 650 }
658 651
659 /** 652 /**
660 * Gives focus to the individual pages textfield when 'print-pages' textbox is 653 * Gives focus to the individual pages textfield when 'print-pages' textbox is
661 * clicked. 654 * clicked.
662 */ 655 */
663 function handleIndividualPagesCheckbox() { 656 function handleIndividualPagesCheckbox() {
664 onPageSelectionMayHaveChanged();
665 $('individual-pages').focus(); 657 $('individual-pages').focus();
666 } 658 }
667 659
668 /** 660 /**
669 * When the user switches printing orientation mode the page field selection is 661 * When the user switches printing orientation mode the page field selection is
670 * reset to "all pages selected". After the change the number of pages will be 662 * reset to "all pages selected". After the change the number of pages will be
671 * different and currently selected page numbers might no longer be valid. 663 * different and currently selected page numbers might no longer be valid.
672 * Even if they are still valid the content of these pages will be different. 664 * Even if they are still valid the content of these pages will be different.
673 */ 665 */
674 function onLayoutModeToggle() { 666 function onLayoutModeToggle() {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 addTimerToPageRangeField(); 845 addTimerToPageRangeField();
854 } 846 }
855 847
856 /** 848 /**
857 * When the user stops typing in the page range textfield or clicks on the 849 * When the user stops typing in the page range textfield or clicks on the
858 * 'all-pages' checkbox, a new print preview is requested, only if 850 * 'all-pages' checkbox, a new print preview is requested, only if
859 * 1) The input is compeletely valid (it can be parsed in its entirety). 851 * 1) The input is compeletely valid (it can be parsed in its entirety).
860 * 2) The newly selected pages differ from the previously selected. 852 * 2) The newly selected pages differ from the previously selected.
861 */ 853 */
862 function onPageSelectionMayHaveChanged() { 854 function onPageSelectionMayHaveChanged() {
855 if ($('print-pages').checked)
856 pageRangesFieldChanged();
863 var validityLevel = getSelectedPagesValidityLevel(); 857 var validityLevel = getSelectedPagesValidityLevel();
864 var currentlySelectedPages = getSelectedPagesSet(); 858 var currentlySelectedPages = getSelectedPagesSet();
865 859
866 // Toggling between "all pages"/"some pages" radio buttons while having an 860 // Toggling between "all pages"/"some pages" radio buttons while having an
867 // invalid entry in the page selection textfield still requires updating the 861 // invalid entry in the page selection textfield still requires updating the
868 // print summary and print button. 862 // print summary and print button.
869 if (validityLevel < 1 || 863 if (validityLevel < 1 ||
870 areArraysEqual(previouslySelectedPages, currentlySelectedPages)) { 864 areArraysEqual(previouslySelectedPages, currentlySelectedPages)) {
871 updatePrintButtonState(); 865 updatePrintButtonState();
872 updatePrintSummary(); 866 updatePrintSummary();
(...skipping 25 matching lines...) Expand all
898 copiesField.value = 1; 892 copiesField.value = 1;
899 else { 893 else {
900 var newValue = getCopies() + sign * 1; 894 var newValue = getCopies() + sign * 1;
901 if (newValue < copiesField.min || newValue > copiesField.max) 895 if (newValue < copiesField.min || newValue > copiesField.max)
902 return; 896 return;
903 copiesField.value = newValue; 897 copiesField.value = newValue;
904 } 898 }
905 copiesFieldChanged(); 899 copiesFieldChanged();
906 } 900 }
907 901
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698