| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('print_preview.ticket_items', function() { | 5 cr.define('print_preview.ticket_items', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Page range ticket item whose value is a {@code string} that represents | 9 * Page range ticket item whose value is a {@code string} that represents |
| 10 * which pages in the document should be printed. | 10 * which pages in the document should be printed. |
| 11 * @param {!print_preview.DocumentInfo} documentInfo Information about the | 11 * @param {!print_preview.DocumentInfo} documentInfo Information about the |
| 12 * document to print. | 12 * document to print. |
| 13 * @constructor | 13 * @constructor |
| 14 * @extends {print_preview.ticket_items.TicketItem} | 14 * @extends {print_preview.ticket_items.TicketItem} |
| 15 */ | 15 */ |
| 16 function PageRange(documentInfo) { | 16 function PageRange(documentInfo) { |
| 17 print_preview.ticket_items.TicketItem.call( | 17 print_preview.ticket_items.TicketItem.call( |
| 18 this, | 18 this, null /*appState*/, null /*field*/, null /*destinationStore*/, |
| 19 null /*appState*/, | |
| 20 null /*field*/, | |
| 21 null /*destinationStore*/, | |
| 22 documentInfo); | 19 documentInfo); |
| 23 } | 20 } |
| 24 | 21 |
| 25 /** | 22 /** |
| 26 * Impossibly large page number. | 23 * Impossibly large page number. |
| 27 * @type {number} | 24 * @type {number} |
| 28 * @const | 25 * @const |
| 29 * @private | 26 * @private |
| 30 */ | 27 */ |
| 31 PageRange.MAX_PAGE_NUMBER_ = 1000000000; | 28 PageRange.MAX_PAGE_NUMBER_ = 1000000000; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 /** @override */ | 60 /** @override */ |
| 64 getCapabilityNotAvailableValueInternal: function() { | 61 getCapabilityNotAvailableValueInternal: function() { |
| 65 return ''; | 62 return ''; |
| 66 }, | 63 }, |
| 67 | 64 |
| 68 /** | 65 /** |
| 69 * @return {string} The value of the ticket item as a string. | 66 * @return {string} The value of the ticket item as a string. |
| 70 * @private | 67 * @private |
| 71 */ | 68 */ |
| 72 getValueAsString_: function() { | 69 getValueAsString_: function() { |
| 73 return /** @type {string} */(this.getValue()); | 70 return /** @type {string} */ (this.getValue()); |
| 74 }, | 71 }, |
| 75 | 72 |
| 76 /** | 73 /** |
| 77 * @return {!Array<Object<{from: number, to: number}>>} A list of page | 74 * @return {!Array<Object<{from: number, to: number}>>} A list of page |
| 78 * ranges. | 75 * ranges. |
| 79 */ | 76 */ |
| 80 getPageRanges: function() { | 77 getPageRanges: function() { |
| 81 var pageRanges = pageRangeTextToPageRanges(this.getValueAsString_()); | 78 var pageRanges = pageRangeTextToPageRanges(this.getValueAsString_()); |
| 82 return pageRanges instanceof Array ? pageRanges : []; | 79 return pageRanges instanceof Array ? pageRanges : []; |
| 83 }, | 80 }, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 100 getDocumentNumPages: function() { | 97 getDocumentNumPages: function() { |
| 101 return this.getDocumentInfoInternal().pageCount; | 98 return this.getDocumentInfoInternal().pageCount; |
| 102 }, | 99 }, |
| 103 | 100 |
| 104 /** | 101 /** |
| 105 * @return {!PageRangeStatus} | 102 * @return {!PageRangeStatus} |
| 106 */ | 103 */ |
| 107 checkValidity: function() { | 104 checkValidity: function() { |
| 108 var pageRanges = pageRangeTextToPageRanges( | 105 var pageRanges = pageRangeTextToPageRanges( |
| 109 this.getValueAsString_(), this.getDocumentInfoInternal().pageCount); | 106 this.getValueAsString_(), this.getDocumentInfoInternal().pageCount); |
| 110 return pageRanges instanceof Array ? | 107 return pageRanges instanceof Array ? PageRangeStatus.NO_ERROR : |
| 111 PageRangeStatus.NO_ERROR : pageRanges; | 108 pageRanges; |
| 112 }, | 109 }, |
| 113 }; | 110 }; |
| 114 | 111 |
| 115 // Export | 112 // Export |
| 116 return { | 113 return {PageRange: PageRange}; |
| 117 PageRange: PageRange | |
| 118 }; | |
| 119 }); | 114 }); |
| OLD | NEW |