Chromium Code Reviews| Index: chrome/browser/resources/print_preview/header_footer_settings.js |
| 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 0000000000000000000000000000000000000000..f7d2560a238533b1a5513480d0d6b6d513b5aefa |
| --- /dev/null |
| +++ b/chrome/browser/resources/print_preview/header_footer_settings.js |
| @@ -0,0 +1,69 @@ |
| +// 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. |
| + * |
|
James Hawkins
2011/08/15 19:39:35
Remove blank comment line.
Aayush Kumar
2011/08/15 21:37:37
Done.
|
| + * @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, |
| + }; |
| +}); |