forked from 0x2620/pandora
fix (some) copy & paste bugs in edits
This commit is contained in:
parent
83dbe50894
commit
086682548f
2 changed files with 36 additions and 26 deletions
|
@ -27,6 +27,15 @@ pandora.ui.editPanel = function() {
|
|||
);
|
||||
}
|
||||
|
||||
function getClips(ids) {
|
||||
return ids.map(function(id) {
|
||||
var clip = Ox.getObjectById(edit.clips, id);
|
||||
return (
|
||||
clip.annotation || clip.item + '/' + clip['in'] + '-' + clip.out
|
||||
) + '/' + id;
|
||||
});
|
||||
}
|
||||
|
||||
function getSmallTimelineURL() {
|
||||
var fps = 25,
|
||||
width = Math.floor(edit.duration * fps),
|
||||
|
@ -109,44 +118,38 @@ pandora.ui.editPanel = function() {
|
|||
})
|
||||
.bindEvent({
|
||||
copy: function(data) {
|
||||
pandora.clipboard.copy(data.ids.map(function(id) {
|
||||
var clip = Ox.getObjectById(edit.clips, id);
|
||||
return clip.annotation || clip.item + '/' + clip['in'] + '-' + clip.out;
|
||||
}), 'clip');
|
||||
pandora.clipboard.copy(getClips(data.ids), 'clip');
|
||||
},
|
||||
copyadd: function(data) {
|
||||
pandora.clipboard.add(data.ids.map(function(id) {
|
||||
var clip = Ox.getObjectById(edit.clips, id);
|
||||
return clip.annotation || clip.item + '/' + clip['in'] + '-' + clip.out;
|
||||
}), 'clip');
|
||||
pandora.clipboard.add(getClips(data.ids), 'clip');
|
||||
},
|
||||
cut: function(data) {
|
||||
var clips;
|
||||
if (edit.editable) {
|
||||
pandora.clipboard.copy(data.ids.map(function(id) {
|
||||
var clip = Ox.getObjectById(edit.clips, id);
|
||||
return clip.annotation || clip.item + '/' + clip['in'] + '-' + clip.out;
|
||||
}), 'clip');
|
||||
pandora.doHistory('cut', data.ids, ui.edit, function(result) {
|
||||
clips = getClips(data.ids);
|
||||
pandora.clipboard.copy(clips, 'clip');
|
||||
pandora.doHistory('cut', clips, ui.edit, function(result) {
|
||||
Ox.Request.clearCache('getEdit');
|
||||
updateClips(result.data.clips);
|
||||
});
|
||||
}
|
||||
},
|
||||
cutadd: function(data) {
|
||||
var clips;
|
||||
if (edit.editable) {
|
||||
pandora.clipboard.add(data.ids.map(function(id) {
|
||||
var clip = Ox.getObjectById(edit.clips, id);
|
||||
return clip.annotation || clip.item + '/' + clip['in'] + '-' + clip.out;
|
||||
}), 'clip');
|
||||
pandora.doHistory('cut', data.ids, ui.edit, function(result) {
|
||||
clips = getClips(data.ids);
|
||||
pandora.clipboard.add(clips, 'clip');
|
||||
pandora.doHistory('cut', clips, ui.edit, function(result) {
|
||||
Ox.Request.clearCache('getEdit');
|
||||
updateClips(result.data.clips);
|
||||
});
|
||||
}
|
||||
},
|
||||
'delete': function(data) {
|
||||
var clips;
|
||||
if (edit.editable) {
|
||||
pandora.doHistory('delete', data.ids, ui.edit, function(result) {
|
||||
clips = getClips(data.ids);
|
||||
pandora.doHistory('delete', clips, ui.edit, function(result) {
|
||||
Ox.Request.clearCache('getEdit');
|
||||
updateClips(result.data.clips);
|
||||
});
|
||||
|
|
|
@ -316,6 +316,7 @@ pandora.createLinks = function($element) {
|
|||
items: action == 'cut' || action == 'delete' ? [items]
|
||||
: action == 'copy' || action == 'paste' ? [addedItems]
|
||||
: [items, addedItems],
|
||||
positions: [],
|
||||
targets: targets,
|
||||
text: text
|
||||
});
|
||||
|
@ -382,7 +383,7 @@ pandora.createLinks = function($element) {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
pandora.api.addClips({clips: parseClips(items), edit: target, index: 0}, callback);
|
||||
pandora.api.addClips({clips: getClipData(items), edit: target, index: -1}, callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,11 +418,7 @@ pandora.createLinks = function($element) {
|
|||
callback && callback();
|
||||
}
|
||||
|
||||
function getType(items) {
|
||||
return items[0] && Ox.contains(items[0], '/') ? 'clip' : 'item';
|
||||
}
|
||||
|
||||
function parseClips(items) {
|
||||
function getClipData(items) {
|
||||
return items.map(function(clip) {
|
||||
var split = clip.split('/'),
|
||||
item = split[0],
|
||||
|
@ -437,12 +434,22 @@ pandora.createLinks = function($element) {
|
|||
});
|
||||
}
|
||||
|
||||
function getClipIds(items) {
|
||||
return items.map(function(clip) {
|
||||
return clip.split('/').pop();
|
||||
});
|
||||
}
|
||||
|
||||
function getType(items) {
|
||||
return items[0] && Ox.contains(items[0], '/') ? 'clip' : 'item';
|
||||
}
|
||||
|
||||
function removeItems(items, target, callback) {
|
||||
var type = getType(items);
|
||||
if (type == 'item') {
|
||||
pandora.api.removeListItems({items: items, list: target}, callback);
|
||||
} else {
|
||||
pandora.api.removeClips({clips: parseClips(items), edit: target}, callback);
|
||||
pandora.api.removeClips({ids: getClipIds(items), edit: target}, callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue