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 |
index 2fc715217f0b56c82e52de1eafb0d87717850f69..2f66e9010bac1befcbf1d4d82ce5d135751f6909 100644 |
--- a/chrome/browser/resources/print_preview/data/ticket_items/page_range.js |
+++ b/chrome/browser/resources/print_preview/data/ticket_items/page_range.js |
@@ -24,13 +24,21 @@ cr.define('print_preview.ticket_items', function() { |
this.documentInfo_ = documentInfo; |
}; |
+ /** |
+ * Impossibly large page number. |
+ * @type {number} |
+ * @const |
+ * @private |
+ */ |
+ PageRange.MAX_PAGE_NUMBER_ = 1000000000; |
+ |
PageRange.prototype = { |
__proto__: print_preview.ticket_items.TicketItem.prototype, |
/** @override */ |
wouldValueBeValid: function(value) { |
- return value == '' || |
- isPageRangeTextValid(value, this.documentInfo_.pageCount); |
+ return null != pageRangeTextToPageRanges(value, |
+ this.documentInfo_.pageCount); |
Toscano
2013/02/11 21:25:13
if this.documentInfo_.pageCount is 0, then this co
Vitaly Buka (NO REVIEWS)
2013/02/12 00:46:44
Done.
|
}, |
/** |
@@ -38,13 +46,9 @@ cr.define('print_preview.ticket_items', function() { |
* 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); |
- } |
+ var pageNumberList = pageRangeTextToPageList( |
+ this.getValue(), this.documentInfo_.pageCount); |
+ return new print_preview.PageNumberSet(pageNumberList); |
}, |
/** @override */ |
@@ -60,6 +64,38 @@ cr.define('print_preview.ticket_items', function() { |
/** @override */ |
getCapabilityNotAvailableValueInternal: function() { |
return ''; |
+ }, |
+ |
+ /** |
+ * @return {!Array.<object.<{from: number, to: number}>>} A list of page |
+ * ranges suitable for use in the native layer. |
+ */ |
+ getPageRanges: function(page_count) { |
+ if (page_count === undefined) |
+ page_count = this.documentInfo_.pageCount; |
+ var page_ranges = pageRangeTextToPageRanges(this.getValue(), page_count); |
+ return page_ranges ? page_ranges : []; |
+ }, |
+ |
+ /** |
+ * @return {print_preview.ticket_items.PageRange} Copy of this object. |
+ */ |
+ clone: function() { |
+ var range = new PageRange(this.documentInfo_); |
+ range.updateValue(this.getValue()); |
+ return range; |
+ }, |
+ |
+ /** |
+ * @param {print_preview.ticket_items.PageRange} other Page range to compare |
+ * against. |
+ * @return {boolean} Whether another page range is equal to current one. |
+ */ |
+ equals: function(other) { |
+ if (other == null) |
Toscano
2013/02/11 21:25:13
Plz always use braces.
Vitaly Buka (NO REVIEWS)
2013/02/12 00:46:44
Done.
|
+ return false; |
+ return areRangesEqual(this.getPageRanges(PageRange.MAX_PAGE_NUMBER_), |
+ other.getPageRanges(PageRange.MAX_PAGE_NUMBER_)); |
} |
}; |