Use sdk/panel onOpen event listener

When the panel is constructed, Recommend.js's handlePanelOpen is specified as the callback function for whenever the panel opens. The telemetry logging for panel open events is done here. This way, Recommend.js does not have to keep track of the state of the panel.

Closes #66
This commit is contained in:
casebenton 2016-08-09 15:34:59 -07:00
Родитель dccf1b7628
Коммит 4fc20345be
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -19,7 +19,7 @@ class Recommender {
constructor() {
this.telemetryLog = new TelemetryLog();
const methodsToBind = ['endOnboard', 'showPanel', 'waitForWindow',
'handlePanelHide', 'hidePanel'];
'handlePanelHide', 'handlePanelShow', 'hidePanel'];
for (let key of methodsToBind) { // eslint-disable-line prefer-const
this[key] = this[key].bind(this);
}
@ -72,18 +72,22 @@ class Recommender {
height: panelRecHeight + footerHeight,
contentURL: './recommendation/recWindow.html',
contentScriptFile: './recommendation/notify.js',
onShow: this.handlePanelShow,
onHide: this.handlePanelHide,
});
}
showPanel(button) {
this.telemetryLog.showPanel(this.activeRecDomain);
button.handlePanelOpen();
this.panel.show({
position: button,
});
}
handlePanelShow() {
this.telemetryLog.showPanel(this.activeRecDomain);
}
handlePanelHide() {
this.telemetryLog.hidePanel(this.activeRecDomain);
const win = tabs.activeTab.window;