mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 23:45:29 +02:00
feat: Refactor splitViews module and add browser-splitViews module
This commit is contained in:
parent
779a0251ba
commit
0b1af942fe
2 changed files with 14 additions and 0 deletions
|
@ -1,108 +0,0 @@
|
|||
|
||||
class SplitViewsBase {
|
||||
/**
|
||||
* @type {SplitView[]}
|
||||
*/
|
||||
data;
|
||||
|
||||
/**
|
||||
* @param {SplitViewConfig} config
|
||||
*/
|
||||
constructor(config) {
|
||||
this.config = config;
|
||||
this.data = [];
|
||||
this.currentView = -1;
|
||||
this.addEventListeners();
|
||||
this.log('SplitViewsBase initialized');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} message
|
||||
* @protected
|
||||
*/
|
||||
log(message) {
|
||||
console.log(`SplitViews: ${message}`);
|
||||
}
|
||||
|
||||
addEventListeners() {
|
||||
window.addEventListener('TabClose', this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Event} event
|
||||
*/
|
||||
handleEvent(event) {
|
||||
switch (event.type) {
|
||||
case 'TabClose':
|
||||
this.onTabClose(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Event} event
|
||||
*/
|
||||
onTabClose(event) {
|
||||
}
|
||||
|
||||
get isActivated() {
|
||||
return this.currentView !== -1;
|
||||
}
|
||||
|
||||
get activeView() {
|
||||
if (!this.isActivated) {
|
||||
throw new Error('No active view');
|
||||
}
|
||||
return this.data[this.currentView];
|
||||
}
|
||||
}
|
||||
|
||||
// Public API exposed by the module
|
||||
export class SplitViews extends SplitViewsBase {
|
||||
/**
|
||||
* @param {SplitViewConfig} config
|
||||
*/
|
||||
constructor(config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {MockedExports.Browser} browser
|
||||
*/
|
||||
onLocationChange(browser) {
|
||||
this.log('onLocationChange');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {SplitType} type
|
||||
*/
|
||||
tileCurrentView(type) {
|
||||
this.log('tileCurrentView');
|
||||
}
|
||||
|
||||
closeCurrentView() {
|
||||
this.log('closeCurrentView');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {MockedExports.BrowserTab} tab
|
||||
*/
|
||||
tabIsInActiveView(tab) {
|
||||
this.log('tabIsInActiveView');
|
||||
return false;
|
||||
}
|
||||
|
||||
getActiveViewTabs() {
|
||||
this.log('getActiveViewTabs');
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {MockedExports.BrowserTab[]} tabs
|
||||
* @param {SplitType} type
|
||||
* @private
|
||||
*/
|
||||
createSplitView(tabs, type = this.config.defaultSplitView) {
|
||||
this.log('createSplitView');
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue