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

Side by Side Diff: chrome/browser/resources/print_preview/search/destination_list_item.js

Issue 979303002: Update UI for extension destinations in print preview destination list (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 9 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
OLDNEW
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
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 = '-webkit-image-set(' +
148 'url(chrome://extension-icon/' +
149 this.destination_.extensionId + '/24/1) 1x,' +
150 'url(chrome://extension-icon/' +
151 this.destination_.extensionId + '/48/1) 2x)';
152 extensionIconEl.title = loadTimeData.getStringF(
153 'extensionDestinationIconTooltip',
154 this.destination_.extensionName);
155 extensionIconEl.onclick = this.onExtensionIconClicked_.bind(this);
156 extensionIconEl.onkeydown = this.onExtensionIconKeyDown_.bind(this);
157 }
158
159 var extensionIndicatorEl =
160 this.getChildElement('.extension-controlled-indicator');
161 setIsVisible(extensionIndicatorEl, this.destination_.isExtension);
162
135 // Initialize the element which renders the destination's offline status. 163 // Initialize the element which renders the destination's offline status.
136 this.getElement().classList.toggle('stale', this.destination_.isOffline); 164 this.getElement().classList.toggle('stale', this.destination_.isOffline);
137 var offlineStatusEl = this.getChildElement('.offline-status'); 165 var offlineStatusEl = this.getChildElement('.offline-status');
138 offlineStatusEl.textContent = this.destination_.offlineStatusText; 166 offlineStatusEl.textContent = this.destination_.offlineStatusText;
139 setIsVisible(offlineStatusEl, this.destination_.isOffline); 167 setIsVisible(offlineStatusEl, this.destination_.isOffline);
140 168
141 // Initialize registration promo element for Privet unregistered printers. 169 // Initialize registration promo element for Privet unregistered printers.
142 setIsVisible( 170 setIsVisible(
143 this.getChildElement('.register-promo'), 171 this.getChildElement('.register-promo'),
144 this.destination_.connectionStatus == 172 this.destination_.connectionStatus ==
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 253
226 /** 254 /**
227 * Called when the registration promo is clicked. 255 * Called when the registration promo is clicked.
228 * @private 256 * @private
229 */ 257 */
230 onRegisterPromoClicked_: function() { 258 onRegisterPromoClicked_: function() {
231 var promoClickedEvent = new Event( 259 var promoClickedEvent = new Event(
232 DestinationListItem.EventType.REGISTER_PROMO_CLICKED); 260 DestinationListItem.EventType.REGISTER_PROMO_CLICKED);
233 promoClickedEvent.destination = this.destination_; 261 promoClickedEvent.destination = this.destination_;
234 this.eventTarget_.dispatchEvent(promoClickedEvent); 262 this.eventTarget_.dispatchEvent(promoClickedEvent);
263 },
264
265 /**
266 * Handles click and 'Enter' key down events for the extension icon element.
267 * It opens extensions page with the extension associated with the
268 * destination highlighted.
269 * @param {MouseEvent|KeyboardEvent} e The event to handle.
270 * @private
271 */
272 onExtensionIconClicked_: function(e) {
273 e.stopPropagation();
274 window.open('chrome://extensions?id=' + this.destination_.extensionId);
275 },
276
277 /**
278 * Handles key down event for the extensin icon element. Keys different than
279 * 'Enter' are ignored.
280 * @param {KeyboardEvent} e The event to handle.
281 * @private
282 */
283 onExtensionIconKeyDown_: function(e) {
284 if (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey)
285 return;
286 if (e.keyCode != 13 /* Enter */)
287 return;
288 this.onExtensionIconClicked_(event);
235 } 289 }
236 }; 290 };
237 291
238 // Export 292 // Export
239 return { 293 return {
240 DestinationListItem: DestinationListItem 294 DestinationListItem: DestinationListItem
241 }; 295 };
242 }); 296 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698