forked from 0x2620/oxjs
add find-as-you-type to video player
This commit is contained in:
parent
2842ec8d09
commit
8e8b9c18a4
2 changed files with 34 additions and 24 deletions
|
|
@ -430,6 +430,7 @@ Ox.VideoPlayer = function(options, self) {
|
|||
.appendTo(self.$find);
|
||||
|
||||
self.$findInput = Ox.Input({
|
||||
changeOnKeypress: true,
|
||||
value: self.options.find
|
||||
})
|
||||
.css({
|
||||
|
|
@ -439,15 +440,18 @@ Ox.VideoPlayer = function(options, self) {
|
|||
WebkitBoxShadow: '0 0 0'
|
||||
})
|
||||
.bindEvent({
|
||||
focus: function() {
|
||||
self.inputHasFocus = true;
|
||||
},
|
||||
blur: function() {
|
||||
self.inputHasFocus = false;
|
||||
},
|
||||
submit: function() {
|
||||
focus: function() {
|
||||
self.inputHasFocus = true;
|
||||
},
|
||||
change: function(data) {
|
||||
submitFindInput(data.value, false);
|
||||
},
|
||||
submit: function(data) {
|
||||
self.inputHasFocus = false;
|
||||
submitFindInput();
|
||||
submitFindInput(data.value, true);
|
||||
}
|
||||
})
|
||||
.appendTo(self.$find);
|
||||
|
|
@ -1044,7 +1048,7 @@ Ox.VideoPlayer = function(options, self) {
|
|||
}
|
||||
}
|
||||
|
||||
function find(query) {
|
||||
function find(query, hasPressedEnter) {
|
||||
var results = [];
|
||||
Ox.print(query)
|
||||
if (query.length) {
|
||||
|
|
@ -1055,8 +1059,7 @@ Ox.VideoPlayer = function(options, self) {
|
|||
out: subtitle.out
|
||||
} : null;
|
||||
});
|
||||
if (results.length == 0) {
|
||||
// fixme: doesn't happen
|
||||
if (results.length == 0 && hasPressedEnter) {
|
||||
self.$findInput.focusInput();
|
||||
}
|
||||
}
|
||||
|
|
@ -1679,15 +1682,15 @@ Ox.VideoPlayer = function(options, self) {
|
|||
}).show();
|
||||
}
|
||||
|
||||
function submitFindInput() {
|
||||
self.options.find = self.$findInput.options('value');
|
||||
self.results = find(self.options.find);
|
||||
function submitFindInput(value, hasPressedEnter) {
|
||||
self.options.find = value;
|
||||
self.results = find(self.options.find, hasPressedEnter);
|
||||
self.$results.html(self.results.length);
|
||||
self.$timeline && self.$timeline.options({
|
||||
find: self.options.find,
|
||||
results: self.results
|
||||
});
|
||||
if (self.results.length) {
|
||||
if (hasPressedEnter && self.results.length) {
|
||||
goToNextResult(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue