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

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

Issue 7358002: Print Preview: Refactoring layout mode related logic to LayoutSettings class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updating method comments Created 9 years, 5 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) 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 LayoutSettings object. This object encapsulates all settings and
10 * logic related to layout mode (portrait/landscape).
11 * @constructor
12 */
13 function LayoutSettings() {
14 this.layoutOption_ = $('layout-option');
15 this.portraitRadioButton_ = $('portrait');
16 this.landscapeRadioButton_ = $('landscape');
17 }
18
19 cr.addSingletonGetter(LayoutSettings);
20
21 LayoutSettings.prototype = {
22 /**
23 * The div containing all layout related options.
24 * @type {HTMLDivElement}
25 */
26 get layoutOption() {
27 return this.layoutOption_;
28 },
29
30 /**
31 * The radio button corresponding to the portrait option.
32 * @type {HTMLInputElement}
33 */
34 get portraitRadioButton() {
35 return this.portraitRadioButton_;
36 },
37
38 /**
39 * The radio button corresponding to the landscape option.
40 * @type {HTMLInputElement}
41 */
42 get landscapeRadioButton() {
43 return this.landscapeRadioButton_;
44 },
45
46 /**
47 * @return {boolean} true if |this.landscapeRadioButton_| is checked, false
48 * if not.
49 */
50 isLandscape: function() {
51 return this.landscapeRadioButton_.checked;
52 },
53
54 /**
55 * Adding listeners to all layout related controls. The listeners take care
56 * of altering their behavior depending on |hasPendingPreviewRequest|.
57 */
58 addEventListeners: function() {
59 this.landscapeRadioButton_.onclick = function() {
60 if (!hasPendingPreviewRequest)
61 this.onLayoutButtonClick();
62 }.bind(this);
63 this.portraitRadioButton_.onclick = function() {
64 if (!hasPendingPreviewRequest)
65 this.onLayoutButtonClick();
66 }.bind(this);
67 },
68
69 /**
70 * Listener executing when |this.landscapeRadioButton_| or
71 * |this.portraitRadioButton_| is clicked.
72 */
73 onLayoutButtonClick: function() {
74 // If the chosen layout is same as before, nothing needs to be done.
75 if (printSettings.isLandscape == this.isLandscape())
76 return;
77 setDefaultValuesAndRegeneratePreview();
78 }
79 };
80
81 return {
82 LayoutSettings: LayoutSettings,
83 };
84 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698