Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/lib/xmodule/xmodule/js/spec/video/general_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
});

it('set current video speed via cookie', function() {
expect(state.speed).toEqual('1.50');
expect(state.speed).toEqual(1.5);
});
});

Expand Down
8 changes: 4 additions & 4 deletions common/lib/xmodule/xmodule/js/spec/video/initialize_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function(Initialize) {

$.each(map, function(key, expected) {
Initialize.prototype.setSpeed.call(state, key);
expect(state.speed).toBe(expected);
expect(state.speed).toBe(parseFloat(expected));
});
});
});
Expand All @@ -207,7 +207,7 @@ function(Initialize) {
});

it('set new speed', function() {
expect(state.speed).toEqual('0.75');
expect(state.speed).toEqual(0.75);
});
});

Expand All @@ -217,7 +217,7 @@ function(Initialize) {
});

it('set speed to 1.0x', function() {
expect(state.speed).toEqual('1.0');
expect(state.speed).toEqual(1);
});
});

Expand All @@ -230,7 +230,7 @@ function(Initialize) {

$.each(map, function(key, expected) {
Initialize.prototype.setSpeed.call(state, key);
expect(state.speed).toBe(expected);
expect(state.speed).toBe(parseFloat(expected));
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ function(VideoPlayer) {

it('create video caption', function() {
expect(state.videoCaption).toBeDefined();
expect(state.speed).toEqual('1.50');
expect(state.speed).toEqual(1.5);
expect(state.config.transcriptTranslationUrl)
.toEqual('/transcript/translation/__lang__');
});

it('create video speed control', function() {
expect(state.videoSpeedControl).toBeDefined();
expect(state.videoSpeedControl.el).toHaveClass('speeds');
expect(state.speed).toEqual('1.50');
expect(state.speed).toEqual(1.5);
});

it('create video progress slider', function() {
Expand Down
1 change: 1 addition & 0 deletions common/lib/xmodule/xmodule/js/src/video/01_initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ function(VideoPlayer, i18n, moment, _) {
newSpeed = map[newSpeed];
this.speed = _.contains(this.speeds, newSpeed) ? newSpeed : '1.0';
}
this.speed = parseFloat(this.speed);
}

function getVideoMetadata(url, callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,22 @@
* not differs from current speed.
*/
setSpeed: function(speed, silent, forceUpdate) {
if (speed !== this.currentSpeed || forceUpdate) {
var newSpeed = this.state.speedToString(speed);
if (newSpeed !== this.currentSpeed || forceUpdate) {
this.speedsContainer
.find('li')
.siblings("li[data-speed='" + speed + "']");
.siblings("li[data-speed='" + newSpeed + "']");

this.speedButton.find('.value').text(speed + 'x');
this.currentSpeed = speed;
this.speedButton.find('.value').text(newSpeed + 'x');
this.currentSpeed = newSpeed;

if (!silent) {
this.el.trigger('speedchange', [speed, this.state.speed]);
this.el.trigger('speedchange', [newSpeed, this.state.speed]);
}
}

this.resetActiveSpeed();
this.setActiveSpeed(speed);
this.setActiveSpeed(newSpeed);
},

resetActiveSpeed: function() {
Expand All @@ -254,13 +255,13 @@
},

setActiveSpeed: function(speed) {
var speedOption = this.speedsContainer.find('li[data-speed="' + speed + '"]');
var speedOption = this.speedsContainer.find('li[data-speed="' + this.state.speedToString(speed) + '"]');

speedOption.addClass('is-active')
.find('.speed-option')
.attr('aria-pressed', 'true');

this.speedButton.attr('title', gettext('Video speed: ') + speed + 'x');
this.speedButton.attr('title', gettext('Video speed: ') + this.state.speedToString(speed) + 'x');
},

/**
Expand Down
32 changes: 20 additions & 12 deletions common/lib/xmodule/xmodule/js/src/video/095_video_context_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ function(Component) {
},

appendContent: function(content) {
this.getElement().append(content);
var $content = $(content);
this.getElement().append($content);
return this;
},

Expand Down Expand Up @@ -246,8 +247,8 @@ function(Component) {
},

open: function() {
var menu = (this.isRendered) ? this.getElement() : this.populateElement();
this.container.append(menu);
var $menu = (this.isRendered) ? this.getElement() : this.populateElement();
this.container.append($menu);
AbstractItem.prototype.open.call(this);
this.overlay.show(this.container);
return this;
Expand Down Expand Up @@ -354,7 +355,8 @@ function(Component) {
},

show: function(container) {
$(container).append(this.getElement());
var $elem = $(this.getElement());
$(container).append($elem);
this.delegateEvents();
return this;
},
Expand Down Expand Up @@ -389,7 +391,10 @@ function(Component) {
},

createElement: function() {
var element = $('<li />', {
var $spanElem,
$listElem,
$element = $('<li />', {
// var element = $('<li />', {
'class': ['submenu-item', 'menu-item', this.options.prefix + 'submenu-item'].join(' '),
'aria-expanded': 'false',
'aria-haspopup': 'true',
Expand All @@ -398,21 +403,24 @@ function(Component) {
'tabindex': -1
});

this.label = $('<span />', {
$spanElem = $('<span />', {
'id': 'submenu-item-label-' + this.id,
'text': this.options.label
}).appendTo(element);
});
this.label = $spanElem.appendTo($element);

this.list = $('<ol />', {
$listElem = $('<ol />', {
'class': ['submenu', this.options.prefix + 'submenu'].join(' '),
'role': 'menu'
}).appendTo(element);
});
this.list = $listElem.appendTo($element);

return element;
return $element;
},

appendContent: function(content) {
this.list.append(content);
var $content = $(content);
this.list.append($content);
return this;
},

Expand Down Expand Up @@ -627,7 +635,7 @@ function(Component) {
}, {
label: i18n.Speed,
items: _.map(state.speeds, function(speed) {
var isSelected = speed === state.speed;
var isSelected = parseFloat(speed) === state.speed;
return {label: speed + 'x', callback: speedCallback, speed: speed, isSelected: isSelected};
}),
initialize: function(menuitem) {
Expand Down
4 changes: 2 additions & 2 deletions common/lib/xmodule/xmodule/js/src/video/09_events_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
onSpeedChange: function(event, newSpeed, oldSpeed) {
this.log('speed_change_video', {
current_time: this.getCurrentTime(),
old_speed: oldSpeed,
new_speed: newSpeed
old_speed: this.state.speedToString(oldSpeed),
new_speed: this.state.speedToString(newSpeed)
});
},

Expand Down