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

Side by Side 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: Address cl comments. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 cr.define('print_preview', function() {
6 'use strict';
7
8 /**
9 * Print options section to control printer advanced options.
10 * @param {!print_preview.DestinationStore} destinationStore Used to determine
11 * the selected destination.
12 * @constructor
13 * @extends {print_preview.Component}
14 */
15 function AdvancedOptionsSettings(destinationStore) {
16 print_preview.Component.call(this);
17
18 /**
19 * Used to determine the selected destination.
20 * @private {!print_preview.DestinationStore}
21 */
22 this.destinationStore_ = destinationStore;
23 };
24
25 /**
26 * Event types dispatched by the component.
27 * @enum {string}
28 */
29 AdvancedOptionsSettings.EventType = {
30 BUTTON_ACTIVATED: 'print_preview.AdvancedOptionsSettings.BUTTON_ACTIVATED'
31 };
32
33 AdvancedOptionsSettings.prototype = {
34 __proto__: print_preview.Component.prototype,
35
36 /** @param {boolean} Whether the component is enabled. */
37 set isEnabled(isEnabled) {
38 this.getButton_().disabled = !isEnabled;
39 },
40
41 /** @override */
42 enterDocument: function() {
43 print_preview.Component.prototype.enterDocument.call(this);
44
45 fadeOutOption(this.getElement(), true);
46
47 this.tracker.add(
48 this.getButton_(), 'click', function() {
49 cr.dispatchSimpleEvent(
50 this, AdvancedOptionsSettings.EventType.BUTTON_ACTIVATED);
51 }.bind(this));
52 this.tracker.add(
53 this.destinationStore_,
54 print_preview.DestinationStore.EventType.DESTINATION_SELECT,
55 this.onDestinationSelect_.bind(this));
56 this.tracker.add(
57 this.destinationStore_,
58 print_preview.DestinationStore.EventType.
59 SELECTED_DESTINATION_CAPABILITIES_READY,
60 this.onDestinationSelect_.bind(this));
61 },
62
63 /**
64 * @return {HTMLElement}
65 * @private
66 */
67 getButton_: function() {
68 return this.getChildElement('.advanced-options-settings-button');
69 },
70
71 /**
72 * Called when the destination selection has changed. Updates UI elements.
73 * @private
74 */
75 onDestinationSelect_: function() {
76 var destination = this.destinationStore_.selectedDestination;
77 var vendorCapabilities =
78 destination &&
79 destination.capabilities &&
80 destination.capabilities.printer &&
81 destination.capabilities.printer.vendor_capability;
82 if (false && vendorCapabilities) {
83 fadeInOption(this.getElement());
84 } else {
85 fadeOutOption(this.getElement());
86 }
87 }
88 };
89
90 // Export
91 return {
92 AdvancedOptionsSettings: AdvancedOptionsSettings
93 };
94 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698