From 1fe6765e8ba1b2ae1a7d949b3d9396859c084914 Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 19 May 2011 20:34:53 +0200 Subject: [PATCH] make find-as-you-type work with both timelines --- .../Ox.UI/js/Video/Ox.LargeVideoTimeline.js | 13 +++++---- source/Ox.UI/js/Video/Ox.VideoEditor.js | 29 +++++++++++++++---- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/source/Ox.UI/js/Video/Ox.LargeVideoTimeline.js b/source/Ox.UI/js/Video/Ox.LargeVideoTimeline.js index e8384320..f9b60105 100644 --- a/source/Ox.UI/js/Video/Ox.LargeVideoTimeline.js +++ b/source/Ox.UI/js/Video/Ox.LargeVideoTimeline.js @@ -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] = $('
') - .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') { diff --git a/source/Ox.UI/js/Video/Ox.VideoEditor.js b/source/Ox.UI/js/Video/Ox.VideoEditor.js index 709ce069..4e169066 100644 --- a/source/Ox.UI/js/Video/Ox.VideoEditor.js +++ b/source/Ox.UI/js/Video/Ox.VideoEditor.js @@ -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(); } }