forked from 0x2620/pandora
history: add split and join
This commit is contained in:
parent
5b3d4608ea
commit
04eff288dd
1 changed files with 23 additions and 5 deletions
|
@ -297,25 +297,33 @@ pandora.createLinks = function($element) {
|
||||||
removeItems(items, targets[0], function() {
|
removeItems(items, targets[0], function() {
|
||||||
addItems(items, targets[1], addToHistory);
|
addItems(items, targets[1], addToHistory);
|
||||||
});
|
});
|
||||||
|
} else if (action == 'split' || action == 'join') {
|
||||||
|
removeItems(items[0], targets[0], function() {
|
||||||
|
addItems(items[1], targets[0], addToHistory);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
function addToHistory(result, addedItems) {
|
function addToHistory(result, addedItems) {
|
||||||
var actions = {
|
var actions = {
|
||||||
copy: 'Copying',
|
copy: 'Copying',
|
||||||
cut: 'Cutting',
|
cut: 'Cutting',
|
||||||
'delete': 'Deleting',
|
'delete': 'Deleting',
|
||||||
|
join: 'Joining',
|
||||||
move: 'Moving',
|
move: 'Moving',
|
||||||
paste: 'Pasting'
|
paste: 'Pasting',
|
||||||
|
split: 'Splitting'
|
||||||
},
|
},
|
||||||
|
length = action == 'join' || action == 'split' ? items[0].length : items.length,
|
||||||
type = getType(items),
|
type = getType(items),
|
||||||
text = Ox._(actions[action]) + ' ' + (
|
text = Ox._(actions[action]) + ' ' + (
|
||||||
items.length == 1 ? Ox._(type == 'item' ? pandora.site.itemName.singular : 'Clip')
|
length == 1 ? Ox._(type == 'item' ? pandora.site.itemName.singular : 'Clip')
|
||||||
: items.length + ' ' + Ox._(type == 'item' ? pandora.site.itemName.plural : 'Clips')
|
: length + ' ' + Ox._(type == 'item' ? pandora.site.itemName.plural : 'Clips')
|
||||||
);
|
);
|
||||||
pandora.history.add({
|
pandora.history.add({
|
||||||
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]
|
||||||
: [items, addedItems],
|
: action == 'move' ? [items, addedItems]
|
||||||
|
: [items],
|
||||||
positions: [],
|
positions: [],
|
||||||
targets: targets,
|
targets: targets,
|
||||||
text: text
|
text: text
|
||||||
|
@ -383,7 +391,9 @@ pandora.createLinks = function($element) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
pandora.api.addClips({clips: getClipData(items), edit: target, index: 0}, callback);
|
pandora.api.addClips({clips: getClipData(items), edit: target, index: 0}, function(result) {
|
||||||
|
callback(result, getClipItems(result.data.clips));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,6 +450,14 @@ pandora.createLinks = function($element) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getClipItems(clips) {
|
||||||
|
return clips.map(function(clip) {
|
||||||
|
return (
|
||||||
|
clip.annotation || clip.item + '/' + clip['in'] + '-' + clip.out
|
||||||
|
) + '/' + (clip.id || '');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function getType(items) {
|
function getType(items) {
|
||||||
return items[0] && Ox.contains(items[0], '/') ? 'clip' : 'item';
|
return items[0] && Ox.contains(items[0], '/') ? 'clip' : 'item';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue