Chromium Code Reviews| 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..a7b500ffe463b03f221dde963df36b096b528329 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,6 +2,19 @@ |
| // 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'; |
|
dpapad
2017/05/05 17:32:50
Nit (optional): You might be able to create a shor
rbpotter
2017/05/05 18:25:46
Done.
|
| @@ -19,37 +32,30 @@ 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_[ |
| + print_preview.ticket_items.CustomMarginsOrientation.TOP] = |
| + print_preview.ticket_items.CustomMarginsOrientation.BOTTOM; |
| + CustomMargins.OppositeOrientation_[ |
| + print_preview.ticket_items.CustomMarginsOrientation.RIGHT] = |
| + print_preview.ticket_items.CustomMarginsOrientation.LEFT; |
| + CustomMargins.OppositeOrientation_[ |
| + print_preview.ticket_items.CustomMarginsOrientation.BOTTOM] = |
| + print_preview.ticket_items.CustomMarginsOrientation.TOP; |
| + CustomMargins.OppositeOrientation_[ |
| + print_preview.ticket_items.CustomMarginsOrientation.LEFT] = |
| + print_preview.ticket_items.CustomMarginsOrientation.RIGHT; |
| /** |
| * Minimum distance in points that two margins can be separated by. |
| @@ -65,8 +71,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 print_preview.ticket_items.CustomMarginsOrientation) { |
| + var o = print_preview.ticket_items.CustomMarginsOrientation[key]; |
| var max = this.getMarginMax_( |
| o, margins.get(CustomMargins.OppositeOrientation_[o])); |
| if (margins.get(o) > max || margins.get(o) < 0) { |
| @@ -87,7 +93,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 +108,14 @@ 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(print_preview.ticket_items. |
| + CustomMarginsOrientation.TOP)), |
| + Math.round(margins.get(print_preview.ticket_items. |
| + CustomMarginsOrientation.RIGHT)), |
| + Math.round(margins.get(print_preview.ticket_items. |
| + CustomMarginsOrientation.BOTTOM)), |
| + Math.round(margins.get(print_preview.ticket_items. |
| + CustomMarginsOrientation.LEFT))); |
| } |
| print_preview.ticket_items.TicketItem.prototype.updateValue.call( |
| this, margins); |
| @@ -114,7 +124,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 +150,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 +158,13 @@ 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 == |
| + print_preview.ticket_items.CustomMarginsOrientation.TOP || |
| + orientation == |
| + print_preview.ticket_items.CustomMarginsOrientation.BOTTOM) ? |
| + this.getDocumentInfoInternal().pageSize.height : |
| + this.getDocumentInfoInternal().pageSize.width; |
| var totalMargin = dimensionLength - |
| CustomMargins.MINIMUM_MARGINS_DISTANCE_; |