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
3 // found in the LICENSE file.
5 cr.define('print_preview.ticket_items', function() {
9 * Page range ticket item whose value is a {@code string} that represents
10 * which pages in the document should be printed.
11 * @param {!print_preview.DocumentInfo} documentInfo Information about the
14 * @extends {print_preview.ticket_items.TicketItem}
16 function PageRange(documentInfo) {
17 print_preview.ticket_items.TicketItem.call(
21 null /*destinationStore*/,
26 * Impossibly large page number.
31 PageRange.MAX_PAGE_NUMBER_ = 1000000000;
33 PageRange.prototype = {
34 __proto__: print_preview.ticket_items.TicketItem.prototype,
37 wouldValueBeValid: function(value) {
38 return null != pageRangeTextToPageRanges(
39 value, this.getDocumentInfoInternal().pageCount);
43 * @return {!print_preview.PageNumberSet} Set of page numbers defined by the
46 getPageNumberSet: function() {
47 var pageNumberList = pageRangeTextToPageList(
48 this.getValue(), this.getDocumentInfoInternal().pageCount);
49 return new print_preview.PageNumberSet(pageNumberList);
53 isCapabilityAvailable: function() {
58 getDefaultValueInternal: function() {
63 getCapabilityNotAvailableValueInternal: function() {
68 * @return {!Array.<Object.<{from: number, to: number}>>} A list of page
71 getPageRanges: function() {
72 return pageRangeTextToPageRanges(this.getValue()) || [];
76 * @return {!Array.<object.<{from: number, to: number}>>} A list of page
77 * ranges suitable for use in the native layer.
78 * TODO(vitalybuka): this should be removed when native layer switched to
81 getDocumentPageRanges: function() {
82 var pageRanges = pageRangeTextToPageRanges(
83 this.getValue(), this.getDocumentInfoInternal().pageCount);
84 return pageRanges || [];