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

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

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 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
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 LayoutSettings object. This object encapsulates all settings and 9 * Creates a LayoutSettings object. This object encapsulates all settings and
10 * logic related to layout mode (portrait/landscape). 10 * logic related to layout mode (portrait/landscape).
(...skipping 27 matching lines...) Expand all
38 }, 38 },
39 39
40 /** @override */ 40 /** @override */
41 set isEnabled(isEnabled) { 41 set isEnabled(isEnabled) {
42 this.select_.disabled = !isEnabled; 42 this.select_.disabled = !isEnabled;
43 }, 43 },
44 44
45 /** @override */ 45 /** @override */
46 enterDocument: function() { 46 enterDocument: function() {
47 print_preview.SettingsSection.prototype.enterDocument.call(this); 47 print_preview.SettingsSection.prototype.enterDocument.call(this);
48 this.tracker.add( 48 this.tracker.add(this.select_, 'change', this.onSelectChange_.bind(this));
49 this.select_, 'change', this.onSelectChange_.bind(this));
50 this.tracker.add( 49 this.tracker.add(
51 this.landscapeTicketItem_, 50 this.landscapeTicketItem_,
52 print_preview.ticket_items.TicketItem.EventType.CHANGE, 51 print_preview.ticket_items.TicketItem.EventType.CHANGE,
53 this.onLandscapeTicketItemChange_.bind(this)); 52 this.onLandscapeTicketItemChange_.bind(this));
54 }, 53 },
55 54
56 /** 55 /**
57 * Called when the select element is changed. Updates the print ticket 56 * Called when the select element is changed. Updates the print ticket
58 * layout selection. 57 * layout selection.
59 * @private 58 * @private
60 */ 59 */
61 onSelectChange_: function() { 60 onSelectChange_: function() {
62 var select = this.select_; 61 var select = this.select_;
63 var isLandscape = 62 var isLandscape =
64 select.options[select.selectedIndex].value == 'landscape'; 63 select.options[select.selectedIndex].value == 'landscape';
65 this.landscapeTicketItem_.updateValue(isLandscape); 64 this.landscapeTicketItem_.updateValue(isLandscape);
66 }, 65 },
67 66
68 /** 67 /**
69 * @return {!HTMLSelectElement} Select element containing the layout 68 * @return {!HTMLSelectElement} Select element containing the layout
70 * options. 69 * options.
71 * @private 70 * @private
72 */ 71 */
73 get select_() { 72 get select_() {
74 return /** @type {!HTMLSelectElement} */( 73 return /** @type {!HTMLSelectElement} */ (
75 this.getChildElement('.layout-settings-select')); 74 this.getChildElement('.layout-settings-select'));
76 }, 75 },
77 76
78 /** 77 /**
79 * Called when the print ticket store changes state. Updates the state of 78 * Called when the print ticket store changes state. Updates the state of
80 * the radio buttons and hides the setting if necessary. 79 * the radio buttons and hides the setting if necessary.
81 * @private 80 * @private
82 */ 81 */
83 onLandscapeTicketItemChange_: function() { 82 onLandscapeTicketItemChange_: function() {
84 if (this.isAvailable()) { 83 if (this.isAvailable()) {
85 var select = this.select_; 84 var select = this.select_;
86 var valueToSelect = 85 var valueToSelect =
87 this.landscapeTicketItem_.getValue() ? 'landscape' : 'portrait'; 86 this.landscapeTicketItem_.getValue() ? 'landscape' : 'portrait';
88 for (var i = 0; i < select.options.length; i++) { 87 for (var i = 0; i < select.options.length; i++) {
89 if (select.options[i].value == valueToSelect) { 88 if (select.options[i].value == valueToSelect) {
90 select.selectedIndex = i; 89 select.selectedIndex = i;
91 break; 90 break;
92 } 91 }
93 } 92 }
94 } 93 }
95 this.updateUiStateInternal(); 94 this.updateUiStateInternal();
96 } 95 }
97 }; 96 };
98 97
99 // Export 98 // Export
100 return { 99 return {LayoutSettings: LayoutSettings};
101 LayoutSettings: LayoutSettings
102 };
103 }); 100 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698