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

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

Issue 2834453004: Remove print preview scaling flag (Closed)
Patch Set: address comment Created 3 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
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 // TODO(rltoscano): Move data/* into print_preview.data namespace 5 // TODO(rltoscano): Move data/* into print_preview.data namespace
6 6
7 // <include src="component.js"> 7 // <include src="component.js">
8 // <include src="print_preview_focus_manager.js"> 8 // <include src="print_preview_focus_manager.js">
9 9
10 cr.define('print_preview', function() { 10 cr.define('print_preview', function() {
11 'use strict'; 11 'use strict';
12 12
13 /** 13 /**
14 * Container class for Chromium's print preview. 14 * Container class for Chromium's print preview.
15 * @constructor 15 * @constructor
16 * @extends {print_preview.Component} 16 * @extends {print_preview.Component}
17 */ 17 */
18 function PrintPreview() { 18 function PrintPreview() {
19 print_preview.Component.call(this); 19 print_preview.Component.call(this);
20 20
21 /** 21 /**
22 * Whether the print scaling feature is enabled.
23 * @type {boolean}
24 * @private
25 */
26 this.scalingEnabled_ = loadTimeData.getBoolean('scalingEnabled');
27
28 /**
29 * Used to communicate with Chromium's print system. 22 * Used to communicate with Chromium's print system.
30 * @type {!print_preview.NativeLayer} 23 * @type {!print_preview.NativeLayer}
31 * @private 24 * @private
32 */ 25 */
33 this.nativeLayer_ = new print_preview.NativeLayer(); 26 this.nativeLayer_ = new print_preview.NativeLayer();
34 27
35 /** 28 /**
36 * Event target that contains information about the logged in user. 29 * Event target that contains information about the logged in user.
37 * @type {!print_preview.UserInfo} 30 * @type {!print_preview.UserInfo}
38 * @private 31 * @private
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 152
160 /** 153 /**
161 * Component that renders the DPI settings. 154 * Component that renders the DPI settings.
162 * @type {!print_preview.DpiSettings} 155 * @type {!print_preview.DpiSettings}
163 * @private 156 * @private
164 */ 157 */
165 this.dpiSettings_ = 158 this.dpiSettings_ =
166 new print_preview.DpiSettings(this.printTicketStore_.dpi); 159 new print_preview.DpiSettings(this.printTicketStore_.dpi);
167 this.addChild(this.dpiSettings_); 160 this.addChild(this.dpiSettings_);
168 161
169 if (this.scalingEnabled_) { 162 /**
170 /** 163 * Component that renders the scaling settings.
171 * Component that renders the scaling settings. 164 * @type {!print_preview.ScalingSettings}
172 * @type {!print_preview.ScalingSettings} 165 * @private
173 * @private 166 */
174 */ 167 this.scalingSettings_ =
175 this.scalingSettings_ = 168 new print_preview.ScalingSettings(this.printTicketStore_.scaling,
176 new print_preview.ScalingSettings(this.printTicketStore_.scaling, 169 this.printTicketStore_.fitToPage);
177 this.printTicketStore_.fitToPage); 170 this.addChild(this.scalingSettings_);
178 this.addChild(this.scalingSettings_);
179 }
180 171
181 /** 172 /**
182 * Component that renders miscellaneous print options. 173 * Component that renders miscellaneous print options.
183 * @type {!print_preview.OtherOptionsSettings} 174 * @type {!print_preview.OtherOptionsSettings}
184 * @private 175 * @private
185 */ 176 */
186 this.otherOptionsSettings_ = new print_preview.OtherOptionsSettings( 177 this.otherOptionsSettings_ = new print_preview.OtherOptionsSettings(
187 this.printTicketStore_.duplex, 178 this.printTicketStore_.duplex,
188 this.printTicketStore_.fitToPage, 179 this.printTicketStore_.fitToPage,
189 this.printTicketStore_.cssBackground, 180 this.printTicketStore_.cssBackground,
(...skipping 22 matching lines...) Expand all
212 203
213 var settingsSections = [ 204 var settingsSections = [
214 this.destinationSettings_, 205 this.destinationSettings_,
215 this.pageSettings_, 206 this.pageSettings_,
216 this.copiesSettings_, 207 this.copiesSettings_,
217 this.mediaSizeSettings_, 208 this.mediaSizeSettings_,
218 this.layoutSettings_, 209 this.layoutSettings_,
219 this.marginSettings_, 210 this.marginSettings_,
220 this.colorSettings_, 211 this.colorSettings_,
221 this.dpiSettings_, 212 this.dpiSettings_,
213 this.scalingSettings_,
222 this.otherOptionsSettings_, 214 this.otherOptionsSettings_,
223 this.advancedOptionsSettings_]; 215 this.advancedOptionsSettings_];
224 if (this.scalingEnabled_) {
225 settingsSections.splice(8, 0, this.scalingSettings_);
226 }
227 216
228 /** 217 /**
229 * Component representing more/less settings button. 218 * Component representing more/less settings button.
230 * @type {!print_preview.MoreSettings} 219 * @type {!print_preview.MoreSettings}
231 * @private 220 * @private
232 */ 221 */
233 this.moreSettings_ = new print_preview.MoreSettings( 222 this.moreSettings_ = new print_preview.MoreSettings(
234 this.destinationStore_, settingsSections); 223 this.destinationStore_, settingsSections);
235 this.addChild(this.moreSettings_); 224 this.addChild(this.moreSettings_);
236 225
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 print_preview.NativeLayer.EventType.FILE_SELECTION_COMPLETE, 355 print_preview.NativeLayer.EventType.FILE_SELECTION_COMPLETE,
367 this.onFileSelectionComplete_.bind(this)); 356 this.onFileSelectionComplete_.bind(this));
368 this.tracker.add( 357 this.tracker.add(
369 this.nativeLayer_, 358 this.nativeLayer_,
370 print_preview.NativeLayer.EventType.SETTINGS_INVALID, 359 print_preview.NativeLayer.EventType.SETTINGS_INVALID,
371 this.onSettingsInvalid_.bind(this)); 360 this.onSettingsInvalid_.bind(this));
372 this.tracker.add( 361 this.tracker.add(
373 this.nativeLayer_, 362 this.nativeLayer_,
374 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS, 363 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS,
375 this.onPrintPresetOptionsFromDocument_.bind(this)); 364 this.onPrintPresetOptionsFromDocument_.bind(this));
376 if (this.scalingEnabled_) { 365 this.tracker.add(
377 this.tracker.add( 366 this.nativeLayer_,
378 this.nativeLayer_, 367 print_preview.NativeLayer.EventType.PAGE_COUNT_READY,
379 print_preview.NativeLayer.EventType.PAGE_COUNT_READY, 368 this.onPageCountReady_.bind(this));
380 this.onPageCountReady_.bind(this));
381 }
382 this.tracker.add( 369 this.tracker.add(
383 this.nativeLayer_, 370 this.nativeLayer_,
384 print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED, 371 print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED,
385 this.onPrivetPrintFailed_.bind(this)); 372 this.onPrivetPrintFailed_.bind(this));
386 this.tracker.add( 373 this.tracker.add(
387 this.nativeLayer_, 374 this.nativeLayer_,
388 print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST, 375 print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST,
389 this.onManipulateSettingsForTest_.bind(this)); 376 this.onManipulateSettingsForTest_.bind(this));
390 377
391 if ($('system-dialog-link')) { 378 if ($('system-dialog-link')) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 this.printHeader_.decorate($('print-header')); 483 this.printHeader_.decorate($('print-header'));
497 this.destinationSearch_.decorate($('destination-search')); 484 this.destinationSearch_.decorate($('destination-search'));
498 this.destinationSettings_.decorate($('destination-settings')); 485 this.destinationSettings_.decorate($('destination-settings'));
499 this.pageSettings_.decorate($('page-settings')); 486 this.pageSettings_.decorate($('page-settings'));
500 this.copiesSettings_.decorate($('copies-settings')); 487 this.copiesSettings_.decorate($('copies-settings'));
501 this.layoutSettings_.decorate($('layout-settings')); 488 this.layoutSettings_.decorate($('layout-settings'));
502 this.colorSettings_.decorate($('color-settings')); 489 this.colorSettings_.decorate($('color-settings'));
503 this.mediaSizeSettings_.decorate($('media-size-settings')); 490 this.mediaSizeSettings_.decorate($('media-size-settings'));
504 this.marginSettings_.decorate($('margin-settings')); 491 this.marginSettings_.decorate($('margin-settings'));
505 this.dpiSettings_.decorate($('dpi-settings')); 492 this.dpiSettings_.decorate($('dpi-settings'));
506 if (this.scalingEnabled_) 493 this.scalingSettings_.decorate($('scaling-settings'));
507 this.scalingSettings_.decorate($('scaling-settings'));
508 this.otherOptionsSettings_.decorate($('other-options-settings')); 494 this.otherOptionsSettings_.decorate($('other-options-settings'));
509 this.advancedOptionsSettings_.decorate($('advanced-options-settings')); 495 this.advancedOptionsSettings_.decorate($('advanced-options-settings'));
510 this.advancedSettings_.decorate($('advanced-settings')); 496 this.advancedSettings_.decorate($('advanced-settings'));
511 this.moreSettings_.decorate($('more-settings')); 497 this.moreSettings_.decorate($('more-settings'));
512 this.previewArea_.decorate($('preview-area')); 498 this.previewArea_.decorate($('preview-area'));
513 }, 499 },
514 500
515 /** 501 /**
516 * Sets whether the controls in the print preview are enabled. 502 * Sets whether the controls in the print preview are enabled.
517 * @param {boolean} isEnabled Whether the controls in the print preview are 503 * @param {boolean} isEnabled Whether the controls in the print preview are
518 * enabled. 504 * enabled.
519 * @private 505 * @private
520 */ 506 */
521 setIsEnabled_: function(isEnabled) { 507 setIsEnabled_: function(isEnabled) {
522 if ($('system-dialog-link')) 508 if ($('system-dialog-link'))
523 $('system-dialog-link').classList.toggle('disabled', !isEnabled); 509 $('system-dialog-link').classList.toggle('disabled', !isEnabled);
524 if ($('open-pdf-in-preview-link')) 510 if ($('open-pdf-in-preview-link'))
525 $('open-pdf-in-preview-link').classList.toggle('disabled', !isEnabled); 511 $('open-pdf-in-preview-link').classList.toggle('disabled', !isEnabled);
526 this.printHeader_.isEnabled = isEnabled; 512 this.printHeader_.isEnabled = isEnabled;
527 this.destinationSettings_.isEnabled = isEnabled; 513 this.destinationSettings_.isEnabled = isEnabled;
528 this.pageSettings_.isEnabled = isEnabled; 514 this.pageSettings_.isEnabled = isEnabled;
529 this.copiesSettings_.isEnabled = isEnabled; 515 this.copiesSettings_.isEnabled = isEnabled;
530 this.layoutSettings_.isEnabled = isEnabled; 516 this.layoutSettings_.isEnabled = isEnabled;
531 this.colorSettings_.isEnabled = isEnabled; 517 this.colorSettings_.isEnabled = isEnabled;
532 this.mediaSizeSettings_.isEnabled = isEnabled; 518 this.mediaSizeSettings_.isEnabled = isEnabled;
533 this.marginSettings_.isEnabled = isEnabled; 519 this.marginSettings_.isEnabled = isEnabled;
534 this.dpiSettings_.isEnabled = isEnabled; 520 this.dpiSettings_.isEnabled = isEnabled;
535 if (this.scalingEnabled_) 521 this.scalingSettings_.isEnabled = isEnabled;
536 this.scalingSettings_.isEnabled = isEnabled;
537 this.otherOptionsSettings_.isEnabled = isEnabled; 522 this.otherOptionsSettings_.isEnabled = isEnabled;
538 this.advancedOptionsSettings_.isEnabled = isEnabled; 523 this.advancedOptionsSettings_.isEnabled = isEnabled;
539 }, 524 },
540 525
541 /** 526 /**
542 * Prints the document or launches a pdf preview on the local system. 527 * Prints the document or launches a pdf preview on the local system.
543 * @param {boolean} isPdfPreview Whether to launch the pdf preview. 528 * @param {boolean} isPdfPreview Whether to launch the pdf preview.
544 * @private 529 * @private
545 */ 530 */
546 printDocumentOrOpenPdfPreview_: function(isPdfPreview) { 531 printDocumentOrOpenPdfPreview_: function(isPdfPreview) {
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 // <include src="search/recent_destination_list.js"> 1349 // <include src="search/recent_destination_list.js">
1365 // <include src="search/destination_list_item.js"> 1350 // <include src="search/destination_list_item.js">
1366 // <include src="search/destination_search.js"> 1351 // <include src="search/destination_search.js">
1367 // <include src="search/fedex_tos.js"> 1352 // <include src="search/fedex_tos.js">
1368 // <include src="search/provisional_destination_resolver.js"> 1353 // <include src="search/provisional_destination_resolver.js">
1369 1354
1370 window.addEventListener('DOMContentLoaded', function() { 1355 window.addEventListener('DOMContentLoaded', function() {
1371 printPreview = new print_preview.PrintPreview(); 1356 printPreview = new print_preview.PrintPreview();
1372 printPreview.initialize(); 1357 printPreview.initialize();
1373 }); 1358 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/data/app_state.js ('k') | chrome/browser/ui/webui/print_preview/print_preview_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698