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 * Copies ticket item whose value is a {@code string} that indicates how many
10 * copies of the document should be printed. The ticket item is backed by a
11 * string since the user can textually input the copies value.
12 * @param {!print_preview.DestinationStore} destinationStore Destination store
13 * used determine if a destination has the copies capability.
15 * @extends {print_preview.ticket_items.TicketItem}
17 function Copies(destinationStore
) {
18 print_preview
.ticket_items
.TicketItem
.call(
19 this, null /*appState*/, null /*field*/, destinationStore
);
23 __proto__
: print_preview
.ticket_items
.TicketItem
.prototype,
26 wouldValueBeValid: function(value
) {
27 if (/[^\d]+/.test(value
)) {
30 var copies
= parseInt(value
, 10);
31 if (copies
> 999 || copies
< 1) {
38 isCapabilityAvailable: function() {
39 return !!this.getCopiesCapability_();
42 /** @return {number} The number of copies indicated by the ticket item. */
43 getValueAsNumber: function() {
44 return parseInt(this.getValue(), 10);
48 getDefaultValueInternal: function() {
49 var cap
= this.getCopiesCapability_();
50 return cap
.hasOwnProperty('default') ? cap
.default : '1';
54 getCapabilityNotAvailableValueInternal: function() {
59 * @return {Object} Copies capability of the selected destination.
62 getCopiesCapability_: function() {
63 var dest
= this.getSelectedDestInternal();
66 dest
.capabilities
.printer
&&
67 dest
.capabilities
.printer
.copies
) ||