this.toggleButton = this.$refs.toggle;
this.editorWrapEl = this.container.closest('.page-editor');
+ // State
+ this.open = false;
+ this.tab = '';
+
this.setupListeners();
// Set the first tab as active on load
const isOpen = this.container.classList.contains('open');
this.toggleButton.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
this.editorWrapEl.classList.toggle('toolbox-open', isOpen);
+ this.open = isOpen;
+ this.emitState();
}
setActiveTab(tabName, openToolbox = false) {
if (openToolbox && !this.container.classList.contains('open')) {
this.toggle();
}
+
+ this.tab = tabName;
+ this.emitState();
+ }
+
+ emitState() {
+ this.$emit('change', {tab: this.tab, open: this.open});
}
}