limit highlight to layer

This commit is contained in:
j 2018-08-07 17:12:22 +01:00
commit 8b14537dce
2 changed files with 61 additions and 14 deletions

View file

@ -19,6 +19,7 @@ Ox.VideoAnnotationPanel <f> VideoAnnotationPanel Object
embedselection <!> embedselection
findannotations <!> findannotations
find <!> find
findLayer <s|*> limit find to layer
importannotations <!> importannotations
info <!> info
key_* <!> key_*
@ -66,6 +67,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
enableSetPosterFrame: false,
enableSubtitles: false,
find: '',
findLayer: '*',
fps: 25,
getFrameURL: null,
getLargeTimelineURL: null,
@ -409,7 +411,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
enablePosition: true,
enableSubtitles: self.options.enableSubtitles,
externalControls: true,
find: self.options.find,
find: getSubtitlesFind(),
height: self.sizes.player[i].height,
id: 'player' + Ox.toTitleCase(type),
'in': self.options['in'],
@ -495,7 +497,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
self.$timeline[0] = Ox.LargeVideoTimeline({
cuts: self.options.cuts,
duration: self.options.duration,
find: self.options.find,
find: getSubtitlesFind(),
getImageURL: self.options.getLargeTimelineURL,
id: 'timelineLarge',
'in': self.options['in'],
@ -523,7 +525,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
self.$timeline[1] = Ox.BlockVideoTimeline({
cuts: self.options.cuts,
duration: self.options.duration,
find: self.options.find,
find: getSubtitlesFind(),
getImageURL: self.options.getSmallTimelineURL,
id: 'timelineSmall',
'in': self.options['in'],
@ -789,6 +791,28 @@ Ox.VideoAnnotationPanel = function(options, self) {
})
.appendTo(self.$menubar);
self.$findLayerSelect = Ox.Select({
items: [
{id: '*', title: Ox._('Find: {0}', [Ox._('All')])},
].concat(self.options.layers.map(function(layer) {
return {
id: layer.id,
title: Ox._('Find: {0}', [Ox._(layer.title)])
}
})),
value: self.options.findLayer,
width: 128,
overlap: 'right',
})
.css({float: 'right', background: 'transparent'})
.bindEvent({
change: function(data) {
self.options.findLayer = data.value;
submitFindInput(self.$findInput.value(), false);
},
})
.appendTo(self.$menubar);
self.$nextButton = Ox.Button({
disabled: true,
style: 'symbol',
@ -832,6 +856,7 @@ Ox.VideoAnnotationPanel = function(options, self) {
enableExport: self.options.enableExport,
enableImport: self.options.enableImport,
highlight: self.options.find,
highlightLayer: self.options.findLayer,
'in': self.options['in'],
itemName: self.options.itemName,
layers: self.options.layers,
@ -1032,9 +1057,10 @@ Ox.VideoAnnotationPanel = function(options, self) {
if (query.length) {
query = query.toLowerCase();
results = self.annotations.filter(function(annotation) {
return Ox.decodeHTMLEntities(Ox.stripTags(
annotation.value.toLowerCase()
)).indexOf(query) > -1;
return Ox.contains(['*', annotation.layer], self.options.findLayer)
&& Ox.decodeHTMLEntities(Ox.stripTags(
annotation.value.toLowerCase()
)).indexOf(query) > -1;
});
}
return results;
@ -1069,7 +1095,9 @@ Ox.VideoAnnotationPanel = function(options, self) {
function getAnnotations() {
return Ox.flatten(self.options.layers.map(function(layer) {
return layer.items;
return layer.items.map(function(item) {
return Ox.extend({layer: layer.id}, item)
});
})).sort(sortAnnotations);
}
@ -1226,6 +1254,12 @@ Ox.VideoAnnotationPanel = function(options, self) {
: [];
}
function getSubtitlesFind() {
return Ox.contains(
[self.options.subtitlesLayer, '*'], self.options.findLayer
) ? self.options.find : '';
}
function getWords() {
var words = [];
Ox.forEach(Ox.count(Ox.words(
@ -1542,11 +1576,12 @@ Ox.VideoAnnotationPanel = function(options, self) {
self.$clearButton.options({
disabled: !self.options.find
});
self.$player.forEach(function($player) {
$player.options({find: self.options.find});
$player.options({find: getSubtitlesFind()});
});
self.$timeline.forEach(function($timeline) {
$timeline.options({find: self.options.find});
$timeline.options({find: getSubtitlesFind()});
});
self.$timeline[1].options({results: self.results});
if (hasPressedEnter) {
@ -1558,7 +1593,10 @@ Ox.VideoAnnotationPanel = function(options, self) {
self.$findInput.focusInput(true);
}
}
self.$annotationPanel.options({highlight: self.options.find});
self.$annotationPanel.options({
highlight: self.options.find,
highlightLayer: self.options.findLayer,
});
}
function toggleAnnotations(data) {