addSettingsItemHandler: typeof SettingsButton.prototype.onAddSettingsItem
disposeSettingsItemHandler: typeof SettingsButton.prototype.onDisposeSettingsItem
- playerClickHandler: typeof SettingsButton.prototype.onPlayerClick
+ documentClickHandler: typeof SettingsButton.prototype.onDocumentClick
userInactiveHandler: typeof SettingsButton.prototype.onUserInactive
private settingsButtonOptions: SettingsButtonOptions
// Event handlers
this.addSettingsItemHandler = this.onAddSettingsItem.bind(this)
this.disposeSettingsItemHandler = this.onDisposeSettingsItem.bind(this)
- this.playerClickHandler = this.onPlayerClick.bind(this)
+ this.documentClickHandler = this.onDocumentClick.bind(this)
this.userInactiveHandler = this.onUserInactive.bind(this)
this.buildMenu()
this.player().one('play', () => this.hideDialog())
}
- onPlayerClick (event: MouseEvent) {
+ onDocumentClick (event: MouseEvent) {
const element = event.target as HTMLElement
- if (element.classList.contains('vjs-settings') || element.parentElement.classList.contains('vjs-settings')) {
+
+ if (
+ element && element.classList &&
+ (element.classList.contains('vjs-settings') || element.parentElement.classList.contains('vjs-settings'))
+ ) {
return
}
}
}
+ document.removeEventListener('click', this.documentClickHandler)
+ if (this.isInIframe()) {
+ window.removeEventListener('blur', this.documentClickHandler)
+ }
+
this.hideDialog()
if (this.settingsButtonOptions.entries.length === 0) {
}
bindEvents () {
- this.player().on('click', this.playerClickHandler)
+ document.addEventListener('click', this.documentClickHandler)
+ if (this.isInIframe()) {
+ window.addEventListener('blur', this.documentClickHandler)
+ }
+
this.player().on('addsettingsitem', this.addSettingsItemHandler)
this.player().on('disposesettingsitem', this.disposeSettingsItemHandler)
this.player().on('userinactive', this.userInactiveHandler)
}
}
+ isInIframe () {
+ return window.self !== window.top
+ }
+
}
Component.registerComponent('SettingsButton', SettingsButton)