Chromium Code Reviews| Index: chrome/browser/resources/print_preview/data/margins.js |
| diff --git a/chrome/browser/resources/print_preview/data/margins.js b/chrome/browser/resources/print_preview/data/margins.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..027dfba7196828d1f15788fc43c5e44ef366474a |
| --- /dev/null |
| +++ b/chrome/browser/resources/print_preview/data/margins.js |
| @@ -0,0 +1,97 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +cr.define('print_preview', function() { |
| + 'use strict'; |
| + |
| + /** |
| + * Creates a Margins object that holds four margin values in points. |
| + * |
| + * @param {number} top The top margin in pts. |
| + * @param {number} right The right margin in pts. |
| + * @param {number} bottom The bottom margin in pts. |
| + * @param {number} left The left margin in pts. |
| + * @constructor |
| + */ |
| + function Margins(top, right, bottom, left) { |
| + /** |
| + * Top margin in points. |
| + * @type {number} |
| + * @private |
| + */ |
| + this.top_ = top; |
| + |
| + /** |
| + * Right margin in points. |
| + * @type {number} |
| + * @private |
| + */ |
| + this.right_ = right; |
| + |
| + /** |
| + * Bottom margin in points. |
| + * @type {number} |
| + * @private |
| + */ |
| + this.bottom_ = bottom; |
| + |
| + /** |
| + * Left margin in points. |
| + * @type {number} |
| + * @private |
| + */ |
| + this.left_ = left; |
| + }; |
| + |
| + /** |
| + * Enumeration of margin types. |
| + * @enum {string} |
| + */ |
| + Margins.Type = { |
| + DEFAULT: 'default', |
|
dpapad
2012/04/24 01:24:56
Why changing these to strings?
Robert Toscano
2012/04/24 22:29:56
Good question. The only reason why numbers were us
dpapad
2012/04/24 22:50:19
Alternatively you could add one more enum constant
Robert Toscano
2012/04/28 01:41:37
Ok, I'll go with what you suggest except for the U
dpapad
2012/04/30 16:19:26
Ok, just make sure to initialize variables to null
|
| + NO_MARGINS: 'no-margins', |
| + MINIMUM: 'minimum', |
| + CUSTOM: 'custom' |
| + }, |
| + |
| + Margins.prototype = { |
| + /** @return {number} Top margin in points. */ |
| + get top() { |
| + return this.top_; |
| + }, |
| + |
| + /** @return {number} Right margin in points. */ |
| + get right() { |
| + return this.right_; |
| + }, |
| + |
| + /** @return {number} Bottom margin in points. */ |
| + get bottom() { |
| + return this.bottom_; |
| + }, |
| + |
| + /** @return {number} Left margin in points. */ |
| + get left() { |
| + return this.left_; |
| + }, |
| + |
| + /** |
| + * @param {print_preview.Margins} other The other margins object to compare |
| + * against. |
| + * @return {boolean} Whether this margins object is equal to another. |
| + */ |
| + equals: function(other) { |
| + return other != null && |
| + this.top_ == other.top_ && |
| + this.right_ == other.right_ && |
| + this.bottom_ == other.bottom_ && |
| + this.left_ == other.left_; |
| + } |
| + }; |
| + |
| + // Export |
| + return { |
| + Margins: Margins |
| + }; |
| +}); |