OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 cr.define('print_preview', function() { | |
6 'use strict'; | |
7 | |
8 /** | |
9 * Creates a HeaderFooterSettings object. This object encapsulates all | |
10 * settings and logic related to the headers and footers checkbox. | |
11 * @constructor | |
12 */ | |
13 function HeaderFooterSettings() { | |
14 this.headerFooterOption_ = $('header-footer-option'); | |
15 this.headerFooterCheckbox_ = $('header-footer'); | |
16 } | |
17 | |
18 cr.addSingletonGetter(HeaderFooterSettings); | |
19 | |
20 HeaderFooterSettings.prototype = { | |
21 /** | |
22 * The checkbox corresponding to the headers and footers option. | |
23 * @type {HTMLInputElement} | |
24 */ | |
25 get headerFooterCheckbox() { | |
26 return this.headerFooterCheckbox_; | |
27 }, | |
28 | |
29 /** | |
30 * Checks whether the Headers and Footers checkbox is checked or not. | |
31 * @return {boolean} true if Headers and Footers are checked. | |
32 */ | |
33 hasHeaderFooter: function() { | |
34 return this.headerFooterCheckbox_.checked; | |
35 }, | |
36 | |
37 /** | |
38 * Adding listeners to header footer related controls. | |
39 */ | |
40 addEventListeners: function() { | |
41 this.headerFooterCheckbox_.onclick = | |
42 this.onHeaderFooterChanged_.bind(this); | |
43 document.addEventListener('PDFLoaded', this.onPDFLoaded_.bind(this)); | |
44 }, | |
45 | |
46 /** | |
47 * Listener executing when the user selects or de-selects the headers | |
48 * and footers option. | |
49 * @private | |
50 */ | |
51 onHeaderFooterChanged_: function() { | |
52 requestPrintPreview(); | |
53 }, | |
54 | |
55 /** | |
56 * Listener executing when a PDFLoaded event occurs. | |
57 * @private | |
58 */ | |
59 onPDFLoaded_: function() { | |
60 if (!previewModifiable) | |
61 fadeOutElement(this.headerFooterOption_); | |
62 }, | |
63 }; | |
64 | |
65 return { | |
66 HeaderFooterSettings: HeaderFooterSettings, | |
67 }; | |
68 }); | |
OLD | NEW |