From a1e0f7116a63859d702f372d7a28c6dbbf851303 Mon Sep 17 00:00:00 2001 From: Valera Rozuvan Date: Mon, 30 Sep 2013 17:53:32 +0300 Subject: [PATCH] Added hard-coded flag to video.html that turns on/off autohiding of captions. Front-end functionality was not removed. When flag is set to "True", old behaviour of autohiding of controls and captions will be enabled. --- .../xmodule/xmodule/js/src/video/01_initialize.js | 7 +++++++ .../xmodule/js/src/video/04_video_control.js | 4 ++-- .../xmodule/js/src/video/09_video_caption.js | 6 +++--- lms/templates/video.html | 13 +++++++++++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/video/01_initialize.js b/common/lib/xmodule/xmodule/js/src/video/01_initialize.js index d9f0addabf..2a25240678 100644 --- a/common/lib/xmodule/xmodule/js/src/video/01_initialize.js +++ b/common/lib/xmodule/xmodule/js/src/video/01_initialize.js @@ -295,6 +295,11 @@ function (VideoPlayer) { ), youtubeStreams: this.el.data('streams'), + autohideHtml5: ( + this.el.data('autohide-html5') + .toString().toLowerCase() === 'true' + ), + sub: this.el.data('sub'), mp4Source: this.el.data('mp4-source'), webmSource: this.el.data('webm-source'), @@ -307,6 +312,8 @@ function (VideoPlayer) { availableQualities: ['hd720', 'hd1080', 'highres'] }; + console.log('this.config.autohideHtml5 = ' + this.config.autohideHtml5); + // Check if the YT test timeout has been set. If not, or it is in // improper format, then set to default value. tempYtTestTimeout = parseInt(this.el.data('yt-test-timeout'), 10); diff --git a/common/lib/xmodule/xmodule/js/src/video/04_video_control.js b/common/lib/xmodule/xmodule/js/src/video/04_video_control.js index 796ba07060..8ba7490cef 100644 --- a/common/lib/xmodule/xmodule/js/src/video/04_video_control.js +++ b/common/lib/xmodule/xmodule/js/src/video/04_video_control.js @@ -57,7 +57,7 @@ function () { state.videoControl.play(); } - if (state.videoType === 'html5') { + if ((state.videoType === 'html5') && (state.config.autohideHtml5)) { state.videoControl.fadeOutTimeout = state.config.fadeOutTimeout; state.videoControl.el.addClass('html5'); @@ -81,7 +81,7 @@ function () { state.videoControl.fullScreenEl.on('click', state.videoControl.toggleFullScreen); $(document).on('keyup', state.videoControl.exitFullScreen); - if (state.videoType === 'html5') { + if ((state.videoType === 'html5') && (state.config.autohideHtml5)) { state.el.on('mousemove', state.videoControl.showControls); state.el.on('keydown', state.videoControl.showControls); } 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 13f2fe0db0..54dee1fc7f 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 @@ -152,7 +152,7 @@ function () { this.videoCaption.onMovement ); - if (this.videoType === 'html5') { + if ((this.videoType === 'html5') && (this.config.autohideHtml5)) { this.el.on('mousemove', this.videoCaption.autoShowCaptions); this.el.on('keydown', this.videoCaption.autoShowCaptions); @@ -335,7 +335,7 @@ function () { this.videoCaption.setSubtitlesHeight(); - if (this.videoType === 'html5') { + if ((this.videoType === 'html5') && (this.config.autohideHtml5)) { this.videoCaption.fadeOutTimeout = this.config.fadeOutTimeout; this.videoCaption.subtitlesEl.addClass('html5'); @@ -698,7 +698,7 @@ function () { function setSubtitlesHeight() { var height = 0; - if (this.videoType === 'html5'){ + if ((this.videoType === 'html5') && (this.config.autohideHtml5)) { // on page load captionHidden = undefined if ( ( diff --git a/lms/templates/video.html b/lms/templates/video.html index caf0aaa06f..d0e61a5f74 100644 --- a/lms/templates/video.html +++ b/lms/templates/video.html @@ -26,6 +26,19 @@ data-yt-test-timeout="${yt_test_timeout}" data-yt-test-url="${yt_test_url}" + ## For now, the option "data-autohide-html5" is hard coded. This option + ## either enables or disables autohiding of controls and captions on mouse + ## inactivity. If set to true, controls and captions will autohide for + ## HTML5 sources (non-YouTube) after a period of mouse inactivity over the + ## whole video. When the mouse moves (or a key is pressed while any part of + ## the video player is focused), the captions and controls will be shown + ## once again. + ## + ## There is no option in the "Advanced Editor" to set this option. However, + ## this option will have an effect if changed to "True". The code on + ## front-end exists. + data-autohide-html5="False" + tabindex="-1" >