Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FEC-13725): [Related Plugin]: Add Events (used by kava analytics) #63

Merged
merged 5 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/components/related-overlay/related-overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ interface RelatedOverlayProps {
/**
* Overlay which wraps the related grid and controls its layout and visibility.
*

* @param {object} props Component props.
* @param {RelatedManager} props.relatedManager Related manager instance.
* @param {boolean} props.isPaused Indicates whether playback is paused.
Expand Down
7 changes: 5 additions & 2 deletions src/event/related-event.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
export namespace RelatedEvent {
const RELATED_CLICKED: string;
const RELATED_SELECTED: string;
const RELATED_OPEN: string;
const RELATED_CLOSE: string;
const RELATED_ENTRY_SELECTED: string;
const RELATED_ENTRY_AUTO_PLAYED: string;
const RELATED_GRID_DISPLAYED: string;
}
18 changes: 15 additions & 3 deletions src/event/related-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@
* Related plugin event types.
*/
const RelatedEvent = {
/**
* Fired when the user clicks the button to show the related list.
*/
RELATED_OPEN: 'related_open',
/**
* Fired when the user clicks the button to close the related list.
*/
RELATED_CLOSE: 'related_close',
/**
* Fired when the user selects an entry from the list or the grid.
*/
RELATED_SELECTED: 'related_selected',
RELATED_ENTRY_SELECTED: 'related_entry_selected',
/**
* Fired when the user clicks the button to show the related list.
* Fired when the user selects an entry from the list or the grid.
*/
RELATED_ENTRY_AUTO_PLAYED: 'related_entry_auto_played',
/**
* Fired when the related grid is shown or hidden.
*/
RELATED_CLICKED: 'related_clicked'
RELATED_GRID_DISPLAYED: 'related_grid_displayed'
};

export {RelatedEvent};
10 changes: 7 additions & 3 deletions src/related-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class RelatedManager extends KalturaPlayer.core.FakeEventTarget {
this.clearNextEntryTimeout();
this.nextEntryTimeoutId = window.setTimeout(() => {
this.playByIndex(0);
this.player.dispatchEvent(new KalturaPlayer.core.FakeEvent(RelatedEvent.RELATED_ENTRY_AUTO_PLAYED));
}, seconds * 1000);
} else {
this.playByIndex(0);
Expand All @@ -258,7 +259,7 @@ class RelatedManager extends KalturaPlayer.core.FakeEventTarget {
playSelected(internalIndex: number) {
this.logger.info('going to play selected entry');
this.playByIndex(internalIndex);
this.player.dispatchEvent(new KalturaPlayer.core.FakeEvent(RelatedEvent.RELATED_SELECTED));
this.player.dispatchEvent(new KalturaPlayer.core.FakeEvent(RelatedEvent.RELATED_ENTRY_SELECTED));
}

/**
Expand Down Expand Up @@ -397,6 +398,7 @@ class RelatedManager extends KalturaPlayer.core.FakeEventTarget {
set isGridVisible(isGridVisible: boolean) {
this._isGridVisible = isGridVisible;
this.dispatchEvent(new KalturaPlayer.core.FakeEvent(RelatedInternalEvent.GRID_VISIBILITY_CHANGED, this._isGridVisible));
if (isGridVisible) this.player.dispatchEvent(new KalturaPlayer.core.FakeEvent(RelatedEvent.RELATED_GRID_DISPLAYED));
}

/**
Expand All @@ -417,8 +419,10 @@ class RelatedManager extends KalturaPlayer.core.FakeEventTarget {
set isListVisible(isListVisible: boolean) {
this._isListVisible = isListVisible;
this.dispatchEvent(new KalturaPlayer.core.FakeEvent(RelatedInternalEvent.LIST_VISIBILITY_CHANGED, this._isListVisible));
if (this._isListVisible) {
this.player.dispatchEvent(new KalturaPlayer.core.FakeEvent(RelatedEvent.RELATED_CLICKED));
if (isListVisible) {
this.player.dispatchEvent(new KalturaPlayer.core.FakeEvent(RelatedEvent.RELATED_OPEN, {expandMode: this.config?.expandMode}));
} else {
this.player.dispatchEvent(new KalturaPlayer.core.FakeEvent(RelatedEvent.RELATED_CLOSE, {expandMode: this.config?.expandMode}));
}
}
}
Expand Down
Loading