Index: chrome/browser/resources/print_preview/data/ticket_items/page_range.js |
diff --git a/chrome/browser/resources/print_preview/data/ticket_items/page_range.js b/chrome/browser/resources/print_preview/data/ticket_items/page_range.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2fc715217f0b56c82e52de1eafb0d87717850f69 |
--- /dev/null |
+++ b/chrome/browser/resources/print_preview/data/ticket_items/page_range.js |
@@ -0,0 +1,70 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+cr.define('print_preview.ticket_items', function() { |
+ 'use strict'; |
+ |
+ /** |
+ * Page range ticket item whose value is a {@code string} that represents |
+ * which pages in the document should be printed. |
+ * @param {!print_preview.DocumentInfo} documentInfo Information about the |
+ * document to print. |
+ * @constructor |
+ * @extends {print_preview.ticket_items.TicketItem} |
+ */ |
+ function PageRange(documentInfo) { |
+ print_preview.ticket_items.TicketItem.call(this); |
+ |
+ /** |
+ * Information about the document to print. |
+ * @type {!print_preview.DocumentInfo} |
+ * @private |
+ */ |
+ this.documentInfo_ = documentInfo; |
+ }; |
+ |
+ PageRange.prototype = { |
+ __proto__: print_preview.ticket_items.TicketItem.prototype, |
+ |
+ /** @override */ |
+ wouldValueBeValid: function(value) { |
+ return value == '' || |
+ isPageRangeTextValid(value, this.documentInfo_.pageCount); |
+ }, |
+ |
+ /** |
+ * @return {!print_preview.PageNumberSet} Set of page numbers defined by the |
+ * page range string. |
+ */ |
+ getPageNumberSet: function() { |
+ if (this.isValid()) { |
+ return print_preview.PageNumberSet.parse( |
+ this.getValue(), this.documentInfo_.pageCount); |
+ } else { |
+ return print_preview.PageNumberSet.parse( |
+ this.getDefaultValueInternal(), this.documentInfo_.pageCount); |
+ } |
+ }, |
+ |
+ /** @override */ |
+ isCapabilityAvailable: function() { |
+ return true; |
+ }, |
+ |
+ /** @override */ |
+ getDefaultValueInternal: function() { |
+ return ''; |
+ }, |
+ |
+ /** @override */ |
+ getCapabilityNotAvailableValueInternal: function() { |
+ return ''; |
+ } |
+ }; |
+ |
+ // Export |
+ return { |
+ PageRange: PageRange |
+ }; |
+}); |