fix #1891 (update subtitles on edit)
This commit is contained in:
parent
cd5b1ac367
commit
0873d27f92
3 changed files with 22 additions and 21 deletions
|
@ -1,5 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
// FIXME: should be Ox.AnnotationFolders
|
||||
|
||||
/*@
|
||||
Ox.AnnotationPanel <f> Video Annotation Panel
|
||||
options <o> Options object
|
||||
|
|
|
@ -157,7 +157,7 @@ Ox.BlockVideoTimeline = function(options, self) {
|
|||
out: self.options.out,
|
||||
results: self.options.results,
|
||||
state: self.options.state,
|
||||
subtitles: self.options.subtitles,
|
||||
subtitles: Ox.clone(self.options.subtitles, true),
|
||||
type: self.options.type,
|
||||
width: Math.round(self.options.duration)
|
||||
});
|
||||
|
@ -275,7 +275,7 @@ Ox.BlockVideoTimeline = function(options, self) {
|
|||
}
|
||||
|
||||
function setSubtitles() {
|
||||
self.$image.options({subtitles: self.options.subtitles});
|
||||
self.$image.options({subtitles: Ox.clone(self.options.subtitles, true)});
|
||||
updateTimelines();
|
||||
}
|
||||
|
||||
|
|
|
@ -341,7 +341,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
|||
showMarkers: true,
|
||||
showMilliseconds: 3,
|
||||
sizeIsLarge: self.options.videoSize == 'large',
|
||||
subtitles: Ox.clone(self.options.subtitles),
|
||||
subtitles: Ox.clone(self.options.subtitles, true),
|
||||
type: type,
|
||||
video: type == 'play' ? self.options.video : self.options.getFrameURL,
|
||||
volume: self.options.volume,
|
||||
|
@ -413,7 +413,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
|||
//matches: self.options.matches,
|
||||
out: self.options.out,
|
||||
position: self.options.position,
|
||||
subtitles: self.options.enableSubtitles ? self.options.subtitles : [],
|
||||
subtitles: self.options.enableSubtitles ? Ox.clone(self.options.subtitles, true) : [],
|
||||
type: self.options.timeline,
|
||||
width: self.sizes.timeline[0].width
|
||||
})
|
||||
|
@ -443,7 +443,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
|||
results: find(self.options.find),
|
||||
showPointMarkers: true,
|
||||
state: self.options.selected ? 'selected' : 'default',
|
||||
subtitles: self.options.enableSubtitles ? self.options.subtitles : [],
|
||||
subtitles: self.options.enableSubtitles ? Ox.clone(self.options.subtitles, true) : [],
|
||||
type: self.options.timeline,
|
||||
videoId: self.options.videoId,
|
||||
width: self.sizes.timeline[1].width
|
||||
|
@ -1026,19 +1026,19 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
|||
}
|
||||
|
||||
function getSelectedLayer() {
|
||||
var layer;
|
||||
var selectedLayer;
|
||||
Ox.forEach(self.options.layers, function(layer) {
|
||||
Ox.forEach(layer.items, function(item) {
|
||||
if (item.id == self.options.selected) {
|
||||
layer = layer.id;
|
||||
selectedLayer = layer.id;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (layer) {
|
||||
if (selectedLayer) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return layer;
|
||||
return selectedLayer;
|
||||
}
|
||||
|
||||
function getSizes(scrollbarIsVisible) {
|
||||
|
@ -1112,7 +1112,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
|||
function getSubtitles() {
|
||||
return self.options.subtitlesLayer ? self.options.layers.filter(function(layer) {
|
||||
return layer.id == self.options.subtitlesLayer;
|
||||
})[0].map(function(subtitle) {
|
||||
})[0].items.map(function(subtitle) {
|
||||
return {
|
||||
id: subtitle.id,
|
||||
'in': subtitle['in'],
|
||||
|
@ -1253,12 +1253,6 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
|||
if (self.options['in'] > self.options.out) {
|
||||
setPoint(point == 'in' ? 'out' : 'in', position, keepSelected);
|
||||
} else {
|
||||
if (
|
||||
self.options.selected && self.options.subtitlesLayer
|
||||
&& getSelectedLayer() == self.options.subtitlesLayer
|
||||
) {
|
||||
updateSubtitles();
|
||||
}
|
||||
self.$annotationPanel.options({
|
||||
'in': self.options['in'],
|
||||
out: self.options.out
|
||||
|
@ -1468,7 +1462,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
|||
});
|
||||
self.$timeline.forEach(function($timeline) {
|
||||
$timeline.options({
|
||||
subtitles: self.options.enableSubtitles ? self.options.subtitles : []
|
||||
subtitles: self.options.enableSubtitles ? Ox.clone(self.options.subtitles, true) : []
|
||||
});
|
||||
});
|
||||
that.triggerEvent('subtitles', {
|
||||
|
@ -1479,11 +1473,13 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
|||
function updateSubtitles() {
|
||||
self.options.subtitles = getSubtitles();
|
||||
self.$player.forEach(function($player) {
|
||||
player.options({subtitles: self.options.subtitles});
|
||||
});
|
||||
self.$timeline.forEach(function($timeline) {
|
||||
$timeline.options({subtitles: self.options.subtitles});
|
||||
$player.options({subtitles: Ox.clone(self.options.subtitles, true)});
|
||||
});
|
||||
if (self.options.enableSubtitles) {
|
||||
self.$timeline.forEach(function($timeline) {
|
||||
$timeline.options({subtitles: Ox.clone(self.options.subtitles, true)});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function updateTimelines() {
|
||||
|
@ -1548,6 +1544,9 @@ Ox.VideoAnnotationPanel = function(options, self) {
|
|||
that.updateAnnotation = function(id, annotation) {
|
||||
// called from editannotation callback
|
||||
self.options.selected = annotation.id; // fixme: needed?
|
||||
if (getSelectedLayer() == self.options.subtitlesLayer) {
|
||||
updateSubtitles();
|
||||
}
|
||||
self.$annotationPanel.updateItem(id, annotation);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue