make find-as-you-type work with both timelines
This commit is contained in:
parent
9f4f9dfa39
commit
1fe6765e8b
2 changed files with 31 additions and 11 deletions
|
@ -173,8 +173,10 @@ Ox.LargeVideoTimeline = function(options, self) {
|
||||||
function setSubtitles() {
|
function setSubtitles() {
|
||||||
self.$subtitles = [];
|
self.$subtitles = [];
|
||||||
self.options.subtitles.forEach(function(subtitle, i) {
|
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>')
|
self.$subtitles[i] = $('<div>')
|
||||||
.addClass('OxSubtitle' + (self.options.matches.indexOf(i) > -1 ? ' OxHighlight' : ''))
|
.addClass('OxSubtitle' + (found ? ' OxHighlight' : ''))
|
||||||
.css({
|
.css({
|
||||||
left: (subtitle['in'] * self.fps) + 'px',
|
left: (subtitle['in'] * self.fps) + 'px',
|
||||||
width: (((subtitle.out - subtitle['in']) * self.fps) - 2) + 'px'
|
width: (((subtitle.out - subtitle['in']) * self.fps) - 2) + 'px'
|
||||||
|
@ -215,10 +217,11 @@ Ox.LargeVideoTimeline = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.setOption = function(key, value) {
|
self.setOption = function(key, value) {
|
||||||
if (key == 'in') {
|
if (key == 'find') {
|
||||||
setPointMarker('in');
|
that.find('.OxSubtitle').remove();
|
||||||
} else if (key == 'out') {
|
setSubtitles();
|
||||||
setPointMarker('out');
|
} else if (key == 'in' || key == 'out') {
|
||||||
|
setPointMarker(key);
|
||||||
} else if (key == 'position') {
|
} else if (key == 'position') {
|
||||||
setPosition();
|
setPosition();
|
||||||
} else if (key == 'subtitles') {
|
} else if (key == 'subtitles') {
|
||||||
|
|
|
@ -70,6 +70,14 @@ Ox.VideoEditor = function(options, self) {
|
||||||
key_down: function() {
|
key_down: function() {
|
||||||
movePositionBy(self.sizes.timeline[0].width);
|
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() {
|
key_i: function() {
|
||||||
setPoint('in', self.options.position);
|
setPoint('in', self.options.position);
|
||||||
},
|
},
|
||||||
|
@ -98,6 +106,9 @@ Ox.VideoEditor = function(options, self) {
|
||||||
key_shift_down: function() {
|
key_shift_down: function() {
|
||||||
movePositionBy(self.options.duration);
|
movePositionBy(self.options.duration);
|
||||||
},
|
},
|
||||||
|
key_shift_g: function() {
|
||||||
|
self.results.length && setPosition(getNextPosition('result', -1));
|
||||||
|
},
|
||||||
key_shift_left: function() {
|
key_shift_left: function() {
|
||||||
movePositionBy(-1);
|
movePositionBy(-1);
|
||||||
},
|
},
|
||||||
|
@ -477,7 +488,7 @@ Ox.VideoEditor = function(options, self) {
|
||||||
.css({float: 'right'})
|
.css({float: 'right'})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: function() {
|
click: function() {
|
||||||
|
setPosition(getNextPosition('result', 1))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.appendTo(self.$menubar);
|
.appendTo(self.$menubar);
|
||||||
|
@ -492,7 +503,7 @@ Ox.VideoEditor = function(options, self) {
|
||||||
.css({float: 'right'})
|
.css({float: 'right'})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: function() {
|
click: function() {
|
||||||
|
setPosition(getNextPosition('result', -1))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.appendTo(self.$menubar);
|
.appendTo(self.$menubar);
|
||||||
|
@ -574,15 +585,16 @@ Ox.VideoEditor = function(options, self) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fixme: why not goToNextPosition()?
|
||||||
function getNextPosition(type, direction) {
|
function getNextPosition(type, direction) {
|
||||||
var found = false,
|
var found = false,
|
||||||
position = 0,
|
position = 0,
|
||||||
positions;
|
positions;
|
||||||
if (type == 'cut') {
|
if (type == 'cut') {
|
||||||
positions = self.options.cuts;
|
positions = self.options.cuts;
|
||||||
} else if (type == 'match') {
|
} else if (type == 'result') {
|
||||||
positions = $.map(self.options.matches, function(v, i) {
|
positions = $.map(self.results, function(v, i) {
|
||||||
return self.options.subtitles[v]['in'];
|
return v['in'];
|
||||||
});
|
});
|
||||||
} else if (type == 'subtitle') {
|
} else if (type == 'subtitle') {
|
||||||
positions = $.map(self.options.subtitles, function(v, i) {
|
positions = $.map(self.options.subtitles, function(v, i) {
|
||||||
|
@ -836,6 +848,9 @@ Ox.VideoEditor = function(options, self) {
|
||||||
self.$clearButton.options({
|
self.$clearButton.options({
|
||||||
disabled: !self.options.find
|
disabled: !self.options.find
|
||||||
});
|
});
|
||||||
|
self.$timeline[0].options({
|
||||||
|
find: self.options.find,
|
||||||
|
});
|
||||||
self.$timeline[1].options({
|
self.$timeline[1].options({
|
||||||
find: self.options.find,
|
find: self.options.find,
|
||||||
results: self.results
|
results: self.results
|
||||||
|
@ -844,7 +859,9 @@ Ox.VideoEditor = function(options, self) {
|
||||||
opacity: self.results.length ? 1 : 0.25
|
opacity: self.results.length ? 1 : 0.25
|
||||||
});
|
});
|
||||||
if (hasPressedEnter) {
|
if (hasPressedEnter) {
|
||||||
self.results.length ? (function() {})() : self.$findInput.focusInput();
|
self.results.length ?
|
||||||
|
setPosition(getNextPosition('result', 1)) :
|
||||||
|
self.$findInput.focusInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue