From 5c5102baf048943ee34ea57b2028dbeefeff480d Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 10 Feb 2014 10:53:45 +0000 Subject: [PATCH] fix sort by year --- static/js/editPanel.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/static/js/editPanel.js b/static/js/editPanel.js index e1e0f66f8..388d5b0e8 100644 --- a/static/js/editPanel.js +++ b/static/js/editPanel.js @@ -521,8 +521,9 @@ pandora.ui.editPanel = function(isEmbed) { } function sortClips(callback) { - var sort = pandora.user.ui.editSort; - var key = sort[0].key; + var sort = pandora.user.ui.editSort, + key = sort[0].key, + index; if (key == 'position') { key = 'in'; } @@ -531,6 +532,13 @@ pandora.ui.editPanel = function(isEmbed) { 'title', 'director', 'year', 'videoRatio' ].indexOf(key) > -1) { sortBy(key); + index = 0; + edit.clips.forEach(function(clip) { + clip.sort = index++; + if (sort[0].operator == '-') { + clip.sort = -clip.sort; + } + }); updateDuration(); callback(edit.clips); } else { @@ -550,10 +558,7 @@ pandora.ui.editPanel = function(isEmbed) { }); } function sortBy(key) { - edit.clips = Ox.sortBy(edit.clips, key); - if (sort[0].operator == '-') { - edit.clips.reverse(); - } + edit.clips = Ox.sortBy(edit.clips, sort[0].operator + key); } }