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

50 lines
1.2 KiB
TypeScript
Raw Normal View History

import type { GoToPageEvent } from '../Events/GoToPageEvent';
import type { OpenTabEvent } from '../Events/OpenTabEvent';
import { IframeApiContribution, sendToWorkadventure } from './IframeApiContribution';
import {LoadPageEvent} from "../Events/LoadPageEvent";
2021-06-17 11:30:16 +02:00
import type { LoadPageEvent } from '../Events/LoadPageEvent';
class WorkadventureNavigationCommands extends IframeApiContribution<WorkadventureNavigationCommands> {
readonly subObjectIdentifier = "nav"
readonly addMethodsAtRoot = true
callbacks = []
openTab(url: string): void {
sendToWorkadventure({
"type": 'openTab',
"data": {
url
} as OpenTabEvent
});
}
goToPage(url: string): void {
sendToWorkadventure({
"type": 'goToPage',
"data": {
url
} as GoToPageEvent
});
}
goToRoom(url: string): void {
window.parent.postMessage({
"type" : 'loadPage',
"data" : {
url
} as LoadPageEvent
2021-06-17 11:30:16 +02:00
<<<<<<< Updated upstream
},'*');
2021-06-17 11:30:16 +02:00
=======
},'*');
>>>>>>> Stashed changes
}
}
export default new WorkadventureNavigationCommands();