1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-23 21:34:13 +03:00

Merge pull request #261 from kwonoj/feat-tab-cycle

feat(tab): enable cycle tab selection
This commit is contained in:
Eugene Pankov 2017-12-14 19:48:48 +01:00 committed by GitHub
commit ace81aced2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View File

@ -3,6 +3,7 @@ appearance:
dockScreen: current dockScreen: current
dockFill: 50 dockFill: 50
tabsLocation: top tabsLocation: top
cycleTabs: true
theme: Standard theme: Standard
frame: thin frame: thin
css: '/* * { color: blue !important; } */' css: '/* * { color: blue !important; } */'

View File

@ -3,6 +3,7 @@ import { Injectable, ComponentFactoryResolver, Injector, Optional } from '@angul
import { DefaultTabProvider } from '../api/defaultTabProvider' import { DefaultTabProvider } from '../api/defaultTabProvider'
import { BaseTabComponent } from '../components/baseTab.component' import { BaseTabComponent } from '../components/baseTab.component'
import { Logger, LogService } from '../services/log.service' import { Logger, LogService } from '../services/log.service'
import { ConfigService } from '../services/config.service'
export declare type TabComponentType = new (...args: any[]) => BaseTabComponent export declare type TabComponentType = new (...args: any[]) => BaseTabComponent
@ -18,6 +19,7 @@ export class AppService {
constructor ( constructor (
private componentFactoryResolver: ComponentFactoryResolver, private componentFactoryResolver: ComponentFactoryResolver,
@Optional() private defaultTabProvider: DefaultTabProvider, @Optional() private defaultTabProvider: DefaultTabProvider,
private config: ConfigService,
private injector: Injector, private injector: Injector,
log: LogService, log: LogService,
) { ) {
@ -70,16 +72,24 @@ export class AppService {
} }
nextTab () { nextTab () {
let tabIndex = this.tabs.indexOf(this.activeTab) if (this.tabs.length > 1) {
if (tabIndex < this.tabs.length - 1) { let tabIndex = this.tabs.indexOf(this.activeTab)
this.selectTab(this.tabs[tabIndex + 1]) if (tabIndex < this.tabs.length - 1) {
this.selectTab(this.tabs[tabIndex + 1])
} else if (this.config.store.appearance.cycleTabs) {
this.selectTab(this.tabs[0])
}
} }
} }
previousTab () { previousTab () {
let tabIndex = this.tabs.indexOf(this.activeTab) if (this.tabs.length > 1) {
if (tabIndex > 0) { let tabIndex = this.tabs.indexOf(this.activeTab)
this.selectTab(this.tabs[tabIndex - 1]) if (tabIndex > 0) {
this.selectTab(this.tabs[tabIndex - 1])
} else if (this.config.store.appearance.cycleTabs) {
this.selectTab(this.tabs[this.tabs.length - 1])
}
} }
} }