Commit d02945c3 authored by alekseys@chromium.org's avatar alekseys@chromium.org

Add a button to Print Preivew to open printer's Advanced options dialog.

BUG=397741

Review URL: https://codereview.chromium.org/473553002

Cr-Commit-Position: refs/heads/master@{#289655}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289655 0039d316-1c4b-4281-b951-d872f2087c98
parent 0eadcd5a
...@@ -8311,6 +8311,12 @@ Keep your key file in a safe place. You will need it to create new versions of y ...@@ -8311,6 +8311,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_PRINT_PREVIEW_ADVANCED_SETTINGS_DIALOG_CONFIRM" desc="In title case: The text for the accept button on the printer advanced settings dialog."> <message name="IDS_PRINT_PREVIEW_ADVANCED_SETTINGS_DIALOG_CONFIRM" desc="In title case: The text for the accept button on the printer advanced settings dialog.">
Apply Apply
</message> </message>
<message name="IDS_PRINT_PREVIEW_ADVANCED_OPTIONS_LABEL" desc="Printer advanced options section label.">
Advanced
</message>
<message name="IDS_PRINT_PREVIEW_SHOW_ADVANCED_OPTIONS" desc="The text for the button to open the printer's advanced settings dialog.">
Change printer options...
</message>
</if> </if>
<!-- Load State --> <!-- Load State -->
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<link rel="stylesheet" href="settings/page_settings.css"> <link rel="stylesheet" href="settings/page_settings.css">
<link rel="stylesheet" href="settings/margin_settings.css"> <link rel="stylesheet" href="settings/margin_settings.css">
<link rel="stylesheet" href="settings/media_size_settings.css"> <link rel="stylesheet" href="settings/media_size_settings.css">
<link rel="stylesheet" href="settings/advanced_options_settings.css">
<link rel="stylesheet" href="settings/advanced_settings/advanced_settings.css"> <link rel="stylesheet" href="settings/advanced_settings/advanced_settings.css">
<link rel="stylesheet" href="settings/advanced_settings/advanced_settings_item.css"> <link rel="stylesheet" href="settings/advanced_settings/advanced_settings_item.css">
<link rel="stylesheet" href="previewarea/preview_area.css"> <link rel="stylesheet" href="previewarea/preview_area.css">
...@@ -58,6 +59,7 @@ ...@@ -58,6 +59,7 @@
<include src="settings/color_settings.html"/> <include src="settings/color_settings.html"/>
<include src="settings/margin_settings.html"/> <include src="settings/margin_settings.html"/>
<include src="settings/other_options_settings.html"/> <include src="settings/other_options_settings.html"/>
<include src="settings/advanced_options_settings.html"/>
</div> </div>
<div id="link-container"> <div id="link-container">
<div> <div>
......
...@@ -158,6 +158,15 @@ cr.define('print_preview', function() { ...@@ -158,6 +158,15 @@ cr.define('print_preview', function() {
this.printTicketStore_.headerFooter); this.printTicketStore_.headerFooter);
this.addChild(this.otherOptionsSettings_); this.addChild(this.otherOptionsSettings_);
/**
* Component that renders the advanced options button.
* @type {!print_preview.AdvancedOptionsSettings}
* @private
*/
this.advancedOptionsSettings_ = new print_preview.AdvancedOptionsSettings(
this.destinationStore_);
this.addChild(this.advancedOptionsSettings_);
/** /**
* Component used to search for print destinations. * Component used to search for print destinations.
* @type {!print_preview.AdvancedSettings} * @type {!print_preview.AdvancedSettings}
...@@ -383,6 +392,11 @@ cr.define('print_preview', function() { ...@@ -383,6 +392,11 @@ cr.define('print_preview', function() {
print_preview.DestinationListItem.EventType.REGISTER_PROMO_CLICKED, print_preview.DestinationListItem.EventType.REGISTER_PROMO_CLICKED,
this.onCloudPrintRegisterPromoClick_.bind(this)); this.onCloudPrintRegisterPromoClick_.bind(this));
this.tracker.add(
this.advancedOptionsSettings_,
print_preview.AdvancedOptionsSettings.EventType.BUTTON_ACTIVATED,
this.onAdvancedOptionsButtonActivated_.bind(this));
// TODO(rltoscano): Move no-destinations-promo into its own component // TODO(rltoscano): Move no-destinations-promo into its own component
// instead being part of PrintPreview. // instead being part of PrintPreview.
this.tracker.add( this.tracker.add(
...@@ -411,6 +425,7 @@ cr.define('print_preview', function() { ...@@ -411,6 +425,7 @@ cr.define('print_preview', function() {
this.colorSettings_.decorate($('color-settings')); this.colorSettings_.decorate($('color-settings'));
this.marginSettings_.decorate($('margin-settings')); this.marginSettings_.decorate($('margin-settings'));
this.otherOptionsSettings_.decorate($('other-options-settings')); this.otherOptionsSettings_.decorate($('other-options-settings'));
this.advancedOptionsSettings_.decorate($('advanced-options-settings'));
this.advancedSettings_.decorate($('advanced-settings')); this.advancedSettings_.decorate($('advanced-settings'));
this.previewArea_.decorate($('preview-area')); this.previewArea_.decorate($('preview-area'));
...@@ -436,6 +451,7 @@ cr.define('print_preview', function() { ...@@ -436,6 +451,7 @@ cr.define('print_preview', function() {
this.colorSettings_.isEnabled = isEnabled; this.colorSettings_.isEnabled = isEnabled;
this.marginSettings_.isEnabled = isEnabled; this.marginSettings_.isEnabled = isEnabled;
this.otherOptionsSettings_.isEnabled = isEnabled; this.otherOptionsSettings_.isEnabled = isEnabled;
this.advancedOptionsSettings_.isEnabled = isEnabled;
}, },
/** /**
...@@ -850,6 +866,16 @@ cr.define('print_preview', function() { ...@@ -850,6 +866,16 @@ cr.define('print_preview', function() {
this.destinationStore_.startLoadPrivetDestinations(); this.destinationStore_.startLoadPrivetDestinations();
}, },
/**
* Called when the destination settings' change button is activated.
* Displays the destination search component.
* @private
*/
onAdvancedOptionsButtonActivated_: function() {
this.advancedSettings_.showForDestination(
this.destinationStore_.selectedDestination);
},
/** /**
* Called when the destination search dispatches manage cloud destinations * Called when the destination search dispatches manage cloud destinations
* event. Calls corresponding native layer method. * event. Calls corresponding native layer method.
...@@ -1172,6 +1198,7 @@ cr.define('print_preview', function() { ...@@ -1172,6 +1198,7 @@ cr.define('print_preview', function() {
<include src="settings/margin_settings.js"/> <include src="settings/margin_settings.js"/>
<include src="settings/destination_settings.js"/> <include src="settings/destination_settings.js"/>
<include src="settings/other_options_settings.js"/> <include src="settings/other_options_settings.js"/>
<include src="settings/advanced_options_settings.js"/>
<include src="settings/advanced_settings/advanced_settings.js"/> <include src="settings/advanced_settings/advanced_settings.js"/>
<include src="settings/advanced_settings/advanced_settings_item.js"/> <include src="settings/advanced_settings/advanced_settings_item.js"/>
......
/* Copyright 2014 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
#advanced-options-settings .advanced-options-settings-button {
height: 28px;
margin: 10px 0;
}
<div id="advanced-options-settings" class="two-column visible" hidden>
<h1 i18n-content="advancedOptionsLabel"></h1>
<div class="right-column">
<button class="advanced-options-settings-button"
i18n-content="showAdvancedOptions">
</button>
</div>
</div>
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.define('print_preview', function() {
'use strict';
/**
* Print options section to control printer advanced options.
* @param {!print_preview.DestinationStore} destinationStore Used to determine
* the selected destination.
* @constructor
* @extends {print_preview.Component}
*/
function AdvancedOptionsSettings(destinationStore) {
print_preview.Component.call(this);
/**
* Used to determine the selected destination.
* @private {!print_preview.DestinationStore}
*/
this.destinationStore_ = destinationStore;
};
/**
* Event types dispatched by the component.
* @enum {string}
*/
AdvancedOptionsSettings.EventType = {
BUTTON_ACTIVATED: 'print_preview.AdvancedOptionsSettings.BUTTON_ACTIVATED'
};
AdvancedOptionsSettings.prototype = {
__proto__: print_preview.Component.prototype,
/** @param {boolean} Whether the component is enabled. */
set isEnabled(isEnabled) {
this.getButton_().disabled = !isEnabled;
},
/** @override */
enterDocument: function() {
print_preview.Component.prototype.enterDocument.call(this);
fadeOutOption(this.getElement(), true);
this.tracker.add(
this.getButton_(), 'click', function() {
cr.dispatchSimpleEvent(
this, AdvancedOptionsSettings.EventType.BUTTON_ACTIVATED);
}.bind(this));
this.tracker.add(
this.destinationStore_,
print_preview.DestinationStore.EventType.DESTINATION_SELECT,
this.onDestinationSelect_.bind(this));
this.tracker.add(
this.destinationStore_,
print_preview.DestinationStore.EventType.
SELECTED_DESTINATION_CAPABILITIES_READY,
this.onDestinationSelect_.bind(this));
},
/**
* @return {HTMLElement}
* @private
*/
getButton_: function() {
return this.getChildElement('.advanced-options-settings-button');
},
/**
* Called when the destination selection has changed. Updates UI elements.
* @private
*/
onDestinationSelect_: function() {
var destination = this.destinationStore_.selectedDestination;
var vendorCapabilities =
destination &&
destination.capabilities &&
destination.capabilities.printer &&
destination.capabilities.printer.vendor_capability;
if (false && vendorCapabilities) {
fadeInOption(this.getElement());
} else {
fadeOutOption(this.getElement());
}
}
};
// Export
return {
AdvancedOptionsSettings: AdvancedOptionsSettings
};
});
...@@ -339,6 +339,10 @@ content::WebUIDataSource* CreatePrintPreviewUISource() { ...@@ -339,6 +339,10 @@ content::WebUIDataSource* CreatePrintPreviewUISource() {
"advancedSettingsDialogConfirm", "advancedSettingsDialogConfirm",
IDS_PRINT_PREVIEW_ADVANCED_SETTINGS_DIALOG_CONFIRM); IDS_PRINT_PREVIEW_ADVANCED_SETTINGS_DIALOG_CONFIRM);
source->AddLocalizedString("cancel", IDS_CANCEL); source->AddLocalizedString("cancel", IDS_CANCEL);
source->AddLocalizedString("advancedOptionsLabel",
IDS_PRINT_PREVIEW_ADVANCED_OPTIONS_LABEL);
source->AddLocalizedString("showAdvancedOptions",
IDS_PRINT_PREVIEW_SHOW_ADVANCED_OPTIONS);
source->SetJsonPath("strings.js"); source->SetJsonPath("strings.js");
source->AddResourcePath("print_preview.js", IDR_PRINT_PREVIEW_JS); source->AddResourcePath("print_preview.js", IDR_PRINT_PREVIEW_JS);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment