make clip edit part of history

This commit is contained in:
rolux 2013-08-09 18:36:02 +00:00
parent d5c50192f4
commit 93ef9d9f6a

View file

@ -293,6 +293,8 @@ pandora.createLinks = function($element) {
addItems(items, targets[0], addToHistory); addItems(items, targets[0], addToHistory);
} else if (action == 'cut' || action == 'delete') { } else if (action == 'cut' || action == 'delete') {
removeItems(items, targets[0], addToHistory); removeItems(items, targets[0], addToHistory);
} else if (action == 'edit') {
editItem(items[1], addToHistory);
} else if (action == 'join' || action == 'split') { } else if (action == 'join' || action == 'split') {
removeItems(items[0], targets[0], function() { removeItems(items[0], targets[0], function() {
addItems(items[1], targets[0], addToHistory); addItems(items[1], targets[0], addToHistory);
@ -313,7 +315,9 @@ pandora.createLinks = function($element) {
paste: 'Pasting', paste: 'Pasting',
split: 'Splitting' split: 'Splitting'
}, },
length = action == 'join' || action == 'split' ? items[0].length : items.length, length = action == 'edit' ? 1
: action == 'join' || action == 'split' ? items[0].length
: items.length,
type = getType(items), type = getType(items),
text = Ox._(actions[action]) + ' ' + ( text = Ox._(actions[action]) + ' ' + (
length == 1 ? Ox._(type == 'item' ? pandora.site.itemName.singular : 'Clip') length == 1 ? Ox._(type == 'item' ? pandora.site.itemName.singular : 'Clip')
@ -323,6 +327,7 @@ pandora.createLinks = function($element) {
action: action, action: action,
items: action == 'cut' || action == 'delete' ? [items] items: action == 'cut' || action == 'delete' ? [items]
: action == 'copy' || action == 'paste' ? [addedItems] : action == 'copy' || action == 'paste' ? [addedItems]
: action == 'edit' ? items
: action == 'join' || action == 'split' ? [items[0], addedItems] : action == 'join' || action == 'split' ? [items[0], addedItems]
: [items, addedItems], // move : [items, addedItems], // move
positions: [], positions: [],
@ -340,6 +345,8 @@ pandora.createLinks = function($element) {
addItems(object.items[0], object.targets[0], done); addItems(object.items[0], object.targets[0], done);
} else if (object.action == 'cut' || object.action == 'delete') { } else if (object.action == 'cut' || object.action == 'delete') {
removeItems(object.items[0], object.targets[0], done); removeItems(object.items[0], object.targets[0], done);
} else if (object.action == 'edit') {
editItem(object.items[1], done);
} else if (object.action == 'join' || object.action == 'split') { } else if (object.action == 'join' || object.action == 'split') {
removeItems(object.items[0], object.targets[0], function() { removeItems(object.items[0], object.targets[0], function() {
addItems(object.items[1], object.targets[0], done); addItems(object.items[1], object.targets[0], done);
@ -350,7 +357,7 @@ pandora.createLinks = function($element) {
}); });
} }
} }
function done(result, addedItems) { function done() {
doneHistory(object, callback); doneHistory(object, callback);
} }
}; };
@ -362,6 +369,8 @@ pandora.createLinks = function($element) {
removeItems(object.items[0], object.targets[0], done); removeItems(object.items[0], object.targets[0], done);
} else if (object.action == 'cut' || object.action == 'delete') { } else if (object.action == 'cut' || object.action == 'delete') {
addItems(object.items[0], object.targets[0], done); addItems(object.items[0], object.targets[0], done);
} else if (object.action == 'edit') {
editItem(object.items[0], done);
} else if (object.action == 'join' || object.action == 'split') { } else if (object.action == 'join' || object.action == 'split') {
removeItems(object.items[1], object.targets[0], function() { removeItems(object.items[1], object.targets[0], function() {
addItems(object.items[0], object.targets[0], done); addItems(object.items[0], object.targets[0], done);
@ -372,7 +381,7 @@ pandora.createLinks = function($element) {
}); });
} }
} }
function done(result, addedItems) { function done() {
doneHistory(object, callback); doneHistory(object, callback);
} }
}; };
@ -410,7 +419,7 @@ pandora.createLinks = function($element) {
function doneHistory(object, callback) { function doneHistory(object, callback) {
var list, listData, var list, listData,
type = getType(object.items[0]), type = getType(object.items),
ui = pandora.user.ui; ui = pandora.user.ui;
if (type == 'item' && ui.section == 'items') { if (type == 'item' && ui.section == 'items') {
Ox.Request.clearCache('find'); Ox.Request.clearCache('find');
@ -442,6 +451,16 @@ pandora.createLinks = function($element) {
callback && callback(); callback && callback();
} }
function editItem(item, callback) {
var clip = getClipData([item])[0],
id = getClipIds([item])[0];
pandora.api.editClip({
id: id,
'in': clip['in'],
out: clip.out
}, callback);
}
function getClipData(items) { function getClipData(items) {
return items.map(function(clip) { return items.map(function(clip) {
var split = clip.split('/'), var split = clip.split('/'),
@ -473,9 +492,7 @@ pandora.createLinks = function($element) {
} }
function getType(items) { function getType(items) {
return items[0] && ( return Ox.contains(items[0], '/') || Ox.contains(items[0][0], '/') ? 'clip' : 'item';
Ox.contains(items[0], '/') || Ox.contains(items[0][0], '/')
) ? 'clip' : 'item';
} }
function removeItems(items, target, callback) { function removeItems(items, target, callback) {