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

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

Issue 477133004: Printe Preview: add 'More/less options' button and make non-essential sections collapsible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Print Preview UI tests adjusted. 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 cr.define('print_preview', function() { 5 cr.define('print_preview', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Print options section to control printer advanced options. 9 * Print options section to control printer advanced options.
10 * @param {!print_preview.DestinationStore} destinationStore Used to determine 10 * @param {!print_preview.DestinationStore} destinationStore Used to determine
11 * the selected destination. 11 * the selected destination.
12 * @constructor 12 * @constructor
13 * @extends {print_preview.Component} 13 * @extends {print_preview.SettingsSection}
14 */ 14 */
15 function AdvancedOptionsSettings(destinationStore) { 15 function AdvancedOptionsSettings(destinationStore) {
16 print_preview.Component.call(this); 16 print_preview.SettingsSection.call(this);
17 17
18 /** 18 /**
19 * Used to determine the selected destination. 19 * Used to determine the selected destination.
20 * @private {!print_preview.DestinationStore} 20 * @private {!print_preview.DestinationStore}
21 */ 21 */
22 this.destinationStore_ = destinationStore; 22 this.destinationStore_ = destinationStore;
23 }; 23 };
24 24
25 /** 25 /**
26 * Event types dispatched by the component. 26 * Event types dispatched by the component.
27 * @enum {string} 27 * @enum {string}
28 */ 28 */
29 AdvancedOptionsSettings.EventType = { 29 AdvancedOptionsSettings.EventType = {
30 BUTTON_ACTIVATED: 'print_preview.AdvancedOptionsSettings.BUTTON_ACTIVATED' 30 BUTTON_ACTIVATED: 'print_preview.AdvancedOptionsSettings.BUTTON_ACTIVATED'
31 }; 31 };
32 32
33 AdvancedOptionsSettings.prototype = { 33 AdvancedOptionsSettings.prototype = {
34 __proto__: print_preview.Component.prototype, 34 __proto__: print_preview.SettingsSection.prototype,
35
36 /** @override */
37 isAvailable: function() {
38 var destination = this.destinationStore_.selectedDestination;
39 var vendorCapabilities =
40 destination &&
41 destination.capabilities &&
42 destination.capabilities.printer &&
43 destination.capabilities.printer.vendor_capability;
44 return false && !!vendorCapabilities;
45 },
46
47 /** @override */
48 hasCollapsibleContent: function() {
49 return this.isAvailable();
50 },
35 51
36 /** @param {boolean} Whether the component is enabled. */ 52 /** @param {boolean} Whether the component is enabled. */
37 set isEnabled(isEnabled) { 53 set isEnabled(isEnabled) {
38 this.getButton_().disabled = !isEnabled; 54 this.getButton_().disabled = !isEnabled;
39 }, 55 },
40 56
41 /** @override */ 57 /** @override */
42 enterDocument: function() { 58 enterDocument: function() {
43 print_preview.Component.prototype.enterDocument.call(this); 59 print_preview.SettingsSection.prototype.enterDocument.call(this);
44
45 fadeOutOption(this.getElement(), true);
46 60
47 this.tracker.add( 61 this.tracker.add(
48 this.getButton_(), 'click', function() { 62 this.getButton_(), 'click', function() {
49 cr.dispatchSimpleEvent( 63 cr.dispatchSimpleEvent(
50 this, AdvancedOptionsSettings.EventType.BUTTON_ACTIVATED); 64 this, AdvancedOptionsSettings.EventType.BUTTON_ACTIVATED);
51 }.bind(this)); 65 }.bind(this));
52 this.tracker.add( 66 this.tracker.add(
53 this.destinationStore_, 67 this.destinationStore_,
54 print_preview.DestinationStore.EventType.DESTINATION_SELECT, 68 print_preview.DestinationStore.EventType.DESTINATION_SELECT,
55 this.onDestinationSelect_.bind(this)); 69 this.onDestinationChanged_.bind(this));
56 this.tracker.add( 70 this.tracker.add(
57 this.destinationStore_, 71 this.destinationStore_,
58 print_preview.DestinationStore.EventType. 72 print_preview.DestinationStore.EventType.
59 SELECTED_DESTINATION_CAPABILITIES_READY, 73 SELECTED_DESTINATION_CAPABILITIES_READY,
60 this.onDestinationSelect_.bind(this)); 74 this.onDestinationChanged_.bind(this));
61 }, 75 },
62 76
63 /** 77 /**
64 * @return {HTMLElement} 78 * @return {HTMLElement}
65 * @private 79 * @private
66 */ 80 */
67 getButton_: function() { 81 getButton_: function() {
68 return this.getChildElement('.advanced-options-settings-button'); 82 return this.getChildElement('.advanced-options-settings-button');
69 }, 83 },
70 84
71 /** 85 /**
72 * Called when the destination selection has changed. Updates UI elements. 86 * Called when the destination selection has changed. Updates UI elements.
73 * @private 87 * @private
74 */ 88 */
75 onDestinationSelect_: function() { 89 onDestinationChanged_: function() {
76 var destination = this.destinationStore_.selectedDestination; 90 this.updateUiStateInternal();
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 } 91 }
88 }; 92 };
89 93
90 // Export 94 // Export
91 return { 95 return {
92 AdvancedOptionsSettings: AdvancedOptionsSettings 96 AdvancedOptionsSettings: AdvancedOptionsSettings
93 }; 97 };
94 }); 98 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698