make selected annotation scroll into view

This commit is contained in:
rlx 2012-01-11 15:02:33 +05:30
parent e4dd393834
commit 923f71e6de
4 changed files with 30 additions and 11 deletions

View file

@ -199,13 +199,17 @@ Ox.ArrayEditable = function(options, self) {
function triggerSelectEvent() { function triggerSelectEvent() {
if (!self.triggered) { if (!self.triggered) {
that.triggerEvent('select', {id: self.options.selected}); that.triggerEvent('select', Ox.extend({
id: self.options.selected
}, self.options.selected ? {
top: self.$items[self.selected].offset().top
} : {}));
self.triggered = true; self.triggered = true;
setTimeout(function() { setTimeout(function() {
self.triggered = false; self.triggered = false;
}, 250); }, 250);
} }
}; }
self.setOption = function(key, value) { self.setOption = function(key, value) {
if (key == 'items') { if (key == 'items') {

View file

@ -25,7 +25,11 @@ Ox.AnnotationPanel = function(options, self) {
collapsed: false, collapsed: false,
editable: false, editable: false,
id: '', id: '',
'in': 0,
item: '',
items: [], items: [],
out: 0,
position: 0,
range: 'all', range: 'all',
selected: '', selected: '',
sort: 'position', sort: 'position',
@ -57,7 +61,7 @@ Ox.AnnotationPanel = function(options, self) {
id: 'add', id: 'add',
style: 'symbol', style: 'symbol',
title: 'add', title: 'add',
tooltip: 'Add', tooltip: 'Add ' + self.options.item,
type: 'image' type: 'image'
}).bindEvent({ }).bindEvent({
click: function(data) { click: function(data) {
@ -131,9 +135,7 @@ Ox.AnnotationPanel = function(options, self) {
function selectAnnotation(data) { function selectAnnotation(data) {
var item = Ox.getObjectById(self.options.items, data.id); var item = Ox.getObjectById(self.options.items, data.id);
self.options.selected = item ? data.id : ''; self.options.selected = item ? data.id : '';
that.triggerEvent('select', Ox.extend({ that.triggerEvent('select', Ox.extend(data, item ? {
id: data.id
}, item ? {
'in': item['in'], 'in': item['in'],
out: item.out, out: item.out,
layer: self.options.id layer: self.options.id

View file

@ -396,10 +396,8 @@ Ox.VideoEditor = function(options, self) {
self.$annotationPanel[i_].options({selected: ''}); self.$annotationPanel[i_].options({selected: ''});
} }
}); });
selectAnnotation(data);
} else {
// ...
} }
selectAnnotation(data);
}, },
submit: submitAnnotation, submit: submitAnnotation,
toggle: function(data) { toggle: function(data) {
@ -1100,11 +1098,26 @@ Ox.VideoEditor = function(options, self) {
if (self.options.selected) { if (self.options.selected) {
setPoint('in', data['in']); setPoint('in', data['in']);
setPoint('out', data.out); setPoint('out', data.out);
Ox.print('???', JSON.stringify(self.options.selected), getPanel(self.options.selected))
getPanel(self.options.selected).options({selected: self.options.selected}); getPanel(self.options.selected).options({selected: self.options.selected});
} }
setTimelineState(); setTimelineState();
updateEditMenu(); updateEditMenu();
if (data.top) {
var height = self.$annotations.height(),
scrollTop = self.$annotations.scrollTop();
data.top -= 60; // 20 + 24 + 16
Ox.print('HEIGHT', height, 'SCROLLTOP', scrollTop, 'TOP', data.top);
if (data.top < 0 || data.top > height - 16) {
if (data.top < 0) {
scrollTop += data.top - 3;
} else if (data.top > height - 16) {
scrollTop += data.top - height + 14;
}
self.$annotations.animate({
scrollTop: scrollTop + 'px'
}, 0);
}
}
that.triggerEvent('select', { that.triggerEvent('select', {
id: self.options.selected id: self.options.selected
}); });

View file

@ -740,7 +740,7 @@ Video
} }
.OxThemeClassic .OxAnnotationPanel .OxEditableElement.OxSelected { .OxThemeClassic .OxAnnotationPanel .OxEditableElement.OxSelected {
background: rgb(128, 128, 255); background: rgb(192, 192, 255);
box-shadow: 0 0 1px rgb(64, 64, 64); box-shadow: 0 0 1px rgb(64, 64, 64);
} }
.OxThemeClassic .OxAnnotationPanel .OxEditableElement input { .OxThemeClassic .OxAnnotationPanel .OxEditableElement input {