workadventure/front/src/Api/iframe/nav.ts

60 lines
1.4 KiB
TypeScript
Raw Normal View History

import type { GoToPageEvent } from '../Events/GoToPageEvent';
import type { OpenTabEvent } from '../Events/OpenTabEvent';
import { IframeApiContribution, sendToWorkadventure } from './IframeApiContribution';
import type {OpenCoWebSiteEvent} from "../Events/OpenCoWebSiteEvent";
2021-06-22 16:07:31 +02:00
import type {LoadPageEvent} from "../Events/LoadPageEvent";
class WorkadventureNavigationCommands extends IframeApiContribution<WorkadventureNavigationCommands> {
callbacks = []
openTab(url: string): void {
sendToWorkadventure({
"type": 'openTab',
"data": {
url
2021-06-23 14:54:06 +02:00
}
});
}
goToPage(url: string): void {
sendToWorkadventure({
"type": 'goToPage',
"data": {
url
2021-06-23 14:54:06 +02:00
}
});
}
goToRoom(url: string): void {
2021-06-17 11:32:59 +02:00
sendToWorkadventure({
"type": 'loadPage',
"data": {
url
2021-06-23 14:54:06 +02:00
}
2021-06-17 11:32:59 +02:00
});
}
openCoWebSite(url: string, allowApi: boolean = false, allowPolicy: string = ""): void {
sendToWorkadventure({
"type": 'openCoWebSite',
"data": {
url,
allowApi,
allowPolicy,
2021-06-23 14:54:06 +02:00
}
});
}
closeCoWebSite(): void {
sendToWorkadventure({
"type": 'closeCoWebSite',
data: null
});
}
}
export default new WorkadventureNavigationCommands();