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

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

Issue 10083060: [Print Preview]: Added code to support pdf fit to page functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 8 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
(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;
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.updateMoreOptionsVisibility_();
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.updateMoreOptionsVisibility_();
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 updateMoreOptionsVisibility_: function() {
dpapad 2012/04/19 18:38:39 rename to updateVisibility? MoreOptions seems redu
kmadhusu 2012/04/19 20:44:54 Done.
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 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698