make cycling through matches work, even when matches have the same in/out

This commit is contained in:
rlx 2012-02-01 12:47:59 +00:00
parent 1ae47b761b
commit addd277748

View file

@ -442,14 +442,14 @@ Ox.VideoEditor = function(options, self) {
width: 256
}).open();
} else if (id == 'downloadVideo') {
that.triggerEvent('downloadvideo');
that.triggerEvent('downloadVideo');
} else if (id == 'downloadSelection') {
that.triggerEvent('downloadselection', {
that.triggerEvent('downloadSelection', {
'in': self.options['in'],
out: self.options.out,
});
} else if (id == 'embedSelection') {
that.triggerEvent('embedselection', {
that.triggerEvent('embedSelection', {
'in': self.options['in'],
out: self.options.out,
});
@ -547,7 +547,7 @@ Ox.VideoEditor = function(options, self) {
changeOnKeypress: true,
placeholder: 'Find...',
value: self.options.find,
width: 96
width: 128
})
.css({float: 'right', background: 'transparent'})
.bindEvent({
@ -780,22 +780,13 @@ Ox.VideoEditor = function(options, self) {
ret = -1;
} else if (a['in'] > b['in']) {
ret = 1;
} else if (a.out > b.out) {
ret = -1;
} else if (a.out < b.out) {
ret = -1;
} else if (a.out > b.out) {
ret = 1;
}
return ret;
});
Ox.print('RESULTS:', results)
/*
results = Ox.map(self.options.subtitles, function(subtitle) {
return subtitle.text.toLowerCase().indexOf(query) > -1 ? {
'in': subtitle['in'],
out: subtitle.out
} : null;
});
*/
}
return results;
}
@ -890,25 +881,33 @@ Ox.VideoEditor = function(options, self) {
}
function getNextResult(direction) {
var found = false,
result,
results = Ox.clone(self.results);
direction == -1 && results.reverse();
Ox.forEach(results, function(v) {
if (
direction == 1
? v['in'] > self.options.position
: v['in'] < self.options.position
) {
result = v;
found = true;
return false;
var found = false, index, result;
if (
self.currentResult
&& self.options.position == Ox.getObjectById(self.results, self.currentResult)['in']
) {
index = Ox.getIndexById(self.results, self.currentResult);
result = self.results[Ox.mod(index + direction, self.results.length)];
} else {
direction == -1 && self.results.reverse();
Ox.forEach(self.results, function(v) {
if (
direction == 1
? v['in'] > self.options.position
: v['in'] < self.options.position
) {
result = v;
found = true;
return false;
}
});
direction == -1 && self.results.reverse();
if (!found) {
Ox.print('!found', direction, self.results[direction == 1 ? 0 : results.length - 1])
result = self.results[direction == 1 ? 0 : self.results.length - 1];
}
});
direction == -1 && results.reverse();
if (!found) {
result = results[direction == 1 ? 0 : results.length - 1];
}
self.currentResult = result.id;
return result;
}
@ -1064,7 +1063,6 @@ Ox.VideoEditor = function(options, self) {
// FIXME
// self.editing = false;
self.options.selected = data.id;
Ox.print('SOS???', self.options.selected);
if (self.options.selected) {
self.options.annotationsRange != 'position' && setPosition(data['in']);
setPoint('in', data['in'], true);
@ -1072,9 +1070,7 @@ Ox.VideoEditor = function(options, self) {
}
self.$annotationPanel.options({selected: self.options.selected});
setTimelineState();
that.triggerEvent('select', {
id: self.options.selected
});
that.triggerEvent('select', {id: self.options.selected});
}
function selectCut() {
@ -1227,7 +1223,6 @@ Ox.VideoEditor = function(options, self) {
if (hasPressedEnter) {
that.triggerEvent('find', {find: self.options.find});
if (self.results.length) {
Ox.print('HELLO?>??', getNextResult(1))
selectAnnotation(getNextResult(1));
} else {
self.$findInput.focusInput(true);