Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1989)

Unified Diff: chrome/browser/resources/print_preview/data/ticket_items/header_footer.js

Issue 10108001: Refactor print preview web ui (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes broken tests Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/data/ticket_items/header_footer.js
diff --git a/chrome/browser/resources/print_preview/data/ticket_items/header_footer.js b/chrome/browser/resources/print_preview/data/ticket_items/header_footer.js
new file mode 100644
index 0000000000000000000000000000000000000000..b741d192c9134e43ff21955d4bc3ecd3b5a60623
--- /dev/null
+++ b/chrome/browser/resources/print_preview/data/ticket_items/header_footer.js
@@ -0,0 +1,99 @@
+// 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.ticket_items', function() {
+ 'use strict';
+
+ /**
+ * Header-footer ticket item whose value is a {@code boolean} that indicates
+ * whether the document should be printed with headers and footers.
+ * @param {!print_preview.DocumentInfo} documentInfo Information about the
+ * document to print.
+ * @param {!print_preview.ticket_items.MarginsType} marginsType Ticket item
+ * that stores which predefined margins to print with.
+ * @param {!print_preview.ticket_items.CustomMargins} customMargins Ticket
+ * item that stores custom margin values.
+ * @constructor
+ * @extends {print_preview.ticket_items.TicketItem}
+ */
+ function HeaderFooter(documentInfo, marginsType, customMargins) {
+ print_preview.ticket_items.TicketItem.call(this);
+
+ /**
+ * Information about the document to print.
+ * @type {!print_preview.DocumentInfo}
+ * @private
+ */
+ this.documentInfo_ = documentInfo;
+
+ /**
+ * Ticket item that stores which predefined margins to print with.
+ * @type {!print_preview.ticket_items.MarginsType}
+ * @private
+ */
+ this.marginsType_ = marginsType;
+
+ /**
+ * Ticket item that stores custom margin values.
+ * @type {!print_preview.ticket_items.CustomMargins}
+ * @private
+ */
+ this.customMargins_ = customMargins;
+ };
+
+ /**
+ * Minimum value of a top or bottom margin that can fit a header and footer.
+ * @type {number}
+ * @const
+ * @private
+ */
+ HeaderFooter.MIN_MARGIN_SIZE_ = 72.0 / 2.0; // Half inch.
+
+ HeaderFooter.prototype = {
+ __proto__: print_preview.ticket_items.TicketItem.prototype,
+
+ /** @override */
+ wouldValueBeValid: function(value) {
+ return true;
+ },
+
+ /** @override */
+ isCapabilityAvailable: function() {
+ if (!this.documentInfo_.isModifiable ||
+ this.marginsType_.getValue() ==
+ print_preview.ticket_items.MarginsType.Value.NO_MARGINS) {
+ return false;
+ }
+ if (this.marginsType_.getValue() ==
+ print_preview.ticket_items.MarginsType.Value.CUSTOM) {
+ if (!this.customMargins_.isValid()) {
+ return false;
+ }
+ var marginsInPts = this.customMargins_.getValueInPts();
+ var orientEnum = print_preview.ticket_items.CustomMargins.Orientation;
+ if (marginsInPts.get(orientEnum.TOP) < HeaderFooter.MIN_MARGIN_SIZE_ &&
+ marginsInPts.get(orientEnum.BOTTOM) <
+ HeaderFooter.MIN_MARGIN_SIZE_) {
+ return false;
+ }
+ }
+ return true;
+ },
+
+ /** @override */
+ getDefaultValueInternal: function() {
+ return true;
+ },
+
+ /** @override */
+ getCapabilityNotAvailableValueInternal: function() {
+ return false;
+ }
+ };
+
+ // Export
+ return {
+ HeaderFooter: HeaderFooter
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698