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

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

Issue 150943006: Show destination offline status in the print preview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 (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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 print_preview.Component.prototype.enterDocument.call(this); 88 print_preview.Component.prototype.enterDocument.call(this);
89 this.tracker.add(this.getElement(), 'click', this.onActivate_.bind(this)); 89 this.tracker.add(this.getElement(), 'click', this.onActivate_.bind(this));
90 }, 90 },
91 91
92 /** 92 /**
93 * Initializes the element which renders the print destination's 93 * Initializes the element which renders the print destination's
94 * offline status. 94 * offline status.
95 * @private 95 * @private
96 */ 96 */
97 initializeOfflineStatusElement_: function() { 97 initializeOfflineStatusElement_: function() {
98 if (arrayContains([print_preview.Destination.ConnectionStatus.OFFLINE, 98 if (this.destination_.isOffline) {
99 print_preview.Destination.ConnectionStatus.DORMANT],
100 this.destination_.connectionStatus)) {
101 this.getElement().classList.add(DestinationListItem.Classes_.STALE); 99 this.getElement().classList.add(DestinationListItem.Classes_.STALE);
102 var offlineDurationMs = Date.now() - this.destination_.lastAccessTime;
103 var offlineMessageId;
104 if (offlineDurationMs > 31622400000.0) { // One year.
105 offlineMessageId = 'offlineForYear';
106 } else if (offlineDurationMs > 2678400000.0) { // One month.
107 offlineMessageId = 'offlineForMonth';
108 } else if (offlineDurationMs > 604800000.0) { // One week.
109 offlineMessageId = 'offlineForWeek';
110 } else {
111 offlineMessageId = 'offline';
112 }
113 var offlineStatusEl = this.getChildElement('.offline-status'); 100 var offlineStatusEl = this.getChildElement('.offline-status');
114 offlineStatusEl.textContent = localStrings.getString(offlineMessageId); 101 offlineStatusEl.textContent = this.destination_.offlineStatusText;
115 setIsVisible(offlineStatusEl, true); 102 setIsVisible(offlineStatusEl, true);
116 } 103 }
117 }, 104 },
118 105
119 /** 106 /**
120 * Initialize registration promo element for Privet unregistered printers. 107 * Initialize registration promo element for Privet unregistered printers.
121 */ 108 */
122 initializeRegistrationPromoElement_: function() { 109 initializeRegistrationPromoElement_: function() {
123 if (this.destination_.connectionStatus == 110 if (this.destination_.connectionStatus ==
124 print_preview.Destination.ConnectionStatus.UNREGISTERED) { 111 print_preview.Destination.ConnectionStatus.UNREGISTERED) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 promoClickedEvent.destination = this.destination_; 165 promoClickedEvent.destination = this.destination_;
179 this.eventTarget_.dispatchEvent(promoClickedEvent); 166 this.eventTarget_.dispatchEvent(promoClickedEvent);
180 } 167 }
181 }; 168 };
182 169
183 // Export 170 // Export
184 return { 171 return {
185 DestinationListItem: DestinationListItem 172 DestinationListItem: DestinationListItem
186 }; 173 };
187 }); 174 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698