OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * Component that renders a destination item in a destination list. | 9 * Component that renders a destination item in a destination list. |
10 * @param {!cr.EventTarget} eventTarget Event target to dispatch selection | 10 * @param {!cr.EventTarget} eventTarget Event target to dispatch selection |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 textContent += ' (' + property + ')'; | 125 textContent += ' (' + property + ')'; |
126 return true; | 126 return true; |
127 } | 127 } |
128 }, this); | 128 }, this); |
129 } else { | 129 } else { |
130 // Show just the display name and nothing else to lessen visual clutter. | 130 // Show just the display name and nothing else to lessen visual clutter. |
131 nameEl.textContent = textContent; | 131 nameEl.textContent = textContent; |
132 } | 132 } |
133 nameEl.title = textContent; | 133 nameEl.title = textContent; |
134 | 134 |
135 if (this.destination_.isExtension) { | |
136 var extensionNameEl = this.getChildElement('.extension-name'); | |
137 var extensionName = this.destination_.extensionName; | |
138 extensionNameEl.title = this.destination_.extensionName; | |
139 if (this.query_) { | |
140 extensionNameEl.textContent = ''; | |
141 this.addTextWithHighlight_(extensionNameEl, extensionName); | |
142 } else { | |
143 extensionNameEl.textContent = this.destination_.extensionName; | |
144 } | |
145 | |
146 var extensionIconEl = this.getChildElement('.extension-icon'); | |
147 extensionIconEl.style.backgroundImage = | |
148 this.destination_.extensionIconImageStyle; | |
149 extensionIconEl.title = loadTimeData.getStringF( | |
150 'extensionDestinationIconTooltip', | |
151 this.destination_.extensionName); | |
152 var extensionId = this.destination_.extensionId; | |
Aleksey Shlyapnikov
2015/03/06 00:27:39
What do you need this var for?
tbarzic
2015/03/06 03:16:11
removed
| |
153 extensionIconEl.onclick = this.onExtensionIconClicked_.bind(this); | |
154 extensionIconEl.onkeydown = this.onExtensionIconKeyDown_.bind(this); | |
155 } | |
156 | |
157 var extensionIndicatorEl = | |
158 this.getChildElement('.extension-controlled-indicator'); | |
159 setIsVisible(extensionIndicatorEl, this.destination_.isExtension); | |
160 | |
135 // Initialize the element which renders the destination's offline status. | 161 // Initialize the element which renders the destination's offline status. |
136 this.getElement().classList.toggle('stale', this.destination_.isOffline); | 162 this.getElement().classList.toggle('stale', this.destination_.isOffline); |
137 var offlineStatusEl = this.getChildElement('.offline-status'); | 163 var offlineStatusEl = this.getChildElement('.offline-status'); |
138 offlineStatusEl.textContent = this.destination_.offlineStatusText; | 164 offlineStatusEl.textContent = this.destination_.offlineStatusText; |
139 setIsVisible(offlineStatusEl, this.destination_.isOffline); | 165 setIsVisible(offlineStatusEl, this.destination_.isOffline); |
140 | 166 |
141 // Initialize registration promo element for Privet unregistered printers. | 167 // Initialize registration promo element for Privet unregistered printers. |
142 setIsVisible( | 168 setIsVisible( |
143 this.getChildElement('.register-promo'), | 169 this.getChildElement('.register-promo'), |
144 this.destination_.connectionStatus == | 170 this.destination_.connectionStatus == |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 | 251 |
226 /** | 252 /** |
227 * Called when the registration promo is clicked. | 253 * Called when the registration promo is clicked. |
228 * @private | 254 * @private |
229 */ | 255 */ |
230 onRegisterPromoClicked_: function() { | 256 onRegisterPromoClicked_: function() { |
231 var promoClickedEvent = new Event( | 257 var promoClickedEvent = new Event( |
232 DestinationListItem.EventType.REGISTER_PROMO_CLICKED); | 258 DestinationListItem.EventType.REGISTER_PROMO_CLICKED); |
233 promoClickedEvent.destination = this.destination_; | 259 promoClickedEvent.destination = this.destination_; |
234 this.eventTarget_.dispatchEvent(promoClickedEvent); | 260 this.eventTarget_.dispatchEvent(promoClickedEvent); |
261 }, | |
262 | |
263 /** | |
264 * Handles click and 'Enter' key down events for the extension icon element. | |
265 * It opens extensions page with the extension associated with the | |
266 * destination highlighted. | |
267 * @param {MouseEvent|KeyboardEvent} e The event to handle. | |
268 * @private | |
269 */ | |
270 onExtensionIconClicked_: function(e) { | |
271 e.stopPropagation(); | |
272 window.open('chrome://extensions?id=' + this.destination_.extensionId); | |
273 }, | |
274 | |
275 /** | |
276 * Handles key down event for the extensin icon element. Keys different than | |
277 * 'Enter' are ignored. | |
278 * @param {KeyboardEvent} e The event to handle. | |
279 * @private | |
280 */ | |
281 onExtensionIconKeyDown_: function(e) { | |
282 if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) | |
283 return; | |
284 if (e.keyCode != 13 /* Enter */) | |
285 return; | |
286 this.onExtensionIconClicked_(event); | |
235 } | 287 } |
236 }; | 288 }; |
237 | 289 |
238 // Export | 290 // Export |
239 return { | 291 return { |
240 DestinationListItem: DestinationListItem | 292 DestinationListItem: DestinationListItem |
241 }; | 293 }; |
242 }); | 294 }); |
OLD | NEW |