From 0fc5299bda9c7d098c076cbb2a94f2cca6753a9f Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 19 May 2011 21:03:35 +0200 Subject: [PATCH] add autocomplete menu --- source/Ox.UI/js/Video/Ox.VideoEditor.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/Ox.UI/js/Video/Ox.VideoEditor.js b/source/Ox.UI/js/Video/Ox.VideoEditor.js index 4e169066..acd11fd6 100644 --- a/source/Ox.UI/js/Video/Ox.VideoEditor.js +++ b/source/Ox.UI/js/Video/Ox.VideoEditor.js @@ -144,6 +144,19 @@ Ox.VideoEditor = function(options, self) { videoRatio: self.options.videoWidth / self.options.videoHeight }); + self.words = [] + Ox.forEach(Ox.count(Ox.words(self.options.subtitles.map(function(subtitle) { + return subtitle.text; + }).join(' '))), function(count, word) { + self.words.push({count: count, word: word}); + }); + self.words = self.words.sort(function(a, b) { + return b.count - a.count; + }).map(function(obj) { + return obj.word; + }); + Ox.print('WORDS', self.words) + self.$editor = new Ox.Element() .addClass('OxVideoEditor') .click(function(e) { @@ -447,6 +460,10 @@ Ox.VideoEditor = function(options, self) { .appendTo(self.$menubar); self.$findInput = Ox.Input({ + autocomplete: self.words, + autocompleteSelect: true, + autocompleteSelectHighlight: true, + autocompleteSelectSubmit: true, changeOnKeypress: true, placeholder: 'Find...', width: 96