| Index: chrome/browser/resources/print_preview/data/ticket_items/custom_margins.js
|
| diff --git a/chrome/browser/resources/print_preview/data/ticket_items/custom_margins.js b/chrome/browser/resources/print_preview/data/ticket_items/custom_margins.js
|
| index c756981db7d1fa0ae1dacce0a091baa56c52c12d..dfa74230c0f1d7a6047b62c32bf5eddacd770a81 100644
|
| --- a/chrome/browser/resources/print_preview/data/ticket_items/custom_margins.js
|
| +++ b/chrome/browser/resources/print_preview/data/ticket_items/custom_margins.js
|
| @@ -2,9 +2,25 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +cr.exportPath('print_preview.ticket_items');
|
| +
|
| +/**
|
| + * Enumeration of the orientations of margins.
|
| + * @enum {string}
|
| + */
|
| +print_preview.ticket_items.CustomMarginsOrientation = {
|
| + TOP: 'top',
|
| + RIGHT: 'right',
|
| + BOTTOM: 'bottom',
|
| + LEFT: 'left'
|
| +};
|
| +
|
| cr.define('print_preview.ticket_items', function() {
|
| 'use strict';
|
|
|
| + var CustomMarginsOrientation =
|
| + print_preview.ticket_items.CustomMarginsOrientation;
|
| +
|
| /**
|
| * Custom page margins ticket item whose value is a
|
| * {@code print_preview.Margins}.
|
| @@ -19,37 +35,26 @@ cr.define('print_preview.ticket_items', function() {
|
| print_preview.ticket_items.TicketItem.call(
|
| this,
|
| appState,
|
| - print_preview.AppState.Field.CUSTOM_MARGINS,
|
| + print_preview.AppStateField.CUSTOM_MARGINS,
|
| null /*destinationStore*/,
|
| documentInfo);
|
| - };
|
| -
|
| - /**
|
| - * Enumeration of the orientations of margins.
|
| - * @enum {string}
|
| - */
|
| - CustomMargins.Orientation = {
|
| - TOP: 'top',
|
| - RIGHT: 'right',
|
| - BOTTOM: 'bottom',
|
| - LEFT: 'left'
|
| - };
|
| + }
|
|
|
| /**
|
| * Mapping of a margin orientation to its opposite.
|
| - * @type {!Object<!print_preview.ticket_items.CustomMargins.Orientation,
|
| - * !print_preview.ticket_items.CustomMargins.Orientation>}
|
| + * @type {!Object<!print_preview.ticket_items.CustomMarginsOrientation,
|
| + * !print_preview.ticket_items.CustomMarginsOrientation>}
|
| * @private
|
| */
|
| CustomMargins.OppositeOrientation_ = {};
|
| - CustomMargins.OppositeOrientation_[CustomMargins.Orientation.TOP] =
|
| - CustomMargins.Orientation.BOTTOM;
|
| - CustomMargins.OppositeOrientation_[CustomMargins.Orientation.RIGHT] =
|
| - CustomMargins.Orientation.LEFT;
|
| - CustomMargins.OppositeOrientation_[CustomMargins.Orientation.BOTTOM] =
|
| - CustomMargins.Orientation.TOP;
|
| - CustomMargins.OppositeOrientation_[CustomMargins.Orientation.LEFT] =
|
| - CustomMargins.Orientation.RIGHT;
|
| + CustomMargins.OppositeOrientation_[CustomMarginsOrientation.TOP] =
|
| + CustomMarginsOrientation.BOTTOM;
|
| + CustomMargins.OppositeOrientation_[CustomMarginsOrientation.RIGHT] =
|
| + CustomMarginsOrientation.LEFT;
|
| + CustomMargins.OppositeOrientation_[CustomMarginsOrientation.BOTTOM] =
|
| + CustomMarginsOrientation.TOP;
|
| + CustomMargins.OppositeOrientation_[CustomMarginsOrientation.LEFT] =
|
| + CustomMarginsOrientation.RIGHT;
|
|
|
| /**
|
| * Minimum distance in points that two margins can be separated by.
|
| @@ -65,8 +70,8 @@ cr.define('print_preview.ticket_items', function() {
|
| /** @override */
|
| wouldValueBeValid: function(value) {
|
| var margins = /** @type {!print_preview.Margins} */ (value);
|
| - for (var key in CustomMargins.Orientation) {
|
| - var o = CustomMargins.Orientation[key];
|
| + for (var key in CustomMarginsOrientation) {
|
| + var o = CustomMarginsOrientation[key];
|
| var max = this.getMarginMax_(
|
| o, margins.get(CustomMargins.OppositeOrientation_[o]));
|
| if (margins.get(o) > max || margins.get(o) < 0) {
|
| @@ -87,7 +92,7 @@ cr.define('print_preview.ticket_items', function() {
|
| },
|
|
|
| /**
|
| - * @param {!print_preview.ticket_items.CustomMargins.Orientation}
|
| + * @param {!print_preview.ticket_items.CustomMarginsOrientation}
|
| * orientation Specifies the margin to get the maximum value for.
|
| * @return {number} Maximum value in points of the specified margin.
|
| */
|
| @@ -102,10 +107,10 @@ cr.define('print_preview.ticket_items', function() {
|
| var margins = /** @type {!print_preview.Margins} */ (value);
|
| if (margins != null) {
|
| margins = new print_preview.Margins(
|
| - Math.round(margins.get(CustomMargins.Orientation.TOP)),
|
| - Math.round(margins.get(CustomMargins.Orientation.RIGHT)),
|
| - Math.round(margins.get(CustomMargins.Orientation.BOTTOM)),
|
| - Math.round(margins.get(CustomMargins.Orientation.LEFT)));
|
| + Math.round(margins.get(CustomMarginsOrientation.TOP)),
|
| + Math.round(margins.get(CustomMarginsOrientation.RIGHT)),
|
| + Math.round(margins.get(CustomMarginsOrientation.BOTTOM)),
|
| + Math.round(margins.get(CustomMarginsOrientation.LEFT)));
|
| }
|
| print_preview.ticket_items.TicketItem.prototype.updateValue.call(
|
| this, margins);
|
| @@ -114,7 +119,7 @@ cr.define('print_preview.ticket_items', function() {
|
| /**
|
| * Updates the specified margin in points while keeping the value within
|
| * a maximum and minimum.
|
| - * @param {!print_preview.ticket_items.CustomMargins.Orientation}
|
| + * @param {!print_preview.ticket_items.CustomMarginsOrientation}
|
| * orientation Specifies the margin to update.
|
| * @param {number} value Updated margin value in points.
|
| */
|
| @@ -140,7 +145,7 @@ cr.define('print_preview.ticket_items', function() {
|
| },
|
|
|
| /**
|
| - * @param {!print_preview.ticket_items.CustomMargins.Orientation}
|
| + * @param {!print_preview.ticket_items.CustomMarginsOrientation}
|
| * orientation Specifies which margin to get the maximum value of.
|
| * @param {number} oppositeMargin Value of the margin in points
|
| * opposite the specified margin.
|
| @@ -148,10 +153,10 @@ cr.define('print_preview.ticket_items', function() {
|
| * @private
|
| */
|
| getMarginMax_: function(orientation, oppositeMargin) {
|
| - var dimensionLength = (orientation == CustomMargins.Orientation.TOP ||
|
| - orientation == CustomMargins.Orientation.BOTTOM) ?
|
| - this.getDocumentInfoInternal().pageSize.height :
|
| - this.getDocumentInfoInternal().pageSize.width;
|
| + var dimensionLength = (orientation == CustomMarginsOrientation.TOP ||
|
| + orientation == CustomMarginsOrientation.BOTTOM) ?
|
| + this.getDocumentInfoInternal().pageSize.height :
|
| + this.getDocumentInfoInternal().pageSize.width;
|
|
|
| var totalMargin = dimensionLength -
|
| CustomMargins.MINIMUM_MARGINS_DISTANCE_;
|
|
|