Chromium Code Reviews| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 * Updates the controls with printer capabilities information. | 178 * Updates the controls with printer capabilities information. |
| 179 * @param {Object} settingInfo printer setting information. | 179 * @param {Object} settingInfo printer setting information. |
| 180 */ | 180 */ |
| 181 function updateWithPrinterCapabilities(settingInfo) { | 181 function updateWithPrinterCapabilities(settingInfo) { |
| 182 var disableColorOption = settingInfo.disableColorOption; | 182 var disableColorOption = settingInfo.disableColorOption; |
| 183 var setColorAsDefault = settingInfo.setColorAsDefault; | 183 var setColorAsDefault = settingInfo.setColorAsDefault; |
| 184 var colorOption = $('color'); | 184 var colorOption = $('color'); |
| 185 var bwOption = $('bw'); | 185 var bwOption = $('bw'); |
| 186 | 186 |
| 187 if (disableColorOption) | 187 if (disableColorOption) |
| 188 $('color-options').classList.add("hidden"); | 188 fadeOutElement($('color-options')); |
| 189 else | 189 else |
| 190 $('color-options').classList.remove("hidden"); | 190 fadeInElement($('color-options')); |
| 191 | 191 |
| 192 if (colorOption.checked != setColorAsDefault) { | 192 if (colorOption.checked != setColorAsDefault) { |
| 193 colorOption.checked = setColorAsDefault; | 193 colorOption.checked = setColorAsDefault; |
| 194 bwOption.checked = !setColorAsDefault; | 194 bwOption.checked = !setColorAsDefault; |
| 195 setColor(colorOption.checked); | 195 setColor(colorOption.checked); |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 | 198 |
| 199 /** | 199 /** |
| 200 * Disables or enables all controls in the options pane except for the cancel | 200 * Disables or enables all controls in the options pane except for the cancel |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 * Called when the PDF plugin loads its document. | 470 * Called when the PDF plugin loads its document. |
| 471 */ | 471 */ |
| 472 function onPDFLoad() { | 472 function onPDFLoad() { |
| 473 if (isLandscape()) | 473 if (isLandscape()) |
| 474 $('pdf-viewer').fitToWidth(); | 474 $('pdf-viewer').fitToWidth(); |
| 475 else | 475 else |
| 476 $('pdf-viewer').fitToHeight(); | 476 $('pdf-viewer').fitToHeight(); |
| 477 | 477 |
| 478 $('dancing-dots').classList.add('invisible'); | 478 $('dancing-dots').classList.add('invisible'); |
| 479 | 479 |
| 480 if (!previewModifiable) { | 480 if (!previewModifiable) |
| 481 $('landscape').disabled = true; | 481 fadeOutElement($('landscape-option')); |
|
Lei Zhang
2011/05/26 01:13:28
I wonder if we should still disable it though? Can
| |
| 482 $('portrait').disabled = true; | |
| 483 } | |
| 484 | 482 |
| 485 updateCopiesButtonsState(); | 483 updateCopiesButtonsState(); |
| 486 } | 484 } |
| 487 | 485 |
| 488 /** | 486 /** |
| 489 * Update the print preview when new preview data is available. | 487 * Update the print preview when new preview data is available. |
| 490 * Create the PDF plugin as needed. | 488 * Create the PDF plugin as needed. |
| 491 * Called from PrintPreviewUI::PreviewDataIsAvailable(). | 489 * Called from PrintPreviewUI::PreviewDataIsAvailable(). |
| 492 * @param {number} pageCount The expected total pages count. | 490 * @param {number} pageCount The expected total pages count. |
| 493 * @param {string} jobTitle The print job title. | 491 * @param {string} jobTitle The print job title. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 var individualPagesField = $('individual-pages'); | 613 var individualPagesField = $('individual-pages'); |
| 616 var individualPagesHint = $('individual-pages-hint'); | 614 var individualPagesHint = $('individual-pages-hint'); |
| 617 var validityLevel = getSelectedPagesValidityLevel(); | 615 var validityLevel = getSelectedPagesValidityLevel(); |
| 618 | 616 |
| 619 if (validityLevel == 1) | 617 if (validityLevel == 1) |
| 620 individualPagesField.classList.remove('invalid'); | 618 individualPagesField.classList.remove('invalid'); |
| 621 else | 619 else |
| 622 individualPagesField.classList.add('invalid'); | 620 individualPagesField.classList.add('invalid'); |
| 623 | 621 |
| 624 if (individualPagesField.value.length == 0) { | 622 if (individualPagesField.value.length == 0) { |
| 625 hideInvalidHint(individualPagesHint); | 623 fadeOutElement(individualPagesHint); |
| 626 } else if (currentlySelectedPages.length == 0) { | 624 } else if (currentlySelectedPages.length == 0) { |
| 627 individualPagesHint.classList.remove('suggestion'); | 625 individualPagesHint.classList.remove('suggestion'); |
| 628 individualPagesHint.classList.add('invalid'); | 626 individualPagesHint.classList.add('invalid'); |
| 629 individualPagesHint.innerHTML = | 627 individualPagesHint.innerHTML = |
| 630 localStrings.getStringF('pageRangeInstruction', | 628 localStrings.getStringF('pageRangeInstruction', |
| 631 localStrings.getString( | 629 localStrings.getString( |
| 632 'examplePageRangeText')); | 630 'examplePageRangeText')); |
| 633 showInvalidHint(individualPagesHint); | 631 fadeInElement(individualPagesHint); |
| 634 } else if (individualPagesField.value.replace(/\s*/g,'') != | 632 } else if (individualPagesField.value.replace(/\s*/g,'') != |
| 635 getPageRangesSuggestion().replace(/\s*/g,'')) { | 633 getPageRangesSuggestion().replace(/\s*/g,'')) { |
| 636 individualPagesHint.innerHTML = | 634 individualPagesHint.innerHTML = |
| 637 localStrings.getStringF('didYouMean', getPageRangesSuggestion()); | 635 localStrings.getStringF('didYouMean', getPageRangesSuggestion()); |
| 638 individualPagesHint.classList.remove('invalid'); | 636 individualPagesHint.classList.remove('invalid'); |
| 639 individualPagesHint.classList.add('suggestion'); | 637 individualPagesHint.classList.add('suggestion'); |
| 640 showInvalidHint(individualPagesHint); | 638 fadeInElement(individualPagesHint); |
| 641 } else if (individualPagesField.value.replace(/\s*/g,'') == | 639 } else if (individualPagesField.value.replace(/\s*/g,'') == |
| 642 getPageRangesSuggestion().replace(/\s*/g,'')) { | 640 getPageRangesSuggestion().replace(/\s*/g,'')) { |
| 643 hideInvalidHint(individualPagesHint); | 641 fadeOutElement(individualPagesHint); |
| 644 } | 642 } |
| 645 | 643 |
| 646 resetPageRangeFieldTimer(); | 644 resetPageRangeFieldTimer(); |
| 647 updatePrintButtonState(); | 645 updatePrintButtonState(); |
| 648 updatePrintSummary(); | 646 updatePrintSummary(); |
| 649 } | 647 } |
| 650 | 648 |
| 651 /** | 649 /** |
| 652 * Updates the state of the increment/decrement buttons based on the current | 650 * Updates the state of the increment/decrement buttons based on the current |
| 653 * 'copies' value. | 651 * 'copies' value. |
| 654 */ | 652 */ |
| 655 function updateCopiesButtonsState() { | 653 function updateCopiesButtonsState() { |
| 656 var copiesField = $('copies'); | 654 var copiesField = $('copies'); |
| 657 if (!isNumberOfCopiesValid()) { | 655 if (!isNumberOfCopiesValid()) { |
| 658 copiesField.classList.add('invalid'); | 656 copiesField.classList.add('invalid'); |
| 659 $('increment').disabled = false; | 657 $('increment').disabled = false; |
| 660 $('decrement').disabled = false; | 658 $('decrement').disabled = false; |
| 661 showInvalidHint($('copies-hint')); | 659 fadeInElement($('copies-hint')); |
| 662 } | 660 } |
| 663 else { | 661 else { |
| 664 copiesField.classList.remove('invalid'); | 662 copiesField.classList.remove('invalid'); |
| 665 $('increment').disabled = (getCopies() == copiesField.max) ? true : false; | 663 $('increment').disabled = (getCopies() == copiesField.max) ? true : false; |
| 666 $('decrement').disabled = (getCopies() == copiesField.min) ? true : false; | 664 $('decrement').disabled = (getCopies() == copiesField.min) ? true : false; |
| 667 hideInvalidHint($('copies-hint')); | 665 fadeOutElement($('copies-hint')); |
| 668 } | 666 } |
| 669 } | 667 } |
| 670 | 668 |
| 671 /** | 669 /** |
| 672 * Updates the print summary based on the currently selected user options. | 670 * Updates the print summary based on the currently selected user options. |
| 673 * | 671 * |
| 674 */ | 672 */ |
| 675 function updatePrintSummary() { | 673 function updatePrintSummary() { |
| 676 var copies = getCopies(); | 674 var copies = getCopies(); |
| 677 var printSummary = $('print-summary'); | 675 var printSummary = $('print-summary'); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 return; | 742 return; |
| 745 | 743 |
| 746 $('individual-pages').classList.remove('invalid'); | 744 $('individual-pages').classList.remove('invalid'); |
| 747 setDefaultValuesAndRegeneratePreview(); | 745 setDefaultValuesAndRegeneratePreview(); |
| 748 } | 746 } |
| 749 | 747 |
| 750 /** | 748 /** |
| 751 * Sets the default values and sends a request to regenerate preview data. | 749 * Sets the default values and sends a request to regenerate preview data. |
| 752 */ | 750 */ |
| 753 function setDefaultValuesAndRegeneratePreview() { | 751 function setDefaultValuesAndRegeneratePreview() { |
| 754 hideInvalidHint($('individual-pages-hint')); | 752 fadeOutElement($('individual-pages-hint')); |
| 755 totalPageCount = -1; | 753 totalPageCount = -1; |
| 756 previouslySelectedPages.length = 0; | 754 previouslySelectedPages.length = 0; |
| 757 requestPrintPreview(); | 755 requestPrintPreview(); |
| 758 } | 756 } |
| 759 | 757 |
| 760 /** | 758 /** |
| 761 * Returns a list of all pages in the specified ranges. The pages are listed in | 759 * Returns a list of all pages in the specified ranges. The pages are listed in |
| 762 * the order they appear in the 'individual-pages' textbox and duplicates are | 760 * the order they appear in the 'individual-pages' textbox and duplicates are |
| 763 * not eliminated. If the page ranges can't be parsed an empty list is | 761 * not eliminated. If the page ranges can't be parsed an empty list is |
| 764 * returned. | 762 * returned. |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 this.isLandscape = ''; | 974 this.isLandscape = ''; |
| 977 } | 975 } |
| 978 | 976 |
| 979 /** | 977 /** |
| 980 * Takes a snapshot of the print settings. | 978 * Takes a snapshot of the print settings. |
| 981 */ | 979 */ |
| 982 PrintSettings.prototype.save = function() { | 980 PrintSettings.prototype.save = function() { |
| 983 this.deviceName = getSelectedPrinterName(); | 981 this.deviceName = getSelectedPrinterName(); |
| 984 this.isLandscape = isLandscape(); | 982 this.isLandscape = isLandscape(); |
| 985 } | 983 } |
| OLD | NEW |