this.addChild(this.marginSettings_);
/**
+ * Component that renders the DPI settings.
+ * @type {!print_preview.DpiSettings}
+ * @private
+ */
+ this.dpiSettings_ =
+ new print_preview.DpiSettings(this.printTicketStore_.dpi);
+ this.addChild(this.dpiSettings_);
+
+ /**
* Component that renders miscellaneous print options.
* @type {!print_preview.OtherOptionsSettings}
* @private
this.printTicketStore_);
this.addChild(this.advancedSettings_);
- /**
- * Component representing more/less settings button.
- * @type {!print_preview.MoreSettings}
- * @private
- */
var settingsSections = [
this.destinationSettings_,
this.pageSettings_,
this.layoutSettings_,
this.marginSettings_,
this.colorSettings_,
+ this.dpiSettings_,
this.otherOptionsSettings_,
this.advancedOptionsSettings_];
+ /**
+ * Component representing more/less settings button.
+ * @type {!print_preview.MoreSettings}
+ * @private
+ */
this.moreSettings_ = new print_preview.MoreSettings(
this.destinationStore_, settingsSections);
this.addChild(this.moreSettings_);
this.isInAppKioskMode_ = false;
/**
- * Whether Print with System Dialog option is available.
+ * Whether Print with System Dialog link should be hidden. Overrides the
+ * default rules for System dialog link visibility.
* @type {boolean}
* @private
*/
- this.isSystemDialogAvailable_ = false;
+ this.hideSystemDialogLink_ = true;
/**
* State of the print preview UI.
INITIALIZING: 'initializing',
READY: 'ready',
OPENING_PDF_PREVIEW: 'opening-pdf-preview',
- OPENING_CLOUD_PRINT_DIALOG: 'opening-cloud-print-dialog',
OPENING_NATIVE_PRINT_DIALOG: 'opening-native-print-dialog',
PRINTING: 'printing',
FILE_SELECTION: 'file-selection',
print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST,
this.onManipulateSettingsForTest_.bind(this));
- this.tracker.add(
- $('system-dialog-link'),
- 'click',
- this.openSystemPrintDialog_.bind(this));
- this.tracker.add(
- $('cloud-print-dialog-link'),
- 'click',
- this.onCloudPrintDialogLinkClick_.bind(this));
+ if ($('system-dialog-link')) {
+ this.tracker.add(
+ $('system-dialog-link'),
+ 'click',
+ this.openSystemPrintDialog_.bind(this));
+ }
if ($('open-pdf-in-preview-link')) {
this.tracker.add(
$('open-pdf-in-preview-link'),
this.layoutSettings_.decorate($('layout-settings'));
this.colorSettings_.decorate($('color-settings'));
this.marginSettings_.decorate($('margin-settings'));
+ this.dpiSettings_.decorate($('dpi-settings'));
this.otherOptionsSettings_.decorate($('other-options-settings'));
this.advancedOptionsSettings_.decorate($('advanced-options-settings'));
this.advancedSettings_.decorate($('advanced-settings'));
* @private
*/
setIsEnabled_: function(isEnabled) {
- $('system-dialog-link').disabled = !isEnabled;
- $('cloud-print-dialog-link').disabled = !isEnabled;
- if ($('open-pdf-in-preview-link')) {
- $('open-pdf-in-preview-link').disabled = !isEnabled;
- }
+ if ($('system-dialog-link'))
+ $('system-dialog-link').classList.toggle('disabled', !isEnabled);
+ if ($('open-pdf-in-preview-link'))
+ $('open-pdf-in-preview-link').classList.toggle('disabled', !isEnabled);
this.printHeader_.isEnabled = isEnabled;
this.destinationSettings_.isEnabled = isEnabled;
this.pageSettings_.isEnabled = isEnabled;
this.layoutSettings_.isEnabled = isEnabled;
this.colorSettings_.isEnabled = isEnabled;
this.marginSettings_.isEnabled = isEnabled;
+ this.dpiSettings_.isEnabled = isEnabled;
this.otherOptionsSettings_.isEnabled = isEnabled;
this.advancedOptionsSettings_.isEnabled = isEnabled;
},
(this.uiState_ == PrintPreview.UiState_.PRINTING ||
this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW ||
this.uiState_ == PrintPreview.UiState_.FILE_SELECTION ||
- this.uiState_ == PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG ||
this.isInKioskAutoPrintMode_) &&
this.destinationStore_.selectedDestination &&
this.destinationStore_.selectedDestination.capabilities;
}
assert(this.printTicketStore_.isTicketValid(),
'Trying to print with invalid ticket');
- if (this.uiState_ == PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG) {
- this.nativeLayer_.startShowCloudPrintDialog(
- this.printTicketStore_.pageRange.getPageNumberSet().size);
- } else {
- if (getIsVisible(this.moreSettings_.getElement())) {
- new print_preview.PrintSettingsUiMetricsContext().record(
- this.moreSettings_.isExpanded ?
- print_preview.Metrics.PrintSettingsUiBucket.
- PRINT_WITH_SETTINGS_EXPANDED :
- print_preview.Metrics.PrintSettingsUiBucket.
- PRINT_WITH_SETTINGS_COLLAPSED);
- }
- this.nativeLayer_.startPrint(
- this.destinationStore_.selectedDestination,
- this.printTicketStore_,
- this.cloudPrintInterface_,
- this.documentInfo_,
- this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW,
- this.showSystemDialogBeforeNextPrint_);
- this.showSystemDialogBeforeNextPrint_ = false;
+ if (getIsVisible(this.moreSettings_.getElement())) {
+ new print_preview.PrintSettingsUiMetricsContext().record(
+ this.moreSettings_.isExpanded ?
+ print_preview.Metrics.PrintSettingsUiBucket.
+ PRINT_WITH_SETTINGS_EXPANDED :
+ print_preview.Metrics.PrintSettingsUiBucket.
+ PRINT_WITH_SETTINGS_COLLAPSED);
}
+ this.nativeLayer_.startPrint(
+ this.destinationStore_.selectedDestination,
+ this.printTicketStore_,
+ this.cloudPrintInterface_,
+ this.documentInfo_,
+ this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW,
+ this.showSystemDialogBeforeNextPrint_);
+ this.showSystemDialogBeforeNextPrint_ = false;
return PrintPreview.PrintAttemptResult_.PRINTED;
},
openSystemPrintDialog_: function() {
if (!this.shouldShowSystemDialogLink_())
return;
+ if ($('system-dialog-link').classList.contains('disabled'))
+ return;
if (cr.isWindows) {
this.showSystemDialogBeforeNextPrint_ = true;
this.printDocumentOrOpenPdfPreview_(false /*isPdfPreview*/);
return;
}
- setIsVisible($('system-dialog-throbber'), true);
+ setIsVisible(getRequiredElement('system-dialog-throbber'), true);
this.setIsEnabled_(false);
this.uiState_ = PrintPreview.UiState_.OPENING_NATIVE_PRINT_DIALOG;
this.nativeLayer_.startShowSystemDialog();
this.appState_.setInitialized();
$('document-title').innerText = settings.documentTitle;
- this.isSystemDialogAvailable_ = !settings.hidePrintWithSystemDialogLink &&
- !settings.isInAppKioskMode;
- setIsVisible($('system-dialog-link'), this.shouldShowSystemDialogLink_());
+ this.hideSystemDialogLink_ = settings.hidePrintWithSystemDialogLink ||
+ settings.isInAppKioskMode;
+ if ($('system-dialog-link')) {
+ setIsVisible($('system-dialog-link'),
+ this.shouldShowSystemDialogLink_());
+ }
},
/**
onPreviewGenerationFail_: function() {
this.isPreviewGenerationInProgress_ = false;
this.printHeader_.isPrintButtonEnabled = false;
- if (this.uiState_ == PrintPreview.UiState_.PRINTING) {
+ if (this.uiState_ == PrintPreview.UiState_.PRINTING)
this.nativeLayer_.startCancelPendingPrint();
- } else if (this.uiState_ ==
- PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG) {
- this.uiState_ = PrintPreview.UiState_.READY;
- }
},
/**
* @private
*/
onOpenPdfInPreviewLinkClick_: function() {
+ if ($('open-pdf-in-preview-link').classList.contains('disabled'))
+ return;
assert(this.uiState_ == PrintPreview.UiState_.READY,
'Trying to open pdf in preview when not in ready state: ' +
this.uiState_);
- setIsVisible($('open-preview-app-throbber'), true);
+ setIsVisible(getRequiredElement('open-preview-app-throbber'), true);
this.previewArea_.showCustomMessage(
loadTimeData.getString('openingPDFInPreview'));
this.printDocumentOrOpenPdfPreview_(true /*isPdfPreview*/);
* to the preview area.
* @param {KeyboardEvent} e The keyboard event.
* @private
+ * @suppress {uselessCode}
+ * Current compiler preprocessor leaves all the code inside all the <if>s,
+ * so the compiler claims that code after first return is unreachable.
*/
onKeyDown_: function(e) {
// Escape key closes the dialog.
if (e.keyCode == 27 && !e.shiftKey && !e.ctrlKey && !e.altKey &&
!e.metaKey) {
- <if expr="toolkit_views">
+<if expr="toolkit_views">
// On the toolkit_views environment, ESC key is handled by C++-side
// instead of JS-side.
return;
- </if>
- <if expr="not toolkit_views">
+</if>
+<if expr="not toolkit_views">
this.close_();
- </if>
+</if>
e.preventDefault();
return;
}
if (e.keyCode == 13 /*enter*/ &&
!document.querySelector('.overlay:not([hidden])') &&
this.destinationStore_.selectedDestination &&
- this.printTicketStore_.isTicketValid()) {
+ this.printTicketStore_.isTicketValid() &&
+ this.printHeader_.isPrintButtonEnabled) {
assert(this.uiState_ == PrintPreview.UiState_.READY,
'Trying to print when not in ready state: ' + this.uiState_);
- var activeElementTag = document.activeElement ?
- document.activeElement.tagName.toUpperCase() : '';
- if (activeElementTag != 'BUTTON' && activeElementTag != 'SELECT') {
+ var activeElementTag = document.activeElement.tagName.toUpperCase();
+ if (activeElementTag != 'BUTTON' && activeElementTag != 'SELECT' &&
+ activeElementTag != 'A') {
this.printDocumentOrOpenPdfPreview_(false /*isPdfPreview*/);
e.preventDefault();
}
*/
onAdvancedOptionsButtonActivated_: function() {
this.advancedSettings_.showForDestination(
- this.destinationStore_.selectedDestination);
+ assert(this.destinationStore_.selectedDestination));
},
/**
* @private
*/
onManipulateSettingsForTest_: function(event) {
- if ('selectSaveAsPdfDestination' in event.settings) {
+ var settings =
+ /** @type {print_preview.PreviewSettings} */(event.settings);
+ if ('selectSaveAsPdfDestination' in settings) {
this.saveAsPdfForTest_(); // No parameters.
- } else if ('layoutSettings' in event.settings) {
- this.setLayoutSettingsForTest_(event.settings.layoutSettings.portrait);
- } else if ('pageRange' in event.settings) {
- this.setPageRangeForTest_(event.settings.pageRange);
- } else if ('headersAndFooters' in event.settings) {
- this.setHeadersAndFootersForTest_(event.settings.headersAndFooters);
- } else if ('backgroundColorsAndImages' in event.settings) {
+ } else if ('layoutSettings' in settings) {
+ this.setLayoutSettingsForTest_(settings.layoutSettings.portrait);
+ } else if ('pageRange' in settings) {
+ this.setPageRangeForTest_(settings.pageRange);
+ } else if ('headersAndFooters' in settings) {
+ this.setHeadersAndFootersForTest_(settings.headersAndFooters);
+ } else if ('backgroundColorsAndImages' in settings) {
this.setBackgroundColorsAndImagesForTest_(
- event.settings.backgroundColorsAndImages);
- } else if ('margins' in event.settings) {
- this.setMarginsForTest_(event.settings.margins);
+ settings.backgroundColorsAndImages);
+ } else if ('margins' in settings) {
+ this.setMarginsForTest_(settings.margins);
}
},
* @return {boolean} Returns true if link should be shown.
*/
shouldShowSystemDialogLink_: function() {
- if (!this.isSystemDialogAvailable_)
+ if (cr.isChromeOS || this.hideSystemDialogLink_)
return false;
if (!cr.isWindows)
return true;
var selectedDest = this.destinationStore_.selectedDestination;
- return selectedDest &&
+ return !!selectedDest &&
selectedDest.origin == print_preview.Destination.Origin.LOCAL &&
selectedDest.id !=
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF;
},
/**
- * Called when the open-cloud-print-dialog link is clicked. Opens the Google
- * Cloud Print web dialog.
- * @private
- */
- onCloudPrintDialogLinkClick_: function() {
- assert(this.uiState_ == PrintPreview.UiState_.READY,
- 'Opening Google Cloud Print dialog when not in ready state: ' +
- this.uiState_);
- setIsVisible($('cloud-print-dialog-throbber'), true);
- this.setIsEnabled_(false);
- this.uiState_ = PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG;
- this.printIfReady_();
- },
-
- /**
* Called when a print destination is selected. Shows/hides the "Print with
* Cloud Print" link in the navbar.
* @private
*/
onDestinationSelect_: function() {
- var selectedDest = this.destinationStore_.selectedDestination;
- setIsVisible(
- $('cloud-print-dialog-link'),
- selectedDest && !cr.isChromeOS && !selectedDest.isLocal);
- setIsVisible(
- $('system-dialog-link'),
- this.shouldShowSystemDialogLink_());
- if (selectedDest && this.isInKioskAutoPrintMode_) {
+ if ($('system-dialog-link')) {
+ setIsVisible($('system-dialog-link'),
+ this.shouldShowSystemDialogLink_());
+ }
+ if (this.destinationStore_.selectedDestination &&
+ this.isInKioskAutoPrintMode_) {
this.onPrintButtonClick_();
}
},
this.cloudPrintInterface_ &&
this.userInfo_.activeUser &&
!this.appState_.isGcpPromoDismissed &&
- !this.destinationStore_.isLocalDestinationsSearchInProgress &&
- !this.destinationStore_.isCloudDestinationsSearchInProgress &&
+ !this.destinationStore_.isLocalDestinationSearchInProgress &&
+ !this.destinationStore_.isCloudDestinationSearchInProgress &&
this.destinationStore_.hasOnlyDefaultCloudDestinations();
setIsVisible(this.getChildElement('#no-destinations-promo'),
isPromoVisible);
<include src="data/ticket_items/collate.js">
<include src="data/ticket_items/color.js">
<include src="data/ticket_items/copies.js">
+<include src="data/ticket_items/dpi.js">
<include src="data/ticket_items/duplex.js">
<include src="data/ticket_items/header_footer.js">
<include src="data/ticket_items/media_size.js">
<include src="metrics.js">
<include src="settings/settings_section.js">
+<include src="settings/settings_section_select.js">
<include src="settings/page_settings.js">
<include src="settings/copies_settings.js">
+<include src="settings/dpi_settings.js">
<include src="settings/media_size_settings.js">
<include src="settings/layout_settings.js">
<include src="settings/color_settings.js">