make find-as-you-type work with both timelines

This commit is contained in:
rolux 2011-05-19 20:34:53 +02:00
parent 9f4f9dfa39
commit 1fe6765e8b
2 changed files with 31 additions and 11 deletions

View file

@ -173,8 +173,10 @@ Ox.LargeVideoTimeline = function(options, self) {
function setSubtitles() {
self.$subtitles = [];
self.options.subtitles.forEach(function(subtitle, i) {
var found = self.options.find &&
subtitle.text.toLowerCase().indexOf(self.options.find.toLowerCase()) > -1;
self.$subtitles[i] = $('<div>')
.addClass('OxSubtitle' + (self.options.matches.indexOf(i) > -1 ? ' OxHighlight' : ''))
.addClass('OxSubtitle' + (found ? ' OxHighlight' : ''))
.css({
left: (subtitle['in'] * self.fps) + 'px',
width: (((subtitle.out - subtitle['in']) * self.fps) - 2) + 'px'
@ -215,10 +217,11 @@ Ox.LargeVideoTimeline = function(options, self) {
}
self.setOption = function(key, value) {
if (key == 'in') {
setPointMarker('in');
} else if (key == 'out') {
setPointMarker('out');
if (key == 'find') {
that.find('.OxSubtitle').remove();
setSubtitles();
} else if (key == 'in' || key == 'out') {
setPointMarker(key);
} else if (key == 'position') {
setPosition();
} else if (key == 'subtitles') {

View file

@ -70,6 +70,14 @@ Ox.VideoEditor = function(options, self) {
key_down: function() {
movePositionBy(self.sizes.timeline[0].width);
},
key_f: function() {
setTimeout(function() {
self.$findInput.focusInput();
});
},
key_g: function() {
self.results.length && setPosition(getNextPosition('result', 1));
},
key_i: function() {
setPoint('in', self.options.position);
},
@ -98,6 +106,9 @@ Ox.VideoEditor = function(options, self) {
key_shift_down: function() {
movePositionBy(self.options.duration);
},
key_shift_g: function() {
self.results.length && setPosition(getNextPosition('result', -1));
},
key_shift_left: function() {
movePositionBy(-1);
},
@ -477,7 +488,7 @@ Ox.VideoEditor = function(options, self) {
.css({float: 'right'})
.bindEvent({
click: function() {
setPosition(getNextPosition('result', 1))
}
})
.appendTo(self.$menubar);
@ -492,7 +503,7 @@ Ox.VideoEditor = function(options, self) {
.css({float: 'right'})
.bindEvent({
click: function() {
setPosition(getNextPosition('result', -1))
}
})
.appendTo(self.$menubar);
@ -574,15 +585,16 @@ Ox.VideoEditor = function(options, self) {
return results;
}
// fixme: why not goToNextPosition()?
function getNextPosition(type, direction) {
var found = false,
position = 0,
positions;
if (type == 'cut') {
positions = self.options.cuts;
} else if (type == 'match') {
positions = $.map(self.options.matches, function(v, i) {
return self.options.subtitles[v]['in'];
} else if (type == 'result') {
positions = $.map(self.results, function(v, i) {
return v['in'];
});
} else if (type == 'subtitle') {
positions = $.map(self.options.subtitles, function(v, i) {
@ -836,6 +848,9 @@ Ox.VideoEditor = function(options, self) {
self.$clearButton.options({
disabled: !self.options.find
});
self.$timeline[0].options({
find: self.options.find,
});
self.$timeline[1].options({
find: self.options.find,
results: self.results
@ -844,7 +859,9 @@ Ox.VideoEditor = function(options, self) {
opacity: self.results.length ? 1 : 0.25
});
if (hasPressedEnter) {
self.results.length ? (function() {})() : self.$findInput.focusInput();
self.results.length ?
setPosition(getNextPosition('result', 1)) :
self.$findInput.focusInput();
}
}