From acee6e0382ebbb2193ae713f542af31f1e9ec12f Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 7 Feb 2014 12:12:15 +0000 Subject: [PATCH] fix reverse sort --- static/js/editPanel.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/static/js/editPanel.js b/static/js/editPanel.js index d00dbc571..a39e162a4 100644 --- a/static/js/editPanel.js +++ b/static/js/editPanel.js @@ -464,10 +464,7 @@ pandora.ui.editPanel = function() { 'id', 'index', 'in', 'out', 'duration', 'title', 'director', 'year', 'videoRatio' ].indexOf(key) > -1) { - edit.clips = Ox.sortBy(edit.clips, key); - if (sort[0].operator == '-') { - edit.clips.reverse(); - } + sortBy(key); updateDuration(); callback(edit.clips); } else { @@ -476,13 +473,22 @@ pandora.ui.editPanel = function() { sort: sort }, function(result) { edit.clips.forEach(function(clip) { - clip['sort'] = result.data.clips.indexOf(clip.id); + clip.sort = result.data.clips.indexOf(clip.id); + if (sort[0].operator == '-') { + clip.sort = -clip.sort; + } }); - edit.clips = Ox.sortBy(edit.clips, 'sort'); + sortBy('sort'); updateDuration(); callback(edit.clips); }); } + function sortBy(key) { + edit.clips = Ox.sortBy(edit.clips, key); + if (sort[0].operator == '-') { + edit.clips.reverse(); + } + } } function updateDuration() {