Commit 9f95c358 by clrux

Merge pull request #12198 from edx/clrux/ac-383

AC-383 language menu events only when menu opens
parents 66e2d062 665b3dcf
...@@ -130,7 +130,8 @@ ...@@ -130,7 +130,8 @@
state.el.trigger('language_menu:hide'); state.el.trigger('language_menu:hide');
expect(Logger.log).toHaveBeenCalledWith('video_hide_cc_menu', { expect(Logger.log).toHaveBeenCalledWith('video_hide_cc_menu', {
id: 'id', id: 'id',
code: 'html5' code: 'html5',
language: 'en'
}); });
}); });
......
...@@ -105,7 +105,7 @@ define('video/09_events_plugin.js', [], function() { ...@@ -105,7 +105,7 @@ define('video/09_events_plugin.js', [], function() {
}, },
onHideLanguageMenu: function () { onHideLanguageMenu: function () {
this.log('video_hide_cc_menu'); this.log('video_hide_cc_menu', { language: this.getCurrentLanguage() });
}, },
onShowCaptions: function () { onShowCaptions: function () {
...@@ -121,6 +121,11 @@ define('video/09_events_plugin.js', [], function() { ...@@ -121,6 +121,11 @@ define('video/09_events_plugin.js', [], function() {
return player ? player.currentTime : 0; return player ? player.currentTime : 0;
}, },
getCurrentLanguage: function() {
var language = this.state.lang;
return language;
},
log: function (eventName, data) { log: function (eventName, data) {
var logInfo = _.extend({ var logInfo = _.extend({
id: this.state.id, id: this.state.id,
......
...@@ -325,9 +325,6 @@ ...@@ -325,9 +325,6 @@
var button = this.languageChooserEl, var button = this.languageChooserEl,
menu = button.parent().find('.menu'); menu = button.parent().find('.menu');
this.state.el.trigger('language_menu:show');
button button
.addClass('is-opened'); .addClass('is-opened');
...@@ -341,8 +338,6 @@ ...@@ -341,8 +338,6 @@
var button = this.languageChooserEl; var button = this.languageChooserEl;
this.state.el.trigger('language_menu:hide');
button button
.removeClass('is-opened') .removeClass('is-opened')
.find('.language-menu') .find('.language-menu')
...@@ -381,7 +376,13 @@ ...@@ -381,7 +376,13 @@
onContainerMouseEnter: function (event) { onContainerMouseEnter: function (event) {
event.preventDefault(); event.preventDefault();
$(event.currentTarget).find('.lang').addClass('is-opened'); $(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 @@ ...@@ -392,7 +393,13 @@
onContainerMouseLeave: function (event) { onContainerMouseLeave: function (event) {
event.preventDefault(); event.preventDefault();
$(event.currentTarget).find('.lang').removeClass('is-opened'); $(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');
}
}, },
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment