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 15 matching lines...) Expand all Loading... | |
26 // Destination list special value constants. | 26 // Destination list special value constants. |
27 const PRINT_TO_PDF = 'Print To PDF'; | 27 const PRINT_TO_PDF = 'Print To PDF'; |
28 const MANAGE_PRINTERS = 'Manage Printers'; | 28 const MANAGE_PRINTERS = 'Manage Printers'; |
29 | 29 |
30 // State of the print preview settings. | 30 // State of the print preview settings. |
31 var printSettings = new PrintSettings(); | 31 var printSettings = new PrintSettings(); |
32 | 32 |
33 // The name of the default or last used printer. | 33 // The name of the default or last used printer. |
34 var defaultOrLastUsedPrinterName = ''; | 34 var defaultOrLastUsedPrinterName = ''; |
35 | 35 |
36 // True when a pending print preview request exists. | |
37 var hasPendingPreviewRequest = false; | |
38 | |
39 // True when a pending print file request exists. | |
40 var hasPendingPrintFileRequest = false; | |
41 | |
42 // True when preview tab has some error. | |
43 var hasError = false; | |
kmadhusu
2011/06/09 20:15:09
Removed hasCompatiblePlugin and isInitiatorTabClos
| |
44 | |
36 /** | 45 /** |
37 * Window onload handler, sets up the page and starts print preview by getting | 46 * Window onload handler, sets up the page and starts print preview by getting |
38 * the printer list. | 47 * the printer list. |
39 */ | 48 */ |
40 function onLoad() { | 49 function onLoad() { |
41 $('system-dialog-link').addEventListener('click', showSystemDialog); | 50 $('system-dialog-link').addEventListener('click', showSystemDialog); |
42 $('cancel-button').addEventListener('click', handleCancelButtonClick); | 51 $('cancel-button').addEventListener('click', handleCancelButtonClick); |
43 | 52 |
44 if (!checkCompatiblePluginExists()) { | 53 if (!checkCompatiblePluginExists()) { |
45 displayErrorMessage(localStrings.getString('noPlugin'), false); | 54 displayErrorMessage(localStrings.getString('noPlugin'), false); |
46 $('mainview').parentElement.removeChild($('dummy-viewer')); | 55 $('mainview').parentElement.removeChild($('dummy-viewer')); |
47 return; | 56 return; |
48 } | 57 } |
49 $('mainview').parentElement.removeChild($('dummy-viewer')); | 58 $('mainview').parentElement.removeChild($('dummy-viewer')); |
50 | 59 |
51 $('printer-list').disabled = true; | 60 $('printer-list').disabled = true; |
52 $('print-button').disabled = true; | 61 $('print-button').onclick = printFile; |
62 | |
63 setDefaultHandlersForPagesAndCopiesControls(); | |
53 showLoadingAnimation(); | 64 showLoadingAnimation(); |
54 chrome.send('getDefaultPrinter'); | 65 chrome.send('getDefaultPrinter'); |
55 } | 66 } |
56 | 67 |
57 /** | 68 /** |
69 * Handles the individual pages input event. | |
70 */ | |
71 function handleIndividualPagesInputEvent() { | |
72 $('print-pages').checked = true; | |
73 resetPageRangeFieldTimer(); | |
74 } | |
75 | |
76 /** | |
77 * Handles the individual pages blur event. | |
78 */ | |
79 function onPageRangesFieldBlur() { | |
80 $('print-pages').checked = true; | |
dpapad
2011/06/09 20:32:38
Since this line exists also in handleIndividualPag
kmadhusu
2011/06/09 21:27:11
(just repeating our in-person conversation): This
| |
81 validatePageRangesField(); | |
82 updatePrintButtonState(); | |
83 } | |
84 | |
85 /** | |
86 * Sets the default event handlers for pages and copies controls. | |
87 */ | |
88 function setDefaultHandlersForPagesAndCopiesControls() { | |
89 var allPages = $('all-pages'); | |
90 var printPages = $('print-pages'); | |
91 var individualPages = $('individual-pages'); | |
92 | |
93 allPages.onclick = null; | |
94 printPages.onclick = null; | |
95 individualPages.oninput = null; | |
96 individualPages.onfocus = null; | |
97 individualPages.onblur = null; | |
98 | |
99 if (!hasError) { | |
100 allPages.onclick = updatePrintButtonState; | |
101 printPages.onclick = handleIndividualPagesCheckbox; | |
102 individualPages.onblur = onPageRangesFieldBlur; | |
103 } | |
104 | |
105 $('copies').oninput = copiesFieldChanged; | |
106 $('increment').onclick = function() { onCopiesButtonsClicked(1); }; | |
107 $('decrement').onclick = function() { onCopiesButtonsClicked(-1); }; | |
108 } | |
109 | |
110 /** | |
58 * Adds event listeners to the settings controls. | 111 * Adds event listeners to the settings controls. |
59 */ | 112 */ |
60 function addEventListeners() { | 113 function addEventListeners() { |
61 $('print-button').onclick = printFile; | |
62 | |
63 // Controls that require preview rendering. | 114 // Controls that require preview rendering. |
64 $('all-pages').onclick = onPageSelectionMayHaveChanged; | 115 $('all-pages').onclick = onPageSelectionMayHaveChanged; |
65 $('print-pages').onclick = handleIndividualPagesCheckbox; | 116 $('print-pages').onclick = handleIndividualPagesCheckbox; |
66 var individualPages = $('individual-pages'); | 117 var individualPages = $('individual-pages'); |
67 individualPages.onblur = function() { | 118 individualPages.onblur = function() { |
68 clearTimeout(timerId); | 119 clearTimeout(timerId); |
69 onPageSelectionMayHaveChanged(); | 120 onPageSelectionMayHaveChanged(); |
70 }; | 121 }; |
71 individualPages.onfocus = addTimerToPageRangeField; | 122 individualPages.onfocus = addTimerToPageRangeField; |
72 individualPages.oninput = resetPageRangeFieldTimer; | 123 individualPages.oninput = handleIndividualPagesInputEvent; |
73 $('landscape').onclick = onLayoutModeToggle; | 124 $('landscape').onclick = onLayoutModeToggle; |
74 $('portrait').onclick = onLayoutModeToggle; | 125 $('portrait').onclick = onLayoutModeToggle; |
75 $('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities; | 126 $('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities; |
76 | 127 |
77 // Controls that dont require preview rendering. | 128 // Controls that dont require preview rendering. |
78 $('copies').oninput = function() { | 129 $('copies').oninput = function() { |
79 copiesFieldChanged(); | 130 copiesFieldChanged(); |
80 updatePrintButtonState(); | 131 updatePrintButtonState(); |
81 updatePrintSummary(); | 132 updatePrintSummary(); |
82 }; | 133 }; |
83 $('two-sided').onclick = handleTwoSidedClick; | 134 $('two-sided').onclick = handleTwoSidedClick; |
84 $('color').onclick = function() { setColor(true); }; | 135 $('color').onclick = function() { setColor(true); }; |
85 $('bw').onclick = function() { setColor(false); }; | 136 $('bw').onclick = function() { setColor(false); }; |
86 $('increment').onclick = function() { | 137 $('increment').onclick = function() { |
87 onCopiesButtonsClicked(1); | 138 onCopiesButtonsClicked(1); |
88 updatePrintButtonState(); | 139 updatePrintButtonState(); |
89 updatePrintSummary(); | 140 updatePrintSummary(); |
90 }; | 141 }; |
91 $('decrement').onclick = function() { | 142 $('decrement').onclick = function() { |
92 onCopiesButtonsClicked(-1); | 143 onCopiesButtonsClicked(-1); |
93 updatePrintButtonState(); | 144 updatePrintButtonState(); |
94 updatePrintSummary(); | 145 updatePrintSummary(); |
95 }; | 146 }; |
96 } | 147 } |
97 | 148 |
98 /** | 149 /** |
99 * Removes event listeners from the settings controls. | 150 * Removes event listeners from the settings controls. |
100 */ | 151 */ |
101 function removeEventListeners() { | 152 function removeEventListeners() { |
102 // Controls that require preview rendering. | |
103 $('print-button').disabled = true; | |
104 $('all-pages').onclick = null; | |
105 $('print-pages').onclick = null; | |
106 var individualPages = $('individual-pages'); | |
107 individualPages.onblur = null; | |
108 individualPages.onfocus = null; | |
109 individualPages.oninput = null; | |
110 clearTimeout(timerId); | 153 clearTimeout(timerId); |
154 setDefaultHandlersForPagesAndCopiesControls(); | |
155 | |
156 // Controls that require preview rendering | |
111 $('landscape').onclick = null; | 157 $('landscape').onclick = null; |
112 $('portrait').onclick = null; | 158 $('portrait').onclick = null; |
113 $('printer-list').onchange = null; | 159 $('printer-list').onchange = null; |
114 | 160 |
115 // Controls that dont require preview rendering. | 161 // Controls that dont require preview rendering. |
116 $('copies').oninput = copiesFieldChanged; | |
117 $('two-sided').onclick = null; | 162 $('two-sided').onclick = null; |
118 $('color').onclick = null; | 163 $('color').onclick = null; |
119 $('bw').onclick = null; | 164 $('bw').onclick = null; |
120 $('increment').onclick = function() { onCopiesButtonsClicked(1); }; | |
121 $('decrement').onclick = function() { onCopiesButtonsClicked(-1); }; | |
122 } | 165 } |
123 | 166 |
124 /** | 167 /** |
125 * Asks the browser to close the preview tab. | 168 * Asks the browser to close the preview tab. |
126 */ | 169 */ |
127 function handleCancelButtonClick() { | 170 function handleCancelButtonClick() { |
128 chrome.send('closePrintPreviewTab'); | 171 chrome.send('closePrintPreviewTab'); |
129 } | 172 } |
130 | 173 |
131 /** | 174 /** |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 var deviceName = ''; | 365 var deviceName = ''; |
323 if (selectedPrinter >= 0) | 366 if (selectedPrinter >= 0) |
324 deviceName = printerList.options[selectedPrinter].value; | 367 deviceName = printerList.options[selectedPrinter].value; |
325 return deviceName; | 368 return deviceName; |
326 } | 369 } |
327 | 370 |
328 /** | 371 /** |
329 * Asks the browser to print the preview PDF based on current print settings. | 372 * Asks the browser to print the preview PDF based on current print settings. |
330 */ | 373 */ |
331 function printFile() { | 374 function printFile() { |
375 hasPendingPrintFileRequest = hasPendingPreviewRequest ? true : false; | |
dpapad
2011/06/09 20:32:38
I agree with thestig on this,
"hasPendingPrintFil
kmadhusu
2011/06/09 21:27:11
Done.
| |
376 | |
377 if (hasPendingPrintFileRequest) { | |
378 if (getSelectedPrinterName() != PRINT_TO_PDF) | |
379 chrome.send('hidePreview'); | |
380 return; | |
381 } | |
382 | |
332 if (getSelectedPrinterName() != PRINT_TO_PDF) { | 383 if (getSelectedPrinterName() != PRINT_TO_PDF) { |
333 $('print-button').classList.add('loading'); | 384 $('print-button').classList.add('loading'); |
334 $('cancel-button').classList.add('loading'); | 385 $('cancel-button').classList.add('loading'); |
335 $('print-summary').innerHTML = localStrings.getString('printing'); | 386 $('print-summary').innerHTML = localStrings.getString('printing'); |
336 removeEventListeners(); | 387 removeEventListeners(); |
337 window.setTimeout(function() { chrome.send('print', [getSettingsJSON()]); }, | 388 window.setTimeout(function() { chrome.send('print', [getSettingsJSON()]); }, |
338 1000); | 389 1000); |
339 } else | 390 } else { |
340 chrome.send('print', [getSettingsJSON()]); | 391 chrome.send('print', [getSettingsJSON()]); |
392 } | |
341 } | 393 } |
342 | 394 |
343 /** | 395 /** |
344 * Asks the browser to generate a preview PDF based on current print settings. | 396 * Asks the browser to generate a preview PDF based on current print settings. |
345 */ | 397 */ |
346 function requestPrintPreview() { | 398 function requestPrintPreview() { |
399 hasPendingPreviewRequest = true; | |
347 removeEventListeners(); | 400 removeEventListeners(); |
348 printSettings.save(); | 401 printSettings.save(); |
349 showLoadingAnimation(); | 402 showLoadingAnimation(); |
350 chrome.send('getPreview', [getSettingsJSON()]); | 403 chrome.send('getPreview', [getSettingsJSON()]); |
351 } | 404 } |
352 | 405 |
353 /** | 406 /** |
354 * Set the default printer. If there is one, generate a print preview. | 407 * Set the default printer. If there is one, generate a print preview. |
355 * @param {string} printer Name of the default printer. Empty if none. | 408 * @param {string} printer Name of the default printer. Empty if none. |
356 */ | 409 */ |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
430 var pdfViewer = $('pdf-viewer'); | 483 var pdfViewer = $('pdf-viewer'); |
431 if (!pdfViewer) { | 484 if (!pdfViewer) { |
432 return; | 485 return; |
433 } | 486 } |
434 pdfViewer.grayscale(!color); | 487 pdfViewer.grayscale(!color); |
435 } | 488 } |
436 | 489 |
437 /** | 490 /** |
438 * Display an error message in the center of the preview area. | 491 * Display an error message in the center of the preview area. |
439 * @param {string} errorMessage The error message to be displayed. | 492 * @param {string} errorMessage The error message to be displayed. |
440 * @param {boolean} showButton Indivates whether the "Reopen the page" button | 493 * @param {boolean} showButton Indicates whether the "Reopen the page" button |
441 * should be displayed. | 494 * should be displayed. |
442 */ | 495 */ |
443 function displayErrorMessage(errorMessage, showButton) { | 496 function displayErrorMessage(errorMessage, showButton) { |
497 hasError = true; | |
498 $('print-button').disabled = true; | |
444 $('overlay-layer').classList.remove('invisible'); | 499 $('overlay-layer').classList.remove('invisible'); |
445 $('dancing-dots-text').classList.add('hidden'); | 500 $('dancing-dots-text').classList.add('hidden'); |
446 $('error-text').innerHTML = errorMessage; | 501 $('error-text').innerHTML = errorMessage; |
447 $('error-text').classList.remove('hidden'); | 502 $('error-text').classList.remove('hidden'); |
448 if (showButton) | 503 if (showButton) |
449 $('reopen-page').classList.remove('hidden'); | 504 $('reopen-page').classList.remove('hidden'); |
450 else | 505 else |
451 $('reopen-page').classList.add('hidden'); | 506 $('reopen-page').classList.add('hidden'); |
452 | 507 |
453 removeEventListeners(); | 508 removeEventListeners(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 * @param {string} jobTitle The print job title. | 544 * @param {string} jobTitle The print job title. |
490 * @param {boolean} modifiable If the preview is modifiable. | 545 * @param {boolean} modifiable If the preview is modifiable. |
491 * @param {string} previewUid Preview unique identifier. | 546 * @param {string} previewUid Preview unique identifier. |
492 */ | 547 */ |
493 function updatePrintPreview(pageCount, jobTitle, modifiable, previewUid) { | 548 function updatePrintPreview(pageCount, jobTitle, modifiable, previewUid) { |
494 var tempPrintSettings = new PrintSettings(); | 549 var tempPrintSettings = new PrintSettings(); |
495 tempPrintSettings.save(); | 550 tempPrintSettings.save(); |
496 | 551 |
497 previewModifiable = modifiable; | 552 previewModifiable = modifiable; |
498 | 553 |
554 hasPendingPreviewRequest = false; | |
555 | |
499 if (totalPageCount == -1) | 556 if (totalPageCount == -1) |
500 totalPageCount = pageCount; | 557 totalPageCount = pageCount; |
501 | 558 |
502 if (previouslySelectedPages.length == 0) | 559 if (previouslySelectedPages.length == 0) |
503 for (var i = 0; i < totalPageCount; i++) | 560 for (var i = 0; i < totalPageCount; i++) |
504 previouslySelectedPages.push(i+1); | 561 previouslySelectedPages.push(i+1); |
505 | 562 |
506 if (printSettings.deviceName != tempPrintSettings.deviceName) { | 563 if (printSettings.deviceName != tempPrintSettings.deviceName) { |
507 updateControlsWithSelectedPrinterCapabilities(); | 564 updateControlsWithSelectedPrinterCapabilities(); |
508 return; | 565 return; |
509 } else if (printSettings.isLandscape != tempPrintSettings.isLandscape) { | 566 } else if (printSettings.isLandscape != tempPrintSettings.isLandscape) { |
510 setDefaultValuesAndRegeneratePreview(); | 567 setDefaultValuesAndRegeneratePreview(); |
511 return; | 568 return; |
512 } else if (isSelectedPagesValid()) { | 569 } else if (isSelectedPagesValid()) { |
513 var currentlySelectedPages = getSelectedPagesSet(); | 570 var currentlySelectedPages = getSelectedPagesSet(); |
514 if (!areArraysEqual(previouslySelectedPages, currentlySelectedPages)) { | 571 if (!areArraysEqual(previouslySelectedPages, currentlySelectedPages)) { |
515 previouslySelectedPages = currentlySelectedPages; | 572 previouslySelectedPages = currentlySelectedPages; |
516 requestPrintPreview(); | 573 requestPrintPreview(); |
517 return; | 574 return; |
518 } | 575 } |
519 } | 576 } |
520 | 577 |
521 if (!isSelectedPagesValid()) | 578 if (!isSelectedPagesValid()) |
522 pageRangesFieldChanged(); | 579 pageRangesFieldChanged(); |
523 | 580 |
524 // Update the current tab title. | 581 // Update the current tab title. |
525 document.title = localStrings.getStringF('printPreviewTitleFormat', jobTitle); | 582 document.title = localStrings.getStringF('printPreviewTitleFormat', jobTitle); |
526 | 583 |
527 createPDFPlugin(previewUid); | 584 createPDFPlugin(previewUid); |
585 | |
dpapad
2011/06/09 20:32:38
nit: Remove blank line.
kmadhusu
2011/06/09 21:27:11
Done.
| |
528 updatePrintSummary(); | 586 updatePrintSummary(); |
529 updatePrintButtonState(); | 587 updatePrintButtonState(); |
530 addEventListeners(); | 588 addEventListeners(); |
589 | |
590 if (hasPendingPrintFileRequest) | |
591 printFile(); | |
531 } | 592 } |
532 | 593 |
533 /** | 594 /** |
534 * Create the PDF plugin or reload the existing one. | 595 * Create the PDF plugin or reload the existing one. |
535 * @param {string} previewUid Preview unique identifier. | 596 * @param {string} previewUid Preview unique identifier. |
536 */ | 597 */ |
537 function createPDFPlugin(previewUid) { | 598 function createPDFPlugin(previewUid) { |
538 // Enable the print button. | 599 // Enable the print button. |
539 if (!$('printer-list').disabled) { | 600 if (!$('printer-list').disabled) { |
540 $('print-button').disabled = false; | 601 $('print-button').disabled = false; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 /** | 660 /** |
600 * Listener function that executes whenever a change occurs in the 'copies' | 661 * Listener function that executes whenever a change occurs in the 'copies' |
601 * field. | 662 * field. |
602 */ | 663 */ |
603 function copiesFieldChanged() { | 664 function copiesFieldChanged() { |
604 updateCopiesButtonsState(); | 665 updateCopiesButtonsState(); |
605 $('collate-option').hidden = getCopies() <= 1; | 666 $('collate-option').hidden = getCopies() <= 1; |
606 } | 667 } |
607 | 668 |
608 /** | 669 /** |
609 * Executes whenever a blur event occurs on the 'individual-pages' | 670 * Validates the page ranges text and updates the hint accordingly. |
610 * field or when the timer expires. It takes care of | |
611 * 1) showing/hiding warnings/suggestions | |
612 * 2) updating print button/summary | |
613 */ | 671 */ |
614 function pageRangesFieldChanged() { | 672 function validatePageRangesField() { |
615 var currentlySelectedPages = getSelectedPagesSet(); | |
616 var individualPagesField = $('individual-pages'); | 673 var individualPagesField = $('individual-pages'); |
617 var individualPagesHint = $('individual-pages-hint'); | 674 var individualPagesHint = $('individual-pages-hint'); |
618 | 675 |
619 if (isSelectedPagesValid()) { | 676 if (isSelectedPagesValid()) { |
620 individualPagesField.classList.remove('invalid'); | 677 individualPagesField.classList.remove('invalid'); |
621 fadeOutElement(individualPagesHint); | 678 fadeOutElement(individualPagesHint); |
622 } else { | 679 } else { |
623 individualPagesField.classList.add('invalid'); | 680 individualPagesField.classList.add('invalid'); |
624 individualPagesHint.classList.remove('suggestion'); | 681 individualPagesHint.classList.remove('suggestion'); |
625 individualPagesHint.innerHTML = | 682 individualPagesHint.innerHTML = |
626 localStrings.getStringF('pageRangeInstruction', | 683 localStrings.getStringF('pageRangeInstruction', |
627 localStrings.getString( | 684 localStrings.getString( |
628 'examplePageRangeText')); | 685 'examplePageRangeText')); |
629 fadeInElement(individualPagesHint); | 686 fadeInElement(individualPagesHint); |
630 } | 687 } |
688 } | |
689 | |
690 /** | |
691 * Executes whenever a blur event occurs on the 'individual-pages' | |
692 * field or when the timer expires. It takes care of | |
693 * 1) showing/hiding warnings/suggestions | |
694 * 2) updating print button/summary | |
695 */ | |
696 function pageRangesFieldChanged() { | |
697 validatePageRangesField(); | |
631 | 698 |
632 resetPageRangeFieldTimer(); | 699 resetPageRangeFieldTimer(); |
633 updatePrintButtonState(); | 700 updatePrintButtonState(); |
634 updatePrintSummary(); | 701 updatePrintSummary(); |
635 } | 702 } |
636 | 703 |
637 /** | 704 /** |
638 * Updates the state of the increment/decrement buttons based on the current | 705 * Updates the state of the increment/decrement buttons based on the current |
639 * 'copies' value. | 706 * 'copies' value. |
640 */ | 707 */ |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
799 var successfullyParsed = 0; | 866 var successfullyParsed = 0; |
800 var parts = pageText.split(/,/); | 867 var parts = pageText.split(/,/); |
801 | 868 |
802 for (var i = 0; i < parts.length; ++i) { | 869 for (var i = 0; i < parts.length; ++i) { |
803 var part = parts[i].replace(/\s*/g, ''); | 870 var part = parts[i].replace(/\s*/g, ''); |
804 if (part.length == 0) | 871 if (part.length == 0) |
805 continue; | 872 continue; |
806 | 873 |
807 var match = part.match(/^([0-9]+)-([0-9]*)$/); | 874 var match = part.match(/^([0-9]+)-([0-9]*)$/); |
808 if (match && isValidNonZeroPositiveInteger(match[1])) { | 875 if (match && isValidNonZeroPositiveInteger(match[1])) { |
876 if (!match[2] && totalPageCount == -1) { | |
877 successfullyParsed += 1; | |
878 continue; | |
879 } | |
809 var from = parseInt(match[1], 10); | 880 var from = parseInt(match[1], 10); |
810 var to = match[2] ? parseInt(match[2], 10) : totalPageCount; | 881 var to = match[2] ? parseInt(match[2], 10) : totalPageCount; |
811 | 882 |
812 if (!to || from > to) | 883 if (!to || from > to) |
813 return false; | 884 return false; |
814 } else if (!isValidNonZeroPositiveInteger(part) || | 885 } else if (!isValidNonZeroPositiveInteger(part) || (totalPageCount != -1 && |
815 !(parseInt(part, 10) <= totalPageCount)) { | 886 !(parseInt(part, 10) <= totalPageCount))) { |
816 return false; | 887 return false; |
817 } | 888 } |
818 successfullyParsed += 1; | 889 successfullyParsed += 1; |
819 } | 890 } |
820 return successfullyParsed > 0 | 891 return successfullyParsed > 0 |
821 } | 892 } |
822 | 893 |
823 /** | 894 /** |
824 * Returns true if |value| is a valid non zero positive integer. | 895 * Returns true if |value| is a valid non zero positive integer. |
825 * @param {string} value The string to be tested. | 896 * @param {string} value The string to be tested. |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
955 this.isLandscape = ''; | 1026 this.isLandscape = ''; |
956 } | 1027 } |
957 | 1028 |
958 /** | 1029 /** |
959 * Takes a snapshot of the print settings. | 1030 * Takes a snapshot of the print settings. |
960 */ | 1031 */ |
961 PrintSettings.prototype.save = function() { | 1032 PrintSettings.prototype.save = function() { |
962 this.deviceName = getSelectedPrinterName(); | 1033 this.deviceName = getSelectedPrinterName(); |
963 this.isLandscape = isLandscape(); | 1034 this.isLandscape = isLandscape(); |
964 } | 1035 } |
OLD | NEW |