pass index to split/join to keep position
This commit is contained in:
parent
b20a655fa8
commit
9eae0a0762
2 changed files with 30 additions and 10 deletions
|
@ -215,8 +215,9 @@ pandora.ui.editPanel = function(isEmbed) {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
join: function(data) {
|
join: function(data) {
|
||||||
var clips = [serializeClips(data.ids), serializeClips(data.join)];
|
var clips = [serializeClips(data.ids), serializeClips(data.join)],
|
||||||
pandora.doHistory('join', clips, ui.edit, function(result) {
|
index = pandora.$ui.editPanel.getPasteIndex() - 1;
|
||||||
|
pandora.doHistory('join', clips, ui.edit, index, function(result) {
|
||||||
edit.clips = edit.clips.filter(function(clip) {
|
edit.clips = edit.clips.filter(function(clip) {
|
||||||
return !Ox.contains(data.ids, clip.id);
|
return !Ox.contains(data.ids, clip.id);
|
||||||
}).concat(result.data.clips);
|
}).concat(result.data.clips);
|
||||||
|
@ -314,11 +315,25 @@ pandora.ui.editPanel = function(isEmbed) {
|
||||||
sortClips(updateClips);
|
sortClips(updateClips);
|
||||||
},
|
},
|
||||||
split: function(data) {
|
split: function(data) {
|
||||||
var clips = [serializeClips(data.ids), serializeClips(data.split)];
|
var clips = [serializeClips(data.ids), serializeClips(data.split)],
|
||||||
pandora.doHistory('split', clips, ui.edit, function(result) {
|
index = pandora.$ui.editPanel.getPasteIndex() - 1;
|
||||||
|
pandora.doHistory('split', clips, ui.edit, index, function(result) {
|
||||||
updateClips(edit.clips.filter(function(clip) {
|
updateClips(edit.clips.filter(function(clip) {
|
||||||
return !Ox.contains(data.ids, clip.id);
|
return !Ox.contains(data.ids, clip.id);
|
||||||
|
}).map(function(clip) {
|
||||||
|
if (clip.index >= result.data.clips[0].index) {
|
||||||
|
clip.index += result.data.clips.length
|
||||||
|
}
|
||||||
|
return clip;
|
||||||
}).concat(result.data.clips));
|
}).concat(result.data.clips));
|
||||||
|
//fixme: what resets the position here?
|
||||||
|
var position = that.options('position');
|
||||||
|
that.options({
|
||||||
|
selected: result.data.clips.map(function(clip) { return clip.id}),
|
||||||
|
});
|
||||||
|
setTimeout(function() {
|
||||||
|
that.options('position', position);
|
||||||
|
}, 500);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
subtitles: function(data) {
|
subtitles: function(data) {
|
||||||
|
|
|
@ -353,9 +353,10 @@ pandora.createLinks = function($element) {
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
pandora.doHistory = function(action, items, targets, callback) {
|
pandora.doHistory = function(action, items, targets, index, callback) {
|
||||||
items = Ox.makeArray(items);
|
items = Ox.makeArray(items);
|
||||||
targets = Ox.makeArray(targets);
|
targets = Ox.makeArray(targets);
|
||||||
|
callback = Ox.last(arguments);
|
||||||
if (action == 'copy' || action == 'paste') {
|
if (action == 'copy' || action == 'paste') {
|
||||||
addItems(items, targets[0], addToHistory);
|
addItems(items, targets[0], addToHistory);
|
||||||
} else if (action == 'cut' || action == 'delete') {
|
} else if (action == 'cut' || action == 'delete') {
|
||||||
|
@ -364,7 +365,7 @@ pandora.createLinks = function($element) {
|
||||||
editItem(items[1], addToHistory);
|
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], index, addToHistory);
|
||||||
});
|
});
|
||||||
} else if (action == 'move') {
|
} else if (action == 'move') {
|
||||||
removeItems(items, targets[0], function() {
|
removeItems(items, targets[0], function() {
|
||||||
|
@ -456,8 +457,14 @@ pandora.createLinks = function($element) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function addItems(items, target, callback) {
|
function addItems(items, target, index, callback) {
|
||||||
var clips, type = getType(items);
|
var clips, type = getType(items);
|
||||||
|
if (Ox.isUndefined(callback)) {
|
||||||
|
callback = index;
|
||||||
|
index = pandora.$ui.editPanel
|
||||||
|
? pandora.$ui.editPanel.getPasteIndex()
|
||||||
|
: void 0;
|
||||||
|
}
|
||||||
if (type == 'item') {
|
if (type == 'item') {
|
||||||
pandora.api.find({
|
pandora.api.find({
|
||||||
query: {
|
query: {
|
||||||
|
@ -485,9 +492,7 @@ pandora.createLinks = function($element) {
|
||||||
pandora.api.addClips({
|
pandora.api.addClips({
|
||||||
clips: pandora.getClipData(items),
|
clips: pandora.getClipData(items),
|
||||||
edit: target,
|
edit: target,
|
||||||
index: pandora.$ui.editPanel
|
index: index
|
||||||
? pandora.$ui.editPanel.getPasteIndex()
|
|
||||||
: void 0
|
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
// adding clips creates new ids, so mutate items in history
|
// adding clips creates new ids, so mutate items in history
|
||||||
items.splice.apply(items, [0, items.length].concat(
|
items.splice.apply(items, [0, items.length].concat(
|
||||||
|
|
Loading…
Reference in a new issue