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

Side by Side Diff: chrome/browser/resources/print_preview/header_footer_settings.js

Issue 9699040: PrintPreview: Hide/Show the header footer option based on print frame margins. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: addressed review comments Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('print_preview', function() { 5 cr.define('print_preview', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Creates a HeaderFooterSettings object. This object encapsulates all 9 * Creates a HeaderFooterSettings object. This object encapsulates all
10 * settings and logic related to the headers and footers checkbox. 10 * settings and logic related to the headers and footers checkbox.
11 * @constructor 11 * @constructor
12 */ 12 */
13 function HeaderFooterSettings() { 13 function HeaderFooterSettings() {
14 this.headerFooterOption_ = $('header-footer-option'); 14 this.headerFooterOption_ = $('header-footer-option');
15 this.headerFooterCheckbox_ = $('header-footer'); 15 this.headerFooterCheckbox_ = $('header-footer');
16 this.headerFooterApplies_ = false;
17 this.addEventListeners_(); 16 this.addEventListeners_();
18 } 17 }
19 18
20 cr.addSingletonGetter(HeaderFooterSettings); 19 cr.addSingletonGetter(HeaderFooterSettings);
21 20
22 HeaderFooterSettings.prototype = { 21 HeaderFooterSettings.prototype = {
23 /** 22 /**
24 * The checkbox corresponding to the headers and footers option. 23 * The checkbox corresponding to the headers and footers option.
25 * @type {HTMLInputElement} 24 * @type {HTMLInputElement}
26 */ 25 */
27 get headerFooterCheckbox() { 26 get headerFooterCheckbox() {
28 return this.headerFooterCheckbox_; 27 return this.headerFooterCheckbox_;
29 }, 28 },
30 29
31 /** 30 /**
32 * Checks whether the Headers and Footers checkbox is checked or not. 31 * Checks whether the Headers and Footers checkbox is checked or not.
33 * @return {boolean} true if Headers and Footers are checked. 32 * @return {boolean} true if Headers and Footers are checked.
34 */ 33 */
35 hasHeaderFooter: function() { 34 hasHeaderFooter: function() {
36 return this.headerFooterApplies_ && this.headerFooterCheckbox_.checked; 35 return previewModifiable && this.headerFooterCheckbox_.checked;
37 }, 36 },
38 37
39 /** 38 /**
40 * Sets the state of the headers footers checkbox. 39 * Sets the state of the headers footers checkbox.
41 * @param {boolean} checked True if the headers footers checkbox shoule be 40 * @param {boolean} checked True if the headers footers checkbox shoule be
42 * checked, false if not. 41 * checked, false if not.
43 */ 42 */
44 setChecked: function(checked) { 43 setChecked: function(checked) {
45 this.headerFooterCheckbox_.checked = checked; 44 this.headerFooterCheckbox_.checked = checked;
46 }, 45 },
47 46
48 /** 47 /**
49 * Adding listeners to header footer related controls. 48 * Adding listeners to header footer related controls.
50 * @private 49 * @private
51 */ 50 */
52 addEventListeners_: function() { 51 addEventListeners_: function() {
53 this.headerFooterCheckbox_.onclick = 52 this.headerFooterCheckbox_.onclick =
54 this.onHeaderFooterChanged_.bind(this); 53 this.onHeaderFooterChanged_.bind(this);
55 document.addEventListener(customEvents.PDF_LOADED, 54 document.addEventListener(customEvents.PDF_LOADED,
56 this.onPDFLoaded_.bind(this)); 55 this.onPDFLoaded_.bind(this));
57 document.addEventListener(customEvents.MARGINS_SELECTION_CHANGED,
58 this.onMarginsSelectionChanged_.bind(this));
59 },
60
61 onMarginsSelectionChanged_: function(event) {
62 this.headerFooterApplies_ = event.selectedMargins !=
63 print_preview.MarginSettings.MARGINS_VALUE_NO_MARGINS;
64 this.setVisible_(this.headerFooterApplies_);
65 }, 56 },
66 57
67 /** 58 /**
68 * Listener executing when the user selects or de-selects the headers 59 * Listener executing when the user selects or de-selects the headers
69 * and footers option. 60 * and footers option.
70 * @private 61 * @private
71 */ 62 */
72 onHeaderFooterChanged_: function() { 63 onHeaderFooterChanged_: function() {
73 requestPrintPreview(); 64 requestPrintPreview();
74 }, 65 },
75 66
76 /** 67 /**
77 * Listener executing when a |customEvents.PDF_LOADED| event occurs. 68 * Listener executing when a |customEvents.PDF_LOADED| event occurs.
78 * @private 69 * @private
79 */ 70 */
80 onPDFLoaded_: function() { 71 onPDFLoaded_: function() {
81 if (!previewModifiable) 72 if (!previewModifiable)
82 this.setVisible_(false); 73 this.setVisible_(false);
dpapad 2012/03/15 17:01:18 This is throwing an error. s/setVisible_/setVisib
kmadhusu 2012/03/15 18:46:25 Fixed.
83 }, 74 },
84 75
85 /** 76 /**
86 * Hides or shows |this.headerFooterOption|. 77 * Hides or shows |this.headerFooterOption|.
87 * @param {boolean} visible True if |this.headerFooterOption| should be 78 * @param {boolean} visible True if |this.headerFooterOption| should be
88 * shown. 79 * shown.
89 * @private
90 */ 80 */
91 setVisible_: function(visible) { 81 setVisible: function(visible) {
92 if (visible) 82 if (visible)
93 fadeInOption(this.headerFooterOption_); 83 fadeInOption(this.headerFooterOption_);
94 else 84 else
95 fadeOutOption(this.headerFooterOption_); 85 fadeOutOption(this.headerFooterOption_);
96 } 86 }
97 }; 87 };
98 88
99 return { 89 return {
100 HeaderFooterSettings: HeaderFooterSettings 90 HeaderFooterSettings: HeaderFooterSettings
101 }; 91 };
102 }); 92 });
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_preview_message_handler.cc ('k') | chrome/browser/resources/print_preview/margin_settings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698