| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 NAME: 'destination-settings-name', | 61 NAME: 'destination-settings-name', |
| 62 STALE: 'stale', |
| 62 THOBBER_NAME: 'destination-throbber-name' | 63 THOBBER_NAME: 'destination-throbber-name' |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 DestinationSettings.prototype = { | 66 DestinationSettings.prototype = { |
| 66 __proto__: print_preview.Component.prototype, | 67 __proto__: print_preview.Component.prototype, |
| 67 | 68 |
| 68 /** @param {boolean} Whether the component is enabled. */ | 69 /** @param {boolean} Whether the component is enabled. */ |
| 69 set isEnabled(isEnabled) { | 70 set isEnabled(isEnabled) { |
| 70 var changeButton = this.getElement().getElementsByClassName( | 71 var changeButton = this.getElement().getElementsByClassName( |
| 71 DestinationSettings.Classes_.CHANGE_BUTTON)[0]; | 72 DestinationSettings.Classes_.CHANGE_BUTTON)[0]; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 var destination = this.destinationStore_.selectedDestination; | 109 var destination = this.destinationStore_.selectedDestination; |
| 109 var nameEl = this.getElement().getElementsByClassName( | 110 var nameEl = this.getElement().getElementsByClassName( |
| 110 DestinationSettings.Classes_.NAME)[0]; | 111 DestinationSettings.Classes_.NAME)[0]; |
| 111 nameEl.textContent = destination.displayName; | 112 nameEl.textContent = destination.displayName; |
| 112 nameEl.title = destination.displayName; | 113 nameEl.title = destination.displayName; |
| 113 | 114 |
| 114 var iconEl = this.getElement().getElementsByClassName( | 115 var iconEl = this.getElement().getElementsByClassName( |
| 115 DestinationSettings.Classes_.ICON)[0]; | 116 DestinationSettings.Classes_.ICON)[0]; |
| 116 iconEl.src = destination.iconUrl; | 117 iconEl.src = destination.iconUrl; |
| 117 | 118 |
| 119 var location = destination.location; |
| 118 var locationEl = this.getElement().getElementsByClassName( | 120 var locationEl = this.getElement().getElementsByClassName( |
| 119 DestinationSettings.Classes_.LOCATION)[0]; | 121 DestinationSettings.Classes_.LOCATION)[0]; |
| 120 locationEl.textContent = destination.location; | 122 locationEl.textContent = location; |
| 121 locationEl.title = destination.location; | 123 locationEl.title = location; |
| 122 | 124 |
| 123 setIsVisible(this.getElement().querySelector('.throbber-container'), | 125 var offlineStatusText = destination.offlineStatusText; |
| 124 false); | 126 var offlineStatusEl = |
| 125 setIsVisible( | 127 this.getChildElement('.destination-settings-offline-status'); |
| 126 this.getElement().querySelector('.destination-settings-box'), true); | 128 offlineStatusEl.textContent = offlineStatusText; |
| 129 offlineStatusEl.title = offlineStatusText; |
| 130 |
| 131 var isOffline = destination.isOffline; |
| 132 var destinationSettingsBoxEl = |
| 133 this.getChildElement('.destination-settings-box'); |
| 134 destinationSettingsBoxEl.classList.toggle( |
| 135 DestinationSettings.Classes_.STALE, isOffline); |
| 136 setIsVisible(locationEl, !isOffline); |
| 137 setIsVisible(offlineStatusEl, isOffline); |
| 138 |
| 139 setIsVisible(this.getChildElement('.throbber-container'), false); |
| 140 setIsVisible(destinationSettingsBoxEl, true); |
| 127 }, | 141 }, |
| 128 | 142 |
| 129 onSelectedDestinationNameSet_: function() { | 143 onSelectedDestinationNameSet_: function() { |
| 130 var destinationName = | 144 var destinationName = |
| 131 this.destinationStore_.selectedDestination.displayName; | 145 this.destinationStore_.selectedDestination.displayName; |
| 132 var nameEl = this.getElement().getElementsByClassName( | 146 var nameEl = this.getElement().getElementsByClassName( |
| 133 DestinationSettings.Classes_.THOBBER_NAME)[0]; | 147 DestinationSettings.Classes_.THOBBER_NAME)[0]; |
| 134 nameEl.textContent = destinationName; | 148 nameEl.textContent = destinationName; |
| 135 nameEl.title = destinationName; | 149 nameEl.title = destinationName; |
| 136 } | 150 } |
| 137 }; | 151 }; |
| 138 | 152 |
| 139 // Export | 153 // Export |
| 140 return { | 154 return { |
| 141 DestinationSettings: DestinationSettings | 155 DestinationSettings: DestinationSettings |
| 142 }; | 156 }; |
| 143 }); | 157 }); |
| OLD | NEW |