diff --git a/common/lib/xmodule/xmodule/js/spec/video/video_events_plugin_spec.js b/common/lib/xmodule/xmodule/js/spec/video/video_events_plugin_spec.js index b9688c01fe..b6896d19db 100644 --- a/common/lib/xmodule/xmodule/js/spec/video/video_events_plugin_spec.js +++ b/common/lib/xmodule/xmodule/js/spec/video/video_events_plugin_spec.js @@ -130,7 +130,8 @@ state.el.trigger('language_menu:hide'); expect(Logger.log).toHaveBeenCalledWith('video_hide_cc_menu', { id: 'id', - code: 'html5' + code: 'html5', + language: 'en' }); }); diff --git a/common/lib/xmodule/xmodule/js/src/video/09_events_plugin.js b/common/lib/xmodule/xmodule/js/src/video/09_events_plugin.js index fa6efcae22..7c5b080621 100644 --- a/common/lib/xmodule/xmodule/js/src/video/09_events_plugin.js +++ b/common/lib/xmodule/xmodule/js/src/video/09_events_plugin.js @@ -105,7 +105,7 @@ define('video/09_events_plugin.js', [], function() { }, onHideLanguageMenu: function () { - this.log('video_hide_cc_menu'); + this.log('video_hide_cc_menu', { language: this.getCurrentLanguage() }); }, onShowCaptions: function () { @@ -121,6 +121,11 @@ define('video/09_events_plugin.js', [], function() { return player ? player.currentTime : 0; }, + getCurrentLanguage: function() { + var language = this.state.lang; + return language; + }, + log: function (eventName, data) { var logInfo = _.extend({ id: this.state.id, diff --git a/common/lib/xmodule/xmodule/js/src/video/09_video_caption.js b/common/lib/xmodule/xmodule/js/src/video/09_video_caption.js index 8d315ad215..cace102c01 100644 --- a/common/lib/xmodule/xmodule/js/src/video/09_video_caption.js +++ b/common/lib/xmodule/xmodule/js/src/video/09_video_caption.js @@ -325,9 +325,6 @@ var button = this.languageChooserEl, menu = button.parent().find('.menu'); - - this.state.el.trigger('language_menu:show'); - button .addClass('is-opened'); @@ -341,8 +338,6 @@ var button = this.languageChooserEl; - this.state.el.trigger('language_menu:hide'); - button .removeClass('is-opened') .find('.language-menu') @@ -381,7 +376,13 @@ onContainerMouseEnter: function (event) { event.preventDefault(); $(event.currentTarget).find('.lang').addClass('is-opened'); - this.state.el.trigger('language_menu:show'); + + // We only want to fire the analytics event if a menu is + // present instead of on the container hover, since it wraps + // the "CC" and "Transcript" buttons as well. + if ($(event.currentTarget).find('.lang').length) { + this.state.el.trigger('language_menu:show'); + } }, /** @@ -392,7 +393,13 @@ onContainerMouseLeave: function (event) { event.preventDefault(); $(event.currentTarget).find('.lang').removeClass('is-opened'); - this.state.el.trigger('language_menu:hide'); + + // We only want to fire the analytics event if a menu is + // present instead of on the container hover, since it wraps + // the "CC" and "Transcript" buttons as well. + if ($(event.currentTarget).find('.lang').length) { + this.state.el.trigger('language_menu:show'); + } }, /**