BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / resources / print_preview / settings / advanced_options_settings.js
blobe1284a749008675c20693907fa04844d0a27577e
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.
5 cr.define('print_preview', function() {
6   'use strict';
8   /**
9    * Print options section to control printer advanced options.
10    * @param {!print_preview.ticket_item.VendorItems} ticketItem Ticket item to
11    *     check settings availability.
12    * @param {!print_preview.DestinationStore} destinationStore Used to determine
13    *     the selected destination.
14    * @constructor
15    * @extends {print_preview.SettingsSection}
16    */
17   function AdvancedOptionsSettings(ticketItem, destinationStore) {
18     print_preview.SettingsSection.call(this);
20     /**
21      * Ticket item to check settings availability.
22      * @private {!print_preview.ticket_items.VendorItems}
23      */
24     this.ticketItem_ = ticketItem;
26     /**
27      * Used to determine the selected destination.
28      * @private {!print_preview.DestinationStore}
29      */
30     this.destinationStore_ = destinationStore;
31   };
33   /**
34    * Event types dispatched by the component.
35    * @enum {string}
36    */
37   AdvancedOptionsSettings.EventType = {
38     BUTTON_ACTIVATED: 'print_preview.AdvancedOptionsSettings.BUTTON_ACTIVATED'
39   };
41   AdvancedOptionsSettings.prototype = {
42     __proto__: print_preview.SettingsSection.prototype,
44     /** @override */
45     isAvailable: function() {
46       return this.ticketItem_.isCapabilityAvailable();
47     },
49     /** @override */
50     hasCollapsibleContent: function() {
51       return this.isAvailable();
52     },
54     /** @param {boolean} isEnabled Whether the component is enabled. */
55     set isEnabled(isEnabled) {
56       this.getButton_().disabled = !isEnabled;
57     },
59     /** @override */
60     enterDocument: function() {
61       print_preview.SettingsSection.prototype.enterDocument.call(this);
63       this.tracker.add(
64           this.getButton_(), 'click', function() {
65             cr.dispatchSimpleEvent(
66                 this, AdvancedOptionsSettings.EventType.BUTTON_ACTIVATED);
67           }.bind(this));
68       this.tracker.add(
69           this.destinationStore_,
70           print_preview.DestinationStore.EventType.DESTINATION_SELECT,
71           this.onDestinationChanged_.bind(this));
72       this.tracker.add(
73           this.destinationStore_,
74           print_preview.DestinationStore.EventType.
75               SELECTED_DESTINATION_CAPABILITIES_READY,
76           this.onDestinationChanged_.bind(this));
77     },
79     /**
80      * @return {HTMLElement}
81      * @private
82      */
83     getButton_: function() {
84       return this.getChildElement('.advanced-options-settings-button');
85     },
87     /**
88      * Called when the destination selection has changed. Updates UI elements.
89      * @private
90      */
91     onDestinationChanged_: function() {
92       this.updateUiStateInternal();
93     }
94   };
96   // Export
97   return {
98     AdvancedOptionsSettings: AdvancedOptionsSettings
99   };