* @param {!print_preview.DestinationStore} destinationStore Used to determine
* the selected destination.
* @constructor
- * @extends {print_preview.Component}
+ * @extends {print_preview.SettingsSection}
*/
function DestinationSettings(destinationStore) {
- print_preview.Component.call(this);
+ print_preview.SettingsSection.call(this);
/**
* Used to determine the selected destination.
ICON_MOBILE: 'destination-settings-icon-mobile',
ICON_MOBILE_SHARED: 'destination-settings-icon-mobile-shared',
LOCATION: 'destination-settings-location',
- NAME: 'destination-settings-name'
+ NAME: 'destination-settings-name',
+ STALE: 'stale',
+ THOBBER_NAME: 'destination-throbber-name'
};
DestinationSettings.prototype = {
- __proto__: print_preview.Component.prototype,
+ __proto__: print_preview.SettingsSection.prototype,
- /** @param {boolean} Whether the component is enabled. */
+ /** @override */
+ isAvailable: function() {
+ return true;
+ },
+
+ /** @override */
+ hasCollapsibleContent: function() {
+ return false;
+ },
+
+ /** @override */
set isEnabled(isEnabled) {
var changeButton = this.getElement().getElementsByClassName(
DestinationSettings.Classes_.CHANGE_BUTTON)[0];
/** @override */
enterDocument: function() {
- print_preview.Component.prototype.enterDocument.call(this);
+ print_preview.SettingsSection.prototype.enterDocument.call(this);
var changeButton = this.getElement().getElementsByClassName(
DestinationSettings.Classes_.CHANGE_BUTTON)[0];
this.tracker.add(
this.destinationStore_,
print_preview.DestinationStore.EventType.DESTINATION_SELECT,
this.onDestinationSelect_.bind(this));
+ this.tracker_.add(
+ this.destinationStore_,
+ print_preview.DestinationStore.EventType.
+ CACHED_SELECTED_DESTINATION_INFO_READY,
+ this.onSelectedDestinationNameSet_.bind(this));
},
/**
* @private
*/
onDestinationSelect_: function() {
- var destination = this.destinationStore_.selectedDestination;
- var nameEl = this.getElement().getElementsByClassName(
- DestinationSettings.Classes_.NAME)[0];
- nameEl.textContent = destination.displayName;
- nameEl.title = destination.displayName;
+ var destinationSettingsBoxEl =
+ this.getChildElement('.destination-settings-box');
- var iconEl = this.getElement().getElementsByClassName(
- DestinationSettings.Classes_.ICON)[0];
- iconEl.src = destination.iconUrl;
-
- var locationEl = this.getElement().getElementsByClassName(
- DestinationSettings.Classes_.LOCATION)[0];
- locationEl.textContent = destination.location;
- locationEl.title = destination.location;
+ var destination = this.destinationStore_.selectedDestination;
+ if (destination != null) {
+ var nameEl = this.getElement().getElementsByClassName(
+ DestinationSettings.Classes_.NAME)[0];
+ nameEl.textContent = destination.displayName;
+ nameEl.title = destination.displayName;
+
+ var iconEl = this.getElement().getElementsByClassName(
+ DestinationSettings.Classes_.ICON)[0];
+ iconEl.src = destination.iconUrl;
+
+ var hint = destination.hint;
+ var locationEl = this.getElement().getElementsByClassName(
+ DestinationSettings.Classes_.LOCATION)[0];
+ locationEl.textContent = hint;
+ locationEl.title = hint;
+
+ var offlineStatusText = destination.offlineStatusText;
+ var offlineStatusEl =
+ this.getChildElement('.destination-settings-offline-status');
+ offlineStatusEl.textContent = offlineStatusText;
+ offlineStatusEl.title = offlineStatusText;
+
+ var isOffline = destination.isOffline;
+ destinationSettingsBoxEl.classList.toggle(
+ DestinationSettings.Classes_.STALE, isOffline);
+ setIsVisible(locationEl, !isOffline);
+ setIsVisible(offlineStatusEl, isOffline);
+ }
- setIsVisible(this.getElement().querySelector('.throbber'), false);
setIsVisible(
- this.getElement().querySelector('.destination-settings-box'), true);
+ this.getChildElement('.throbber-container'),
+ this.destinationStore_.isAutoSelectDestinationInProgress);
+ setIsVisible(destinationSettingsBoxEl, !!destination);
+ },
+
+ onSelectedDestinationNameSet_: function() {
+ var destinationName =
+ this.destinationStore_.selectedDestination.displayName;
+ var nameEl = this.getElement().getElementsByClassName(
+ DestinationSettings.Classes_.THOBBER_NAME)[0];
+ nameEl.textContent = destinationName;
+ nameEl.title = destinationName;
}
};