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

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

Issue 2524143003: Print Preview: Add option to rasterize PDFs and add JPEG compression. (Closed)
Patch Set: Clean up JS Created 3 years, 12 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 * UI component that renders checkboxes for various print options. 120 * UI component that renders checkboxes for various print options.
121 * @param {!print_preview.ticket_items.Duplex} duplex Duplex ticket item. 121 * @param {!print_preview.ticket_items.Duplex} duplex Duplex ticket item.
122 * @param {!print_preview.ticket_items.FitToPage} fitToPage Fit-to-page ticket 122 * @param {!print_preview.ticket_items.FitToPage} fitToPage Fit-to-page ticket
123 * item. 123 * item.
124 * @param {!print_preview.ticket_items.CssBackground} cssBackground CSS 124 * @param {!print_preview.ticket_items.CssBackground} cssBackground CSS
125 * background ticket item. 125 * background ticket item.
126 * @param {!print_preview.ticket_items.SelectionOnly} selectionOnly Selection 126 * @param {!print_preview.ticket_items.SelectionOnly} selectionOnly Selection
127 * only ticket item. 127 * only ticket item.
128 * @param {!print_preview.ticket_items.HeaderFooter} headerFooter Header 128 * @param {!print_preview.ticket_items.HeaderFooter} headerFooter Header
129 * footer ticket item. 129 * footer ticket item.
130 * @param {!print_preview.ticket_items.Rasterize} rasterize Rasterize ticket
131 * item.
130 * @constructor 132 * @constructor
131 * @extends {print_preview.SettingsSection} 133 * @extends {print_preview.SettingsSection}
132 */ 134 */
133 function OtherOptionsSettings( 135 function OtherOptionsSettings(
134 duplex, fitToPage, cssBackground, selectionOnly, headerFooter) { 136 duplex, fitToPage, cssBackground, selectionOnly, headerFooter,
137 rasterize) {
135 print_preview.SettingsSection.call(this); 138 print_preview.SettingsSection.call(this);
139 /**
140 * @private {boolean} rasterizeEnabled Whether the print as image feature is
141 * enabled.
142 */
143 this.rasterizeEnabled_ = loadTimeData.getBoolean('printPdfAsImageEnabled');
136 144
137 /* 145 /**
138 * @private {!Array<!CheckboxTicketItemElement>} checkbox ticket item 146 * @private {!Array<!CheckboxTicketItemElement>} checkbox ticket item
139 * elements representing the different options in the section. 147 * elements representing the different options in the section.
140 * Selection only must always be the last element in the array. 148 * Selection only must always be the last element in the array.
141 */ 149 */
142 this.elements_ = [ 150 this.elements_ = [
143 new CheckboxTicketItemElement(headerFooter, true, 151 new CheckboxTicketItemElement(headerFooter, true,
144 'header-footer-container'), 152 'header-footer-container'),
145 new CheckboxTicketItemElement(fitToPage, false, 153 new CheckboxTicketItemElement(fitToPage, false,
146 'fit-to-page-container'), 154 'fit-to-page-container'),
147 new CheckboxTicketItemElement(duplex, false, 'duplex-container'), 155 new CheckboxTicketItemElement(duplex, false, 'duplex-container'),
148 new CheckboxTicketItemElement(cssBackground, true, 156 new CheckboxTicketItemElement(cssBackground, true,
149 'css-background-container'), 157 'css-background-container'),
150 new CheckboxTicketItemElement(selectionOnly, true, 158 new CheckboxTicketItemElement(selectionOnly, true,
151 'selection-only-container') 159 'selection-only-container')
152 ]; 160 ];
153 161 if (this.rasterizeEnabled_) {
162 this.elements_.splice(4, 0,
163 new CheckboxTicketItemElement(rasterize, true,
164 'rasterize-container'));
165 }
154 }; 166 };
155 167
156 OtherOptionsSettings.prototype = { 168 OtherOptionsSettings.prototype = {
157 __proto__: print_preview.SettingsSection.prototype, 169 __proto__: print_preview.SettingsSection.prototype,
158 170
159 /** @override */ 171 /** @override */
160 isAvailable: function() { 172 isAvailable: function() {
161 return this.elements_.some(function(element) { 173 return this.elements_.some(function(element) {
162 return element.ticketItem.isCapabilityAvailable(); 174 return element.ticketItem.isCapabilityAvailable();
163 }); 175 });
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 exitDocument: function() { 211 exitDocument: function() {
200 print_preview.SettingsSection.prototype.exitDocument.call(this); 212 print_preview.SettingsSection.prototype.exitDocument.call(this);
201 for (var i = 0; i < this.elements_.length; i++) 213 for (var i = 0; i < this.elements_.length; i++)
202 this.elements_[i].exitDocument(); 214 this.elements_[i].exitDocument();
203 }, 215 },
204 216
205 /** @override */ 217 /** @override */
206 decorateInternal: function() { 218 decorateInternal: function() {
207 for (var i = 0; i < this.elements_.length; i++) 219 for (var i = 0; i < this.elements_.length; i++)
208 this.elements_[i].decorate(); 220 this.elements_[i].decorate();
221 $('rasterize-container').hidden = !this.rasterizeEnabled_;
209 }, 222 },
210 223
211 /** @override */ 224 /** @override */
212 updateUiStateInternal: function() { 225 updateUiStateInternal: function() {
213 if (this.isAvailable()) { 226 if (this.isAvailable()) {
214 for (var i = 0; i < this.elements_.length; i++) 227 for (var i = 0; i < this.elements_.length; i++)
215 this.elements_[i].setVisibility(this.collapseContent); 228 this.elements_[i].setVisibility(this.collapseContent);
216 } 229 }
217 print_preview.SettingsSection.prototype.updateUiStateInternal.call(this); 230 print_preview.SettingsSection.prototype.updateUiStateInternal.call(this);
218 }, 231 },
219 232
220 /** @override */ 233 /** @override */
221 isSectionVisibleInternal: function() { 234 isSectionVisibleInternal: function() {
222 return this.elements_.some(function(element) { 235 return this.elements_.some(function(element) {
223 return element.isVisible(this.collapseContent); 236 return element.isVisible(this.collapseContent);
224 }, this); 237 }, this);
225 }, 238 },
226 239
227 }; 240 };
228 241
229 // Export 242 // Export
230 return { 243 return {
231 OtherOptionsSettings: OtherOptionsSettings 244 OtherOptionsSettings: OtherOptionsSettings
232 }; 245 };
233 }); 246 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698