more sort

This commit is contained in:
j 2013-07-14 14:59:04 +00:00
parent 17f5e2742b
commit e2cb8f7ead

View file

@ -46,7 +46,7 @@ pandora.ui.editPanel = function() {
}); });
pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.mainPanel.replaceElement(1,
that = pandora.$ui.editPanel = Ox.VideoEditPanel({ that = pandora.$ui.editPanel = Ox.VideoEditPanel({
clips: edit.clips, clips: Ox.clone(edit.clips),
clipSize: listSize, clipSize: listSize,
clipSort: ui.clipSort, clipSort: ui.clipSort,
clipSortOptions: [/*...*/], clipSortOptions: [/*...*/],
@ -73,7 +73,7 @@ pandora.ui.editPanel = function() {
smallTimelineURL: getSmallTimelineURL(), smallTimelineURL: getSmallTimelineURL(),
sort: ui.clipSort, sort: ui.clipSort,
sortOptions: [ sortOptions: [
{key: 'index', title: Ox._('Sort Manually'), operator: '+'} {id: 'index', title: Ox._('Sort Manually'), operator: '+'}
].concat( ].concat(
pandora.site.clipKeys.map(function(key) { pandora.site.clipKeys.map(function(key) {
return Ox.extend(Ox.clone(key), { return Ox.extend(Ox.clone(key), {
@ -186,19 +186,27 @@ pandora.ui.editPanel = function() {
pandora.UI.set('clipSize', data.size); pandora.UI.set('clipSize', data.size);
}, },
sort: function(data) { sort: function(data) {
if (data[0] && data[0].key) {
pandora.UI.set('clipSort', data); pandora.UI.set('clipSort', data);
var key = data[0].key;
if (key == 'position') {
key = 'in';
}
if (['id', 'index', 'in', 'out', 'duration'].indexOf(key) > -1) {
edit.clips = Ox.sortBy(edit.clips, key);
if(data[0].operator == '-') {
edit.clips.reverse();
}
updateClips(edit.clips);
} else {
pandora.api.sortClips({ pandora.api.sortClips({
edit: edit.id, edit: edit.id,
sort: data sort: data
}, function(result) { }, function(result) {
Ox.print('sort clips', result.data.clips);
//need to also update ClipList
edit.clips.forEach(function(clip) { edit.clips.forEach(function(clip) {
clip.sort = result.data.clips.indexOf(clip.id); clip[key] = result.data.clips.indexOf(clip.id);
}); });
edit.clips = Ox.sortBy(edit.clips, 'sort'); edit.clips = Ox.sortBy(edit.clips, key);
updateVideos(); updateClips(edit.clips);
}); });
} }
}, },
@ -251,7 +259,7 @@ pandora.ui.editPanel = function() {
edit.duration += clip.duration; edit.duration += clip.duration;
}); });
that.options({ that.options({
clips: clips, clips: Ox.clone(clips),
smallTimelineURL: getSmallTimelineURL(), smallTimelineURL: getSmallTimelineURL(),
video: getVideos() video: getVideos()
}); });