AngularJS Service for handling CMS builder preview mode.
When the game is loaded with ?preview=true inside an iframe, this service replaces the normal API data-loading flow with the following:
- Game sends CHILD_READY to the parent (tga-admin)
- Parent responds with GAME_DATA containing the full game object
- On each builder edit, parent re-sends GAME_DATA with updated data
- Source:
Requires
- module:$window
- module:$rootScope
- module:$log
- module:URLParamsService
Methods
(static) isPreview() → {boolean}
Whether the app is running in preview mode. True only when ?preview=true AND loaded inside an iframe.
- Source:
Returns:
- Type:
-
boolean
(static) sendReady()
Post CHILD_READY to the parent window so the CMS knows the iframe is ready to receive game data.
- Source:
(static) listen(initialCallback, fallbackCallbackopt)
Listen for GAME_DATA messages from the parent window. The first message triggers the initial load callback. Subsequent messages broadcast 'preview:update' on $rootScope.
If no GAME_DATA arrives within READY_TIMEOUT_MS, the fallback callback is invoked so the game can fall back to normal API loading.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
initialCallback |
function
|
called once with the first GAME_DATA message |
|
fallbackCallback |
function
|
<optional> |
called if no response within timeout |
(static) sendState(state)
Post state back to the parent CMS so it can update its UI.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
state |
Object
|
arbitrary state object (e.g. { tossupPlaying: true }) |