@jsxc/jsxc
Version:
Real-time XMPP chat application with video calls, file transfer and encrypted communication
32 lines (23 loc) • 644 B
text/typescript
import Page from './DialogPage';
export default class Navigation {
private history: JQuery[] = [];
constructor(private rootElement: JQuery) {}
public goBack() {
if (this.history.length === 1) {
return;
}
this.history.shift().remove();
this.history[0].appendTo(this.rootElement);
}
public goTo(page: Page) {
let currentPage = this.history[0];
if (currentPage) {
currentPage.detach();
}
this.history.unshift(page.getDOM());
this.history[0].appendTo(this.rootElement);
}
public canGoBack(): boolean {
return this.history.length > 0;
}
}