add slash and backslash keyboard commands to editor view

This commit is contained in:
rlx 2011-02-07 21:44:21 +00:00
parent 87b386e89e
commit e508313baf

View file

@ -7095,8 +7095,7 @@ requires
return; return;
} }
//Ox.print('loadPage', page); //Ox.print('loadPage', page);
var keys = $.inArray('id', self.options.keys) > -1 ? self.options.keys : var keys = $.merge(self.options.keys.indexOf(self.options.unique) == -1 ? [self.options.unique] : [], self.options.keys),
$.merge(self.options.keys, ['id']),
offset = page * self.pageLength, offset = page * self.pageLength,
range = [offset, offset + (page < self.pages - 1 ? range = [offset, offset + (page < self.pages - 1 ?
self.pageLength : self.listLength % self.pageLength)]; self.pageLength : self.listLength % self.pageLength)];
@ -8643,7 +8642,7 @@ requires
$('<div>') $('<div>')
.addClass('OxCell OxTarget') .addClass('OxCell OxTarget')
.css({ .css({
width: (self.options.width - padding - 32) + 'px' width: (self.options.width - padding - 32 + !data.items * 16) + 'px'
}) })
.html(data.title) .html(data.title)
.appendTo($item); .appendTo($item);
@ -10712,8 +10711,12 @@ requires
.html(data.value); .html(data.value);
}, },
items: $.map(self.options.items, function(v, i) { items: $.map(self.options.items, function(v, i) {
return {value: v.value.replace(/\n/g, '<br/>')}; return {
id: i + '',
value: v.value.replace(/\n/g, '<br/>')
};
}), }),
unique: 'id'
}) })
.bindEvent({ .bindEvent({
select: selectAnnotation select: selectAnnotation
@ -10736,13 +10739,9 @@ requires
*/ */
function selectAnnotation(event, data) { function selectAnnotation(event, data) {
var pos = data.selected.ids[0], var pos = parseInt(data.ids[0]),
item = self.options.items[pos]; item = self.options.items[pos];
if (pos != self.selected) { if (pos != self.selected) {
self.selected > -1 &&
self.$annotation[self.selected].removeClass('OxSelected');
self.selected = pos;
self.$annotation[self.selected].addClass('OxSelected');
that.triggerEvent('select', { that.triggerEvent('select', {
'in': item.in, 'in': item.in,
'out': item.out 'out': item.out
@ -11602,16 +11601,16 @@ requires
key_alt_shift_right: function() { key_alt_shift_right: function() {
}, },
key_backslash: function() { key_backslash: function() {
// select current cut select('subtitle');
}, },
key_closebracket: function() { key_closebracket: function() {
movePositionTo('cut', 1); movePositionTo('subtitle', 1);
}, },
key_comma: function() { key_comma: function() {
movePositionTo('subtitle', -1); movePositionTo('cut', -1);
}, },
key_dot: function() { key_dot: function() {
movePositionTo('subtitle', 1); movePositionTo('cut', 1);
}, },
key_down: function() { key_down: function() {
movePositionBy(self.sizes.timeline[0].width); movePositionBy(self.sizes.timeline[0].width);
@ -11627,7 +11626,7 @@ requires
setPoint('out'); setPoint('out');
}, },
key_openbracket: function() { key_openbracket: function() {
movePositionTo('cut', -1); movePositionTo('subtitle', -1);
}, },
key_p: playInToOut, key_p: playInToOut,
key_right: function() { key_right: function() {
@ -11662,6 +11661,9 @@ requires
key_shift_up: function() { key_shift_up: function() {
movePositionBy(-self.options.duration); movePositionBy(-self.options.duration);
}, },
key_slash: function() {
select('cut');
},
key_space: togglePlay, key_space: togglePlay,
key_up: function() { key_up: function() {
movePositionBy(-self.sizes.timeline[0].width); movePositionBy(-self.sizes.timeline[0].width);
@ -11676,7 +11678,11 @@ requires
videoRatio: self.options.videoWidth / self.options.videoHeight videoRatio: self.options.videoWidth / self.options.videoHeight
}); });
self.$video = new Ox.Element().addClass('OxVideoEditor'); self.$editor = new Ox.Element()
.addClass('OxVideoEditor')
.click(function() {
that.gainFocus()
});
self.sizes = getSizes(); self.sizes = getSizes();
@ -11709,7 +11715,7 @@ requires
setPoint(type); setPoint(type);
} }
}) })
.appendTo(self.$video); .appendTo(self.$editor);
}); });
self.$timeline[0] = new Ox.LargeTimeline({ self.$timeline[0] = new Ox.LargeTimeline({
@ -11730,7 +11736,7 @@ requires
}) })
.bindEvent('change', changeTimelineLarge) .bindEvent('change', changeTimelineLarge)
.bindEvent('changeEnd', changeTimelineLarge) .bindEvent('changeEnd', changeTimelineLarge)
.appendTo(self.$video); .appendTo(self.$editor);
self.$timeline[1] = new Ox.BlockTimeline({ self.$timeline[1] = new Ox.BlockTimeline({
cuts: self.options.cuts, cuts: self.options.cuts,
@ -11749,7 +11755,7 @@ requires
top: self.sizes.timeline[1].top + 'px' top: self.sizes.timeline[1].top + 'px'
}) })
.bindEvent('change', changeTimelineSmall) .bindEvent('change', changeTimelineSmall)
.appendTo(self.$video); .appendTo(self.$editor);
self.$annotations = new Ox.Element() self.$annotations = new Ox.Element()
.css({ .css({
@ -11776,7 +11782,7 @@ requires
that.$element = new Ox.SplitPanel({ that.$element = new Ox.SplitPanel({
elements: [ elements: [
{ {
element: self.$video element: self.$editor
}, },
{ {
collapsed: !self.options.showAnnotations, collapsed: !self.options.showAnnotations,
@ -11850,6 +11856,33 @@ requires
return position; return position;
} }
function getPoints(type) {
var found = false,
points,
positions = [];
if (type == 'cut') {
positions = self.options.cuts;
} else if (type == 'match') {
// ...
} else if (type == 'subtitle') {
self.options.subtitles.forEach(function(v, i) {
positions.push(v.in);
positions.push(v.out);
});
}
positions.indexOf(0) == -1 && positions.unshift(0);
positions.indexOf(self.options.duration) == -1 &&
positions.push(self.options.duration);
$.each(positions, function(i, v) {
if (v > self.options.position) {
points = [positions[i - 1], positions[i]];
found = true;
return false;
}
});
return points;
}
function getSizes(scrollbarIsVisible) { function getSizes(scrollbarIsVisible) {
//Ox.print('getSizes', scrollbarIsVisible) //Ox.print('getSizes', scrollbarIsVisible)
var scrollbarWidth = oxui.scrollbarSize, var scrollbarWidth = oxui.scrollbarSize,
@ -11909,7 +11942,7 @@ requires
lines = Math.ceil(self.options.duration / size.timeline[1].width); lines = Math.ceil(self.options.duration / size.timeline[1].width);
height = getHeight(); height = getHeight();
//Ox.print('lines', lines, getHeight(), self.options.height, (scrollbarIsVisible && getHeight() <= self.options.height) ? 'scroll' : 'auto') //Ox.print('lines', lines, getHeight(), self.options.height, (scrollbarIsVisible && getHeight() <= self.options.height) ? 'scroll' : 'auto')
self.$video.css({ self.$editor.css({
overflowY: (scrollbarIsVisible && height <= self.options.height) ? 'scroll' : 'auto' overflowY: (scrollbarIsVisible && height <= self.options.height) ? 'scroll' : 'auto'
}); });
return (!scrollbarIsVisible && height > self.options.height) ? getSizes(true) : size; return (!scrollbarIsVisible && height > self.options.height) ? getSizes(true) : size;
@ -11979,30 +12012,31 @@ requires
function selectAnnotation(event, data) { function selectAnnotation(event, data) {
self.options.position = data.in self.options.position = data.in
self.options.points = [data.in, data.out]; self.options.points = [data.in, data.out - 0.001];
setPosition(); setPosition();
setPoints(); setPoints();
} }
function select(type) {
self.options.points = getPoints(type);
setPoints();
}
function setPoint(point) { function setPoint(point) {
self.options.points[point == 'in' ? 0 : 1] = self.options.position; self.options.points[point == 'in' ? 0 : 1] = self.options.position;
self.$player[point == 'in' ? 1 : 2].options({
position: self.options.position
});
if (self.options.points[1] < self.options.points[0]) { if (self.options.points[1] < self.options.points[0]) {
self.options.points[point == 'in' ? 1 : 0] = self.options.position; self.options.points[point == 'in' ? 1 : 0] = self.options.position;
self.$player[point == 'in' ? 2 : 1].options({
position: self.options.position
});
} }
setPoints(); setPoints();
} }
function setPoints() { function setPoints() {
$.each(self.$player, function(i, v) { $.each(self.$player, function(i, v) {
v.options({ v.options($.extend({
points: self.options.points points: self.options.points
}); }, i ? {
position: self.options.points[i - 1]
} : {}));
}); });
$.each(self.$timeline, function(i, v) { $.each(self.$timeline, function(i, v) {
v.options({ v.options({
@ -13227,7 +13261,7 @@ requires
}, },
{ {
align: 'left', align: 'left',
id: 'hash', id: 'oshash',
operator: '+', operator: '+',
title: 'Hash', title: 'Hash',
unique: true, unique: true,