Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
e788d6ce
Commit
e788d6ce
authored
Aug 22, 2013
by
Valera Rozuvan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Jasmine test for bug fix. Updated comments.
parent
4936b504
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
12 deletions
+76
-12
common/lib/xmodule/xmodule/js/spec/video/video_caption_spec.js
+16
-0
common/lib/xmodule/xmodule/js/src/video/01_initialize.js
+7
-3
common/lib/xmodule/xmodule/js/src/video/09_video_caption.js
+53
-9
No files found.
common/lib/xmodule/xmodule/js/spec/video/video_caption_spec.js
View file @
e788d6ce
...
@@ -126,6 +126,22 @@
...
@@ -126,6 +126,22 @@
expect
(
videoCaption
.
rendered
).
toBeFalsy
();
expect
(
videoCaption
.
rendered
).
toBeFalsy
();
});
});
});
});
describe
(
'when no captions file was specified'
,
function
()
{
beforeEach
(
function
()
{
loadFixtures
(
'video_all.html'
);
// Unspecify the captions file.
$
(
'#example'
).
find
(
'#video_id'
).
data
(
'sub'
,
''
);
state
=
new
Video
(
'#example'
);
videoCaption
=
state
.
videoCaption
;
});
it
(
'captions panel is not shown'
,
function
()
{
expect
(
videoCaption
.
hideSubtitlesEl
.
css
(
'display'
)).
toBe
(
'none'
);
});
});
});
});
describe
(
'mouse movement'
,
function
()
{
describe
(
'mouse movement'
,
function
()
{
...
...
common/lib/xmodule/xmodule/js/src/video/01_initialize.js
View file @
e788d6ce
...
@@ -25,7 +25,9 @@ function (VideoPlayer) {
...
@@ -25,7 +25,9 @@ function (VideoPlayer) {
*
*
* Initialize module exports this function.
* Initialize module exports this function.
*
*
* @param {Object} state A place for all properties, and methods of Video.
* @param {object} state The object containg the state of the video player.
* All other modules, their parameters, public variables, etc. are
* available via this object.
* @param {DOM element} element Container of the entire Video DOM element.
* @param {DOM element} element Container of the entire Video DOM element.
*/
*/
return
function
(
state
,
element
)
{
return
function
(
state
,
element
)
{
...
@@ -40,10 +42,12 @@ function (VideoPlayer) {
...
@@ -40,10 +42,12 @@ function (VideoPlayer) {
/**
/**
* @function _makeFunctionsPublic
* @function _makeFunctionsPublic
*
*
* Functions which will be accessible via 'state' object. When called, these functions will get the 'state'
* Functions which will be accessible via 'state' object. When called,
* these functions will get the 'state'
* object as a context.
* object as a context.
*
*
* @param {Object} state A place for all properties, and methods of Video.
* @param {object} state The object containg the state (properties,
* methods, modules) of the Video player.
*/
*/
function
_makeFunctionsPublic
(
state
)
{
function
_makeFunctionsPublic
(
state
)
{
state
.
setSpeed
=
_
.
bind
(
setSpeed
,
state
);
state
.
setSpeed
=
_
.
bind
(
setSpeed
,
state
);
...
...
common/lib/xmodule/xmodule/js/src/video/09_video_caption.js
View file @
e788d6ce
...
@@ -6,7 +6,20 @@ define(
...
@@ -6,7 +6,20 @@ define(
[],
[],
function
()
{
function
()
{
// VideoCaption() function - what this module "exports".
/**
* @desc VideoCaption module exports a function.
*
* @type {function}
* @access public
*
* @param {object} state - The object containg the state of the video
* player. All other modules, their parameters, public variables, etc.
* are available via this object.
*
* @this {object} The global window object.
*
* @returns {undefined}
*/
return
function
(
state
)
{
return
function
(
state
)
{
state
.
videoCaption
=
{};
state
.
videoCaption
=
{};
...
@@ -64,11 +77,25 @@ function () {
...
@@ -64,11 +77,25 @@ function () {
// The magic private function that makes them available and sets up their context is makeFunctionsPublic().
// The magic private function that makes them available and sets up their context is makeFunctionsPublic().
// ***************************************************************
// ***************************************************************
// function renderElements()
/**
//
* @desc Create any necessary DOM elements, attach them, and set their
// Create any necessary DOM elements, attach them, and set their initial configuration. Also
* initial configuration. Also make the created DOM elements available
// make the created DOM elements available via the 'state' object. Much easier to work this
* via the 'state' object. Much easier to work this way - you don't
// way - you don't have to do repeated jQuery element selects.
* have to do repeated jQuery element selects.
*
* @type {function}
* @access public
*
* @this {object} - The object containg the state of the video
* player. All other modules, their parameters, public variables, etc.
* are available via this object.
*
* @returns {boolean}
* true: The function fethched captions successfully, and compltely
* rendered everything related to captions.
* false: The captions were not fetched. Nothing will be rendered,
* and the CC button will be hidden.
*/
function
renderElements
()
{
function
renderElements
()
{
this
.
videoCaption
.
loaded
=
false
;
this
.
videoCaption
.
loaded
=
false
;
...
@@ -79,12 +106,10 @@ function () {
...
@@ -79,12 +106,10 @@ function () {
this
.
el
.
find
(
'.video-controls .secondary-controls'
).
append
(
this
.
videoCaption
.
hideSubtitlesEl
);
this
.
el
.
find
(
'.video-controls .secondary-controls'
).
append
(
this
.
videoCaption
.
hideSubtitlesEl
);
// Fetch the captions file. If no file was specified, then we hide
// Fetch the captions file. If no file was specified, then we hide
// the "CC" button, and exit from this module. No further caption
// the "CC" button, and return.
// initialization will happen.
if
(
!
this
.
videoCaption
.
fetchCaption
())
{
if
(
!
this
.
videoCaption
.
fetchCaption
())
{
this
.
videoCaption
.
hideSubtitlesEl
.
hide
();
this
.
videoCaption
.
hideSubtitlesEl
.
hide
();
// Abandon all further operations with captions panel.
return
false
;
return
false
;
}
}
...
@@ -136,6 +161,25 @@ function () {
...
@@ -136,6 +161,25 @@ function () {
}
}
}
}
/**
* @desc Fetch the caption file specified by the user. Upn successful
* receival of the file, the captions will be rendered.
*
* @type {function}
* @access public
*
* @this {object} - The object containg the state of the video
* player. All other modules, their parameters, public variables, etc.
* are available via this object.
*
* @returns {boolean}
* true: The user specified a caption file. NOTE: if an error happens
* while the specified file is being retrieved (for example the
* file is missing on the server), this function will still return
* true.
* false: No caption file was specified, or an empty string was
* specified.
*/
function
fetchCaption
()
{
function
fetchCaption
()
{
var
_this
=
this
;
var
_this
=
this
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment