summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources
diff options
context:
space:
mode:
authoraayushkumar@chromium.org <aayushkumar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-17 23:09:36 +0000
committeraayushkumar@chromium.org <aayushkumar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-17 23:09:36 +0000
commit55b23a0e5ac8b7e29ba56892d302286856b7f98a (patch)
treea8eafe6383ba93551cf8ca4bbd262ab2cee3c7cc /chrome/browser/resources
parent4e8e0d15fcc521d60b489dd829084c0507ec57bc (diff)
downloadchromium_src-55b23a0e5ac8b7e29ba56892d302286856b7f98a.zip
chromium_src-55b23a0e5ac8b7e29ba56892d302286856b7f98a.tar.gz
chromium_src-55b23a0e5ac8b7e29ba56892d302286856b7f98a.tar.bz2
Added Header and Footer support in Linux, Windows and Mac for Skia
BUG=67514 TEST= In the preview tab, note added options for printing headers and footers. Toggle with the checkbox and ensure that the correct headers and footers are displayed. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=97219 Review URL: http://codereview.chromium.org/7348010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97233 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r--chrome/browser/resources/print_preview/header_footer_settings.html7
-rw-r--r--chrome/browser/resources/print_preview/header_footer_settings.js68
-rw-r--r--chrome/browser/resources/print_preview/print_preview.css8
-rw-r--r--chrome/browser/resources/print_preview/print_preview.html2
-rw-r--r--chrome/browser/resources/print_preview/print_preview.js7
5 files changed, 92 insertions, 0 deletions
diff --git a/chrome/browser/resources/print_preview/header_footer_settings.html b/chrome/browser/resources/print_preview/header_footer_settings.html
new file mode 100644
index 0000000..66c8a57
--- /dev/null
+++ b/chrome/browser/resources/print_preview/header_footer_settings.html
@@ -0,0 +1,7 @@
+<div id="header-footer-option" class="two-column option visible">
+ <h1 i18n-content="optionsLabel"></h1>
+ <div>
+ <input id="header-footer" type="checkbox" checked>
+ <label for="header-footer" i18n-content="optionHeaderFooter"></label>
+ </div>
+</div>
diff --git a/chrome/browser/resources/print_preview/header_footer_settings.js b/chrome/browser/resources/print_preview/header_footer_settings.js
new file mode 100644
index 0000000..80ac094
--- /dev/null
+++ b/chrome/browser/resources/print_preview/header_footer_settings.js
@@ -0,0 +1,68 @@
+// Copyright (c) 2011 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 HeaderFooterSettings object. This object encapsulates all
+ * settings and logic related to the headers and footers checkbox.
+ * @constructor
+ */
+ function HeaderFooterSettings() {
+ this.headerFooterOption_ = $('header-footer-option');
+ this.headerFooterCheckbox_ = $('header-footer');
+ }
+
+ cr.addSingletonGetter(HeaderFooterSettings);
+
+ HeaderFooterSettings.prototype = {
+ /**
+ * The checkbox corresponding to the headers and footers option.
+ * @type {HTMLInputElement}
+ */
+ get headerFooterCheckbox() {
+ return this.headerFooterCheckbox_;
+ },
+
+ /**
+ * Checks whether the Headers and Footers checkbox is checked or not.
+ * @return {boolean} true if Headers and Footers are checked.
+ */
+ hasHeaderFooter: function() {
+ return this.headerFooterCheckbox_.checked;
+ },
+
+ /**
+ * Adding listeners to header footer related controls.
+ */
+ addEventListeners: function() {
+ this.headerFooterCheckbox_.onclick =
+ this.onHeaderFooterChanged_.bind(this);
+ document.addEventListener('PDFLoaded', this.onPDFLoaded_.bind(this));
+ },
+
+ /**
+ * Listener executing when the user selects or de-selects the headers
+ * and footers option.
+ * @private
+ */
+ onHeaderFooterChanged_: function() {
+ requestPrintPreview();
+ },
+
+ /**
+ * Listener executing when a PDFLoaded event occurs.
+ * @private
+ */
+ onPDFLoaded_: function() {
+ if (!previewModifiable)
+ fadeOutElement(this.headerFooterOption_);
+ },
+ };
+
+ return {
+ HeaderFooterSettings: HeaderFooterSettings,
+ };
+});
diff --git a/chrome/browser/resources/print_preview/print_preview.css b/chrome/browser/resources/print_preview/print_preview.css
index 96a0776..61a9915 100644
--- a/chrome/browser/resources/print_preview/print_preview.css
+++ b/chrome/browser/resources/print_preview/print_preview.css
@@ -346,6 +346,14 @@ html[os=mac] input[type='checkbox']:checked::before {
top: 2px;
}
+html[os=mac] #options-horizontal-separator {
+ display: none;
+}
+
+html[os=mac] #options-option {
+ display: none;
+}
+
input[type='radio'] {
-webkit-box-shadow: inset 0 1px 2px white,
0 1px 2px rgba(0, 0, 0, .2);
diff --git a/chrome/browser/resources/print_preview/print_preview.html b/chrome/browser/resources/print_preview/print_preview.html
index fde7e79..d29ebc5 100644
--- a/chrome/browser/resources/print_preview/print_preview.html
+++ b/chrome/browser/resources/print_preview/print_preview.html
@@ -39,6 +39,8 @@
<hr>
<include src="color_settings.html"></include>
<hr>
+ <include src="header_footer_settings.html"></include>
+ <hr id="options-horizontal-separator">
<div id="system-dialog-div">
<button id="system-dialog-link" class="link-button"
i18n-content="systemDialogOption"></button>
diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js
index 4beefe5..f262ba4 100644
--- a/chrome/browser/resources/print_preview/print_preview.js
+++ b/chrome/browser/resources/print_preview/print_preview.js
@@ -51,6 +51,9 @@ var copiesSettings;
// Object holding all the layout related settings.
var layoutSettings;
+// Object holding all the header footer related settings.
+var headerFooterSettings;
+
// Object holding all the color related settings.
var colorSettings;
@@ -104,10 +107,12 @@ function onLoad() {
pageSettings = print_preview.PageSettings.getInstance();
copiesSettings = print_preview.CopiesSettings.getInstance();
layoutSettings = print_preview.LayoutSettings.getInstance();
+ headerFooterSettings = print_preview.HeaderFooterSettings.getInstance();
colorSettings = print_preview.ColorSettings.getInstance();
printHeader.addEventListeners();
pageSettings.addEventListeners();
copiesSettings.addEventListeners();
+ headerFooterSettings.addEventListeners();
layoutSettings.addEventListeners();
colorSettings.addEventListeners();
$('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities;
@@ -311,6 +316,7 @@ function getSettings() {
'color': colorSettings.isColor(),
'printToPDF': printToPDF,
'isFirstRequest' : false,
+ 'headerFooterEnabled': headerFooterSettings.hasHeaderFooter(),
'requestID': -1};
var printerList = $('printer-list');
@@ -957,5 +963,6 @@ function setDefaultValuesAndRegeneratePreview() {
<include src="print_header.js"/>
<include src="page_settings.js"/>
<include src="copies_settings.js"/>
+<include src="header_footer_settings.js"/>
<include src="layout_settings.js"/>
<include src="color_settings.js"/>