OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 cr.define('print_preview', function() { | |
6 'use strict'; | |
7 | |
8 /** | |
9 * Creates a MoreOptions object. This object encapsulates all | |
10 * settings and logic related to the more options section. | |
11 * @constructor | |
12 */ | |
13 function MoreOptions() { | |
14 // @type {HTMLDivElement} HTML element representing more options. | |
15 this.moreOptions_ = $('more-options'); | |
16 | |
17 // @type {boolean} True if header footer option is hidden. | |
18 this.hideHeaderFooterOption_ = true; | |
dpapad
2012/04/19 21:11:29
Maybe a better name would be headerFooterOptionHid
kmadhusu
2012/04/20 23:03:42
Modified the comment.
| |
19 | |
20 // @type {boolean} True if fit to page option is hidden. | |
21 this.hideFitToPageOption_ = true; | |
22 | |
23 this.addEventListeners_(); | |
24 } | |
25 | |
26 cr.addSingletonGetter(MoreOptions); | |
27 | |
28 MoreOptions.prototype = { | |
29 /** | |
30 * Adding listeners to more options section. | |
31 * @private | |
32 */ | |
33 addEventListeners_: function() { | |
34 document.addEventListener(customEvents.PDF_LOADED, | |
35 this.onPDFLoaded_.bind(this)); | |
36 document.addEventListener( | |
37 customEvents.HEADER_FOOTER_VISIBILITY_CHANGED, | |
38 this.onHeaderFooterVisibilityChanged_.bind(this)); | |
39 document.addEventListener(customEvents.PRINTER_SELECTION_CHANGED, | |
40 this.onPrinterSelectionChanged_.bind(this)); | |
41 }, | |
42 | |
43 /** | |
44 * Listener executing when a |customEvents.HEADER_FOOTER_VISIBILITY_CHANGED| | |
45 * event occurs. | |
46 * @param {cr.Event} event The event that triggered this listener. | |
47 * @private | |
48 */ | |
49 onHeaderFooterVisibilityChanged_: function(event) { | |
50 this.hideHeaderFooterOption_ = !event.headerFooterApplies; | |
51 this.updateVisibility_(); | |
52 }, | |
53 | |
54 /** | |
55 * Listener executing when a |customEvents.PRINTER_SEELCTION_CHANGED| event | |
56 * occurs. | |
57 * @param {cr.Event} event The event that triggered this listener. | |
58 * @private | |
59 */ | |
60 onPrinterSelectionChanged_: function(event) { | |
61 if (previewModifiable) | |
62 return; | |
63 this.hideFitToPageOption_ = event.selectedPrinter == PRINT_TO_PDF; | |
64 this.updateVisibility_(); | |
65 }, | |
66 | |
67 /** | |
68 * Listener executing when a |customEvents.PDF_LOADED| event occurs. | |
69 * @private | |
70 */ | |
71 onPDFLoaded_: function() { | |
72 if (previewModifiable) | |
73 this.hideHeaderFooterOption_ = false; | |
74 else | |
75 this.hideFitToPageOption_ = false; | |
76 }, | |
77 | |
78 /** | |
79 * Hides or shows |this.moreOptions_|. | |
80 * @private | |
81 */ | |
82 updateVisibility_: function() { | |
83 if (this.hideFitToPageOption_ && this.hideHeaderFooterOption_) | |
84 fadeOutOption(this.moreOptions_); | |
85 else | |
86 fadeInOption(this.moreOptions_); | |
87 } | |
88 }; | |
89 | |
90 return { | |
91 MoreOptions: MoreOptions | |
92 }; | |
93 }); | |
OLD | NEW |