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 * Margins type ticket item whose value is a
10 * {@link print_preview.ticket_items.MarginsType.Value} that indicates what
11 * predefined margins type to use.
12 * @param {!print_preview.AppState} appState App state persistence object to
13 * save the state of the margins type selection.
14 * @param {!print_preview.DocumentInfo} documentInfo Information about the
16 * @param {!print_preview.CustomMargins} customMargins Custom margins ticket
17 * item, used to write when margins type changes.
19 * @extends {print_preview.ticket_items.TicketItem}
21 function MarginsType(appState, documentInfo, customMargins) {
22 print_preview.ticket_items.TicketItem.call(
25 print_preview.AppState.Field.MARGINS_TYPE,
26 null /*destinationStore*/,
30 * Custom margins ticket item, used to write when margins type changes.
31 * @type {!print_preview.ticket_items.CustomMargins}
34 this.customMargins_ = customMargins;
38 * Enumeration of margin types. Matches enum MarginType in
39 * printing/print_job_constants.h.
49 MarginsType.prototype = {
50 __proto__: print_preview.ticket_items.TicketItem.prototype,
53 wouldValueBeValid: function(value) {
58 isCapabilityAvailable: function() {
59 return this.getDocumentInfoInternal().isModifiable;
63 getDefaultValueInternal: function() {
64 return MarginsType.Value.DEFAULT;
68 getCapabilityNotAvailableValueInternal: function() {
69 return MarginsType.Value.DEFAULT;
73 updateValueInternal: function(value) {
74 print_preview.ticket_items.TicketItem.prototype.updateValueInternal.call(
76 if (this.isValueEqual(
77 print_preview.ticket_items.MarginsType.Value.CUSTOM)) {
78 // If CUSTOM, set the value of the custom margins so that it won't be
79 // overridden by the default value.
80 this.customMargins_.updateValue(this.customMargins_.getValue());
87 MarginsType: MarginsType