1
0
Fork 0
forked from 0x2620/oxjs

fix multiple id selection in VideoAnnotationPanel chain

This commit is contained in:
j 2025-01-25 10:27:45 +05:30
commit 01596fa174
2 changed files with 32 additions and 26 deletions

View file

@ -581,7 +581,19 @@ Ox.AnnotationFolder = function(options, self) {
function selectAnnotation(data) { function selectAnnotation(data) {
if (self.loaded) { if (self.loaded) {
var item = Ox.getObjectById(self.options.items, data.id); var extendedData;
if (Ox.isArray(data.id) && data.id.length) {
var items = data.id.map(id => {
return Ox.getObjectById(self.options.items, id);
})
self.options.selected = data.id;
extendedData = Ox.extend(data, {
'in': Ox.min(items.map(item => { return item["in"]; })),
out: Ox.max(items.map(item => { return item["out"]; })),
layer: self.options.id
});
} else {
var item = Ox.getObjectById(self.options.items, data.id)
self.options.selected = item ? data.id : ''; self.options.selected = item ? data.id : '';
if (self.widget) { if (self.widget) {
if (self.options.type == 'event') { if (self.options.type == 'event') {
@ -596,11 +608,13 @@ Ox.AnnotationFolder = function(options, self) {
.panToPlace(); .panToPlace();
} }
} }
that.triggerEvent('select', Ox.extend(data, item ? { extendedData = Ox.extend(data, item ? {
'in': item['in'], 'in': item['in'],
out: item.out, out: item.out,
layer: self.options.id layer: self.options.id
} : {})); } : {});
}
that.triggerEvent('select', extendedData)
} }
} }

View file

@ -1357,14 +1357,6 @@ Ox.VideoAnnotationPanel = function(options, self) {
if (Ox.isUndefined(data)) { if (Ox.isUndefined(data)) {
// doubleclick on small timeline // doubleclick on small timeline
data = getAnnotation(); data = getAnnotation();
} else if (Ox.isArray(data.id)) {
var range = data.id.map(id => {
return Ox.getObjectById(self.annotations, id)
})
data['in'] = Ox.min(range.map(annotation => { return annotation["in"]; }))
data['out'] = Ox.max(range.map(annotation => { return annotation["out"]; }))
setPoint('in', data['in'], true);
setPoint('out', data.out, true);
} else if (!data.id && Ox.$elements[that.oxid]) { } else if (!data.id && Ox.$elements[that.oxid]) {
// focus only if in the dom // focus only if in the dom
that.gainFocus(); that.gainFocus();