Change video transcripts to use locators instead of locations.

Part of STUD-870
This commit is contained in:
cahrens
2013-11-26 15:02:25 -05:00
parent f94565d699
commit 5fdfc60957
16 changed files with 130 additions and 138 deletions

View File

@@ -48,7 +48,7 @@ function ($, _, Utils, FileUploader) {
el: $container,
messenger: messenger,
videoListObject: videoListObject,
component_id: 'component_id'
component_locator: 'component_locator'
});
});

View File

@@ -52,7 +52,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
view = new MessageManager({
el: $container,
parent: videoList,
component_id: 'component_id'
component_locator: 'component_locator'
});
});
@@ -60,7 +60,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
expect(fileUploader.initialize).toHaveBeenCalledWith({
el: view.$el,
messenger: view,
component_id: view.component_id,
component_locator: view.component_locator,
videoListObject: view.options.parent
});
});
@@ -215,7 +215,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
function() {
expect(Utils.command).toHaveBeenCalledWith(
action,
view.component_id,
view.component_locator,
videoList,
void(0)
);
@@ -245,7 +245,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
function () {
expect(Utils.command).toHaveBeenCalledWith(
action,
view.component_id,
view.component_locator,
videoList,
{
html5_id: extraParamas
@@ -268,7 +268,7 @@ function ($, _, Utils, MessageManager, FileUploader, sinon) {
function () {
expect(Utils.command).toHaveBeenCalledWith(
action,
view.component_id,
view.component_locator,
videoList,
void(0)
);

View File

@@ -11,7 +11,7 @@ function ($, _, Utils, VideoList, MetadataView, MetadataModel, AbstractEditor, s
'transcripts/metadata-videolist-entry.underscore'
),
abstractEditor = AbstractEditor.prototype,
component_id = 'component_id',
component_locator = 'component_locator',
videoList = [
{
mode: "youtube",
@@ -62,7 +62,7 @@ function ($, _, Utils, VideoList, MetadataView, MetadataModel, AbstractEditor, s
var tpl = sandbox({
'class': 'component',
'data-id': component_id
'data-locator': component_locator
}),
model = new MetadataModel(modelStub),
videoList, $el;
@@ -157,7 +157,7 @@ function ($, _, Utils, VideoList, MetadataView, MetadataModel, AbstractEditor, s
waitsForResponse(function () {
expect(abstractEditor.initialize).toHaveBeenCalled();
expect(messenger.initialize).toHaveBeenCalled();
expect(view.component_id).toBe(component_id);
expect(view.component_locator).toBe(component_locator);
expect(view.$el).toHandle('input');
});
});
@@ -167,7 +167,7 @@ function ($, _, Utils, VideoList, MetadataView, MetadataModel, AbstractEditor, s
expect(abstractEditor.render).toHaveBeenCalled();
expect(Utils.command).toHaveBeenCalledWith(
'check',
component_id,
component_locator,
videoList
);

View File

@@ -72,7 +72,7 @@ function($, Backbone, _, Utils, MetadataView, MetadataCollection) {
syncBasicTab: function (metadataCollection, metadataView) {
var result = [],
getField = Utils.getField,
component_id = this.$el.closest('.component').data('id'),
component_locator = this.$el.closest('.component').data('locator'),
subs = getField(metadataCollection, 'sub'),
values = {},
videoUrl, metadata, modifiedValues;
@@ -99,7 +99,7 @@ function($, Backbone, _, Utils, MetadataView, MetadataCollection) {
if (isSubsModified) {
metadata = $.extend(true, {}, modifiedValues);
// Save module state
Utils.command('save', component_id, null, {
Utils.command('save', component_locator, null, {
metadata: metadata,
current_subs: _.pluck(
Utils.getVideoList(videoUrl.getDisplayValue()),
@@ -110,18 +110,16 @@ function($, Backbone, _, Utils, MetadataView, MetadataCollection) {
// Get values from `Advanced` tab fields (`html5_sources`,
// `youtube_id_1_0`) that should be synchronized.
html5Sources = getField(metadataCollection, 'html5_sources')
.getDisplayValue();
var html5Sources = getField(metadataCollection, 'html5_sources').getDisplayValue();
values.youtube = getField(metadataCollection, 'youtube_id_1_0')
.getDisplayValue();
values.youtube = getField(metadataCollection, 'youtube_id_1_0').getDisplayValue();
values.html5Sources = _.filter(html5Sources, function (value) {
var link = Utils.parseLink(value),
values.html5Sources = _.filter(html5Sources, function (value) {
var link = Utils.parseLink(value),
mode = link && link.mode;
return mode === 'html5' && mode;
});
return mode === 'html5' && mode;
});
// The length of youtube video_id should be 11 characters.

View File

@@ -39,7 +39,7 @@ function($, Backbone, _, Utils) {
tplContainer.html(this.template({
ext: this.validFileExtensions,
component_id: this.options.component_id,
component_locator: this.options.component_locator,
video_list: videoList
}));

View File

@@ -31,12 +31,12 @@ function($, Backbone, _, Utils, FileUploader, gettext) {
initialize: function () {
_.bindAll(this);
this.component_id = this.$el.closest('.component').data('id');
this.component_locator = this.$el.closest('.component').data('locator');
this.fileUploader = new FileUploader({
el: this.$el,
messenger: this,
component_id: this.component_id,
component_locator: this.component_locator,
videoListObject: this.options.parent
});
},
@@ -76,7 +76,7 @@ function($, Backbone, _, Utils, FileUploader, gettext) {
this.$el.find('.transcripts-status')
.removeClass('is-invisible')
.find(this.elClass).html(template({
component_id: encodeURIComponent(this.component_id),
component_locator: encodeURIComponent(this.component_locator),
html5_list: html5List,
grouped_list: groupedList,
subs_id: (params) ? params.subs: ''
@@ -204,7 +204,7 @@ function($, Backbone, _, Utils, FileUploader, gettext) {
*/
processCommand: function (action, errorMessage, videoId) {
var self = this,
component_id = this.component_id,
component_locator = this.component_locator,
videoList = this.options.parent.getVideoObjectsList(),
extraParam, xhr;
@@ -212,7 +212,7 @@ function($, Backbone, _, Utils, FileUploader, gettext) {
extraParam = { html5_id: videoId };
}
xhr = Utils.command(action, component_id, videoList, extraParam)
xhr = Utils.command(action, component_locator, videoList, extraParam)
.done(function (resp) {
var sub = resp.subs;

View File

@@ -46,7 +46,7 @@ function($, Backbone, _, AbstractEditor, Utils, MessageManager, MetadataView) {
_.debounce(_.bind(this.inputHandler, this), this.inputDelay)
);
this.component_id = this.$el.closest('.component').data('id');
this.component_locator = this.$el.closest('.component').data('locator');
},
render: function () {
@@ -55,7 +55,7 @@ function($, Backbone, _, AbstractEditor, Utils, MessageManager, MetadataView) {
.apply(this, arguments);
var self = this,
component_id = this.$el.closest('.component').data('id'),
component_locator = this.$el.closest('.component').data('locator'),
videoList = this.getVideoObjectsList(),
showServerError = function (response) {
@@ -82,7 +82,7 @@ function($, Backbone, _, AbstractEditor, Utils, MessageManager, MetadataView) {
}
// Check current state of Timed Transcripts.
Utils.command('check', component_id, videoList)
Utils.command('check', component_locator, videoList)
.done(function (resp) {
var params = resp,
len = videoList.length,

View File

@@ -295,7 +295,7 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
*
* @param {string} action Action that will be invoked on server. Is a part
* of url.
* @param {string} component_id Id of component.
* @param {string} component_locator the locator of component.
* @param {array} videoList List of object with information about inserted
* urls.
* @param {object} extraParams Extra parameters that can be send to the
@@ -314,7 +314,7 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
// _command() function.
var xhr = null;
return function (action, component_id, videoList, extraParams) {
return function (action, component_locator, videoList, extraParams) {
var params, data;
if (extraParams) {
@@ -326,7 +326,7 @@ define(["jquery", "underscore", "jquery.ajaxQueue"], function($, _) {
}
data = $.extend(
{ id: component_id },
{ locator: component_locator },
{ videos: videoList },
params
);