update video editor

This commit is contained in:
rlx 2012-01-13 00:34:32 +05:30
parent b2e8b2ac82
commit f61e39a788
9 changed files with 141 additions and 80 deletions

View file

@ -72,11 +72,13 @@ Ox.ArrayEditable = function(options, self) {
} }
function deleteItem() { function deleteItem() {
self.options.items.splice(self.selected, 1); if (self.options.editable) {
renderItems(); self.options.items.splice(self.selected, 1);
that.triggerEvent('delete', { renderItems();
id: self.options.selected that.triggerEvent('delete', {
}); id: self.options.selected
});
}
} }
function doubleclick(e) { function doubleclick(e) {
@ -84,7 +86,7 @@ Ox.ArrayEditable = function(options, self) {
$parent = $target.parent(); $parent = $target.parent();
if ($parent.is('.OxEditableElement')) { if ($parent.is('.OxEditableElement')) {
that.editItem(); that.editItem();
} else if(!$target.is('.OxInput')) { } else if (!$target.is('.OxInput')) {
that.triggerEvent('add'); that.triggerEvent('add');
} }
} }
@ -106,7 +108,7 @@ Ox.ArrayEditable = function(options, self) {
.html(', ') .html(', ')
.appendTo(that); .appendTo(that);
self.$items[i] = Ox.Editable({ self.$items[i] = Ox.Editable({
editable: item.editable, editable: self.options.editable && item.editable,
format: function(value) { format: function(value) {
return value || ' ' return value || ' '
}, },
@ -155,6 +157,10 @@ Ox.ArrayEditable = function(options, self) {
self.selected = idOrPosition; self.selected = idOrPosition;
self.options.selected = getSelectedId(); self.options.selected = getSelectedId();
} }
if (self.options.selected == '' && self.editing) {
self.editing = false;
that.blurItem();
}
Ox.print('SELECT ITEM', self.options.selected, self.selected); Ox.print('SELECT ITEM', self.options.selected, self.selected);
that.find('.OxSelected').removeClass('OxSelected'); that.find('.OxSelected').removeClass('OxSelected');
self.selected > -1 && self.$items[self.selected].addClass('OxSelected'); self.selected > -1 && self.$items[self.selected].addClass('OxSelected');
@ -222,12 +228,19 @@ Ox.ArrayEditable = function(options, self) {
selectItem(value); selectItem(value);
} else if (key == 'sort') { } else if (key == 'sort') {
renderItems(); renderItems();
} else if (key == 'width') {
that.css({width: value - 8 + 'px'}); // 2 x 4 px padding
self.options.type == 'textarea' && self.$items.forEach(function($item) {
$item.options({width: value})
});
} }
} }
that.addItem = function(position, item) { that.addItem = function(position, item) {
self.options.items.splice(position, 0, item); if (self.options.editable) {
renderItems(); self.options.items.splice(position, 0, item);
renderItems();
}
//that.triggerEvent('add'); //that.triggerEvent('add');
/* /*
self.values = Ox.filter(values, function(value) { self.values = Ox.filter(values, function(value) {
@ -240,15 +253,20 @@ Ox.ArrayEditable = function(options, self) {
}; };
that.blurItem = function() { that.blurItem = function() {
self.options.selected && self.$items[self.selected].options({ if (self.options.selected) {
editing: false self.$items[self.selected].options({editing: false});
}); } else {
self.$items.forEach(function($item) {
$item.options({editing: false});
});
}
}; };
that.editItem = function() { that.editItem = function() {
if (self.options.selected) { if (self.options.editable && self.options.selected) {
Ox.forEach(self.$items, function($item) { Ox.forEach(self.$items, function($item) {
if ($item.data('position') == self.selected) { if ($item.data('position') == self.selected) {
Ox.print('DBLCLICK')
$item.triggerEvent('doubleclick'); $item.triggerEvent('doubleclick');
return false; return false;
} }
@ -261,7 +279,9 @@ Ox.ArrayEditable = function(options, self) {
}; };
that.removeItem = function(position) { that.removeItem = function(position) {
if (self.options.editable) {
}
}; };
return that; return that;

View file

@ -72,6 +72,7 @@ Ox.Editable = function(options, self) {
} }
function cancel() { function cancel() {
self.options.editing = false;
self.options.value = self.originalValue; self.options.value = self.originalValue;
self.$input.value(formatInputValue()).hide(); self.$input.value(formatInputValue()).hide();
self.$test.html(formatTestValue()); self.$test.html(formatTestValue());

View file

@ -1388,8 +1388,10 @@ Ox.Map = function(options, self) {
if (key == 'height' || key == 'width') { if (key == 'height' || key == 'width') {
that.resizeMap(); that.resizeMap();
} else if (key == 'places') { } else if (key == 'places') {
//fixme: should zoom to new bounds Ox.print('MAP SET OPTIONS PLACES', value);
zoom(0); getMapBounds(function(mapBounds) {
self.map.fitBounds(mapBounds);
});
} else if (key == 'selected') { } else if (key == 'selected') {
selectPlace(value); selectPlace(value);
} else if (key == 'type') { } else if (key == 'type') {

View file

@ -71,7 +71,22 @@ Ox.AnnotationFolder = function(options, self) {
if (self.options.type == 'event') { if (self.options.type == 'event') {
self.$annotations = Ox.Element(); self.$annotations = Ox.Element();
} else if (self.options.type == 'place') { } else if (self.options.type == 'place') {
self.$annotations = Ox.Element(); self.$annotations = Ox.Element()
.css({
width: self.options.width + 'px',
height: '256px'
});
Ox.print('PLACES::', self.places)
self.$map = Ox.Map({
places: getPlaces()
// showLabels: true
})
.bindEvent({
selectplace: function(data) {
selectAnnotation({id: data.annotationId});
}
})
.appendTo(self.$annotations);
} else if (['string', 'text'].indexOf(self.options.type) > -1) { } else if (['string', 'text'].indexOf(self.options.type) > -1) {
self.$annotations = Ox.ArrayEditable({ self.$annotations = Ox.ArrayEditable({
editable: self.options.editable, editable: self.options.editable,
@ -130,6 +145,18 @@ Ox.AnnotationFolder = function(options, self) {
}); });
} }
function getPlaces() {
var places = [];
getAnnotations().forEach(function(item) {
if (item.place && Ox.getIndexById(places, item.place.id) == -1) {
places.push(Ox.extend({
annotationId: item.id
}, item.place));
}
});
return places;
}
function getSort() { function getSort() {
return ({ return ({
duration: ['-duration', '+in', '+value'], duration: ['-duration', '+in', '+value'],
@ -171,27 +198,36 @@ Ox.AnnotationFolder = function(options, self) {
} }
if (key == 'in') { if (key == 'in') {
//fixme: array editable should support item updates while editing //fixme: array editable should support item updates while editing
self.editing || self.options.range == 'selection' && self.$annotations.options({ if (self.editing || self.options.range == 'selection') {
items: getAnnotations() self.options.type == 'place' ? self.$map.options({places: getPlaces()})
}); : self.$annotations.options({items: getAnnotations()});
}
} else if (key == 'out') { } else if (key == 'out') {
self.editing || self.options.range == 'selection' && self.$annotations.options({ if (self.editing || self.options.range == 'selection') {
items: getAnnotations() self.options.type == 'place' ? self.$map.options({places: getPlaces()})
}); : self.$annotations.options({items: getAnnotations()});
}
} else if (key == 'position') { } else if (key == 'position') {
self.editing || self.options.range == 'position' && self.$annotations.options({ if (self.editing || self.options.range == 'position') {
items: getAnnotations() self.options.type == 'place' ? self.$map.options({places: getPlaces()})
}); : self.$annotations.options({items: getAnnotations()});
}
} else if (key == 'range') { } else if (key == 'range') {
self.$annotations.options({items: getAnnotations()}); self.$annotations.options({items: getAnnotations()});
} else if (key == 'selected') { } else if (key == 'selected') {
if (value === '') {
self.editing = false;
}
self.$annotations.options({selected: value}); self.$annotations.options({selected: value});
} else if (key == 'sort') { } else if (key == 'sort') {
self.sort = getSort(); self.sort = getSort();
self.$annotations.options({sort: self.sort}); self.$annotations.options({sort: self.sort});
} else if (key == 'users') { } else if (key == 'users') {
Ox.print('USERS ->', value)
self.$annotations.options({items: getAnnotations()}); self.$annotations.options({items: getAnnotations()});
} else if (key == 'width') {
self.$annotations.options({
width: self.options.type == 'text' ? self.options.width + 8 : self.options.width
});
} }
}; };

View file

@ -98,6 +98,8 @@ Ox.AnnotationPanel = function(options, self) {
}); });
that.triggerEvent('annotations' + data.id, set); that.triggerEvent('annotations' + data.id, set);
} }
// FIXME: this does not work
self.options.selected && getFolder(self.options.selected).gainFocus();
} }
}) })
.appendTo(self.$menubar); .appendTo(self.$menubar);
@ -175,7 +177,7 @@ Ox.AnnotationPanel = function(options, self) {
that.triggerEvent('submit', data); that.triggerEvent('submit', data);
}, },
toggle: function(data) { toggle: function(data) {
that.triggerEvent('toggle', Ox.extend({layer: layer.id}, data)); that.triggerEvent('togglelayer', Ox.extend({layer: layer.id}, data));
} }
}) })
.appendTo(self.$folders); .appendTo(self.$folders);
@ -194,11 +196,6 @@ Ox.AnnotationPanel = function(options, self) {
], ],
orientation: 'vertical' orientation: 'vertical'
}) })
.bindEvent({
resize: resizeAnnotations,
resizeend: resizeendAnnotations,
toggle: toggleAnnotations
})
); );
function getFolder(annotationId) { function getFolder(annotationId) {
@ -242,18 +239,6 @@ Ox.AnnotationPanel = function(options, self) {
that.triggerEvent('select', data); that.triggerEvent('select', data);
} }
function resizeAnnotations() {
}
function resizeendAnnotations() {
}
function toggleAnnotations() {
}
function updateEditMenu() { function updateEditMenu() {
var action = self.options.selected ? 'enableItem' : 'disableItem'; var action = self.options.selected ? 'enableItem' : 'disableItem';
self.$editMenuButton[action]('edit'); self.$editMenuButton[action]('edit');
@ -274,6 +259,10 @@ Ox.AnnotationPanel = function(options, self) {
$folder.options({selected: ''}); $folder.options({selected: ''});
}) })
} }
} else if (key == 'width') {
self.$folder.forEach(function($folder) {
$folder.options({width: self.options.width - Ox.UI.SCROLLBAR_SIZE});
});
} }
}; };

View file

@ -11,6 +11,7 @@ Ox.SmallVideoTimeline = function(options, self) {
.defaults({ .defaults({
// _offset is a hack for cases where all these position: absolute // _offset is a hack for cases where all these position: absolute
// elements have to go into a float: left // elements have to go into a float: left
// FIXME: possible unused and unneeded
_offset: 0, _offset: 0,
disabled: false, disabled: false,
duration: 0, duration: 0,

View file

@ -630,12 +630,12 @@ Ox.VideoEditor = function(options, self) {
layer: data.layer layer: data.layer
}); });
}, },
select: function(data) { resize: resizeAnnotations,
!data.id && that.gainFocus(); resizeend: resizeendAnnotations,
selectAnnotation(data); select: selectAnnotation,
},
submit: submitAnnotation, submit: submitAnnotation,
toggle: function(data) { toggle: toggleAnnotations,
togglelayer: function(data) {
that.triggerEvent('togglelayer', { that.triggerEvent('togglelayer', {
collapsed: data.collapsed, collapsed: data.collapsed,
layer: data.layer layer: data.layer
@ -904,30 +904,11 @@ Ox.VideoEditor = function(options, self) {
function resizeAnnotations(data) { function resizeAnnotations(data) {
self.options.annotationsSize = data.size; self.options.annotationsSize = data.size;
setSizes(); setSizes();
self.$annotationPanel.options({width: data.size});
} }
function resizeendAnnotations(data) { function resizeendAnnotations(data) {
that.triggerEvent('annotationsSize', {size: data.size}); that.triggerEvent('annotationssize', {size: data.size});
}
function resizeEditor(data) {
var width = data.size - 2 * margin + 100;
resizeVideoPlayers(width);
$timelineLarge.options({width: width});
$timelineSmall.options({width: width});
}
function resizePlayers() {
self.$player.forEach(function(v, i) {
v.options({
width: size[i].width,
height: size[i].height
})
.css({
left: size[i].left + 'px',
top: size[i].top + 'px',
});
});
} }
function selectAnnotation(data) { function selectAnnotation(data) {
@ -935,6 +916,8 @@ Ox.VideoEditor = function(options, self) {
if (Ox.isUndefined(data)) { if (Ox.isUndefined(data)) {
// doubleclick on small timeline // doubleclick on small timeline
data = getAnnotation(); data = getAnnotation();
} else if (!data.id) {
that.gainFocus();
} }
self.editing = false; self.editing = false;
self.options.selected = data.id; self.options.selected = data.id;

View file

@ -39,7 +39,9 @@ Ox.VideoPanel = function(options, self) {
resolution: 0, resolution: 0,
scaleToFill: false, scaleToFill: false,
showAnnotations: false, showAnnotations: false,
showLayers: {},
showTimeline: true, showTimeline: true,
showUsers: false,
subtitles: [], subtitles: [],
tooltips: false, tooltips: false,
video: '', video: '',
@ -106,9 +108,11 @@ Ox.VideoPanel = function(options, self) {
paused: function(data) { paused: function(data) {
that.triggerEvent('paused', data); that.triggerEvent('paused', data);
}, },
playing: setPosition, playing: function(data) {
setPosition(data.position, true);
},
position: function(data) { position: function(data) {
setPosition(data); setPosition(data.position);
that.triggerEvent('position', data); that.triggerEvent('position', data);
}, },
resolution: function(data) { resolution: function(data) {
@ -167,15 +171,20 @@ Ox.VideoPanel = function(options, self) {
self.$annotationPanel = Ox.AnnotationPanel({ self.$annotationPanel = Ox.AnnotationPanel({
font: self.options.annotationsFont, font: self.options.annotationsFont,
'in': self.options['in'],
layers: self.options.layers, layers: self.options.layers,
out: self.options.out,
position: self.options.position,
range: self.options.annotationsRange, range: self.options.annotationsRange,
showFonts: true, showFonts: true,
showLayers: self.options.showLayers, showLayers: self.options.showLayers,
showUsers: self.options.showUsers,
sort: self.options.annotationsSort sort: self.options.annotationsSort
}) })
.bindEvent({ .bindEvent({
resize: resizeAnnotations, resize: resizeAnnotations,
resizeend: resizeendAnnotations, resizeend: resizeendAnnotations,
select: selectAnnotation,
toggle: toggleAnnotations toggle: toggleAnnotations
}); });
@ -200,6 +209,7 @@ Ox.VideoPanel = function(options, self) {
function changeTimeline(data) { function changeTimeline(data) {
self.options.position = data.position; self.options.position = data.position;
self.$video.options({position: self.options.position}); self.$video.options({position: self.options.position});
self.$annotationPanel.options({position: self.options.position});
that.triggerEvent('position', {position: self.options.position}); that.triggerEvent('position', {position: self.options.position});
} }
@ -256,12 +266,27 @@ Ox.VideoPanel = function(options, self) {
}); });
} }
function setPosition(data) { function selectAnnotation(data) {
self.options.position = data.position; self.options.selected = data.id;
//self.$video.position(self.options.position); if (self.options.selected) {
self.$timeline.options({ setPosition(data['in']);
position: self.options.position setPoint('in', data['in']);
}); setPoint('out', data.out);
}
}
function setPoint(point, position) {
self.options[point] = position;
self.$video.options(point, position);
self.$timeline.options(point, position);
self.$annotationPanel.options(point, position);
}
function setPosition(position, playing) {
self.options.position = position;
!playing && self.$video.options({position: self.options.position});
self.$timeline.options({position: self.options.position});
self.$annotationPanel.options({position: self.options.position});
} }
function toggleAnnotations(data) { function toggleAnnotations(data) {
@ -300,6 +325,9 @@ Ox.VideoPanel = function(options, self) {
self.$timeline.options({ self.$timeline.options({
position: value position: value
}); });
self.$annotationPanel.options({
position: value
});
} else if (key == 'showAnnotations') { } else if (key == 'showAnnotations') {
that.$element.toggle(1); that.$element.toggle(1);
} else if (key == 'showTimeline') { } else if (key == 'showTimeline') {

View file

@ -1367,7 +1367,7 @@ Ox.VideoPlayer = function(options, self) {
function getTimeline() { function getTimeline() {
var $timeline = Ox.SmallVideoTimeline({ var $timeline = Ox.SmallVideoTimeline({
_offset: getTimelineLeft(), //_offset: getTimelineLeft(),
disabled: !self.options.enableTimeline, disabled: !self.options.enableTimeline,
duration: self.options.duration, duration: self.options.duration,
find: self.options.find, find: self.options.find,
@ -1417,6 +1417,7 @@ Ox.VideoPlayer = function(options, self) {
} }
left += control == 'position' ? self.positionWidth : 16 left += control == 'position' ? self.positionWidth : 16
}); });
Ox.print('TIMELINE_LEFT = ', left)
return left; return left;
} }