OLD | NEW |
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 * Modal dialog for print destination's advanced settings. | 9 * Modal dialog for print destination's advanced settings. |
10 * @param {!print_preview.PrintTicketStore} printTicketStore Contains the | 10 * @param {!print_preview.PrintTicketStore} printTicketStore Contains the |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 __proto__: print_preview.Overlay.prototype, | 52 __proto__: print_preview.Overlay.prototype, |
53 | 53 |
54 /** | 54 /** |
55 * @param {!print_preview.Destination} destination Destination to show | 55 * @param {!print_preview.Destination} destination Destination to show |
56 * advanced settings for. | 56 * advanced settings for. |
57 */ | 57 */ |
58 showForDestination: function(destination) { | 58 showForDestination: function(destination) { |
59 assert(!this.destination_); | 59 assert(!this.destination_); |
60 this.destination_ = destination; | 60 this.destination_ = destination; |
61 this.getChildElement('.advanced-settings-title').textContent = | 61 this.getChildElement('.advanced-settings-title').textContent = |
62 loadTimeData.getStringF('advancedSettingsDialogTitle', | 62 loadTimeData.getStringF( |
63 this.destination_.displayName); | 63 'advancedSettingsDialogTitle', this.destination_.displayName); |
64 this.setIsVisible(true); | 64 this.setIsVisible(true); |
65 this.renderSettings_(); | 65 this.renderSettings_(); |
66 }, | 66 }, |
67 | 67 |
68 /** @override */ | 68 /** @override */ |
69 enterDocument: function() { | 69 enterDocument: function() { |
70 print_preview.Overlay.prototype.enterDocument.call(this); | 70 print_preview.Overlay.prototype.enterDocument.call(this); |
71 | 71 |
72 this.tracker.add( | 72 this.tracker.add( |
73 this.getChildElement('.button-strip .cancel-button'), | 73 this.getChildElement('.button-strip .cancel-button'), 'click', |
74 'click', | |
75 this.cancel.bind(this)); | 74 this.cancel.bind(this)); |
76 | 75 |
77 this.tracker.add( | 76 this.tracker.add( |
78 this.getChildElement('.button-strip .done-button'), | 77 this.getChildElement('.button-strip .done-button'), 'click', |
79 'click', | |
80 this.onApplySettings_.bind(this)); | 78 this.onApplySettings_.bind(this)); |
81 | 79 |
82 this.tracker.add( | 80 this.tracker.add( |
83 assert(this.searchBox_), | 81 assert(this.searchBox_), print_preview.SearchBox.EventType.SEARCH, |
84 print_preview.SearchBox.EventType.SEARCH, | |
85 this.onSearch_.bind(this)); | 82 this.onSearch_.bind(this)); |
86 }, | 83 }, |
87 | 84 |
88 /** @override */ | 85 /** @override */ |
89 decorateInternal: function() { | 86 decorateInternal: function() { |
90 this.searchBox_.render(this.getChildElement('.search-box-area')); | 87 this.searchBox_.render(this.getChildElement('.search-box-area')); |
91 }, | 88 }, |
92 | 89 |
93 /** @override */ | 90 /** @override */ |
94 onSetVisibleInternal: function(isVisible) { | 91 onSetVisibleInternal: function(isVisible) { |
95 if (isVisible) { | 92 if (isVisible) { |
96 this.searchBox_.focus(); | 93 this.searchBox_.focus(); |
97 this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket. | 94 this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket |
98 ADVANCED_SETTINGS_DIALOG_SHOWN); | 95 .ADVANCED_SETTINGS_DIALOG_SHOWN); |
99 } else { | 96 } else { |
100 this.resetSearch_(); | 97 this.resetSearch_(); |
101 this.destination_ = null; | 98 this.destination_ = null; |
102 } | 99 } |
103 }, | 100 }, |
104 | 101 |
105 /** @override */ | 102 /** @override */ |
106 onCancelInternal: function() { | 103 onCancelInternal: function() { |
107 this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket. | 104 this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket |
108 ADVANCED_SETTINGS_DIALOG_CANCELED); | 105 .ADVANCED_SETTINGS_DIALOG_CANCELED); |
109 }, | 106 }, |
110 | 107 |
111 /** @override */ | 108 /** @override */ |
112 onEnterPressedInternal: function() { | 109 onEnterPressedInternal: function() { |
113 var doneButton = this.getChildElement('.button-strip .done-button'); | 110 var doneButton = this.getChildElement('.button-strip .done-button'); |
114 if (!doneButton.disabled) | 111 if (!doneButton.disabled) |
115 doneButton.click(); | 112 doneButton.click(); |
116 return !doneButton.disabled; | 113 return !doneButton.disabled; |
117 }, | 114 }, |
118 | 115 |
(...skipping 19 matching lines...) Expand all Loading... |
138 var atLeastOneMatch = false; | 135 var atLeastOneMatch = false; |
139 var lastVisibleItemWithBubble = null; | 136 var lastVisibleItemWithBubble = null; |
140 this.items_.forEach(function(item) { | 137 this.items_.forEach(function(item) { |
141 item.updateSearchQuery(query); | 138 item.updateSearchQuery(query); |
142 if (getIsVisible(item.getElement())) | 139 if (getIsVisible(item.getElement())) |
143 atLeastOneMatch = true; | 140 atLeastOneMatch = true; |
144 if (item.searchBubbleShown) | 141 if (item.searchBubbleShown) |
145 lastVisibleItemWithBubble = item; | 142 lastVisibleItemWithBubble = item; |
146 }); | 143 }); |
147 setIsVisible( | 144 setIsVisible( |
148 this.getChildElement('.no-settings-match-hint'), | 145 this.getChildElement('.no-settings-match-hint'), !atLeastOneMatch); |
149 !atLeastOneMatch); | |
150 setIsVisible( | 146 setIsVisible( |
151 this.getChildElement('.' + AdvancedSettings.Classes_.EXTRA_PADDING), | 147 this.getChildElement('.' + AdvancedSettings.Classes_.EXTRA_PADDING), |
152 !!lastVisibleItemWithBubble); | 148 !!lastVisibleItemWithBubble); |
153 }, | 149 }, |
154 | 150 |
155 /** | 151 /** |
156 * Resets the filter query. | 152 * Resets the filter query. |
157 * @private | 153 * @private |
158 */ | 154 */ |
159 resetSearch_: function() { | 155 resetSearch_: function() { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 this.items_.forEach(function(item) { | 225 this.items_.forEach(function(item) { |
230 if (item.isModified()) | 226 if (item.isModified()) |
231 values[item.id] = item.selectedValue; | 227 values[item.id] = item.selectedValue; |
232 }.bind(this)); | 228 }.bind(this)); |
233 | 229 |
234 this.printTicketStore_.vendorItems.updateValue(values); | 230 this.printTicketStore_.vendorItems.updateValue(values); |
235 } | 231 } |
236 }; | 232 }; |
237 | 233 |
238 // Export | 234 // Export |
239 return { | 235 return {AdvancedSettings: AdvancedSettings}; |
240 AdvancedSettings: AdvancedSettings | |
241 }; | |
242 }); | 236 }); |
OLD | NEW |