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

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

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 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 * Represents a single option in the Other Options settings section. 9 * Represents a single option in the Other Options settings section.
10 * @param {!print_preview.ticket_items.TicketItem} ticketItem The ticket item 10 * @param {!print_preview.ticket_items.TicketItem} ticketItem The ticket item
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 otherOptionsSettings.updateUiStateInternal(); 95 otherOptionsSettings.updateUiStateInternal();
96 }, 96 },
97 97
98 /** 98 /**
99 * @param {boolean} collapseContent Whether the settings section has content 99 * @param {boolean} collapseContent Whether the settings section has content
100 * collapsed. 100 * collapsed.
101 * @return {boolean} Whether this element should be visible. 101 * @return {boolean} Whether this element should be visible.
102 */ 102 */
103 isVisible: function(collapseContent) { 103 isVisible: function(collapseContent) {
104 return this.ticketItem_.isCapabilityAvailable() && 104 return this.ticketItem_.isCapabilityAvailable() &&
105 (!this.collapsible_ || !collapseContent); 105 (!this.collapsible_ || !collapseContent);
106 }, 106 },
107 107
108 /** 108 /**
109 * Sets the visibility of the element. 109 * Sets the visibility of the element.
110 * @param {boolean} collapseContent Whether the settings section has content 110 * @param {boolean} collapseContent Whether the settings section has content
111 * collapsed. 111 * collapsed.
112 */ 112 */
113 setVisibility: function(collapseContent) { 113 setVisibility: function(collapseContent) {
114 setIsVisible(this.container_, this.isVisible(collapseContent)); 114 setIsVisible(this.container_, this.isVisible(collapseContent));
115 }, 115 },
(...skipping 25 matching lines...) Expand all
141 * enabled. 141 * enabled.
142 */ 142 */
143 this.rasterizeEnabled_ = loadTimeData.getBoolean('printPdfAsImageEnabled'); 143 this.rasterizeEnabled_ = loadTimeData.getBoolean('printPdfAsImageEnabled');
144 144
145 /** 145 /**
146 * @private {!Array<!CheckboxTicketItemElement>} checkbox ticket item 146 * @private {!Array<!CheckboxTicketItemElement>} checkbox ticket item
147 * elements representing the different options in the section. 147 * elements representing the different options in the section.
148 * Selection only must always be the last element in the array. 148 * Selection only must always be the last element in the array.
149 */ 149 */
150 this.elements_ = [ 150 this.elements_ = [
151 new CheckboxTicketItemElement(headerFooter, true, 151 new CheckboxTicketItemElement(
152 'header-footer-container'), 152 headerFooter, true, 'header-footer-container'),
153 new CheckboxTicketItemElement(fitToPage, false, 153 new CheckboxTicketItemElement(fitToPage, false, 'fit-to-page-container'),
154 'fit-to-page-container'),
155 new CheckboxTicketItemElement(duplex, false, 'duplex-container'), 154 new CheckboxTicketItemElement(duplex, false, 'duplex-container'),
156 new CheckboxTicketItemElement(cssBackground, true, 155 new CheckboxTicketItemElement(
157 'css-background-container'), 156 cssBackground, true, 'css-background-container'),
158 new CheckboxTicketItemElement(selectionOnly, true, 157 new CheckboxTicketItemElement(
159 'selection-only-container') 158 selectionOnly, true, 'selection-only-container')
160 ]; 159 ];
161 if (this.rasterizeEnabled_) { 160 if (this.rasterizeEnabled_) {
162 this.elements_.splice(4, 0, 161 this.elements_.splice(
163 new CheckboxTicketItemElement(rasterize, true, 162 4, 0, new CheckboxTicketItemElement(
164 'rasterize-container')); 163 rasterize, true, 'rasterize-container'));
165 } 164 }
166 }; 165 };
167 166
168 OtherOptionsSettings.prototype = { 167 OtherOptionsSettings.prototype = {
169 __proto__: print_preview.SettingsSection.prototype, 168 __proto__: print_preview.SettingsSection.prototype,
170 169
171 /** @override */ 170 /** @override */
172 isAvailable: function() { 171 isAvailable: function() {
173 return this.elements_.some(function(element) { 172 return this.elements_.some(function(element) {
174 return element.ticketItem.isCapabilityAvailable(); 173 return element.ticketItem.isCapabilityAvailable();
(...skipping 15 matching lines...) Expand all
190 * other elements. */ 189 * other elements. */
191 for (var i = 0; i < this.elements_.length - 1; i++) 190 for (var i = 0; i < this.elements_.length - 1; i++)
192 this.elements_[i].checkbox.disabled = !isEnabled; 191 this.elements_[i].checkbox.disabled = !isEnabled;
193 }, 192 },
194 193
195 /** @override */ 194 /** @override */
196 enterDocument: function() { 195 enterDocument: function() {
197 print_preview.SettingsSection.prototype.enterDocument.call(this); 196 print_preview.SettingsSection.prototype.enterDocument.call(this);
198 this.elements_.forEach(function(element) { 197 this.elements_.forEach(function(element) {
199 this.tracker.add( 198 this.tracker.add(
200 element.checkbox, 199 element.checkbox, 'click', element.onCheckboxClick.bind(element));
201 'click',
202 element.onCheckboxClick.bind(element));
203 this.tracker.add( 200 this.tracker.add(
204 element.ticketItem, 201 element.ticketItem,
205 print_preview.ticket_items.TicketItem.EventType.CHANGE, 202 print_preview.ticket_items.TicketItem.EventType.CHANGE,
206 element.onTicketItemChange.bind(element, this)); 203 element.onTicketItemChange.bind(element, this));
207 }, this); 204 }, this);
208 }, 205 },
209 206
210 /** @override */ 207 /** @override */
211 exitDocument: function() { 208 exitDocument: function() {
212 print_preview.SettingsSection.prototype.exitDocument.call(this); 209 print_preview.SettingsSection.prototype.exitDocument.call(this);
(...skipping 20 matching lines...) Expand all
233 /** @override */ 230 /** @override */
234 isSectionVisibleInternal: function() { 231 isSectionVisibleInternal: function() {
235 return this.elements_.some(function(element) { 232 return this.elements_.some(function(element) {
236 return element.isVisible(this.collapseContent); 233 return element.isVisible(this.collapseContent);
237 }, this); 234 }, this);
238 }, 235 },
239 236
240 }; 237 };
241 238
242 // Export 239 // Export
243 return { 240 return {OtherOptionsSettings: OtherOptionsSettings};
244 OtherOptionsSettings: OtherOptionsSettings
245 };
246 }); 241 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698