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

Unified Diff: chrome/browser/resources/print_preview/settings/advanced_options_settings.js

Issue 473553002: Add a button to Print Preivew to open printer's Advanced options dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/settings/advanced_options_settings.js
diff --git a/chrome/browser/resources/print_preview/settings/advanced_options_settings.js b/chrome/browser/resources/print_preview/settings/advanced_options_settings.js
new file mode 100644
index 0000000000000000000000000000000000000000..1027b96abd1023d0ef2781080f462cd8adf8c550
--- /dev/null
+++ b/chrome/browser/resources/print_preview/settings/advanced_options_settings.js
@@ -0,0 +1,94 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
Vitaly Buka (NO REVIEWS) 2014/08/13 18:21:20 same http://www.chromium.org/developers/coding-st
Aleksey Shlyapnikov 2014/08/13 18:35:44 Done.
+// 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
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698