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

Side by Side Diff: chrome/browser/resources/print_preview/settings/destination_settings.js

Issue 233623003: Remember and restore the account last used destination is registered for. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adjust PrintPreview unit test. Created 6 years, 8 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 // TODO(rltoscano): This class needs a throbber while loading the destination 8 // TODO(rltoscano): This class needs a throbber while loading the destination
9 // or another solution is persist the settings of the printer so that next 9 // or another solution is persist the settings of the printer so that next
10 // load is fast. 10 // load is fast.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 onChangeButtonClick_: function() { 99 onChangeButtonClick_: function() {
100 cr.dispatchSimpleEvent( 100 cr.dispatchSimpleEvent(
101 this, DestinationSettings.EventType.CHANGE_BUTTON_ACTIVATE); 101 this, DestinationSettings.EventType.CHANGE_BUTTON_ACTIVATE);
102 }, 102 },
103 103
104 /** 104 /**
105 * Called when the destination selection has changed. Updates UI elements. 105 * Called when the destination selection has changed. Updates UI elements.
106 * @private 106 * @private
107 */ 107 */
108 onDestinationSelect_: function() { 108 onDestinationSelect_: function() {
109 var destination = this.destinationStore_.selectedDestination;
110 var nameEl = this.getElement().getElementsByClassName(
111 DestinationSettings.Classes_.NAME)[0];
112 nameEl.textContent = destination.displayName;
113 nameEl.title = destination.displayName;
114
115 var iconEl = this.getElement().getElementsByClassName(
116 DestinationSettings.Classes_.ICON)[0];
117 iconEl.src = destination.iconUrl;
118
119 var hint = destination.hint;
120 var locationEl = this.getElement().getElementsByClassName(
121 DestinationSettings.Classes_.LOCATION)[0];
122 locationEl.textContent = hint;
123 locationEl.title = hint;
124
125 var offlineStatusText = destination.offlineStatusText;
126 var offlineStatusEl =
127 this.getChildElement('.destination-settings-offline-status');
128 offlineStatusEl.textContent = offlineStatusText;
129 offlineStatusEl.title = offlineStatusText;
130
131 var isOffline = destination.isOffline;
132 var destinationSettingsBoxEl = 109 var destinationSettingsBoxEl =
133 this.getChildElement('.destination-settings-box'); 110 this.getChildElement('.destination-settings-box');
134 destinationSettingsBoxEl.classList.toggle(
135 DestinationSettings.Classes_.STALE, isOffline);
136 setIsVisible(locationEl, !isOffline);
137 setIsVisible(offlineStatusEl, isOffline);
138 111
139 setIsVisible(this.getChildElement('.throbber-container'), false); 112 var destination = this.destinationStore_.selectedDestination;
140 setIsVisible(destinationSettingsBoxEl, true); 113 if (destination != null) {
114 var nameEl = this.getElement().getElementsByClassName(
115 DestinationSettings.Classes_.NAME)[0];
116 nameEl.textContent = destination.displayName;
117 nameEl.title = destination.displayName;
118
119 var iconEl = this.getElement().getElementsByClassName(
120 DestinationSettings.Classes_.ICON)[0];
121 iconEl.src = destination.iconUrl;
122
123 var hint = destination.hint;
124 var locationEl = this.getElement().getElementsByClassName(
125 DestinationSettings.Classes_.LOCATION)[0];
126 locationEl.textContent = hint;
127 locationEl.title = hint;
128
129 var offlineStatusText = destination.offlineStatusText;
130 var offlineStatusEl =
131 this.getChildElement('.destination-settings-offline-status');
132 offlineStatusEl.textContent = offlineStatusText;
133 offlineStatusEl.title = offlineStatusText;
134
135 var isOffline = destination.isOffline;
136 destinationSettingsBoxEl.classList.toggle(
137 DestinationSettings.Classes_.STALE, isOffline);
138 setIsVisible(locationEl, !isOffline);
139 setIsVisible(offlineStatusEl, isOffline);
140 }
141
142 setIsVisible(
143 this.getChildElement('.throbber-container'), destination == null);
144 setIsVisible(destinationSettingsBoxEl, destination != null);
141 }, 145 },
142 146
143 onSelectedDestinationNameSet_: function() { 147 onSelectedDestinationNameSet_: function() {
144 var destinationName = 148 var destinationName =
145 this.destinationStore_.selectedDestination.displayName; 149 this.destinationStore_.selectedDestination.displayName;
146 var nameEl = this.getElement().getElementsByClassName( 150 var nameEl = this.getElement().getElementsByClassName(
147 DestinationSettings.Classes_.THOBBER_NAME)[0]; 151 DestinationSettings.Classes_.THOBBER_NAME)[0];
148 nameEl.textContent = destinationName; 152 nameEl.textContent = destinationName;
149 nameEl.title = destinationName; 153 nameEl.title = destinationName;
150 } 154 }
151 }; 155 };
152 156
153 // Export 157 // Export
154 return { 158 return {
155 DestinationSettings: DestinationSettings 159 DestinationSettings: DestinationSettings
156 }; 160 };
157 }); 161 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/search/destination_search.js ('k') | chrome/test/data/webui/print_preview.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698