fix (some) copy & paste bugs in edits

This commit is contained in:
rolux 2013-08-08 15:51:57 +00:00
parent 6012a4b9ba
commit 83dbe50894
2 changed files with 25 additions and 20 deletions

View file

@ -200,19 +200,7 @@ pandora.ui.editPanel = function() {
paste: function() { paste: function() {
var clips; var clips;
if (pandora.clipboard.type() == 'clip') { if (pandora.clipboard.type() == 'clip') {
clips = pandora.clipboard.paste().map(function(clip) { clips = pandora.clipboard.paste();
var split = clip.split('/'),
item = split[0],
points = split[1].split('-');
return Ox.extend({
item: item
}, points.length == 1 ? {
annotation: clip
} : {
'in': parseFloat(points[0]),
out: parseFloat(points[1])
});
});
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));

View file

@ -360,7 +360,7 @@ pandora.createLinks = function($element) {
}; };
function addItems(items, target, callback) { function addItems(items, target, callback) {
var type = getType(items); var clips, type = getType(items);
if (type == 'item') { if (type == 'item') {
pandora.api.find({ pandora.api.find({
query: { query: {
@ -382,7 +382,7 @@ pandora.createLinks = function($element) {
} }
}); });
} else { } else {
pandora.api.addClips({items: items, edit: target}, callback); pandora.api.addClips({clips: parseClips(items), edit: target, index: 0}, callback);
} }
} }
@ -419,14 +419,31 @@ pandora.createLinks = function($element) {
function getType(items) { function getType(items) {
return items[0] && Ox.contains(items[0], '/') ? 'clip' : 'item'; return items[0] && Ox.contains(items[0], '/') ? 'clip' : 'item';
}; }
function parseClips(items) {
return items.map(function(clip) {
var split = clip.split('/'),
item = split[0],
points = split[1].split('-');
return Ox.extend({
item: item
}, points.length == 1 ? {
annotation: clip
} : {
'in': parseFloat(points[0]),
out: parseFloat(points[1])
});
});
}
function removeItems(items, target, callback) { function removeItems(items, target, callback) {
var type = getType(items); var type = getType(items);
pandora.api[type == 'item' ? 'removeListItems' : 'removeClips']( if (type == 'item') {
Ox.extend({items: items}, type == 'item' ? 'list' : 'edit', target), pandora.api.removeListItems({items: items, list: target}, callback);
callback } else {
); pandora.api.removeClips({clips: parseClips(items), edit: target}, callback);
}
} }
}()); }());