cablegates/static/js/pandora/ui/sortSelect.js

36 lines
1.5 KiB
JavaScript
Raw Normal View History

2011-07-29 18:37:11 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
2011-05-25 19:42:45 +00:00
pandora.ui.sortSelect = function() {
2011-06-19 17:49:25 +00:00
var that = Ox.Select({
2011-05-25 19:42:45 +00:00
id: 'sortSelect',
2011-06-06 15:48:11 +00:00
items: $.map(pandora.site.sortKeys, function(key) {
//Ox.print('????', pandora.user.ui.lists[pandora.user.ui.list].sort.key, key.id)
2011-05-25 19:42:45 +00:00
return $.extend($.extend({}, key), {
2011-06-06 15:48:11 +00:00
checked: pandora.user.ui.lists[pandora.user.ui.list].sort[0].key == key.id,
2011-05-25 19:42:45 +00:00
title: 'Sort by ' + key.title
});
}),
width: 144
})
.css({
float: 'left',
margin: '4px 0 0 4px'
})
.bindEvent({
change: function(event, data) {
var key = data.selected[0].id,
operator = pandora.getSortOperator(key);
pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + key);
2011-06-06 15:48:11 +00:00
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (operator === '' ? 'ascending' : 'descending'));
pandora.$ui.list.options({
sort: [{key: key, operator: operator}]
});
// fixme: why does this not work??
2011-08-18 07:54:46 +00:00
// pandora.UI.set(['lists', pandora.user.ui.list, 'sort'].join('|'), [{key: key, operator: operator}]);
pandora.user.ui.lists[pandora.user.ui.list].sort[0] = {key: key, operator: operator};
pandora.URL.push(pandora.Query.toString());
2011-05-25 19:42:45 +00:00
}
});
return that;
};