edit panel: handle split

This commit is contained in:
rolux 2013-08-09 12:56:07 +00:00
parent 60e1a0b4bd
commit 1f592758ee

View file

@ -29,10 +29,7 @@ pandora.ui.editPanel = function() {
function getClips(ids) { function getClips(ids) {
return ids.map(function(id) { return ids.map(function(id) {
var clip = Ox.getObjectById(edit.clips, id); return Ox.getObjectById(edit.clips, id);
return (
clip.annotation || clip.item + '/' + clip['in'] + '-' + clip.out
) + '/' + id;
}); });
} }
@ -118,42 +115,33 @@ pandora.ui.editPanel = function() {
}) })
.bindEvent({ .bindEvent({
copy: function(data) { copy: function(data) {
pandora.clipboard.copy(getClips(data.ids), 'clip'); pandora.clipboard.copy(serializeClips(data.ids), 'clip');
}, },
copyadd: function(data) { copyadd: function(data) {
pandora.clipboard.add(getClips(data.ids), 'clip'); pandora.clipboard.add(serializeClips(data.ids), 'clip');
}, },
cut: function(data) { cut: function(data) {
var clips; var clips = serializeClips(data.ids);
if (edit.editable) {
clips = getClips(data.ids);
pandora.clipboard.copy(clips, 'clip'); pandora.clipboard.copy(clips, 'clip');
pandora.doHistory('cut', clips, ui.edit, function(result) { pandora.doHistory('cut', clips, ui.edit, function(result) {
Ox.Request.clearCache('getEdit'); Ox.Request.clearCache('getEdit');
updateClips(result.data.clips); updateClips(result.data.clips);
}); });
}
}, },
cutadd: function(data) { cutadd: function(data) {
var clips; var clips = serializeClips(data.ids);
if (edit.editable) {
clips = getClips(data.ids);
pandora.clipboard.add(clips, 'clip'); pandora.clipboard.add(clips, 'clip');
pandora.doHistory('cut', clips, ui.edit, function(result) { pandora.doHistory('cut', clips, ui.edit, function(result) {
Ox.Request.clearCache('getEdit'); Ox.Request.clearCache('getEdit');
updateClips(result.data.clips); updateClips(result.data.clips);
}); });
}
}, },
'delete': function(data) { 'delete': function(data) {
var clips; var clips = serializeClips(data.ids);
if (edit.editable) {
clips = getClips(data.ids);
pandora.doHistory('delete', clips, ui.edit, function(result) { pandora.doHistory('delete', clips, ui.edit, function(result) {
Ox.Request.clearCache('getEdit'); Ox.Request.clearCache('getEdit');
updateClips(result.data.clips); updateClips(result.data.clips);
}); });
}
}, },
edit: function(data) { edit: function(data) {
var args = {id: data.id}, var args = {id: data.id},
@ -182,6 +170,9 @@ pandora.ui.editPanel = function() {
}); });
}); });
}, },
join: function(data) {
Ox.print('JOIN', data);
},
loop: function(data) { loop: function(data) {
pandora.UI.set({videoLoop: data.loop}); pandora.UI.set({videoLoop: data.loop});
}, },
@ -201,14 +192,11 @@ pandora.ui.editPanel = function() {
pandora.UI.set(editsKey('clip'), data.ids[0]); pandora.UI.set(editsKey('clip'), data.ids[0]);
}, },
paste: function() { paste: function() {
var clips; var clips = pandora.clipboard.paste();
if (pandora.clipboard.type() == 'clip') {
clips = pandora.clipboard.paste();
pandora.doHistory('paste', clips, ui.edit, function(result) { pandora.doHistory('paste', clips, ui.edit, function(result) {
Ox.Request.clearCache('getEdit'); Ox.Request.clearCache('getEdit');
updateClips(edit.clips.concat(result.data.clips)); updateClips(edit.clips.concat(result.data.clips));
}); });
}
}, },
playing: function(data) { playing: function(data) {
var set = {}; var set = {};
@ -266,6 +254,14 @@ pandora.ui.editPanel = function() {
}); });
} }
}, },
split: function(data) {
var clips = [serializeClips(data.ids), serializeClips(data.split)];
pandora.doHistory('split', clips, ui.edit, function(result) {
updateClips(edit.clips.filter(function(clip) {
return !Ox.contains(data.ids, clip.id);
}).concat(result.data.clips));
});
},
subtitles: function(data) { subtitles: function(data) {
pandora.UI.set({videoSubtitles: data.subtitles}); pandora.UI.set({videoSubtitles: data.subtitles});
}, },
@ -308,7 +304,7 @@ pandora.ui.editPanel = function() {
item: function(data, sort, size) { item: function(data, sort, size) {
size = size || 128; size = size || 128;
var ui = pandora.user.ui, var ui = pandora.user.ui,
url = '/edit/' + data.id + '/icon'+size+'.jpg?' + data.modified, url = '/edit/' + data.id + '/icon' + size + '.jpg?' + data.modified,
info = Ox.formatDuration(data.duration); info = Ox.formatDuration(data.duration);
return { return {
height: size, height: size,
@ -317,7 +313,7 @@ pandora.ui.editPanel = function() {
info: info, info: info,
url: url, url: url,
width: size, width: size,
} };
}, },
items: function(data, callback) { items: function(data, callback) {
pandora.api.findEdits(data, callback); pandora.api.findEdits(data, callback);
@ -344,6 +340,18 @@ pandora.ui.editPanel = function() {
updateVideos(); updateVideos();
} }
function serializeClips(clips) {
// can be ids or clips
return clips.map(function(clip) {
if (Ox.isString(clip)) {
clip = Ox.getObjectById(edit.clips, clip);
}
return (
clip.annotation || clip.item + '/' + clip['in'] + '-' + clip.out
) + '/' + (clip.id || '');
});
}
function updateClips(clips) { function updateClips(clips) {
edit.clips = clips; edit.clips = clips;
edit.duration = 0; edit.duration = 0;