From c92f19f1b6596bad205b6be3395976c83f3be5ec Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 30 Oct 2011 21:21:26 +0000 Subject: [PATCH] add sortMenu --- static/js/pandora/sortMenu.js | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 static/js/pandora/sortMenu.js diff --git a/static/js/pandora/sortMenu.js b/static/js/pandora/sortMenu.js new file mode 100644 index 00000000..f3fac887 --- /dev/null +++ b/static/js/pandora/sortMenu.js @@ -0,0 +1,50 @@ +// vim: et:ts=4:sw=4:sts=4:ft=javascript + +pandora.ui.sortMenu = function() { + + var that = Ox.Select({ + items: Ox.merge( + pandora.site.clipKeys.map(function(key) { + return Ox.extend(Ox.clone(key), { + checked: key.id == pandora.user.ui.itemSort[0].key, + id: key.id, + title: 'Sort by ' + key.title + }); + }), + [ + {}, + {id: 'ascending', title: 'Ascending', checked: pandora.user.ui.itemSort[0].operator == '+'}, + {id: 'descending', title: 'Descending', checked: pandora.user.ui.itemSort[0].operator == '-'} + ] + ), + selectable: false, + tooltip: 'Sort clips', + type: 'image' + }) + .css({float: 'left', margin: '2px'}) + .bindEvent({ + click: function(data) { + if (data.checked) { + if (['ascending', 'descending'].indexOf(data.id) > -1) { + pandora.UI.set('itemSort', [{ + key: pandora.user.ui.itemSort[0].key, + operator: data.id == 'ascending' ? '+' : '-' + }]); + } else { + pandora.UI.set('itemSort', [{ + key: data.id, + operator: pandora.getSortOperator(data.id) + }]); + } + } + }, + pandora_itemsort: function() { + pandora.$ui.sortMenu.replaceWith( + pandora.$ui.sortMenu = pandora.ui.sortMenu() + ); + } + }); + + return that; + +}; \ No newline at end of file