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

37 lines
1.3 KiB
JavaScript
Raw Normal View History

2011-05-25 19:42:45 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=js
pandora.ui.sortSelect = function() {
var that = new Ox.Select({
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 id = data.selected[0].id,
operator = pandora.getSortOperator(id);
/*
2011-06-06 15:48:11 +00:00
pandora.user.ui.lists[pandora.user.ui.list].sort[0] = {
2011-05-25 19:42:45 +00:00
key: id,
operator: operator
};
*/
2011-06-06 15:48:11 +00:00
pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + id);
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (operator === '' ? 'ascending' : 'descending'));
pandora.$ui.list.sortList(id, operator);
2011-05-25 19:42:45 +00:00
pandora.URL.set(pandora.Query.toString());
}
});
return that;
};