Chromium Code Reviews| 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 // 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 DestinationSettings.Classes_ = { | 51 DestinationSettings.Classes_ = { |
| 52 CHANGE_BUTTON: 'destination-settings-change-button', | 52 CHANGE_BUTTON: 'destination-settings-change-button', |
| 53 ICON: 'destination-settings-icon', | 53 ICON: 'destination-settings-icon', |
| 54 ICON_CLOUD: 'destination-settings-icon-cloud', | 54 ICON_CLOUD: 'destination-settings-icon-cloud', |
| 55 ICON_CLOUD_SHARED: 'destination-settings-icon-cloud-shared', | 55 ICON_CLOUD_SHARED: 'destination-settings-icon-cloud-shared', |
| 56 ICON_GOOGLE_PROMOTED: 'destination-settings-icon-google-promoted', | 56 ICON_GOOGLE_PROMOTED: 'destination-settings-icon-google-promoted', |
| 57 ICON_LOCAL: 'destination-settings-icon-local', | 57 ICON_LOCAL: 'destination-settings-icon-local', |
| 58 ICON_MOBILE: 'destination-settings-icon-mobile', | 58 ICON_MOBILE: 'destination-settings-icon-mobile', |
| 59 ICON_MOBILE_SHARED: 'destination-settings-icon-mobile-shared', | 59 ICON_MOBILE_SHARED: 'destination-settings-icon-mobile-shared', |
| 60 LOCATION: 'destination-settings-location', | 60 LOCATION: 'destination-settings-location', |
| 61 OFFLINE_STATUS: 'destination-settings-offline-status', | |
| 61 NAME: 'destination-settings-name', | 62 NAME: 'destination-settings-name', |
| 63 STALE: 'stale', | |
| 62 THOBBER_NAME: 'destination-throbber-name' | 64 THOBBER_NAME: 'destination-throbber-name' |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 DestinationSettings.prototype = { | 67 DestinationSettings.prototype = { |
| 66 __proto__: print_preview.Component.prototype, | 68 __proto__: print_preview.Component.prototype, |
| 67 | 69 |
| 68 /** @param {boolean} Whether the component is enabled. */ | 70 /** @param {boolean} Whether the component is enabled. */ |
| 69 set isEnabled(isEnabled) { | 71 set isEnabled(isEnabled) { |
| 70 var changeButton = this.getElement().getElementsByClassName( | 72 var changeButton = this.getElement().getElementsByClassName( |
| 71 DestinationSettings.Classes_.CHANGE_BUTTON)[0]; | 73 DestinationSettings.Classes_.CHANGE_BUTTON)[0]; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 var destination = this.destinationStore_.selectedDestination; | 110 var destination = this.destinationStore_.selectedDestination; |
| 109 var nameEl = this.getElement().getElementsByClassName( | 111 var nameEl = this.getElement().getElementsByClassName( |
| 110 DestinationSettings.Classes_.NAME)[0]; | 112 DestinationSettings.Classes_.NAME)[0]; |
| 111 nameEl.textContent = destination.displayName; | 113 nameEl.textContent = destination.displayName; |
| 112 nameEl.title = destination.displayName; | 114 nameEl.title = destination.displayName; |
| 113 | 115 |
| 114 var iconEl = this.getElement().getElementsByClassName( | 116 var iconEl = this.getElement().getElementsByClassName( |
| 115 DestinationSettings.Classes_.ICON)[0]; | 117 DestinationSettings.Classes_.ICON)[0]; |
| 116 iconEl.src = destination.iconUrl; | 118 iconEl.src = destination.iconUrl; |
| 117 | 119 |
| 120 var location = destination.location; | |
| 118 var locationEl = this.getElement().getElementsByClassName( | 121 var locationEl = this.getElement().getElementsByClassName( |
| 119 DestinationSettings.Classes_.LOCATION)[0]; | 122 DestinationSettings.Classes_.LOCATION)[0]; |
| 120 locationEl.textContent = destination.location; | 123 locationEl.textContent = location; |
| 121 locationEl.title = destination.location; | 124 locationEl.title = location; |
| 125 | |
| 126 var offlineStatusText = destination.offlineStatusText; | |
| 127 var offlineStatusEl = this.getElement().getElementsByClassName( | |
|
Toscano
2014/02/12 22:10:29
Why not use this.getChildElement()?
Aleksey Shlyapnikov
2014/02/13 19:10:18
Done.
| |
| 128 DestinationSettings.Classes_.OFFLINE_STATUS)[0]; | |
| 129 offlineStatusEl.textContent = offlineStatusText; | |
| 130 offlineStatusEl.title = offlineStatusText; | |
| 131 | |
| 132 var isOffline = destination.isOffline; | |
| 133 var destinationSettingsBoxEl = | |
| 134 this.getElement().querySelector('.destination-settings-box'); | |
|
Toscano
2014/02/12 22:10:29
Why not use this.getChildElement()?
Aleksey Shlyapnikov
2014/02/13 19:10:18
Done.
| |
| 135 if (isOffline) { | |
| 136 destinationSettingsBoxEl.classList.add( | |
| 137 DestinationSettings.Classes_.STALE); | |
| 138 } else { | |
| 139 destinationSettingsBoxEl.classList.remove( | |
| 140 DestinationSettings.Classes_.STALE); | |
| 141 } | |
|
Toscano
2014/02/12 22:10:29
What about simplifying this if-else statement to:
Aleksey Shlyapnikov
2014/02/13 19:10:18
Done.
| |
| 142 setIsVisible(locationEl, !isOffline); | |
| 143 setIsVisible(offlineStatusEl, isOffline); | |
| 122 | 144 |
| 123 setIsVisible(this.getElement().querySelector('.throbber-container'), | 145 setIsVisible(this.getElement().querySelector('.throbber-container'), |
| 124 false); | 146 false); |
| 125 setIsVisible( | 147 setIsVisible(destinationSettingsBoxEl, true); |
| 126 this.getElement().querySelector('.destination-settings-box'), true); | |
| 127 }, | 148 }, |
| 128 | 149 |
| 129 onSelectedDestinationNameSet_: function() { | 150 onSelectedDestinationNameSet_: function() { |
| 130 var destinationName = | 151 var destinationName = |
| 131 this.destinationStore_.selectedDestination.displayName; | 152 this.destinationStore_.selectedDestination.displayName; |
| 132 var nameEl = this.getElement().getElementsByClassName( | 153 var nameEl = this.getElement().getElementsByClassName( |
| 133 DestinationSettings.Classes_.THOBBER_NAME)[0]; | 154 DestinationSettings.Classes_.THOBBER_NAME)[0]; |
| 134 nameEl.textContent = destinationName; | 155 nameEl.textContent = destinationName; |
| 135 nameEl.title = destinationName; | 156 nameEl.title = destinationName; |
| 136 } | 157 } |
| 137 }; | 158 }; |
| 138 | 159 |
| 139 // Export | 160 // Export |
| 140 return { | 161 return { |
| 141 DestinationSettings: DestinationSettings | 162 DestinationSettings: DestinationSettings |
| 142 }; | 163 }; |
| 143 }); | 164 }); |
| OLD | NEW |