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

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

Issue 8395006: Print Preview: Hiding header/footer options when 'no margins' is selected (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing Created 9 years 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
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/margin_settings.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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;
16 this.addEventListeners_(); 17 this.addEventListeners_();
17 } 18 }
18 19
19 cr.addSingletonGetter(HeaderFooterSettings); 20 cr.addSingletonGetter(HeaderFooterSettings);
20 21
21 HeaderFooterSettings.prototype = { 22 HeaderFooterSettings.prototype = {
22 /** 23 /**
23 * The checkbox corresponding to the headers and footers option. 24 * The checkbox corresponding to the headers and footers option.
24 * @type {HTMLInputElement} 25 * @type {HTMLInputElement}
25 */ 26 */
26 get headerFooterCheckbox() { 27 get headerFooterCheckbox() {
27 return this.headerFooterCheckbox_; 28 return this.headerFooterCheckbox_;
28 }, 29 },
29 30
30 /** 31 /**
31 * Checks whether the Headers and Footers checkbox is checked or not. 32 * Checks whether the Headers and Footers checkbox is checked or not.
32 * @return {boolean} true if Headers and Footers are checked. 33 * @return {boolean} true if Headers and Footers are checked.
33 */ 34 */
34 hasHeaderFooter: function() { 35 hasHeaderFooter: function() {
35 return this.headerFooterCheckbox_.checked; 36 return this.headerFooterApplies_ && this.headerFooterCheckbox_.checked;
36 }, 37 },
37 38
38 /** 39 /**
39 * Adding listeners to header footer related controls. 40 * Adding listeners to header footer related controls.
40 * @private 41 * @private
41 */ 42 */
42 addEventListeners_: function() { 43 addEventListeners_: function() {
43 this.headerFooterCheckbox_.onclick = 44 this.headerFooterCheckbox_.onclick =
44 this.onHeaderFooterChanged_.bind(this); 45 this.onHeaderFooterChanged_.bind(this);
45 document.addEventListener(customEvents.PDF_LOADED, 46 document.addEventListener(customEvents.PDF_LOADED,
46 this.onPDFLoaded_.bind(this)); 47 this.onPDFLoaded_.bind(this));
48 document.addEventListener(customEvents.MARGINS_SELECTION_CHANGED,
49 this.onMarginsSelectionChanged_.bind(this));
50 },
51
52 onMarginsSelectionChanged_: function(event) {
53 this.headerFooterApplies_ = event.selectedMargins !=
54 print_preview.MarginSettings.MARGINS_VALUE_NO_MARGINS
55 this.setVisible_(this.headerFooterApplies_);
47 }, 56 },
48 57
49 /** 58 /**
50 * Listener executing when the user selects or de-selects the headers 59 * Listener executing when the user selects or de-selects the headers
51 * and footers option. 60 * and footers option.
52 * @private 61 * @private
53 */ 62 */
54 onHeaderFooterChanged_: function() { 63 onHeaderFooterChanged_: function() {
55 requestPrintPreview(); 64 requestPrintPreview();
56 }, 65 },
57 66
58 /** 67 /**
59 * Listener executing when a |customEvents.PDF_LOADED| event occurs. 68 * Listener executing when a |customEvents.PDF_LOADED| event occurs.
60 * @private 69 * @private
61 */ 70 */
62 onPDFLoaded_: function() { 71 onPDFLoaded_: function() {
63 if (!previewModifiable) { 72 if (!previewModifiable)
73 this.setVisible_(false);
74 },
75
76 /**
77 * Hides or shows |this.headerFooterOption|.
78 * @{param} visible True if |this.headerFooterOption| should be shown.
79 * @private
80 */
81 setVisible_: function(visible) {
82 if (visible)
83 fadeInOption(this.headerFooterOption_);
84 else
64 fadeOutOption(this.headerFooterOption_); 85 fadeOutOption(this.headerFooterOption_);
65 this.headerFooterCheckbox_.checked = false;
66 }
67 }, 86 },
68 }; 87 };
69 88
70 return { 89 return {
71 HeaderFooterSettings: HeaderFooterSettings, 90 HeaderFooterSettings: HeaderFooterSettings,
72 }; 91 };
73 }); 92 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/margin_settings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698